net: update smoltcp
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
use heapless::Vec;
|
||||
use smoltcp::socket::{Dhcpv4Event, Dhcpv4Socket, SocketHandle};
|
||||
use smoltcp::iface::SocketHandle;
|
||||
use smoltcp::socket::{Dhcpv4Event, Dhcpv4Socket};
|
||||
use smoltcp::time::Instant;
|
||||
|
||||
use super::*;
|
||||
use crate::device::LinkState;
|
||||
use crate::{Interface, SocketSet};
|
||||
use crate::Interface;
|
||||
|
||||
pub struct DhcpConfigurator {
|
||||
handle: Option<SocketHandle>,
|
||||
@ -17,20 +18,16 @@ impl DhcpConfigurator {
|
||||
}
|
||||
|
||||
impl Configurator for DhcpConfigurator {
|
||||
fn poll(
|
||||
&mut self,
|
||||
iface: &mut Interface,
|
||||
sockets: &mut SocketSet,
|
||||
_timestamp: Instant,
|
||||
) -> Event {
|
||||
fn poll(&mut self, iface: &mut Interface, _timestamp: Instant) -> Event {
|
||||
if self.handle.is_none() {
|
||||
let handle = sockets.add(Dhcpv4Socket::new());
|
||||
let handle = iface.add_socket(Dhcpv4Socket::new());
|
||||
self.handle = Some(handle)
|
||||
}
|
||||
|
||||
let mut socket = sockets.get::<Dhcpv4Socket>(self.handle.unwrap());
|
||||
|
||||
let link_up = iface.device_mut().device.link_state() == LinkState::Up;
|
||||
|
||||
let socket = iface.get_socket::<Dhcpv4Socket>(self.handle.unwrap());
|
||||
|
||||
if !link_up {
|
||||
socket.reset();
|
||||
return Event::Deconfigured;
|
||||
|
@ -2,7 +2,7 @@ use heapless::Vec;
|
||||
use smoltcp::time::Instant;
|
||||
use smoltcp::wire::{Ipv4Address, Ipv4Cidr};
|
||||
|
||||
use crate::{Interface, SocketSet};
|
||||
use crate::Interface;
|
||||
|
||||
mod statik;
|
||||
pub use statik::StaticConfigurator;
|
||||
@ -31,6 +31,5 @@ pub struct Config {
|
||||
}
|
||||
|
||||
pub trait Configurator {
|
||||
fn poll(&mut self, iface: &mut Interface, sockets: &mut SocketSet, timestamp: Instant)
|
||||
-> Event;
|
||||
fn poll(&mut self, iface: &mut Interface, timestamp: Instant) -> Event;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use smoltcp::time::Instant;
|
||||
|
||||
use super::*;
|
||||
use crate::{Interface, SocketSet};
|
||||
use crate::Interface;
|
||||
|
||||
pub struct StaticConfigurator {
|
||||
config: Config,
|
||||
@ -18,12 +18,7 @@ impl StaticConfigurator {
|
||||
}
|
||||
|
||||
impl Configurator for StaticConfigurator {
|
||||
fn poll(
|
||||
&mut self,
|
||||
_iface: &mut Interface,
|
||||
_sockets: &mut SocketSet,
|
||||
_timestamp: Instant,
|
||||
) -> Event {
|
||||
fn poll(&mut self, _iface: &mut Interface, _timestamp: Instant) -> Event {
|
||||
if self.returned {
|
||||
Event::NoChange
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user