Struct dhcproto::v6::Message

source ·
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

source

pub fn new(msg_type: MessageType) -> Self

returns a new Message with a random xid and empty opt section

source

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

source

pub fn msg_type(&self) -> MessageType

Get the message’s message type.

source

pub fn set_msg_type(&mut self, msg_type: MessageType) -> &mut Self

Set message type

source

pub fn xid(&self) -> [u8; 3]

Get the message’s transaction id.

source

pub fn xid_num(&self) -> u32

Get the msgs transaction id as a number

source

pub fn set_xid(&mut self, xid: [u8; 3]) -> &mut Self

Set transaction id

source

pub fn set_xid_num(&mut self, xid: u32) -> &mut Self

Set transaction id from u32, will only use last 3 bytes

source

pub fn opts(&self) -> &DhcpOptions

Get a reference to the message’s options.

source

pub fn set_opts(&mut self, opts: DhcpOptions) -> &mut Self

Set DHCP opts

source

pub fn opts_mut(&mut self) -> &mut DhcpOptions

Get a mutable reference to the message’s options.

Trait Implementations§

source§

impl Clone for Message

source§

fn clone(&self) -> Message

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Message

source§

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

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

impl Decodable for Message

source§

fn decode(decoder: &mut Decoder<'_>) -> DecodeResult<Self>

Read the type from the stream
source§

fn from_bytes(bytes: &[u8]) -> DecodeResult<Self>

Returns the object in binary form
source§

impl Default for Message

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Message

source§

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

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

impl Encodable for Message

source§

fn encode(&self, e: &mut Encoder<'_>) -> EncodeResult<()>

encode type to buffer in Encoder
source§

fn to_vec(&self) -> EncodeResult<Vec<u8>>

encode this type into its binary form in a new Vec
source§

impl PartialEq for Message

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Message

source§

impl StructuralEq for Message

source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more