Skip to content

Commit

Permalink
fix: fix combination of feature flags
Browse files Browse the repository at this point in the history
The combination `medium-ieee802154` + `medium-ip` + `proto-ipv4` +
`proto-ipv6` did not compile because of `lookup_hardware_addr`.
  • Loading branch information
thvdveld committed Jul 31, 2023
1 parent 6466817 commit 7044bd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ FEATURES_TEST=(
"std,medium-ieee802154,proto-rpl,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
"std,medium-ip,proto-ipv4,proto-ipv6,socket-tcp,socket-udp"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw"
)

FEATURES_TEST_NIGHTLY=(
Expand Down
19 changes: 13 additions & 6 deletions src/iface/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1336,16 +1336,21 @@ impl InterfaceInner {
let b = dst_addr.as_bytes();
let hardware_addr = match *dst_addr {
#[cfg(feature = "proto-ipv4")]
IpAddress::Ipv4(_addr) => {
HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
IpAddress::Ipv4(_addr) => match self.caps.medium {
#[cfg(feature = "medium-ethernet")]
Medium::Ethernet => HardwareAddress::Ethernet(EthernetAddress::from_bytes(&[
0x01,
0x00,
0x5e,
b[1] & 0x7F,
b[2],
b[3],
]))
}
])),
#[cfg(feature = "medium-ieee802154")]
Medium::Ieee802154 => unreachable!(),
#[cfg(feature = "medium-ip")]
Medium::Ip => unreachable!(),
},
#[cfg(feature = "proto-ipv6")]
IpAddress::Ipv6(_addr) => match self.caps.medium {
#[cfg(feature = "medium-ethernet")]
Expand Down Expand Up @@ -1376,8 +1381,10 @@ impl InterfaceInner {
}

match (src_addr, dst_addr) {
#[cfg(feature = "proto-ipv4")]
(&IpAddress::Ipv4(src_addr), IpAddress::Ipv4(dst_addr)) => {
#[cfg(all(feature = "medium-ethernet", feature = "proto-ipv4"))]
(&IpAddress::Ipv4(src_addr), IpAddress::Ipv4(dst_addr))
if matches!(self.caps.medium, Medium::Ethernet) =>
{
net_debug!(
"address {} not in neighbor cache, sending ARP request",
dst_addr
Expand Down
2 changes: 1 addition & 1 deletion src/iface/neighbor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl Cache {
}
}

#[cfg(any(feature = "medium-ethernet", feature = "medium-ip"))]
#[cfg(feature = "medium-ethernet")]
#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 7044bd1

Please # to comment.