Struct smoltcp::dhcp::Dhcpv4Client [−][src]
Implementations
impl Client
[src]
DHCP client with a RawSocket.
To provide memory for the dynamic IP address, configure your
Interface
with one of ip_addrs
and the ipv4_gateway
being
Ipv4Address::UNSPECIFIED
. You must also assign this 0.0.0.0/0
while the client’s state is Discovering
. Hence, the poll()
method returns a corresponding Config
struct in this case.
You must call dhcp_client.poll()
after iface.poll()
to send
and receive DHCP packets.
pub fn new<'a>(
sockets: &mut SocketSet<'a>,
rx_buffer: RawSocketBuffer<'a>,
tx_buffer: RawSocketBuffer<'a>,
now: Instant
) -> Self
[src]
sockets: &mut SocketSet<'a>,
rx_buffer: RawSocketBuffer<'a>,
tx_buffer: RawSocketBuffer<'a>,
now: Instant
) -> Self
Usage
use smoltcp::socket::{SocketSet, RawSocketBuffer, RawPacketMetadata}; use smoltcp::dhcp::Dhcpv4Client; use smoltcp::time::Instant; let mut sockets = SocketSet::new(vec![]); let dhcp_rx_buffer = RawSocketBuffer::new( [RawPacketMetadata::EMPTY; 1], vec![0; 600] ); let dhcp_tx_buffer = RawSocketBuffer::new( [RawPacketMetadata::EMPTY; 1], vec![0; 600] ); let mut dhcp = Dhcpv4Client::new( &mut sockets, dhcp_rx_buffer, dhcp_tx_buffer, Instant::now() );
pub fn next_poll(&self, now: Instant) -> Duration
[src]
When to send next packet
Useful for suspending execution after polling.
pub fn poll<DeviceT>(
&mut self,
iface: &mut Interface<'_, DeviceT>,
sockets: &mut SocketSet<'_>,
now: Instant
) -> Result<Option<Config>> where
DeviceT: for<'d> Device<'d>,
[src]
&mut self,
iface: &mut Interface<'_, DeviceT>,
sockets: &mut SocketSet<'_>,
now: Instant
) -> Result<Option<Config>> where
DeviceT: for<'d> Device<'d>,
Process incoming packets on the contained RawSocket, and send DHCP requests when timeouts are ready.
Applying the obtained network configuration is left to the user.
A Config can be returned from any valid DHCP reply. The client performs no bookkeeping on configuration or their changes.
pub fn reset(&mut self, now: Instant)
[src]
Reset state and restart discovery phase.
Use this to speed up acquisition of an address in a new network if a link was down and it is now back up.
You must configure a 0.0.0.0
address on your interface
before the next call to poll()
!
Auto Trait Implementations
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,