1 /// Represents an ARP protocol hardware identifier. 2 /// 3 /// You can access the underlying `u16` value by using `.0` and any `u16` 4 /// can be converted to an `ArpHardwareId`: 5 /// 6 /// ``` 7 /// use etherparse::ArpHardwareId; 8 /// 9 /// assert_eq!(ArpHardwareId::ETHER.0, 0x0001); 10 /// assert_eq!(ArpHardwareId::ETHER, ArpHardwareId(0x0001)); 11 /// 12 /// // convert to ArpHardwareId using the from & into trait 13 /// let arp_hrd_id: ArpHardwareId = 0x0001.into(); 14 /// assert_eq!(ArpHardwareId::ETHER, arp_hrd_id); 15 /// 16 /// // convert to u16 using the from & into trait 17 /// let num: u16 = ArpHardwareId::ETHER.into(); 18 /// assert_eq!(0x0001, num); 19 /// ``` 20 /// 21 22 #[derive(Clone, Copy, Eq, PartialEq, Default, Hash)] 23 pub struct ArpHardwareId(pub u16); 24 25 impl ArpHardwareId { 26 // Numbers sourced from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/if_arp.h?id=e33c4963bf536900f917fb65a687724d5539bc21 27 28 pub const NETROM: ArpHardwareId = Self(0); 29 pub const ETHER: ArpHardwareId = Self(1); 30 pub const EETHER: ArpHardwareId = Self(2); 31 pub const AX25: ArpHardwareId = Self(3); 32 pub const PRONET: ArpHardwareId = Self(4); 33 pub const CHAOS: ArpHardwareId = Self(5); 34 pub const IEEE802: ArpHardwareId = Self(6); 35 pub const ARCNET: ArpHardwareId = Self(7); 36 pub const APPLETLK: ArpHardwareId = Self(8); 37 pub const DLCI: ArpHardwareId = Self(15); 38 pub const ATM: ArpHardwareId = Self(19); 39 pub const METRICOM: ArpHardwareId = Self(23); 40 pub const IEEE1394: ArpHardwareId = Self(24); 41 pub const EUI64: ArpHardwareId = Self(27); 42 pub const INFINIBAND: ArpHardwareId = Self(32); 43 pub const SLIP: ArpHardwareId = Self(256); 44 pub const CSLIP: ArpHardwareId = Self(257); 45 pub const SLIP6: ArpHardwareId = Self(258); 46 pub const CSLIP6: ArpHardwareId = Self(259); 47 pub const RSRVD: ArpHardwareId = Self(260); 48 pub const ADAPT: ArpHardwareId = Self(264); 49 pub const ROSE: ArpHardwareId = Self(270); 50 pub const X25: ArpHardwareId = Self(271); 51 pub const HWX25: ArpHardwareId = Self(272); 52 pub const CAN: ArpHardwareId = Self(280); 53 pub const PPP: ArpHardwareId = Self(512); 54 pub const CISCO_HDLC: ArpHardwareId = Self(513); 55 pub const LAPB: ArpHardwareId = Self(516); 56 pub const DDCMP: ArpHardwareId = Self(517); 57 pub const RAWHDLC: ArpHardwareId = Self(518); 58 pub const RAWIP: ArpHardwareId = Self(519); 59 pub const TUNNEL: ArpHardwareId = Self(768); 60 pub const TUNNEL6: ArpHardwareId = Self(769); 61 pub const FRAD: ArpHardwareId = Self(770); 62 pub const SKIP: ArpHardwareId = Self(771); 63 pub const LOOPBACK: ArpHardwareId = Self(772); 64 pub const LOCALTLK: ArpHardwareId = Self(773); 65 pub const FDDI: ArpHardwareId = Self(774); 66 pub const BIF: ArpHardwareId = Self(775); 67 pub const SIT: ArpHardwareId = Self(776); 68 pub const IPDDP: ArpHardwareId = Self(777); 69 pub const IPGRE: ArpHardwareId = Self(778); 70 pub const PIMREG: ArpHardwareId = Self(779); 71 pub const HIPPI: ArpHardwareId = Self(780); 72 pub const ASH: ArpHardwareId = Self(781); 73 pub const ECONET: ArpHardwareId = Self(782); 74 pub const IRDA: ArpHardwareId = Self(783); 75 pub const FCPP: ArpHardwareId = Self(784); 76 pub const FCAL: ArpHardwareId = Self(785); 77 pub const FCPL: ArpHardwareId = Self(786); 78 pub const FCFABRIC: ArpHardwareId = Self(787); 79 pub const IEEE802_TR: ArpHardwareId = Self(800); 80 pub const IEEE80211: ArpHardwareId = Self(801); 81 pub const IEEE80211_PRISM: ArpHardwareId = Self(802); 82 pub const IEEE80211_RADIOTAP: ArpHardwareId = Self(803); 83 pub const IEEE802154: ArpHardwareId = Self(804); 84 pub const IEEE802154_MONITOR: ArpHardwareId = Self(805); 85 pub const PHONET: ArpHardwareId = Self(820); 86 pub const PHONET_PIPE: ArpHardwareId = Self(821); 87 pub const CAIF: ArpHardwareId = Self(822); 88 pub const IP6GRE: ArpHardwareId = Self(823); 89 pub const NETLINK: ArpHardwareId = Self(824); 90 pub const IPV6LOWPAN: ArpHardwareId = Self(825); 91 pub const VSOCKMON: ArpHardwareId = Self(826); 92 pub const VOID: ArpHardwareId = Self(0xFFFF); 93 pub const NONE: ArpHardwareId = Self(0xFFFE); 94 } 95 96 impl From<u16> for ArpHardwareId { 97 #[inline] from(val: u16) -> Self98 fn from(val: u16) -> Self { 99 ArpHardwareId(val) 100 } 101 } 102 103 impl From<ArpHardwareId> for u16 { 104 #[inline] from(val: ArpHardwareId) -> Self105 fn from(val: ArpHardwareId) -> Self { 106 val.0 107 } 108 } 109 110 impl core::fmt::Display for ArpHardwareId { 111 // Names sourced from https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/if_arp.h?id=e33c4963bf536900f917fb65a687724d5539bc21 112 fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result113 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 114 match *self { 115 Self::NETROM => write!(f, "{} (from KA9Q: NET/ROM pseudo)", self.0), 116 Self::ETHER => write!(f, "{} (Ethernet 10Mbps)", self.0), 117 Self::EETHER => write!(f, "{} (Experimental Ethernet)", self.0), 118 Self::AX25 => write!(f, "{} (AX.25 Level 2)", self.0), 119 Self::PRONET => write!(f, "{} (PROnet token ring)", self.0), 120 Self::CHAOS => write!(f, "{} (Chaosnet)", self.0), 121 Self::IEEE802 => write!(f, "{} (IEEE 802.2 Ethernet/TR/TB)", self.0), 122 Self::ARCNET => write!(f, "{} (ARCnet)", self.0), 123 Self::APPLETLK => write!(f, "{} (APPLEtalk)", self.0), 124 Self::DLCI => write!(f, "{} (Frame Relay DLCI)", self.0), 125 Self::ATM => write!(f, "{} (ATM)", self.0), 126 Self::METRICOM => write!(f, "{} (Metricom STRIP (new IANA id))", self.0), 127 Self::IEEE1394 => write!(f, "{} (IEEE 1394 IPv4 - RFC 2734)", self.0), 128 Self::EUI64 => write!(f, "{} (EUI-64)", self.0), 129 Self::INFINIBAND => write!(f, "{} (InfiniBand)", self.0), 130 Self::SLIP => write!(f, "{} (SLIP)", self.0), 131 Self::CSLIP => write!(f, "{} (CSLIP)", self.0), 132 Self::SLIP6 => write!(f, "{} (SLIP6)", self.0), 133 Self::CSLIP6 => write!(f, "{} (CSLIP6)", self.0), 134 Self::RSRVD => write!(f, "{} (Notional KISS type)", self.0), 135 Self::ADAPT => write!(f, "{} (ADAPT)", self.0), 136 Self::ROSE => write!(f, "{} (ROSE)", self.0), 137 Self::X25 => write!(f, "{} (CCITT X.25)", self.0), 138 Self::HWX25 => write!(f, "{} (Boards with X.25 in firmware)", self.0), 139 Self::CAN => write!(f, "{} (Controller Area Network)", self.0), 140 Self::PPP => write!(f, "{} (PPP)", self.0), 141 Self::CISCO_HDLC => write!(f, "{} (Cisco HDLC)", self.0), 142 Self::LAPB => write!(f, "{} (LAPB)", self.0), 143 Self::DDCMP => write!(f, "{} (Digital's DDCMP protocol)", self.0), 144 Self::RAWHDLC => write!(f, "{} (Raw HDLC)", self.0), 145 Self::RAWIP => write!(f, "{} (Raw IP)", self.0), 146 Self::TUNNEL => write!(f, "{} (IPIP tunnel)", self.0), 147 Self::TUNNEL6 => write!(f, "{} (IP6IP6 tunnel)", self.0), 148 Self::FRAD => write!(f, "{} (Frame Relay Access Device)", self.0), 149 Self::SKIP => write!(f, "{} (SKIP vif)", self.0), 150 Self::LOOPBACK => write!(f, "{} (Loopback device)", self.0), 151 Self::LOCALTLK => write!(f, "{} (Localtalk device)", self.0), 152 Self::FDDI => write!(f, "{} (Fiber Distributed Data Interface)", self.0), 153 Self::BIF => write!(f, "{} (AP1000 BIF)", self.0), 154 Self::SIT => write!(f, "{} (sit0 device - IPv6-in-IPv4)", self.0), 155 Self::IPDDP => write!(f, "{} (IP over DDP tunneller)", self.0), 156 Self::IPGRE => write!(f, "{} (GRE over IP)", self.0), 157 Self::PIMREG => write!(f, "{} (PIMSM register interface)", self.0), 158 Self::HIPPI => write!(f, "{} (High Performance Parallel Interface)", self.0), 159 Self::ASH => write!(f, "{} (Nexus 64Mbps Ash)", self.0), 160 Self::ECONET => write!(f, "{} (Acorn Econet)", self.0), 161 Self::IRDA => write!(f, "{} (Linux-IrDA)", self.0), 162 Self::FCPP => write!(f, "{} (Point to point fibrechannel)", self.0), 163 Self::FCAL => write!(f, "{} (Fibrechannel arbitrated loop)", self.0), 164 Self::FCPL => write!(f, "{} (Fibrechannel public loop)", self.0), 165 Self::FCFABRIC => write!(f, "{} (Fibrechannel fabric)", self.0), 166 Self::IEEE802_TR => write!(f, "{} (Magic type ident for TR)", self.0), 167 Self::IEEE80211 => write!(f, "{} (IEEE 802.11)", self.0), 168 Self::IEEE80211_PRISM => write!(f, "{} (IEEE 802.11 + Prism2 header)", self.0), 169 Self::IEEE80211_RADIOTAP => write!(f, "{} (IEEE 802.11 + radiotap header)", self.0), 170 Self::IEEE802154 => write!(f, "{} (IEEE 802.15.4)", self.0), 171 Self::IEEE802154_MONITOR => write!(f, "{} (IEEE 802.15.4 network monitor)", self.0), 172 Self::PHONET => write!(f, "{} (PhoNet media type)", self.0), 173 Self::PHONET_PIPE => write!(f, "{} (PhoNet pipe header)", self.0), 174 Self::CAIF => write!(f, "{} (CAIF media type)", self.0), 175 Self::IP6GRE => write!(f, "{} (GRE over IPv6)", self.0), 176 Self::NETLINK => write!(f, "{} (Netlink header)", self.0), 177 Self::IPV6LOWPAN => write!(f, "{} (IPv6 over LoWPAN)", self.0), 178 Self::VSOCKMON => write!(f, "{} (Vsock monitor header)", self.0), 179 Self::VOID => write!(f, "{:#06X} (Void type, nothing is known)", self.0), 180 Self::NONE => write!(f, "{:#06X} (zero header length)", self.0), 181 _ => write!(f, "{:#06X}", self.0), 182 } 183 } 184 } 185 186 impl core::fmt::Debug for ArpHardwareId { fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result187 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { 188 core::fmt::Display::fmt(&self, f) 189 } 190 } 191 192 #[cfg(test)] 193 mod test { 194 use super::*; 195 use alloc::format; 196 197 #[test] to_u16()198 fn to_u16() { 199 assert_eq!(0, u16::from(ArpHardwareId::NETROM)); 200 assert_eq!(1, u16::from(ArpHardwareId::ETHER)); 201 assert_eq!(2, u16::from(ArpHardwareId::EETHER)); 202 assert_eq!(3, u16::from(ArpHardwareId::AX25)); 203 assert_eq!(4, u16::from(ArpHardwareId::PRONET)); 204 assert_eq!(5, u16::from(ArpHardwareId::CHAOS)); 205 assert_eq!(6, u16::from(ArpHardwareId::IEEE802)); 206 assert_eq!(7, u16::from(ArpHardwareId::ARCNET)); 207 assert_eq!(8, u16::from(ArpHardwareId::APPLETLK)); 208 assert_eq!(15, u16::from(ArpHardwareId::DLCI)); 209 assert_eq!(19, u16::from(ArpHardwareId::ATM)); 210 assert_eq!(23, u16::from(ArpHardwareId::METRICOM)); 211 assert_eq!(24, u16::from(ArpHardwareId::IEEE1394)); 212 assert_eq!(27, u16::from(ArpHardwareId::EUI64)); 213 assert_eq!(32, u16::from(ArpHardwareId::INFINIBAND)); 214 215 assert_eq!(256, u16::from(ArpHardwareId::SLIP)); 216 assert_eq!(257, u16::from(ArpHardwareId::CSLIP)); 217 assert_eq!(258, u16::from(ArpHardwareId::SLIP6)); 218 assert_eq!(259, u16::from(ArpHardwareId::CSLIP6)); 219 assert_eq!(260, u16::from(ArpHardwareId::RSRVD)); 220 assert_eq!(264, u16::from(ArpHardwareId::ADAPT)); 221 assert_eq!(270, u16::from(ArpHardwareId::ROSE)); 222 assert_eq!(271, u16::from(ArpHardwareId::X25)); 223 assert_eq!(272, u16::from(ArpHardwareId::HWX25)); 224 assert_eq!(280, u16::from(ArpHardwareId::CAN)); 225 assert_eq!(512, u16::from(ArpHardwareId::PPP)); 226 assert_eq!(513, u16::from(ArpHardwareId::CISCO_HDLC)); 227 assert_eq!(516, u16::from(ArpHardwareId::LAPB)); 228 assert_eq!(517, u16::from(ArpHardwareId::DDCMP)); 229 assert_eq!(518, u16::from(ArpHardwareId::RAWHDLC)); 230 assert_eq!(519, u16::from(ArpHardwareId::RAWIP)); 231 232 assert_eq!(768, u16::from(ArpHardwareId::TUNNEL)); 233 assert_eq!(769, u16::from(ArpHardwareId::TUNNEL6)); 234 assert_eq!(770, u16::from(ArpHardwareId::FRAD)); 235 assert_eq!(771, u16::from(ArpHardwareId::SKIP)); 236 assert_eq!(772, u16::from(ArpHardwareId::LOOPBACK)); 237 assert_eq!(773, u16::from(ArpHardwareId::LOCALTLK)); 238 assert_eq!(774, u16::from(ArpHardwareId::FDDI)); 239 assert_eq!(775, u16::from(ArpHardwareId::BIF)); 240 assert_eq!(776, u16::from(ArpHardwareId::SIT)); 241 assert_eq!(777, u16::from(ArpHardwareId::IPDDP)); 242 assert_eq!(778, u16::from(ArpHardwareId::IPGRE)); 243 assert_eq!(779, u16::from(ArpHardwareId::PIMREG)); 244 assert_eq!(780, u16::from(ArpHardwareId::HIPPI)); 245 assert_eq!(781, u16::from(ArpHardwareId::ASH)); 246 assert_eq!(782, u16::from(ArpHardwareId::ECONET)); 247 assert_eq!(783, u16::from(ArpHardwareId::IRDA)); 248 249 assert_eq!(784, u16::from(ArpHardwareId::FCPP)); 250 assert_eq!(785, u16::from(ArpHardwareId::FCAL)); 251 assert_eq!(786, u16::from(ArpHardwareId::FCPL)); 252 assert_eq!(787, u16::from(ArpHardwareId::FCFABRIC)); 253 254 assert_eq!(800, u16::from(ArpHardwareId::IEEE802_TR)); 255 assert_eq!(801, u16::from(ArpHardwareId::IEEE80211)); 256 assert_eq!(802, u16::from(ArpHardwareId::IEEE80211_PRISM)); 257 assert_eq!(803, u16::from(ArpHardwareId::IEEE80211_RADIOTAP)); 258 assert_eq!(804, u16::from(ArpHardwareId::IEEE802154)); 259 assert_eq!(805, u16::from(ArpHardwareId::IEEE802154_MONITOR)); 260 261 assert_eq!(820, u16::from(ArpHardwareId::PHONET)); 262 assert_eq!(821, u16::from(ArpHardwareId::PHONET_PIPE)); 263 assert_eq!(822, u16::from(ArpHardwareId::CAIF)); 264 assert_eq!(823, u16::from(ArpHardwareId::IP6GRE)); 265 assert_eq!(824, u16::from(ArpHardwareId::NETLINK)); 266 assert_eq!(825, u16::from(ArpHardwareId::IPV6LOWPAN)); 267 assert_eq!(826, u16::from(ArpHardwareId::VSOCKMON)); 268 269 assert_eq!(0xFFFF, u16::from(ArpHardwareId::VOID)); 270 assert_eq!(0xFFFE, u16::from(ArpHardwareId::NONE)); 271 } 272 273 #[test] from_u16()274 fn from_u16() { 275 assert_eq!(ArpHardwareId::from(0), ArpHardwareId::NETROM); 276 assert_eq!(ArpHardwareId::from(1), ArpHardwareId::ETHER); 277 assert_eq!(ArpHardwareId::from(2), ArpHardwareId::EETHER); 278 assert_eq!(ArpHardwareId::from(3), ArpHardwareId::AX25); 279 assert_eq!(ArpHardwareId::from(4), ArpHardwareId::PRONET); 280 assert_eq!(ArpHardwareId::from(5), ArpHardwareId::CHAOS); 281 assert_eq!(ArpHardwareId::from(6), ArpHardwareId::IEEE802); 282 assert_eq!(ArpHardwareId::from(7), ArpHardwareId::ARCNET); 283 assert_eq!(ArpHardwareId::from(8), ArpHardwareId::APPLETLK); 284 assert_eq!(ArpHardwareId::from(15), ArpHardwareId::DLCI); 285 assert_eq!(ArpHardwareId::from(19), ArpHardwareId::ATM); 286 assert_eq!(ArpHardwareId::from(23), ArpHardwareId::METRICOM); 287 assert_eq!(ArpHardwareId::from(24), ArpHardwareId::IEEE1394); 288 assert_eq!(ArpHardwareId::from(27), ArpHardwareId::EUI64); 289 assert_eq!(ArpHardwareId::from(32), ArpHardwareId::INFINIBAND); 290 291 assert_eq!(ArpHardwareId::from(256), ArpHardwareId::SLIP); 292 assert_eq!(ArpHardwareId::from(257), ArpHardwareId::CSLIP); 293 assert_eq!(ArpHardwareId::from(258), ArpHardwareId::SLIP6); 294 assert_eq!(ArpHardwareId::from(259), ArpHardwareId::CSLIP6); 295 assert_eq!(ArpHardwareId::from(260), ArpHardwareId::RSRVD); 296 assert_eq!(ArpHardwareId::from(264), ArpHardwareId::ADAPT); 297 assert_eq!(ArpHardwareId::from(270), ArpHardwareId::ROSE); 298 assert_eq!(ArpHardwareId::from(271), ArpHardwareId::X25); 299 assert_eq!(ArpHardwareId::from(272), ArpHardwareId::HWX25); 300 assert_eq!(ArpHardwareId::from(280), ArpHardwareId::CAN); 301 assert_eq!(ArpHardwareId::from(512), ArpHardwareId::PPP); 302 assert_eq!(ArpHardwareId::from(513), ArpHardwareId::CISCO_HDLC); 303 assert_eq!(ArpHardwareId::from(516), ArpHardwareId::LAPB); 304 assert_eq!(ArpHardwareId::from(517), ArpHardwareId::DDCMP); 305 assert_eq!(ArpHardwareId::from(518), ArpHardwareId::RAWHDLC); 306 assert_eq!(ArpHardwareId::from(519), ArpHardwareId::RAWIP); 307 308 assert_eq!(ArpHardwareId::from(768), ArpHardwareId::TUNNEL); 309 assert_eq!(ArpHardwareId::from(769), ArpHardwareId::TUNNEL6); 310 assert_eq!(ArpHardwareId::from(770), ArpHardwareId::FRAD); 311 assert_eq!(ArpHardwareId::from(771), ArpHardwareId::SKIP); 312 assert_eq!(ArpHardwareId::from(772), ArpHardwareId::LOOPBACK); 313 assert_eq!(ArpHardwareId::from(773), ArpHardwareId::LOCALTLK); 314 assert_eq!(ArpHardwareId::from(774), ArpHardwareId::FDDI); 315 assert_eq!(ArpHardwareId::from(775), ArpHardwareId::BIF); 316 assert_eq!(ArpHardwareId::from(776), ArpHardwareId::SIT); 317 assert_eq!(ArpHardwareId::from(777), ArpHardwareId::IPDDP); 318 assert_eq!(ArpHardwareId::from(778), ArpHardwareId::IPGRE); 319 assert_eq!(ArpHardwareId::from(779), ArpHardwareId::PIMREG); 320 assert_eq!(ArpHardwareId::from(780), ArpHardwareId::HIPPI); 321 assert_eq!(ArpHardwareId::from(781), ArpHardwareId::ASH); 322 assert_eq!(ArpHardwareId::from(782), ArpHardwareId::ECONET); 323 assert_eq!(ArpHardwareId::from(783), ArpHardwareId::IRDA); 324 325 assert_eq!(ArpHardwareId::from(784), ArpHardwareId::FCPP); 326 assert_eq!(ArpHardwareId::from(785), ArpHardwareId::FCAL); 327 assert_eq!(ArpHardwareId::from(786), ArpHardwareId::FCPL); 328 assert_eq!(ArpHardwareId::from(787), ArpHardwareId::FCFABRIC); 329 330 assert_eq!(ArpHardwareId::from(800), ArpHardwareId::IEEE802_TR); 331 assert_eq!(ArpHardwareId::from(801), ArpHardwareId::IEEE80211); 332 assert_eq!(ArpHardwareId::from(802), ArpHardwareId::IEEE80211_PRISM); 333 assert_eq!(ArpHardwareId::from(803), ArpHardwareId::IEEE80211_RADIOTAP); 334 assert_eq!(ArpHardwareId::from(804), ArpHardwareId::IEEE802154); 335 assert_eq!(ArpHardwareId::from(805), ArpHardwareId::IEEE802154_MONITOR); 336 337 assert_eq!(ArpHardwareId::from(820), ArpHardwareId::PHONET); 338 assert_eq!(ArpHardwareId::from(821), ArpHardwareId::PHONET_PIPE); 339 assert_eq!(ArpHardwareId::from(822), ArpHardwareId::CAIF); 340 assert_eq!(ArpHardwareId::from(823), ArpHardwareId::IP6GRE); 341 assert_eq!(ArpHardwareId::from(824), ArpHardwareId::NETLINK); 342 assert_eq!(ArpHardwareId::from(825), ArpHardwareId::IPV6LOWPAN); 343 assert_eq!(ArpHardwareId::from(826), ArpHardwareId::VSOCKMON); 344 345 assert_eq!(ArpHardwareId::from(0xFFFF), ArpHardwareId::VOID); 346 assert_eq!(ArpHardwareId::from(0xFFFE), ArpHardwareId::NONE); 347 } 348 349 #[test] display_dbg()350 fn display_dbg() { 351 let pairs = &[ 352 (ArpHardwareId::NETROM, "0 (from KA9Q: NET/ROM pseudo)"), 353 (ArpHardwareId::ETHER, "1 (Ethernet 10Mbps)"), 354 (ArpHardwareId::EETHER, "2 (Experimental Ethernet)"), 355 (ArpHardwareId::AX25, "3 (AX.25 Level 2)"), 356 (ArpHardwareId::PRONET, "4 (PROnet token ring)"), 357 (ArpHardwareId::CHAOS, "5 (Chaosnet)"), 358 (ArpHardwareId::IEEE802, "6 (IEEE 802.2 Ethernet/TR/TB)"), 359 (ArpHardwareId::ARCNET, "7 (ARCnet)"), 360 (ArpHardwareId::APPLETLK, "8 (APPLEtalk)"), 361 (ArpHardwareId::DLCI, "15 (Frame Relay DLCI)"), 362 (ArpHardwareId::ATM, "19 (ATM)"), 363 (ArpHardwareId::METRICOM, "23 (Metricom STRIP (new IANA id))"), 364 (ArpHardwareId::IEEE1394, "24 (IEEE 1394 IPv4 - RFC 2734)"), 365 (ArpHardwareId::EUI64, "27 (EUI-64)"), 366 (ArpHardwareId::INFINIBAND, "32 (InfiniBand)"), 367 (ArpHardwareId::SLIP, "256 (SLIP)"), 368 (ArpHardwareId::CSLIP, "257 (CSLIP)"), 369 (ArpHardwareId::SLIP6, "258 (SLIP6)"), 370 (ArpHardwareId::CSLIP6, "259 (CSLIP6)"), 371 (ArpHardwareId::RSRVD, "260 (Notional KISS type)"), 372 (ArpHardwareId::ADAPT, "264 (ADAPT)"), 373 (ArpHardwareId::ROSE, "270 (ROSE)"), 374 (ArpHardwareId::X25, "271 (CCITT X.25)"), 375 (ArpHardwareId::HWX25, "272 (Boards with X.25 in firmware)"), 376 (ArpHardwareId::CAN, "280 (Controller Area Network)"), 377 (ArpHardwareId::PPP, "512 (PPP)"), 378 (ArpHardwareId::CISCO_HDLC, "513 (Cisco HDLC)"), 379 (ArpHardwareId::LAPB, "516 (LAPB)"), 380 (ArpHardwareId::DDCMP, "517 (Digital's DDCMP protocol)"), 381 (ArpHardwareId::RAWHDLC, "518 (Raw HDLC)"), 382 (ArpHardwareId::RAWIP, "519 (Raw IP)"), 383 (ArpHardwareId::TUNNEL, "768 (IPIP tunnel)"), 384 (ArpHardwareId::TUNNEL6, "769 (IP6IP6 tunnel)"), 385 (ArpHardwareId::FRAD, "770 (Frame Relay Access Device)"), 386 (ArpHardwareId::SKIP, "771 (SKIP vif)"), 387 (ArpHardwareId::LOOPBACK, "772 (Loopback device)"), 388 (ArpHardwareId::LOCALTLK, "773 (Localtalk device)"), 389 ( 390 ArpHardwareId::FDDI, 391 "774 (Fiber Distributed Data Interface)", 392 ), 393 (ArpHardwareId::BIF, "775 (AP1000 BIF)"), 394 (ArpHardwareId::SIT, "776 (sit0 device - IPv6-in-IPv4)"), 395 (ArpHardwareId::IPDDP, "777 (IP over DDP tunneller)"), 396 (ArpHardwareId::IPGRE, "778 (GRE over IP)"), 397 (ArpHardwareId::PIMREG, "779 (PIMSM register interface)"), 398 ( 399 ArpHardwareId::HIPPI, 400 "780 (High Performance Parallel Interface)", 401 ), 402 (ArpHardwareId::ASH, "781 (Nexus 64Mbps Ash)"), 403 (ArpHardwareId::ECONET, "782 (Acorn Econet)"), 404 (ArpHardwareId::IRDA, "783 (Linux-IrDA)"), 405 (ArpHardwareId::FCPP, "784 (Point to point fibrechannel)"), 406 (ArpHardwareId::FCAL, "785 (Fibrechannel arbitrated loop)"), 407 (ArpHardwareId::FCPL, "786 (Fibrechannel public loop)"), 408 (ArpHardwareId::FCFABRIC, "787 (Fibrechannel fabric)"), 409 (ArpHardwareId::IEEE802_TR, "800 (Magic type ident for TR)"), 410 (ArpHardwareId::IEEE80211, "801 (IEEE 802.11)"), 411 ( 412 ArpHardwareId::IEEE80211_PRISM, 413 "802 (IEEE 802.11 + Prism2 header)", 414 ), 415 ( 416 ArpHardwareId::IEEE80211_RADIOTAP, 417 "803 (IEEE 802.11 + radiotap header)", 418 ), 419 (ArpHardwareId::IEEE802154, "804 (IEEE 802.15.4)"), 420 ( 421 ArpHardwareId::IEEE802154_MONITOR, 422 "805 (IEEE 802.15.4 network monitor)", 423 ), 424 (ArpHardwareId::PHONET, "820 (PhoNet media type)"), 425 (ArpHardwareId::PHONET_PIPE, "821 (PhoNet pipe header)"), 426 (ArpHardwareId::CAIF, "822 (CAIF media type)"), 427 (ArpHardwareId::IP6GRE, "823 (GRE over IPv6)"), 428 (ArpHardwareId::NETLINK, "824 (Netlink header)"), 429 (ArpHardwareId::IPV6LOWPAN, "825 (IPv6 over LoWPAN)"), 430 (ArpHardwareId::VSOCKMON, "826 (Vsock monitor header)"), 431 (ArpHardwareId::VOID, "0xFFFF (Void type, nothing is known)"), 432 (ArpHardwareId::NONE, "0xFFFE (zero header length)"), 433 (ArpHardwareId::from(0x1234), "0x1234"), 434 ]; 435 436 for (ether_type, str_value) in pairs { 437 assert_eq!(str_value, &format!("{}", ether_type)); 438 assert_eq!(str_value, &format!("{:?}", ether_type)); 439 } 440 } 441 442 #[test] default()443 fn default() { 444 let value: ArpHardwareId = Default::default(); 445 assert_eq!(ArpHardwareId(0), value); 446 } 447 448 #[test] clone_eq()449 fn clone_eq() { 450 let values = &[ 451 ArpHardwareId::NETROM, 452 ArpHardwareId::ETHER, 453 ArpHardwareId::EETHER, 454 ArpHardwareId::AX25, 455 ArpHardwareId::PRONET, 456 ArpHardwareId::CHAOS, 457 ArpHardwareId::IEEE802, 458 ArpHardwareId::ARCNET, 459 ArpHardwareId::APPLETLK, 460 ArpHardwareId::DLCI, 461 ArpHardwareId::ATM, 462 ArpHardwareId::METRICOM, 463 ArpHardwareId::IEEE1394, 464 ArpHardwareId::EUI64, 465 ArpHardwareId::INFINIBAND, 466 ArpHardwareId::SLIP, 467 ArpHardwareId::CSLIP, 468 ArpHardwareId::SLIP6, 469 ArpHardwareId::CSLIP6, 470 ArpHardwareId::RSRVD, 471 ArpHardwareId::ADAPT, 472 ArpHardwareId::ROSE, 473 ArpHardwareId::X25, 474 ArpHardwareId::HWX25, 475 ArpHardwareId::CAN, 476 ArpHardwareId::PPP, 477 ArpHardwareId::CISCO_HDLC, 478 ArpHardwareId::LAPB, 479 ArpHardwareId::DDCMP, 480 ArpHardwareId::RAWHDLC, 481 ArpHardwareId::RAWIP, 482 ArpHardwareId::TUNNEL, 483 ArpHardwareId::TUNNEL6, 484 ArpHardwareId::FRAD, 485 ArpHardwareId::SKIP, 486 ArpHardwareId::LOOPBACK, 487 ArpHardwareId::LOCALTLK, 488 ArpHardwareId::FDDI, 489 ArpHardwareId::BIF, 490 ArpHardwareId::SIT, 491 ArpHardwareId::IPDDP, 492 ArpHardwareId::IPGRE, 493 ArpHardwareId::PIMREG, 494 ArpHardwareId::HIPPI, 495 ArpHardwareId::ASH, 496 ArpHardwareId::ECONET, 497 ArpHardwareId::IRDA, 498 ArpHardwareId::FCPP, 499 ArpHardwareId::FCAL, 500 ArpHardwareId::FCPL, 501 ArpHardwareId::FCFABRIC, 502 ArpHardwareId::IEEE802_TR, 503 ArpHardwareId::IEEE80211, 504 ArpHardwareId::IEEE80211_PRISM, 505 ArpHardwareId::IEEE80211_RADIOTAP, 506 ArpHardwareId::IEEE802154, 507 ArpHardwareId::IEEE802154_MONITOR, 508 ArpHardwareId::PHONET, 509 ArpHardwareId::PHONET_PIPE, 510 ArpHardwareId::CAIF, 511 ArpHardwareId::IP6GRE, 512 ArpHardwareId::NETLINK, 513 ArpHardwareId::IPV6LOWPAN, 514 ArpHardwareId::VSOCKMON, 515 ArpHardwareId::VOID, 516 ArpHardwareId::NONE, 517 ]; 518 519 // clone 520 for v in values { 521 assert_eq!(v, &v.clone()); 522 } 523 524 // eq 525 for (a_pos, a) in values.iter().enumerate() { 526 for (b_pos, b) in values.iter().enumerate() { 527 assert_eq!(a_pos == b_pos, a == b); 528 assert_eq!(a_pos != b_pos, a != b); 529 } 530 } 531 } 532 } 533