From 7044bd103b5284c2bacb8ff8b01209b9e87c1c66 Mon Sep 17 00:00:00 2001 From: Thibaut Vandervelden Date: Mon, 31 Jul 2023 16:25:29 +0200 Subject: [PATCH] fix: fix combination of feature flags The combination `medium-ieee802154` + `medium-ip` + `proto-ipv4` + `proto-ipv6` did not compile because of `lookup_hardware_addr`. --- ci.sh | 1 + src/iface/interface/mod.rs | 19 +++++++++++++------ src/iface/neighbor.rs | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ci.sh b/ci.sh index 3c45f5d7c..d483dd867 100755 --- a/ci.sh +++ b/ci.sh @@ -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=( diff --git a/src/iface/interface/mod.rs b/src/iface/interface/mod.rs index 075fb99ed..bd682496d 100644 --- a/src/iface/interface/mod.rs +++ b/src/iface/interface/mod.rs @@ -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")] @@ -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 diff --git a/src/iface/neighbor.rs b/src/iface/neighbor.rs index 710454edf..959cd7133 100644 --- a/src/iface/neighbor.rs +++ b/src/iface/neighbor.rs @@ -146,7 +146,7 @@ impl Cache { } } -#[cfg(any(feature = "medium-ethernet", feature = "medium-ip"))] +#[cfg(feature = "medium-ethernet")] #[cfg(test)] mod test { use super::*;