net: update smoltcp

This commit is contained in:
Dario Nieuwenhuis
2021-11-26 04:12:14 +01:00
parent 539c007b44
commit c257893da9
10 changed files with 55 additions and 73 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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 {