aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-net/src/lib.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index 23ec33262..4cc191d44 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -269,23 +269,42 @@ impl<D: Driver + 'static> Stack<D> {
269 /// Get whether the network stack has a valid IP configuration. 269 /// Get whether the network stack has a valid IP configuration.
270 /// This is true if the network stack has a static IP configuration or if DHCP has completed 270 /// This is true if the network stack has a static IP configuration or if DHCP has completed
271 pub fn is_config_up(&self) -> bool { 271 pub fn is_config_up(&self) -> bool {
272 let v4_up;
273 let v6_up;
274
272 #[cfg(feature = "proto-ipv4")] 275 #[cfg(feature = "proto-ipv4")]
273 { 276 {
274 return self.config_v4().is_some(); 277 v4_up = self.config_v4().is_some();
278 }
279 #[cfg(not(feature = "proto-ipv4"))]
280 {
281 v4_up = false;
275 } 282 }
276 283
277 #[cfg(not(any(feature = "proto-ipv4")))] 284 #[cfg(feature = "proto-ipv6")]
285 {
286 v6_up = self.config_v6().is_some();
287 }
288 #[cfg(not(feature = "proto-ipv6"))]
278 { 289 {
279 false 290 v6_up = false;
280 } 291 }
292
293 v4_up || v6_up
281 } 294 }
282 295
283 /// Get the current IP configuration. 296 /// Get the current IPv4 configuration.
284 #[cfg(feature = "proto-ipv4")] 297 #[cfg(feature = "proto-ipv4")]
285 pub fn config_v4(&self) -> Option<StaticConfigV4> { 298 pub fn config_v4(&self) -> Option<StaticConfigV4> {
286 self.with(|_s, i| i.static_v4.clone()) 299 self.with(|_s, i| i.static_v4.clone())
287 } 300 }
288 301
302 /// Get the current IPv6 configuration.
303 #[cfg(feature = "proto-ipv6")]
304 pub fn config_v6(&self) -> Option<StaticConfigV6> {
305 self.with(|_s, i| i.static_v6.clone())
306 }
307
289 /// Run the network stack. 308 /// Run the network stack.
290 /// 309 ///
291 /// You must call this in a background task, to process network events. 310 /// You must call this in a background task, to process network events.