add is_link_up, is_config_up
This commit is contained in:
parent
4f528d8fae
commit
4eecb3cfa9
@ -18,7 +18,7 @@ pub use config::{Config, Configurator, Event as ConfigEvent, StaticConfigurator}
|
|||||||
|
|
||||||
pub use device::{Device, LinkState};
|
pub use device::{Device, LinkState};
|
||||||
pub use packet_pool::{Packet, PacketBox, PacketBoxExt, PacketBuf};
|
pub use packet_pool::{Packet, PacketBox, PacketBoxExt, PacketBuf};
|
||||||
pub use stack::{init, is_init, run};
|
pub use stack::{init, is_config_up, is_init, is_link_up, run};
|
||||||
|
|
||||||
#[cfg(feature = "tcp")]
|
#[cfg(feature = "tcp")]
|
||||||
mod tcp_socket;
|
mod tcp_socket;
|
||||||
|
@ -46,6 +46,7 @@ pub(crate) struct Stack {
|
|||||||
iface: Interface,
|
iface: Interface,
|
||||||
pub sockets: SocketSet,
|
pub sockets: SocketSet,
|
||||||
link_up: bool,
|
link_up: bool,
|
||||||
|
config_up: bool,
|
||||||
next_local_port: u16,
|
next_local_port: u16,
|
||||||
configurator: &'static mut dyn Configurator,
|
configurator: &'static mut dyn Configurator,
|
||||||
waker: WakerRegistration,
|
waker: WakerRegistration,
|
||||||
@ -102,6 +103,8 @@ impl Stack {
|
|||||||
for (i, s) in config.dns_servers.iter().enumerate() {
|
for (i, s) in config.dns_servers.iter().enumerate() {
|
||||||
debug!(" DNS server {}: {}", i, s);
|
debug!(" DNS server {}: {}", i, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.config_up = true;
|
||||||
}
|
}
|
||||||
Event::Deconfigured => {
|
Event::Deconfigured => {
|
||||||
debug!("Lost IP configuration");
|
debug!("Lost IP configuration");
|
||||||
@ -110,6 +113,7 @@ impl Stack {
|
|||||||
if medium == Medium::Ethernet {
|
if medium == Medium::Ethernet {
|
||||||
self.iface.routes_mut().remove_default_ipv4_route();
|
self.iface.routes_mut().remove_default_ipv4_route();
|
||||||
}
|
}
|
||||||
|
self.config_up = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,6 +213,7 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
|
|||||||
iface,
|
iface,
|
||||||
sockets,
|
sockets,
|
||||||
link_up: false,
|
link_up: false,
|
||||||
|
config_up: false,
|
||||||
configurator,
|
configurator,
|
||||||
next_local_port: local_port,
|
next_local_port: local_port,
|
||||||
waker: WakerRegistration::new(),
|
waker: WakerRegistration::new(),
|
||||||
@ -221,6 +226,14 @@ pub fn is_init() -> bool {
|
|||||||
STACK.borrow().borrow().is_some()
|
STACK.borrow().borrow().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_link_up() -> bool {
|
||||||
|
STACK.borrow().borrow().as_ref().unwrap().link_up
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_config_up() -> bool {
|
||||||
|
STACK.borrow().borrow().as_ref().unwrap().config_up
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn run() {
|
pub async fn run() {
|
||||||
futures::future::poll_fn(|cx| {
|
futures::future::poll_fn(|cx| {
|
||||||
Stack::with(|stack| stack.poll(cx));
|
Stack::with(|stack| stack.poll(cx));
|
||||||
|
Loading…
Reference in New Issue
Block a user