#[allow(unused_imports)]
use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct MacAddress(pub [u8; 6]);
impl MacAddress {
pub const fn new(bytes: [u8; 6]) -> Self {
Self(bytes)
}
pub const fn broadcast() -> Self {
Self([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF])
}
pub const fn zero() -> Self {
Self([0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
}
pub fn is_broadcast(&self) -> bool {
self.0 == [0xFF; 6]
}
pub fn is_multicast(&self) -> bool {
self.0[0] & 0x01 != 0
}
pub fn is_unicast(&self) -> bool {
!self.is_multicast()
}
pub fn is_local(&self) -> bool {
self.0[0] & 0x02 != 0
}
pub fn as_bytes(&self) -> &[u8; 6] {
&self.0
}
}
impl From<[u8; 6]> for MacAddress {
fn from(bytes: [u8; 6]) -> Self {
Self(bytes)
}
}