diff options
Diffstat (limited to 'embassy-net/src/config/mod.rs')
| -rw-r--r-- | embassy-net/src/config/mod.rs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/embassy-net/src/config/mod.rs b/embassy-net/src/config/mod.rs new file mode 100644 index 000000000..16470f7e6 --- /dev/null +++ b/embassy-net/src/config/mod.rs | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | use heapless::consts::*; | ||
| 2 | use heapless::Vec; | ||
| 3 | use smoltcp::time::Instant; | ||
| 4 | use smoltcp::wire::{Ipv4Address, Ipv4Cidr}; | ||
| 5 | |||
| 6 | use crate::fmt::*; | ||
| 7 | use crate::{Interface, SocketSet}; | ||
| 8 | |||
| 9 | mod statik; | ||
| 10 | pub use statik::StaticConfigurator; | ||
| 11 | |||
| 12 | #[cfg(feature = "dhcpv4")] | ||
| 13 | mod dhcp; | ||
| 14 | #[cfg(feature = "dhcpv4")] | ||
| 15 | pub use dhcp::DhcpConfigurator; | ||
| 16 | |||
| 17 | /// Return value for the `Configurator::poll` function | ||
| 18 | #[derive(Debug, Clone)] | ||
| 19 | pub enum Event { | ||
| 20 | /// No change has occured to the configuration. | ||
| 21 | NoChange, | ||
| 22 | /// Configuration has been lost (for example, DHCP lease has expired) | ||
| 23 | Deconfigured, | ||
| 24 | /// Configuration has been newly acquired, or modified. | ||
| 25 | Configured(Config), | ||
| 26 | } | ||
| 27 | |||
| 28 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
| 29 | pub struct Config { | ||
| 30 | pub address: Ipv4Cidr, | ||
| 31 | pub gateway: Option<Ipv4Address>, | ||
| 32 | pub dns_servers: Vec<Ipv4Address, U3>, | ||
| 33 | } | ||
| 34 | |||
| 35 | pub trait Configurator { | ||
| 36 | fn poll(&mut self, iface: &mut Interface, sockets: &mut SocketSet, timestamp: Instant) | ||
| 37 | -> Event; | ||
| 38 | } | ||
