net: fix build with medium-ip

This commit is contained in:
Dario Nieuwenhuis 2021-08-20 15:06:06 +02:00
parent 17659e2e44
commit de2039fd1d

View file

@ -9,13 +9,17 @@ use futures::pin_mut;
use smoltcp::iface::InterfaceBuilder; use smoltcp::iface::InterfaceBuilder;
#[cfg(feature = "medium-ethernet")] #[cfg(feature = "medium-ethernet")]
use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes}; use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes};
#[cfg(feature = "medium-ethernet")]
use smoltcp::phy::Device as _; use smoltcp::phy::Device as _;
#[cfg(feature = "medium-ethernet")]
use smoltcp::phy::Medium; use smoltcp::phy::Medium;
use smoltcp::socket::SocketSetItem; use smoltcp::socket::SocketSetItem;
use smoltcp::time::Instant as SmolInstant; use smoltcp::time::Instant as SmolInstant;
#[cfg(feature = "medium-ethernet")] #[cfg(feature = "medium-ethernet")]
use smoltcp::wire::EthernetAddress; use smoltcp::wire::EthernetAddress;
use smoltcp::wire::{IpAddress, IpCidr, Ipv4Address, Ipv4Cidr}; #[cfg(feature = "medium-ethernet")]
use smoltcp::wire::IpAddress;
use smoltcp::wire::{IpCidr, Ipv4Address, Ipv4Cidr};
use crate::config::Configurator; use crate::config::Configurator;
use crate::config::Event; use crate::config::Event;
@ -44,7 +48,9 @@ impl<const ADDR: usize, const SOCK: usize, const NEIGHBOR: usize>
Self { Self {
addresses: [IpCidr::new(Ipv4Address::UNSPECIFIED.into(), 32); ADDR], addresses: [IpCidr::new(Ipv4Address::UNSPECIFIED.into(), 32); ADDR],
sockets: [NONE_SOCKET; SOCK], sockets: [NONE_SOCKET; SOCK],
#[cfg(feature = "medium-ethernet")]
routes: [None; 1], routes: [None; 1],
#[cfg(feature = "medium-ethernet")]
neighbor_cache: [None; NEIGHBOR], neighbor_cache: [None; NEIGHBOR],
} }
} }
@ -84,6 +90,7 @@ impl Stack {
} }
fn poll_configurator(&mut self, timestamp: SmolInstant) { fn poll_configurator(&mut self, timestamp: SmolInstant) {
#[cfg(feature = "medium-ethernet")]
let medium = self.iface.device().capabilities().medium; let medium = self.iface.device().capabilities().medium;
match self match self
@ -180,6 +187,7 @@ pub fn init<const ADDR: usize, const SOCK: usize, const NEIGH: usize>(
configurator: &'static mut dyn Configurator, configurator: &'static mut dyn Configurator,
resources: &'static mut StackResources<ADDR, SOCK, NEIGH>, resources: &'static mut StackResources<ADDR, SOCK, NEIGH>,
) { ) {
#[cfg(feature = "medium-ethernet")]
let medium = device.capabilities().medium; let medium = device.capabilities().medium;
#[cfg(feature = "medium-ethernet")] #[cfg(feature = "medium-ethernet")]