aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Jan Czochański <[email protected]>2023-01-18 10:10:33 +0100
committerDario Nieuwenhuis <[email protected]>2023-01-19 14:44:01 +0100
commit8f4fae9b36f017a8ab65491ef49b72499a9486dc (patch)
treed5bd2b0df691d7602507093426c3ee5a498c8c5f
parent2eae12b7f1cbe38d850ebf30f23a776323815af6 (diff)
Add smoltcp dhcp socket configuration
-rw-r--r--embassy-net/src/lib.rs72
-rw-r--r--examples/nrf52840/src/bin/usb_ethernet.rs11
-rw-r--r--examples/rp/src/bin/usb_ethernet.rs11
-rw-r--r--examples/std/Cargo.toml2
-rw-r--r--examples/std/src/bin/net.rs15
-rw-r--r--examples/std/src/bin/net_udp.rs13
-rw-r--r--examples/stm32f7/src/bin/eth.rs11
-rw-r--r--examples/stm32h7/src/bin/eth.rs11
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs11
-rw-r--r--examples/stm32l5/src/bin/usb_ethernet.rs11
10 files changed, 81 insertions, 87 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index 757d3e27d..c419ec1f9 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -30,6 +30,8 @@ use smoltcp::iface::SocketHandle;
30use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage}; 30use smoltcp::iface::{Interface, InterfaceBuilder, SocketSet, SocketStorage};
31#[cfg(feature = "dhcpv4")] 31#[cfg(feature = "dhcpv4")]
32use smoltcp::socket::dhcpv4; 32use smoltcp::socket::dhcpv4;
33use smoltcp::socket::dhcpv4::RetryConfig;
34use smoltcp::time::Duration;
33// smoltcp reexports 35// smoltcp reexports
34pub use smoltcp::time::{Duration as SmolDuration, Instant as SmolInstant}; 36pub use smoltcp::time::{Duration as SmolDuration, Instant as SmolInstant};
35#[cfg(feature = "medium-ethernet")] 37#[cfg(feature = "medium-ethernet")]
@@ -45,31 +47,53 @@ use crate::device::DriverAdapter;
45const LOCAL_PORT_MIN: u16 = 1025; 47const LOCAL_PORT_MIN: u16 = 1025;
46const LOCAL_PORT_MAX: u16 = 65535; 48const LOCAL_PORT_MAX: u16 = 65535;
47 49
48pub struct StackResources<const SOCK: usize, const NEIGHBOR: usize> { 50pub struct StackResources<const SOCK: usize> {
49 addresses: [IpCidr; 5],
50 sockets: [SocketStorage<'static>; SOCK], 51 sockets: [SocketStorage<'static>; SOCK],
51} 52}
52 53
53impl<const SOCK: usize, const NEIGHBOR: usize> StackResources<SOCK, NEIGHBOR> { 54impl<const SOCK: usize> StackResources<SOCK> {
54 pub fn new() -> Self { 55 pub fn new() -> Self {
55 Self { 56 Self {
56 addresses: [IpCidr::new(Ipv4Address::UNSPECIFIED.into(), 32); 5],
57 sockets: [SocketStorage::EMPTY; SOCK], 57 sockets: [SocketStorage::EMPTY; SOCK],
58 } 58 }
59 } 59 }
60} 60}
61 61
62#[derive(Debug, Clone, PartialEq, Eq)] 62#[derive(Debug, Clone, PartialEq, Eq)]
63pub struct Config { 63pub struct StaticConfig {
64 pub address: Ipv4Cidr, 64 pub address: Ipv4Cidr,
65 pub gateway: Option<Ipv4Address>, 65 pub gateway: Option<Ipv4Address>,
66 pub dns_servers: Vec<Ipv4Address, 3>, 66 pub dns_servers: Vec<Ipv4Address, 3>,
67} 67}
68 68
69pub enum ConfigStrategy { 69#[derive(Debug, Clone, PartialEq, Eq)]
70 Static(Config), 70pub struct DhcpConfig {
71 pub max_lease_duration: Option<Duration>,
72 pub retry_config: RetryConfig,
73 /// Ignore NAKs.
74 pub ignore_naks: bool,
75 /// Server port config
76 pub server_port: u16,
77 /// Client port config
78 pub client_port: u16,
79}
80
81impl Default for DhcpConfig {
82 fn default() -> Self {
83 Self {
84 max_lease_duration: Default::default(),
85 retry_config: Default::default(),
86 ignore_naks: Default::default(),
87 server_port: smoltcp::wire::DHCP_SERVER_PORT,
88 client_port: smoltcp::wire::DHCP_CLIENT_PORT,
89 }
90 }
91}
92
93pub enum Config {
94 Static(StaticConfig),
71 #[cfg(feature = "dhcpv4")] 95 #[cfg(feature = "dhcpv4")]
72 Dhcp, 96 Dhcp(DhcpConfig),
73} 97}
74 98
75pub struct Stack<D: Driver> { 99pub struct Stack<D: Driver> {
@@ -80,7 +104,7 @@ pub struct Stack<D: Driver> {
80struct Inner<D: Driver> { 104struct Inner<D: Driver> {
81 device: D, 105 device: D,
82 link_up: bool, 106 link_up: bool,
83 config: Option<Config>, 107 config: Option<StaticConfig>,
84 #[cfg(feature = "dhcpv4")] 108 #[cfg(feature = "dhcpv4")]
85 dhcp_socket: Option<SocketHandle>, 109 dhcp_socket: Option<SocketHandle>,
86} 110}
@@ -93,17 +117,16 @@ pub(crate) struct SocketStack {
93} 117}
94 118
95impl<D: Driver + 'static> Stack<D> { 119impl<D: Driver + 'static> Stack<D> {
96 pub fn new<const ADDR: usize, const SOCK: usize, const NEIGH: usize>( 120 pub fn new<const SOCK: usize>(
97 mut device: D, 121 mut device: D,
98 config: ConfigStrategy, 122 config: Config,
99 resources: &'static mut StackResources<SOCK, NEIGH>, 123 resources: &'static mut StackResources<SOCK>,
100 random_seed: u64, 124 random_seed: u64,
101 ) -> Self { 125 ) -> Self {
102 #[cfg(feature = "medium-ethernet")] 126 #[cfg(feature = "medium-ethernet")]
103 let medium = device.capabilities().medium; 127 let medium = device.capabilities().medium;
104 128
105 let mut b = InterfaceBuilder::new(); 129 let mut b = InterfaceBuilder::new();
106 b = b.ip_addrs(Vec::<IpCidr, 5>::from_iter(resources.addresses));
107 b = b.random_seed(random_seed); 130 b = b.random_seed(random_seed);
108 131
109 #[cfg(feature = "medium-ethernet")] 132 #[cfg(feature = "medium-ethernet")]
@@ -136,10 +159,12 @@ impl<D: Driver + 'static> Stack<D> {
136 }; 159 };
137 160
138 match config { 161 match config {
139 ConfigStrategy::Static(config) => inner.apply_config(&mut socket, config), 162 Config::Static(config) => inner.apply_config(&mut socket, config),
140 #[cfg(feature = "dhcpv4")] 163 #[cfg(feature = "dhcpv4")]
141 ConfigStrategy::Dhcp => { 164 Config::Dhcp(config) => {
142 let handle = socket.sockets.add(smoltcp::socket::dhcpv4::Socket::new()); 165 let mut dhcp_socket = smoltcp::socket::dhcpv4::Socket::new();
166 inner.apply_dhcp_config(&mut dhcp_socket, config);
167 let handle = socket.sockets.add(dhcp_socket);
143 inner.dhcp_socket = Some(handle); 168 inner.dhcp_socket = Some(handle);
144 } 169 }
145 } 170 }
@@ -170,7 +195,7 @@ impl<D: Driver + 'static> Stack<D> {
170 self.with(|_s, i| i.config.is_some()) 195 self.with(|_s, i| i.config.is_some())
171 } 196 }
172 197
173 pub fn config(&self) -> Option<Config> { 198 pub fn config(&self) -> Option<StaticConfig> {
174 self.with(|_s, i| i.config.clone()) 199 self.with(|_s, i| i.config.clone())
175 } 200 }
176 201
@@ -185,7 +210,7 @@ impl<D: Driver + 'static> Stack<D> {
185} 210}
186 211
187impl SocketStack { 212impl SocketStack {
188 #[allow(clippy::absurd_extreme_comparisons)] 213 #[allow(clippy::absurd_extreme_comparisons, dead_code)]
189 pub fn get_local_port(&mut self) -> u16 { 214 pub fn get_local_port(&mut self) -> u16 {
190 let res = self.next_local_port; 215 let res = self.next_local_port;
191 self.next_local_port = if res >= LOCAL_PORT_MAX { LOCAL_PORT_MIN } else { res + 1 }; 216 self.next_local_port = if res >= LOCAL_PORT_MAX { LOCAL_PORT_MIN } else { res + 1 };
@@ -194,7 +219,7 @@ impl SocketStack {
194} 219}
195 220
196impl<D: Driver + 'static> Inner<D> { 221impl<D: Driver + 'static> Inner<D> {
197 fn apply_config(&mut self, s: &mut SocketStack, config: Config) { 222 fn apply_config(&mut self, s: &mut SocketStack, config: StaticConfig) {
198 #[cfg(feature = "medium-ethernet")] 223 #[cfg(feature = "medium-ethernet")]
199 let medium = self.device.capabilities().medium; 224 let medium = self.device.capabilities().medium;
200 225
@@ -220,6 +245,13 @@ impl<D: Driver + 'static> Inner<D> {
220 self.config = Some(config) 245 self.config = Some(config)
221 } 246 }
222 247
248 fn apply_dhcp_config(&self, socket: &mut smoltcp::socket::dhcpv4::Socket, config: DhcpConfig) {
249 socket.set_ignore_naks(config.ignore_naks);
250 socket.set_max_lease_duration(config.max_lease_duration);
251 socket.set_ports(config.server_port, config.client_port);
252 socket.set_retry_config(config.retry_config);
253 }
254
223 #[allow(unused)] // used only with dhcp 255 #[allow(unused)] // used only with dhcp
224 fn unapply_config(&mut self, s: &mut SocketStack) { 256 fn unapply_config(&mut self, s: &mut SocketStack) {
225 #[cfg(feature = "medium-ethernet")] 257 #[cfg(feature = "medium-ethernet")]
@@ -280,7 +312,7 @@ impl<D: Driver + 'static> Inner<D> {
280 None => {} 312 None => {}
281 Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s), 313 Some(dhcpv4::Event::Deconfigured) => self.unapply_config(s),
282 Some(dhcpv4::Event::Configured(config)) => { 314 Some(dhcpv4::Event::Configured(config)) => {
283 let config = Config { 315 let config = StaticConfig {
284 address: config.address, 316 address: config.address,
285 gateway: config.router, 317 gateway: config.router,
286 dns_servers: config.dns_servers, 318 dns_servers: config.dns_servers,
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs
index e5f704524..1390bfc8f 100644
--- a/examples/nrf52840/src/bin/usb_ethernet.rs
+++ b/examples/nrf52840/src/bin/usb_ethernet.rs
@@ -101,8 +101,8 @@ async fn main(spawner: Spawner) {
101 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr); 101 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr);
102 unwrap!(spawner.spawn(usb_ncm_task(runner))); 102 unwrap!(spawner.spawn(usb_ncm_task(runner)));
103 103
104 let config = embassy_net::ConfigStrategy::Dhcp; 104 let config = embassy_net::Config::Dhcp(Default::default());
105 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 105 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
106 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 106 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
107 // dns_servers: Vec::new(), 107 // dns_servers: Vec::new(),
108 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 108 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
@@ -115,12 +115,7 @@ async fn main(spawner: Spawner) {
115 let seed = u64::from_le_bytes(seed); 115 let seed = u64::from_le_bytes(seed);
116 116
117 // Init network stack 117 // Init network stack
118 let stack = &*singleton!(Stack::new( 118 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
119 device,
120 config,
121 singleton!(StackResources::<1, 2, 8>::new()),
122 seed
123 ));
124 119
125 unwrap!(spawner.spawn(net_task(stack))); 120 unwrap!(spawner.spawn(net_task(stack)));
126 121
diff --git a/examples/rp/src/bin/usb_ethernet.rs b/examples/rp/src/bin/usb_ethernet.rs
index d0aec874a..e9b727127 100644
--- a/examples/rp/src/bin/usb_ethernet.rs
+++ b/examples/rp/src/bin/usb_ethernet.rs
@@ -92,8 +92,8 @@ async fn main(spawner: Spawner) {
92 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr); 92 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr);
93 unwrap!(spawner.spawn(usb_ncm_task(runner))); 93 unwrap!(spawner.spawn(usb_ncm_task(runner)));
94 94
95 let config = embassy_net::ConfigStrategy::Dhcp; 95 let config = embassy_net::Config::Dhcp(Default::default());
96 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 96 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
97 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 97 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
98 // dns_servers: Vec::new(), 98 // dns_servers: Vec::new(),
99 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 99 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
@@ -103,12 +103,7 @@ async fn main(spawner: Spawner) {
103 let seed = 1234; // guaranteed random, chosen by a fair dice roll 103 let seed = 1234; // guaranteed random, chosen by a fair dice roll
104 104
105 // Init network stack 105 // Init network stack
106 let stack = &*singleton!(Stack::new( 106 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
107 device,
108 config,
109 singleton!(StackResources::<1, 2, 8>::new()),
110 seed
111 ));
112 107
113 unwrap!(spawner.spawn(net_task(stack))); 108 unwrap!(spawner.spawn(net_task(stack)));
114 109
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml
index 45b2a4a4f..af1481e08 100644
--- a/examples/std/Cargo.toml
+++ b/examples/std/Cargo.toml
@@ -17,7 +17,7 @@ async-io = "1.6.0"
17env_logger = "0.9.0" 17env_logger = "0.9.0"
18futures = { version = "0.3.17" } 18futures = { version = "0.3.17" }
19log = "0.4.14" 19log = "0.4.14"
20nix = "0.22.1" 20nix = "0.26.2"
21libc = "0.2.101" 21libc = "0.2.101"
22clap = { version = "3.0.0-beta.5", features = ["derive"] } 22clap = { version = "3.0.0-beta.5", features = ["derive"] }
23rand_core = { version = "0.6.3", features = ["std"] } 23rand_core = { version = "0.6.3", features = ["std"] }
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs
index 9b1450b72..1ae39cace 100644
--- a/examples/std/src/bin/net.rs
+++ b/examples/std/src/bin/net.rs
@@ -1,9 +1,11 @@
1#![feature(type_alias_impl_trait)] 1#![feature(type_alias_impl_trait)]
2 2
3use std::default::Default;
4
3use clap::Parser; 5use clap::Parser;
4use embassy_executor::{Executor, Spawner}; 6use embassy_executor::{Executor, Spawner};
5use embassy_net::tcp::TcpSocket; 7use embassy_net::tcp::TcpSocket;
6use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, Stack, StackResources}; 8use embassy_net::{Config, Ipv4Address, Ipv4Cidr, Stack, StackResources};
7use embedded_io::asynch::Write; 9use embedded_io::asynch::Write;
8use heapless::Vec; 10use heapless::Vec;
9use log::*; 11use log::*;
@@ -48,13 +50,13 @@ async fn main_task(spawner: Spawner) {
48 50
49 // Choose between dhcp or static ip 51 // Choose between dhcp or static ip
50 let config = if opts.static_ip { 52 let config = if opts.static_ip {
51 ConfigStrategy::Static(embassy_net::Config { 53 Config::Static(embassy_net::StaticConfig {
52 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), 54 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
53 dns_servers: Vec::new(), 55 dns_servers: Vec::new(),
54 gateway: Some(Ipv4Address::new(192, 168, 69, 1)), 56 gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
55 }) 57 })
56 } else { 58 } else {
57 ConfigStrategy::Dhcp 59 Config::Dhcp(Default::default())
58 }; 60 };
59 61
60 // Generate random seed 62 // Generate random seed
@@ -63,12 +65,7 @@ async fn main_task(spawner: Spawner) {
63 let seed = u64::from_le_bytes(seed); 65 let seed = u64::from_le_bytes(seed);
64 66
65 // Init network stack 67 // Init network stack
66 let stack = &*singleton!(Stack::new( 68 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
67 device,
68 config,
69 singleton!(StackResources::<1, 2, 8>::new()),
70 seed
71 ));
72 69
73 // Launch network task 70 // Launch network task
74 spawner.spawn(net_task(stack)).unwrap(); 71 spawner.spawn(net_task(stack)).unwrap();
diff --git a/examples/std/src/bin/net_udp.rs b/examples/std/src/bin/net_udp.rs
index 392a97f0d..d1a8fe1e0 100644
--- a/examples/std/src/bin/net_udp.rs
+++ b/examples/std/src/bin/net_udp.rs
@@ -3,7 +3,7 @@
3use clap::Parser; 3use clap::Parser;
4use embassy_executor::{Executor, Spawner}; 4use embassy_executor::{Executor, Spawner};
5use embassy_net::udp::UdpSocket; 5use embassy_net::udp::UdpSocket;
6use embassy_net::{ConfigStrategy, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources}; 6use embassy_net::{Config, Ipv4Address, Ipv4Cidr, PacketMetadata, Stack, StackResources};
7use heapless::Vec; 7use heapless::Vec;
8use log::*; 8use log::*;
9use rand_core::{OsRng, RngCore}; 9use rand_core::{OsRng, RngCore};
@@ -47,13 +47,13 @@ async fn main_task(spawner: Spawner) {
47 47
48 // Choose between dhcp or static ip 48 // Choose between dhcp or static ip
49 let config = if opts.static_ip { 49 let config = if opts.static_ip {
50 ConfigStrategy::Static(embassy_net::Config { 50 Config::Static(embassy_net::StaticConfig {
51 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24), 51 address: Ipv4Cidr::new(Ipv4Address::new(192, 168, 69, 2), 24),
52 dns_servers: Vec::new(), 52 dns_servers: Vec::new(),
53 gateway: Some(Ipv4Address::new(192, 168, 69, 1)), 53 gateway: Some(Ipv4Address::new(192, 168, 69, 1)),
54 }) 54 })
55 } else { 55 } else {
56 ConfigStrategy::Dhcp 56 Config::Dhcp(Default::default())
57 }; 57 };
58 58
59 // Generate random seed 59 // Generate random seed
@@ -62,12 +62,7 @@ async fn main_task(spawner: Spawner) {
62 let seed = u64::from_le_bytes(seed); 62 let seed = u64::from_le_bytes(seed);
63 63
64 // Init network stack 64 // Init network stack
65 let stack = &*singleton!(Stack::new( 65 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
66 device,
67 config,
68 singleton!(StackResources::<1, 2, 8>::new()),
69 seed
70 ));
71 66
72 // Launch network task 67 // Launch network task
73 spawner.spawn(net_task(stack)).unwrap(); 68 spawner.spawn(net_task(stack)).unwrap();
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs
index 224cc202b..6f33a4f8b 100644
--- a/examples/stm32f7/src/bin/eth.rs
+++ b/examples/stm32f7/src/bin/eth.rs
@@ -69,20 +69,15 @@ async fn main(spawner: Spawner) -> ! {
69 0, 69 0,
70 ); 70 );
71 71
72 let config = embassy_net::ConfigStrategy::Dhcp; 72 let config = embassy_net::Config::Dhcp(Default::default());
73 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 73 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
74 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 74 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
75 // dns_servers: Vec::new(), 75 // dns_servers: Vec::new(),
76 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 76 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
77 //}); 77 //});
78 78
79 // Init network stack 79 // Init network stack
80 let stack = &*singleton!(Stack::new( 80 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
81 device,
82 config,
83 singleton!(StackResources::<1, 2, 8>::new()),
84 seed
85 ));
86 81
87 // Launch network task 82 // Launch network task
88 unwrap!(spawner.spawn(net_task(&stack))); 83 unwrap!(spawner.spawn(net_task(&stack)));
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 551325ca4..ad7fcc5c0 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -70,20 +70,15 @@ async fn main(spawner: Spawner) -> ! {
70 0, 70 0,
71 ); 71 );
72 72
73 let config = embassy_net::ConfigStrategy::Dhcp; 73 let config = embassy_net::Config::Dhcp(Default::default());
74 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 74 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
75 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 75 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
76 // dns_servers: Vec::new(), 76 // dns_servers: Vec::new(),
77 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 77 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
78 //}); 78 //});
79 79
80 // Init network stack 80 // Init network stack
81 let stack = &*singleton!(Stack::new( 81 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
82 device,
83 config,
84 singleton!(StackResources::<1, 2, 8>::new()),
85 seed
86 ));
87 82
88 // Launch network task 83 // Launch network task
89 unwrap!(spawner.spawn(net_task(&stack))); 84 unwrap!(spawner.spawn(net_task(&stack)));
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs
index 61a08ae10..7d3904f68 100644
--- a/examples/stm32h7/src/bin/eth_client.rs
+++ b/examples/stm32h7/src/bin/eth_client.rs
@@ -71,20 +71,15 @@ async fn main(spawner: Spawner) -> ! {
71 0, 71 0,
72 ); 72 );
73 73
74 let config = embassy_net::ConfigStrategy::Dhcp; 74 let config = embassy_net::Config::Dhcp(Default::default());
75 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 75 //let config = embassy_net::Config::StaticConfig(embassy_net::Config {
76 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 76 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
77 // dns_servers: Vec::new(), 77 // dns_servers: Vec::new(),
78 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 78 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
79 //}); 79 //});
80 80
81 // Init network stack 81 // Init network stack
82 let stack = &*singleton!(Stack::new( 82 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
83 device,
84 config,
85 singleton!(StackResources::<1, 2, 8>::new()),
86 seed
87 ));
88 83
89 // Launch network task 84 // Launch network task
90 unwrap!(spawner.spawn(net_task(&stack))); 85 unwrap!(spawner.spawn(net_task(&stack)));
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs
index b49329ea4..ff44c2fcb 100644
--- a/examples/stm32l5/src/bin/usb_ethernet.rs
+++ b/examples/stm32l5/src/bin/usb_ethernet.rs
@@ -98,8 +98,8 @@ async fn main(spawner: Spawner) {
98 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr); 98 let (runner, device) = class.into_embassy_net_device::<MTU, 4, 4>(singleton!(NetState::new()), our_mac_addr);
99 unwrap!(spawner.spawn(usb_ncm_task(runner))); 99 unwrap!(spawner.spawn(usb_ncm_task(runner)));
100 100
101 let config = embassy_net::ConfigStrategy::Dhcp; 101 let config = embassy_net::Config::Dhcp(Default::default());
102 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 102 //let config = embassy_net::Config::Static(embassy_net::StaticConfig {
103 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), 103 // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24),
104 // dns_servers: Vec::new(), 104 // dns_servers: Vec::new(),
105 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), 105 // gateway: Some(Ipv4Address::new(10, 42, 0, 1)),
@@ -110,12 +110,7 @@ async fn main(spawner: Spawner) {
110 let seed = rng.next_u64(); 110 let seed = rng.next_u64();
111 111
112 // Init network stack 112 // Init network stack
113 let stack = &*singleton!(Stack::new( 113 let stack = &*singleton!(Stack::new(device, config, singleton!(StackResources::<1>::new()), seed));
114 device,
115 config,
116 singleton!(StackResources::<1, 2, 8>::new()),
117 seed
118 ));
119 114
120 unwrap!(spawner.spawn(net_task(stack))); 115 unwrap!(spawner.spawn(net_task(stack)));
121 116