|
|
|
@ -55,6 +55,16 @@ impl fmt::Debug for EUI48Addr {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl std::str::FromStr for EUI48Addr { |
|
|
|
|
type Err = failure::Error; |
|
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self> { |
|
|
|
|
let mut buf = [0u8; 6]; |
|
|
|
|
parse_eui_hyphens(&mut buf, s)?; |
|
|
|
|
Ok(EUI48Addr(buf)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl DnsPacketData for EUI48Addr { |
|
|
|
|
fn deserialize(data: &mut Cursor<Bytes>) -> Result<Self> { |
|
|
|
|
let mut buf = [0u8; 6]; |
|
|
|
@ -71,13 +81,9 @@ impl DnsPacketData for EUI48Addr {
|
|
|
|
|
|
|
|
|
|
impl DnsTextData for EUI48Addr { |
|
|
|
|
fn dns_parse(_context: &DnsTextContext, data: &mut &str) -> Result<Self> { |
|
|
|
|
let field = next_field(data)?; |
|
|
|
|
let mut buf = [0u8; 6]; |
|
|
|
|
parse_eui_hyphens(&mut buf, field)?; |
|
|
|
|
Ok(EUI48Addr(buf)) |
|
|
|
|
next_field(data)?.parse() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// format might fail if there is no (known) text representation.
|
|
|
|
|
fn dns_format(&self, f: &mut DnsTextFormatter) -> fmt::Result { |
|
|
|
|
write!(f, "{}", self) |
|
|
|
|
} |
|
|
|
@ -110,6 +116,16 @@ impl fmt::Debug for EUI64Addr {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl std::str::FromStr for EUI64Addr { |
|
|
|
|
type Err = failure::Error; |
|
|
|
|
|
|
|
|
|
fn from_str(s: &str) -> Result<Self> { |
|
|
|
|
let mut buf = [0u8; 8]; |
|
|
|
|
parse_eui_hyphens(&mut buf, s)?; |
|
|
|
|
Ok(EUI64Addr(buf)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl DnsPacketData for EUI64Addr { |
|
|
|
|
fn deserialize(data: &mut Cursor<Bytes>) -> Result<Self> { |
|
|
|
|
let mut buf = [0u8; 8]; |
|
|
|
@ -126,13 +142,9 @@ impl DnsPacketData for EUI64Addr {
|
|
|
|
|
|
|
|
|
|
impl DnsTextData for EUI64Addr { |
|
|
|
|
fn dns_parse(_context: &DnsTextContext, data: &mut &str) -> Result<Self> { |
|
|
|
|
let field = next_field(data)?; |
|
|
|
|
let mut buf = [0u8; 8]; |
|
|
|
|
parse_eui_hyphens(&mut buf, field)?; |
|
|
|
|
Ok(EUI64Addr(buf)) |
|
|
|
|
next_field(data)?.parse() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// format might fail if there is no (known) text representation.
|
|
|
|
|
fn dns_format(&self, f: &mut DnsTextFormatter) -> fmt::Result { |
|
|
|
|
write!(f, "{}", self) |
|
|
|
|
} |
|
|
|
|