pub struct DhcpRepr<'a> {Show 21 fields
pub message_type: MessageType,
pub transaction_id: u32,
pub secs: u16,
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<Vec<Ipv4Address, MAX_DNS_SERVER_COUNT>>,
pub max_size: Option<u16>,
pub lease_duration: Option<u32>,
pub renew_duration: Option<u32>,
pub rebind_duration: Option<u32>,
pub additional_options: &'a [DhcpOption<'a>],
}
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.
secs: u16
seconds elapsed since client began address acquisition or renewal process the DHCPREQUEST message MUST use the same value in the DHCP message header’s ‘secs’ field and be sent to the same IP broadcast address as the original DHCPDISCOVER message.
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<Vec<Ipv4Address, MAX_DNS_SERVER_COUNT>>
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.
renew_duration: Option<u32>
The DHCP IP renew duration (T1 interval), in seconds, if specified in the packet.
rebind_duration: Option<u32>
The DHCP IP rebind duration (T2 interval), in seconds, if specified in the packet.
additional_options: &'a [DhcpOption<'a>]
When returned from Repr::parse
, this field will be None
.
However, when calling Repr::emit
, this field should contain only
additional DHCP options not known to smoltcp.