pub struct Socket<'a> { /* private fields */ }
Implementations§
Source§impl<'a> Socket<'a>
impl<'a> Socket<'a>
DHCP client socket.
The socket acquires an IP address configuration through DHCP autonomously.
You must query the configuration with .poll()
after every call to Interface::poll()
,
and apply the configuration to the Interface
.
Sourcepub fn set_retry_config(&mut self, config: RetryConfig)
pub fn set_retry_config(&mut self, config: RetryConfig)
Set the retry/timeouts configuration.
Sourcepub fn get_retry_config(&self) -> RetryConfig
pub fn get_retry_config(&self) -> RetryConfig
Gets the current retry/timeouts configuration
Sourcepub fn set_outgoing_options(&mut self, options: &'a [DhcpOption<'a>])
pub fn set_outgoing_options(&mut self, options: &'a [DhcpOption<'a>])
Set the outgoing options.
Sourcepub fn set_receive_packet_buffer(&mut self, buffer: &'a mut [u8])
pub fn set_receive_packet_buffer(&mut self, buffer: &'a mut [u8])
Set the buffer into which incoming DHCP packets are copied into.
Sourcepub fn set_parameter_request_list(&mut self, parameter_request_list: &'a [u8])
pub fn set_parameter_request_list(&mut self, parameter_request_list: &'a [u8])
Set the parameter request list.
This should contain at least OPT_SUBNET_MASK
(1
), OPT_ROUTER
(3
), and OPT_DOMAIN_NAME_SERVER
(6
).
Sourcepub fn max_lease_duration(&self) -> Option<Duration>
pub fn max_lease_duration(&self) -> Option<Duration>
Get the configured max lease duration.
See also Self::set_max_lease_duration()
Sourcepub fn set_max_lease_duration(&mut self, max_lease_duration: Option<Duration>)
pub fn set_max_lease_duration(&mut self, max_lease_duration: Option<Duration>)
Set the max lease duration.
When set, the lease duration will be capped at the configured duration if the DHCP server gives us a longer lease. This is generally not recommended, but can be useful for debugging or reacting faster to network configuration changes.
If None, no max is applied (the lease duration from the DHCP server is used.)
Sourcepub fn ignore_naks(&self) -> bool
pub fn ignore_naks(&self) -> bool
Get whether to ignore NAKs.
See also Self::set_ignore_naks()
Sourcepub fn set_ignore_naks(&mut self, ignore_naks: bool)
pub fn set_ignore_naks(&mut self, ignore_naks: bool)
Set whether to ignore NAKs.
This is not compliant with the DHCP RFCs, since theoretically we must stop using the assigned IP when receiving a NAK. This can increase reliability on broken networks with buggy routers or rogue DHCP servers, however.
Sourcepub fn set_ports(&mut self, server_port: u16, client_port: u16)
pub fn set_ports(&mut self, server_port: u16, client_port: u16)
Set the server/client port
Allows you to specify the ports used by DHCP. This is meant to support esoteric usecases allowed by the dhclient program.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
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.
Sourcepub fn poll(&mut self) -> Option<Event<'_>>
pub fn poll(&mut self) -> Option<Event<'_>>
Query the socket for configuration changes.
The socket has an internal “configuration changed” flag. If set, this function returns the configuration and resets the flag.
Sourcepub fn register_waker(&mut self, waker: &Waker)
pub fn register_waker(&mut self, waker: &Waker)
Register a waker.
The waker is woken on state changes that might affect the return value
of poll
method calls, which indicates a new state in the DHCP configuration
provided by this DHCP socket.
Notes:
- Only one waker can be registered at a time. If another waker was previously registered, it is overwritten and will no longer be woken.
- The Waker is woken only once. Once woken, you must register it again to receive more wakes.