aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-net/src/lib.rs')
-rw-r--r--embassy-net/src/lib.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index afe0d6da0..b58c9cf36 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -18,6 +18,7 @@ use core::cell::RefCell;
18use core::future::{poll_fn, Future}; 18use core::future::{poll_fn, Future};
19use core::task::{Context, Poll}; 19use core::task::{Context, Poll};
20 20
21use embassy_net_driver::{Driver, LinkState, Medium};
21use embassy_sync::waitqueue::WakerRegistration; 22use embassy_sync::waitqueue::WakerRegistration;
22use embassy_time::{Instant, Timer}; 23use embassy_time::{Instant, Timer};
23use futures::pin_mut; 24use futures::pin_mut;
@@ -27,8 +28,6 @@ use smoltcp::iface::SocketHandle;
27use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage}; 28use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage};
28#[cfg(feature = "medium-ethernet")] 29#[cfg(feature = "medium-ethernet")]
29use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes}; 30use smoltcp::iface::{Neighbor, NeighborCache, Route, Routes};
30#[cfg(feature = "medium-ethernet")]
31use smoltcp::phy::Medium;
32#[cfg(feature = "dhcpv4")] 31#[cfg(feature = "dhcpv4")]
33use smoltcp::socket::dhcpv4; 32use smoltcp::socket::dhcpv4;
34// smoltcp reexports 33// smoltcp reexports
@@ -41,7 +40,7 @@ pub use smoltcp::wire::{Ipv6Address, Ipv6Cidr};
41#[cfg(feature = "udp")] 40#[cfg(feature = "udp")]
42pub use smoltcp::{socket::udp::PacketMetadata, wire::IpListenEndpoint}; 41pub use smoltcp::{socket::udp::PacketMetadata, wire::IpListenEndpoint};
43 42
44use crate::device::{Device, DeviceAdapter, LinkState}; 43use crate::device::DriverAdapter;
45 44
46const LOCAL_PORT_MIN: u16 = 1025; 45const LOCAL_PORT_MIN: u16 = 1025;
47const LOCAL_PORT_MAX: u16 = 65535; 46const LOCAL_PORT_MAX: u16 = 65535;
@@ -82,12 +81,12 @@ pub enum ConfigStrategy {
82 Dhcp, 81 Dhcp,
83} 82}
84 83
85pub struct Stack<D: Device> { 84pub struct Stack<D: Driver> {
86 pub(crate) socket: RefCell<SocketStack>, 85 pub(crate) socket: RefCell<SocketStack>,
87 inner: RefCell<Inner<D>>, 86 inner: RefCell<Inner<D>>,
88} 87}
89 88
90struct Inner<D: Device> { 89struct Inner<D: Driver> {
91 device: D, 90 device: D,
92 link_up: bool, 91 link_up: bool,
93 config: Option<Config>, 92 config: Option<Config>,
@@ -102,7 +101,7 @@ pub(crate) struct SocketStack {
102 next_local_port: u16, 101 next_local_port: u16,
103} 102}
104 103
105impl<D: Device + 'static> Stack<D> { 104impl<D: Driver + 'static> Stack<D> {
106 pub fn new<const ADDR: usize, const SOCK: usize, const NEIGH: usize>( 105 pub fn new<const ADDR: usize, const SOCK: usize, const NEIGH: usize>(
107 mut device: D, 106 mut device: D,
108 config: ConfigStrategy, 107 config: ConfigStrategy,
@@ -130,7 +129,7 @@ impl<D: Device + 'static> Stack<D> {
130 b = b.routes(Routes::new(&mut resources.routes[..])); 129 b = b.routes(Routes::new(&mut resources.routes[..]));
131 } 130 }
132 131
133 let iface = b.finalize(&mut DeviceAdapter { 132 let iface = b.finalize(&mut DriverAdapter {
134 inner: &mut device, 133 inner: &mut device,
135 cx: None, 134 cx: None,
136 }); 135 });
@@ -211,7 +210,7 @@ impl SocketStack {
211 } 210 }
212} 211}
213 212
214impl<D: Device + 'static> Inner<D> { 213impl<D: Driver + 'static> Inner<D> {
215 fn apply_config(&mut self, s: &mut SocketStack, config: Config) { 214 fn apply_config(&mut self, s: &mut SocketStack, config: Config) {
216 #[cfg(feature = "medium-ethernet")] 215 #[cfg(feature = "medium-ethernet")]
217 let medium = self.device.capabilities().medium; 216 let medium = self.device.capabilities().medium;
@@ -263,7 +262,7 @@ impl<D: Device + 'static> Inner<D> {
263 s.waker.register(cx.waker()); 262 s.waker.register(cx.waker());
264 263
265 let timestamp = instant_to_smoltcp(Instant::now()); 264 let timestamp = instant_to_smoltcp(Instant::now());
266 let mut smoldev = DeviceAdapter { 265 let mut smoldev = DriverAdapter {
267 cx: Some(cx), 266 cx: Some(cx),
268 inner: &mut self.device, 267 inner: &mut self.device,
269 }; 268 };