Struct Message

Source
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: Ops

Message type (not to be confused with a MessageOptions’s MessageTypes)

§htype: HTypes

Hardware address type

§hlen: u8

Hardware address length

§hops: u8

Optionally used by relay agents when booting via a relay agent. Client sets to zero.

§xid: u32

The 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: u16

Seconds elapsed since client started address acquisition/renewal process. Filled in by client.

§flags: Flags

The 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: Ipv4Addr

Client IP address. Only filled in if the client is in BOUND, RENEW, or REBINDING state and can respond to ARP requests.

§yiaddr: Ipv4Addr

Your IP address

§siaddr: Ipv4Addr

IP address of the next server to use in bootstrap. Returned in DHCPOFFER, DHCPACK by server.

§giaddr: Ipv4Addr

Relay 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: SName

Server host name (optional). Null terminated string. 64 bytes in length.

§file: File

Boot 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 Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DecodeMessage for Message

Source§

type Op = Ops

The type your custom Message uses to represent the op field.
Source§

type Htype = HTypes

The type your custom Message uses to represent the htype field.
Source§

type Hlen = u8

The type your custom Message uses to represent the hlen field.
Source§

type Hops = u8

The type your custom Message uses to represent the hops field.
Source§

type Xid = u32

The type your custom Message uses to represent the xid field.
Source§

type Secs = u16

The type your custom Message uses to represent the secs field.
Source§

type Flags = Flags

The type your custom Message uses to represent the flags field.
Source§

type Ciaddr = Ipv4Addr

The type your custom Message uses to represent the ciaddr field.
Source§

type Yiaddr = Ipv4Addr

The type your custom Message uses to represent the yiaddr field.
Source§

type Siaddr = Ipv4Addr

The type your custom Message uses to represent the siaddr field.
Source§

type Giaddr = Ipv4Addr

The type your custom Message uses to represent the giaddr field.
Source§

type Chaddr = [u8; 16]

The type your custom Message uses to represent the chaddr field.
Source§

type Sname = SName

The type your custom Message uses to represent the sname field.
Source§

type File = File

The type your custom Message uses to represent the file field.
Source§

type Magic = [u8; 4]

The type your custom Message uses to represent the magic field.
Source§

type Options = Vec<MessageOptions>

The type your custom Message uses to represent the options field.
Source§

type Output = Message

Your custom Message.
Source§

fn decode_op(op: &[u8]) -> Self::Op

Convert an op field’s byte into your custom Message’s type.
Source§

fn decode_htype(htype: &[u8]) -> Self::Htype

Convert an htype field’s byte into your custom Message’s type.
Source§

fn decode_hlen(hlen: &[u8]) -> Self::Hlen

Convert an hlen field’s byte into your custom Message’s type.
Source§

fn decode_hops(hops: &[u8]) -> Self::Hops

Convert an hops field’s byte into your custom Message’s type.
Source§

fn decode_xid(xid: &[u8]) -> Self::Xid

Convert an xid field’s bytes into your custom Message’s type.
Source§

fn decode_secs(secs: &[u8]) -> Self::Secs

Convert an secs field’s bytes into your custom Message’s type.
Source§

fn decode_flags(flags: &[u8]) -> Self::Flags

Convert an flags field’s bytes into your custom Message’s type.
Source§

fn decode_ciaddr(ciaddr: &[u8]) -> Self::Ciaddr

Convert an ciaddr field’s bytes into your custom Message’s type.
Source§

fn decode_yiaddr(yiaddr: &[u8]) -> Self::Yiaddr

Convert an yiaddr field’s bytes into your custom Message’s type.
Source§

fn decode_siaddr(siaddr: &[u8]) -> Self::Siaddr

Convert an siaddr field’s bytes into your custom Message’s type.
Source§

fn decode_giaddr(giaddr: &[u8]) -> Self::Giaddr

Convert an giaddr field’s bytes into your custom Message’s type.
Source§

fn decode_chaddr(chaddr: &[u8]) -> Self::Chaddr

Convert an chaddr field’s bytes into your custom Message’s type.
Source§

fn decode_sname(sname: &[u8]) -> Self::Sname

Convert an sname field’s bytes into your custom Message’s type.
Source§

fn decode_file(file: &[u8]) -> Self::File

Convert an file field’s bytes into your custom Message’s type.
Source§

fn decode_magic(_magic: &[u8]) -> Self::Magic

Convert an magic field’s bytes into your custom Message’s type.
Source§

fn decode_options(options: &[u8]) -> Self::Options

Convert an options field’s bytes into your custom Message’s type.
Source§

fn from_bytes(input: &[u8]) -> Result<Self::Output>

decodes a byte array slice into a Message or other type that implements decodeMessage.
Source§

impl EncodeMessage for Message

Source§

fn encode_op(&self) -> u8

Represent any data type as the correct amount of op field bytes.
Source§

fn encode_htype(&self) -> u8

Represent any data type as the correct amount of htype field bytes.
Source§

fn encode_hlen(&self) -> u8

Represent any data type as the correct amount of hlen field bytes.
Source§

fn encode_hops(&self) -> u8

Represent any data type as the correct amount of hops field bytes.
Source§

fn encode_xid(&self) -> [u8; 4]

Represent any data type as the correct amount of xid field bytes.
Source§

fn encode_secs(&self) -> [u8; 2]

Represent any data type as the correct amount of secs field bytes.
Source§

fn encode_flags(&self) -> [u8; 2]

Represent any data type as the correct amount of flags field bytes.
Source§

fn encode_ciaddr(&self) -> [u8; 4]

Represent any data type as the correct amount of ciaddr field bytes.
Source§

fn encode_yiaddr(&self) -> [u8; 4]

Represent any data type as the correct amount of yiaddr field bytes.
Source§

fn encode_siaddr(&self) -> [u8; 4]

Represent any data type as the correct amount of siaddr field bytes.
Source§

fn encode_giaddr(&self) -> [u8; 4]

Represent any data type as the correct amount of giaddr field bytes.
Source§

fn encode_chaddr(&self) -> [u8; 16]

Represent any data type as the correct amount of chaddr field bytes.
Source§

fn encode_sname(&self) -> [u8; 64]

Represent any data type as the correct amount of sname field bytes.
Source§

fn encode_file(&self) -> [u8; 128]

Represent any data type as the correct amount of file field bytes.
Source§

fn encode_options(&self) -> Vec<u8>

Represent any data type as a variable amount of options field bytes.
Source§

fn encode_magic(&self) -> [u8; 4]

Automagically defined because its a constant
Source§

fn to_bytes(&self) -> Result<Vec<u8>>

Encodes a Message into a Vec of bytes by calling the encode_* methods defined in EncodeMessage, and uses a Encoder to store the output.
Source§

impl MessageHelpers for Message

Source§

fn find_option(&self, tag: u8) -> Option<&MessageOptions>

Search this Message’s list of options for a specific option.
Source§

fn add_option(&mut self, option: MessageOptions)

Add an option to the list of options, and ensure that it is added before MessageOptions::End.
Source§

fn get_mac_address(&self) -> MacAddress

Parses the chaddr field as a mac address.
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Deliverable for Message

Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V