pub struct Message { /* private fields */ }
Expand description
See RFC 8415 for updated DHCPv6 info DHCP for Ipv6
All DHCP messages sent between clients and servers share an identical fixed-format header and a variable-format area for options.
All values in the message header and in options are in network byte order.
Options are stored serially in the “options” field, with no padding between the options. Options are byte-aligned but are not aligned in any other way (such as on 2-byte or 4-byte boundaries).
The following diagram illustrates the format of DHCP messages sent between clients and servers:
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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| msg-type | transaction-id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. options .
. (variable number and length) .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
msg-type Identifies the DHCP message type; the
available message types are listed in
Section 7.3. A 1-octet field.
transaction-id The transaction ID for this message exchange.
A 3-octet field.
options Options carried in this message; options are
described in Section 21. A variable-length
field (4 octets less than the size of the
message).
Implementations§
source§impl Message
impl Message
sourcepub fn new(msg_type: MessageType) -> Self
pub fn new(msg_type: MessageType) -> Self
returns a new Message
with a random xid and empty opt section
sourcepub fn new_with_id(msg_type: MessageType, xid: [u8; 3]) -> Self
pub fn new_with_id(msg_type: MessageType, xid: [u8; 3]) -> Self
returns a new Message
with a given xid and message type and empty opt section
sourcepub fn msg_type(&self) -> MessageType
pub fn msg_type(&self) -> MessageType
Get the message’s message type.
sourcepub fn set_msg_type(&mut self, msg_type: MessageType) -> &mut Self
pub fn set_msg_type(&mut self, msg_type: MessageType) -> &mut Self
Set message type
sourcepub fn set_xid_num(&mut self, xid: u32) -> &mut Self
pub fn set_xid_num(&mut self, xid: u32) -> &mut Self
Set transaction id from u32, will only use last 3 bytes
sourcepub fn opts(&self) -> &DhcpOptions
pub fn opts(&self) -> &DhcpOptions
Get a reference to the message’s options.
sourcepub fn set_opts(&mut self, opts: DhcpOptions) -> &mut Self
pub fn set_opts(&mut self, opts: DhcpOptions) -> &mut Self
Set DHCP opts
sourcepub fn opts_mut(&mut self) -> &mut DhcpOptions
pub fn opts_mut(&mut self) -> &mut DhcpOptions
Get a mutable reference to the message’s options.