1 // Copyright 2024, The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 use core::fmt; 16 use core::fmt::Debug; 17 18 // smoltcp uses an old version of bitflag (1.0). The one imported at Android is newer and does not 19 // provide Copy/Clone/Debug/PartialEq/Eq trait implementation by default. Thus we need to add the 20 // implementation here. 21 22 use crate::wire::{NdiscNeighborFlags, NdiscPrefixInfoFlags, NdiscRouterFlags}; 23 24 macro_rules! bitflags_trait { 25 ($name:ident) => { 26 impl Copy for $name {} 27 28 impl Clone for $name { 29 fn clone(&self) -> $name { 30 *self 31 } 32 } 33 34 impl Debug for $name { 35 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 36 Debug::fmt(&self.bits(), f) 37 } 38 } 39 40 impl PartialEq for $name { 41 fn eq(&self, other: &Self) -> bool { 42 PartialEq::eq(&self.bits(), &other.bits()) 43 } 44 } 45 46 impl Eq for $name {} 47 }; 48 } 49 50 bitflags_trait! {NdiscNeighborFlags} 51 bitflags_trait! {NdiscRouterFlags} 52 bitflags_trait! {NdiscPrefixInfoFlags} 53