Struct smoltcp::wire::DhcpRepr[][src]

pub struct DhcpRepr<'a> {
Show 17 fields pub message_type: MessageType, pub transaction_id: u32, pub client_hardware_address: EthernetAddress, pub client_ip: Ipv4Address, pub your_ip: Ipv4Address, pub server_ip: Ipv4Address, pub router: Option<Ipv4Address>, pub subnet_mask: Option<Ipv4Address>, pub relay_agent_ip: Ipv4Address, pub broadcast: bool, pub requested_ip: Option<Ipv4Address>, pub client_identifier: Option<EthernetAddress>, pub server_identifier: Option<Ipv4Address>, pub parameter_request_list: Option<&'a [u8]>, pub dns_servers: Option<[Option<Ipv4Address>; 3]>, pub max_size: Option<u16>, pub lease_duration: Option<u32>,
}
Expand description

A high-level representation of a Dynamic Host Configuration Protocol packet.

DHCP messages have the following layout (see RFC 2131 for details):

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| message_type  | htype (N/A)   |   hlen (N/A)  |   hops        |
+---------------+---------------+---------------+---------------+
|                       transaction_id                          |
+-------------------------------+-------------------------------+
|           secs                |           flags               |
+-------------------------------+-------------------------------+
|                           client_ip                           |
+---------------------------------------------------------------+
|                            your_ip                            |
+---------------------------------------------------------------+
|                           server_ip                           |
+---------------------------------------------------------------+
|                        relay_agent_ip                         |
+---------------------------------------------------------------+
|                                                               |
|                    client_hardware_address                    |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
|                                                               |
|                          sname  (N/A)                         |
+---------------------------------------------------------------+
|                                                               |
|                          file    (N/A)                        |
+---------------------------------------------------------------+
|                                                               |
|                          options                              |
+---------------------------------------------------------------+

It is assumed that the access layer is Ethernet, so htype (the field representing the hardware address type) is always set to 1, and hlen (which represents the hardware address length) is set to 6.

The options field has a variable length.

Fields

message_type: MessageType

This field is also known as op in the RFC. It indicates the type of DHCP message this packet represents.

transaction_id: u32

This field is also known as xid in the RFC. It is a random number chosen by the client, used by the client and server to associate messages and responses between a client and a server.

client_hardware_address: EthernetAddress

This field is also known as chaddr in the RFC and for networks where the access layer is ethernet, it is the client MAC address.

client_ip: Ipv4Address

This field is also known as ciaddr in the RFC. It is only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.

your_ip: Ipv4Address

This field is also known as yiaddr in the RFC.

server_ip: Ipv4Address

This field is also known as siaddr in the RFC. It may be set by the server in DHCPOFFER and DHCPACK messages, and represent the address of the next server to use in bootstrap.

router: Option<Ipv4Address>

Default gateway

subnet_mask: Option<Ipv4Address>

This field comes from a corresponding DhcpOption.

relay_agent_ip: Ipv4Address

This field is also known as giaddr in the RFC. In order to allow DHCP clients on subnets not directly served by DHCP servers to communicate with DHCP servers, DHCP relay agents can be installed on these subnets. The DHCP client broadcasts on the local link; the relay agent receives the broadcast and transmits it to one or more DHCP servers using unicast. The relay agent stores its own IP address in the relay_agent_ip field of the DHCP packet. The DHCP server uses the relay_agent_ip to determine the subnet on which the relay agent received the broadcast, and allocates an IP address on that subnet. When the DHCP server replies to the client, it sends the reply to the relay_agent_ip address, again using unicast. The relay agent then retransmits the response on the local network

broadcast: bool

Broadcast flags. It can be set in DHCPDISCOVER, DHCPINFORM and DHCPREQUEST message if the client requires the response to be broadcasted.

requested_ip: Option<Ipv4Address>

The “requested IP address” option. It can be used by clients in DHCPREQUEST or DHCPDISCOVER messages, or by servers in DHCPDECLINE messages.

client_identifier: Option<EthernetAddress>

The “client identifier” option.

The ‘client identifier’ is an opaque key, not to be interpreted by the server; for example, the ‘client identifier’ may contain a hardware address, identical to the contents of the ‘chaddr’ field, or it may contain another type of identifier, such as a DNS name. The ‘client identifier’ chosen by a DHCP client MUST be unique to that client within the subnet to which the client is attached. If the client uses a ‘client identifier’ in one message, it MUST use that same identifier in all subsequent messages, to ensure that all servers correctly identify the client.

server_identifier: Option<Ipv4Address>

The “server identifier” option. It is used both to identify a DHCP server in a DHCP message and as a destination address from clients to servers.

parameter_request_list: Option<&'a [u8]>

The parameter request list informs the server about which configuration parameters the client is interested in.

dns_servers: Option<[Option<Ipv4Address>; 3]>

DNS servers

max_size: Option<u16>

The maximum size dhcp packet the interface can receive

lease_duration: Option<u32>

The DHCP IP lease duration, specified in seconds.

Implementations

Return the length of a packet that will be emitted from this high-level representation.

Parse a DHCP packet and return a high-level representation.

Emit a high-level representation into a Dynamic Host Configuration Protocol packet.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.