Skip to content

Commit

Permalink
Document DHCPv4 client.
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Jul 31, 2018
1 parent 35b3314 commit cd9773d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/dhcp/clientv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,27 @@ pub struct Client {
/// You must call `poll()` after `iface.poll()` to send and receive
/// DHCP packets.
impl Client {
/// TODO
/// # Usage
/// ```rust
/// 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; 1500]
/// );
/// let dhcp_tx_buffer = RawSocketBuffer::new(
/// [RawPacketMetadata::EMPTY; 1],
/// vec![0; 3000]
/// );
/// let mut dhcp = Dhcpv4Client::new(
/// &mut sockets,
/// dhcp_rx_buffer, dhcp_tx_buffer,
/// Instant::now()
/// );
/// ```
pub fn new<'a, 'b, 'c>(sockets: &mut SocketSet<'a, 'b, 'c>, rx_buffer: RawSocketBuffer<'b, 'c>, tx_buffer: RawSocketBuffer<'b, 'c>, now: Instant) -> Self
where 'b: 'c,
{
Expand Down Expand Up @@ -320,6 +340,8 @@ impl Client {
self.next_egress = now;
}

/// Returns iterable set of DNS servers as received from the DHCP
/// server.
pub fn dns_servers(&self) -> DnsServers {
DnsServers {
dns_servers: &self.dns_servers,
Expand Down

0 comments on commit cd9773d

Please sign in to comment.