[][src]Struct smoltcp::dhcp::Dhcpv4Client

pub struct Dhcpv4Client { /* fields omitted */ }

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]

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]

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.