wire: remove HardwareAddress::BROADCAST
This commit is contained in:
parent
b4764e4973
commit
3269ce6124
|
@ -2165,42 +2165,51 @@ impl<'a> InterfaceInner<'a> {
|
||||||
where
|
where
|
||||||
Tx: TxToken,
|
Tx: TxToken,
|
||||||
{
|
{
|
||||||
|
if dst_addr.is_broadcast() {
|
||||||
|
let hardware_addr = match cx.caps.medium {
|
||||||
|
#[cfg(feature = "medium-ethernet")]
|
||||||
|
Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress::BROADCAST),
|
||||||
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
|
Medium::Ieee802154 => HardwareAddress::Ieee802154(Ieee802154Address::BROADCAST),
|
||||||
|
#[cfg(feature = "medium-ip")]
|
||||||
|
Medium::Ip => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok((hardware_addr, tx_token));
|
||||||
|
}
|
||||||
|
|
||||||
if dst_addr.is_multicast() {
|
if dst_addr.is_multicast() {
|
||||||
let b = dst_addr.as_bytes();
|
let b = dst_addr.as_bytes();
|
||||||
let hardware_addr = match *dst_addr {
|
let hardware_addr = match *dst_addr {
|
||||||
IpAddress::Unspecified => None,
|
IpAddress::Unspecified => unreachable!(),
|
||||||
#[cfg(feature = "proto-ipv4")]
|
#[cfg(feature = "proto-ipv4")]
|
||||||
IpAddress::Ipv4(_addr) => {
|
IpAddress::Ipv4(_addr) => {
|
||||||
Some(HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
|
HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
|
||||||
0x01,
|
0x01,
|
||||||
0x00,
|
0x00,
|
||||||
0x5e,
|
0x5e,
|
||||||
b[1] & 0x7F,
|
b[1] & 0x7F,
|
||||||
b[2],
|
b[2],
|
||||||
b[3],
|
b[3],
|
||||||
])))
|
]))
|
||||||
}
|
}
|
||||||
#[cfg(feature = "proto-ipv6")]
|
#[cfg(feature = "proto-ipv6")]
|
||||||
IpAddress::Ipv6(_addr) => match cx.caps.medium {
|
IpAddress::Ipv6(_addr) => match cx.caps.medium {
|
||||||
#[cfg(feature = "medium-ethernet")]
|
#[cfg(feature = "medium-ethernet")]
|
||||||
Medium::Ethernet => {
|
Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
|
||||||
Some(HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
|
0x33, 0x33, b[12], b[13], b[14], b[15],
|
||||||
0x33, 0x33, b[12], b[13], b[14], b[15],
|
])),
|
||||||
])))
|
|
||||||
}
|
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
Medium::Ieee802154 => {
|
Medium::Ieee802154 => {
|
||||||
// Not sure if this is correct
|
// Not sure if this is correct
|
||||||
Some(HardwareAddress::Ieee802154(Ieee802154Address::BROADCAST))
|
HardwareAddress::Ieee802154(Ieee802154Address::BROADCAST)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "medium-ip")]
|
#[cfg(feature = "medium-ip")]
|
||||||
Medium::Ip => unreachable!(),
|
Medium::Ip => unreachable!(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(hardware_addr) = hardware_addr {
|
return Ok((hardware_addr, tx_token));
|
||||||
return Ok((hardware_addr, tx_token));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let dst_addr = self.route(dst_addr, cx.now)?;
|
let dst_addr = self.route(dst_addr, cx.now)?;
|
||||||
|
|
|
@ -196,9 +196,7 @@ impl<'a> Cache<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn lookup(&self, protocol_addr: &IpAddress, timestamp: Instant) -> Answer {
|
pub(crate) fn lookup(&self, protocol_addr: &IpAddress, timestamp: Instant) -> Answer {
|
||||||
if protocol_addr.is_broadcast() {
|
assert!(protocol_addr.is_unicast());
|
||||||
return Answer::Found(HardwareAddress::BROADCAST);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(&Neighbor {
|
if let Some(&Neighbor {
|
||||||
expires_at,
|
expires_at,
|
||||||
|
|
|
@ -246,7 +246,6 @@ pub use self::dhcpv4::{
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub enum HardwareAddress {
|
pub enum HardwareAddress {
|
||||||
BROADCAST,
|
|
||||||
#[cfg(feature = "medium-ethernet")]
|
#[cfg(feature = "medium-ethernet")]
|
||||||
Ethernet(EthernetAddress),
|
Ethernet(EthernetAddress),
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
|
@ -260,7 +259,6 @@ impl HardwareAddress {
|
||||||
HardwareAddress::Ethernet(addr) => addr.as_bytes(),
|
HardwareAddress::Ethernet(addr) => addr.as_bytes(),
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
HardwareAddress::Ieee802154(addr) => addr.as_bytes(),
|
HardwareAddress::Ieee802154(addr) => addr.as_bytes(),
|
||||||
_ => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +269,6 @@ impl HardwareAddress {
|
||||||
HardwareAddress::Ethernet(addr) => addr.is_unicast(),
|
HardwareAddress::Ethernet(addr) => addr.is_unicast(),
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
HardwareAddress::Ieee802154(addr) => addr.is_unicast(),
|
HardwareAddress::Ieee802154(addr) => addr.is_unicast(),
|
||||||
_ => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +279,6 @@ impl HardwareAddress {
|
||||||
HardwareAddress::Ethernet(addr) => addr.is_broadcast(),
|
HardwareAddress::Ethernet(addr) => addr.is_broadcast(),
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
HardwareAddress::Ieee802154(addr) => addr.is_broadcast(),
|
HardwareAddress::Ieee802154(addr) => addr.is_broadcast(),
|
||||||
_ => todo!(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,7 +286,6 @@ impl HardwareAddress {
|
||||||
impl core::fmt::Display for HardwareAddress {
|
impl core::fmt::Display for HardwareAddress {
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
HardwareAddress::BROADCAST => write!(f, "BROADCAST"),
|
|
||||||
#[cfg(feature = "medium-ethernet")]
|
#[cfg(feature = "medium-ethernet")]
|
||||||
HardwareAddress::Ethernet(addr) => write!(f, "{}", addr),
|
HardwareAddress::Ethernet(addr) => write!(f, "{}", addr),
|
||||||
#[cfg(feature = "medium-ieee802154")]
|
#[cfg(feature = "medium-ieee802154")]
|
||||||
|
|
Loading…
Reference in New Issue