pub struct Message {Show 16 fields
pub op: Ops,
pub htype: HTypes,
pub hlen: u8,
pub hops: u8,
pub xid: u32,
pub secs: u16,
pub flags: Flags,
pub ciaddr: Ipv4Addr,
pub yiaddr: Ipv4Addr,
pub siaddr: Ipv4Addr,
pub giaddr: Ipv4Addr,
pub chaddr: [u8; 16],
pub sname: SName,
pub file: File,
pub magic: [u8; 4],
pub options: Vec<MessageOptions>,
}Expand description
Wraps all the data sent between DHCP clients and servers.
Formally defined in RFC-2131 as:
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 2
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| op (1) | htype (1) | hlen (1) | hops (1) |
+---------------+---------------+---------------+---------------+
| xid (4) |
+-------------------------------+-------------------------------+
| secs (2) | flags (2) |
+-------------------------------+-------------------------------+
| ciaddr (4) |
+---------------------------------------------------------------+
| yiaddr (4) |
+---------------------------------------------------------------+
| siaddr (4) |
+---------------------------------------------------------------+
| giaddr (4) |
+---------------------------------------------------------------+
| chaddr (16) |
+---------------------------------------------------------------+
| sname (64) |
+---------------------------------------------------------------+
| file (128) |
+---------------------------------------------------------------+
| options (variable) |
+---------------------------------------------------------------+Fields§
§op: OpsMessage type (not to be confused with a MessageOptions’s MessageTypes)
htype: HTypesHardware address type
hlen: u8Hardware address length
hops: u8Optionally used by relay agents when booting via a relay agent. Client sets to zero.
xid: u32The transaction id. 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: u16Seconds elapsed since client started address acquisition/renewal process. Filled in by client.
flags: FlagsThe leftmost bit is defined as the Broadcast flag. The remaining bits are reserved for future use, and must be set to zero by clients and ignored by servers and relay agents.
ciaddr: Ipv4AddrClient IP address. Only filled in if the client is in BOUND, RENEW, or REBINDING state and can respond to ARP requests.
yiaddr: Ipv4AddrYour IP address
siaddr: Ipv4AddrIP address of the next server to use in bootstrap. Returned in DHCPOFFER, DHCPACK by server.
giaddr: Ipv4AddrRelay agent IP address. Used in booting via a relay agent.
chaddr: [u8; 16]Client hardware address
If using an ethernet hardware type you can get the value for this field with the mac_address crate. A Client will automatically use mac_address.
sname: SNameServer host name (optional). Null terminated string. 64 bytes in length.
file: FileBoot file name. Null terminated string. Generic name or null in DHCPDISCOVER. Fully qualified directory path name in DHCPOFFER. 128 bytes in length.
magic: [u8; 4]The first four octets of options field with values 99, 130, 83, 99
options: Vec<MessageOptions>A variable length field with a minimum of 312 octets. Options use Tag-Length-Value (TLV) encoding, where multi-byte quantities are in network byte order. The last option must be MessageOptions::End
Trait Implementations§
Source§impl DecodeMessage for Message
impl DecodeMessage for Message
Source§type Options = Vec<MessageOptions>
type Options = Vec<MessageOptions>
Source§fn decode_op(op: &[u8]) -> Self::Op
fn decode_op(op: &[u8]) -> Self::Op
Source§fn decode_htype(htype: &[u8]) -> Self::Htype
fn decode_htype(htype: &[u8]) -> Self::Htype
Source§fn decode_hlen(hlen: &[u8]) -> Self::Hlen
fn decode_hlen(hlen: &[u8]) -> Self::Hlen
Source§fn decode_hops(hops: &[u8]) -> Self::Hops
fn decode_hops(hops: &[u8]) -> Self::Hops
Source§fn decode_xid(xid: &[u8]) -> Self::Xid
fn decode_xid(xid: &[u8]) -> Self::Xid
Source§fn decode_secs(secs: &[u8]) -> Self::Secs
fn decode_secs(secs: &[u8]) -> Self::Secs
Source§fn decode_flags(flags: &[u8]) -> Self::Flags
fn decode_flags(flags: &[u8]) -> Self::Flags
Source§fn decode_ciaddr(ciaddr: &[u8]) -> Self::Ciaddr
fn decode_ciaddr(ciaddr: &[u8]) -> Self::Ciaddr
Source§fn decode_yiaddr(yiaddr: &[u8]) -> Self::Yiaddr
fn decode_yiaddr(yiaddr: &[u8]) -> Self::Yiaddr
Source§fn decode_siaddr(siaddr: &[u8]) -> Self::Siaddr
fn decode_siaddr(siaddr: &[u8]) -> Self::Siaddr
Source§fn decode_giaddr(giaddr: &[u8]) -> Self::Giaddr
fn decode_giaddr(giaddr: &[u8]) -> Self::Giaddr
Source§fn decode_chaddr(chaddr: &[u8]) -> Self::Chaddr
fn decode_chaddr(chaddr: &[u8]) -> Self::Chaddr
Source§fn decode_sname(sname: &[u8]) -> Self::Sname
fn decode_sname(sname: &[u8]) -> Self::Sname
Source§fn decode_file(file: &[u8]) -> Self::File
fn decode_file(file: &[u8]) -> Self::File
Source§fn decode_magic(_magic: &[u8]) -> Self::Magic
fn decode_magic(_magic: &[u8]) -> Self::Magic
Source§fn decode_options(options: &[u8]) -> Self::Options
fn decode_options(options: &[u8]) -> Self::Options
Source§impl EncodeMessage for Message
impl EncodeMessage for Message
Source§fn encode_htype(&self) -> u8
fn encode_htype(&self) -> u8
Source§fn encode_hlen(&self) -> u8
fn encode_hlen(&self) -> u8
Source§fn encode_hops(&self) -> u8
fn encode_hops(&self) -> u8
Source§fn encode_xid(&self) -> [u8; 4]
fn encode_xid(&self) -> [u8; 4]
Source§fn encode_secs(&self) -> [u8; 2]
fn encode_secs(&self) -> [u8; 2]
Source§fn encode_flags(&self) -> [u8; 2]
fn encode_flags(&self) -> [u8; 2]
Source§fn encode_ciaddr(&self) -> [u8; 4]
fn encode_ciaddr(&self) -> [u8; 4]
Source§fn encode_yiaddr(&self) -> [u8; 4]
fn encode_yiaddr(&self) -> [u8; 4]
Source§fn encode_siaddr(&self) -> [u8; 4]
fn encode_siaddr(&self) -> [u8; 4]
Source§fn encode_giaddr(&self) -> [u8; 4]
fn encode_giaddr(&self) -> [u8; 4]
Source§fn encode_chaddr(&self) -> [u8; 16]
fn encode_chaddr(&self) -> [u8; 16]
Source§fn encode_sname(&self) -> [u8; 64]
fn encode_sname(&self) -> [u8; 64]
Source§fn encode_file(&self) -> [u8; 128]
fn encode_file(&self) -> [u8; 128]
Source§fn encode_options(&self) -> Vec<u8> ⓘ
fn encode_options(&self) -> Vec<u8> ⓘ
Source§fn encode_magic(&self) -> [u8; 4]
fn encode_magic(&self) -> [u8; 4]
Source§impl MessageHelpers for Message
impl MessageHelpers for Message
Source§fn find_option(&self, tag: u8) -> Option<&MessageOptions>
fn find_option(&self, tag: u8) -> Option<&MessageOptions>
Source§fn add_option(&mut self, option: MessageOptions)
fn add_option(&mut self, option: MessageOptions)
MessageOptions::End.