Struct smoltcp::wire::DhcpRepr [−][src]
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.
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<[Option<Ipv4Address>; 3]>
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.
Implementations
impl<'a> Repr<'a>
[src]
pub fn buffer_len(&self) -> usize
[src]
Return the length of a packet that will be emitted from this high-level representation.
pub fn parse<T: ?Sized>(packet: &Packet<&'a T>) -> Result<Self> where
T: AsRef<[u8]>,
[src]
T: AsRef<[u8]>,
Parse a DHCP packet and return a high-level representation.
pub fn emit<T: ?Sized>(&self, packet: &mut Packet<&mut T>) -> Result<()> where
T: AsRef<[u8]> + AsMut<[u8]>,
[src]
T: AsRef<[u8]> + AsMut<[u8]>,
Emit a high-level representation into a Dynamic Host Configuration Protocol packet.
Trait Implementations
impl<'a> Clone for Repr<'a>
[src]
impl<'a> Copy for Repr<'a>
[src]
impl<'a> Debug for Repr<'a>
[src]
impl<'a> Eq for Repr<'a>
[src]
impl<'a> PartialEq<Repr<'a>> for Repr<'a>
[src]
impl<'a> StructuralEq for Repr<'a>
[src]
impl<'a> StructuralPartialEq for Repr<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for Repr<'a>
impl<'a> Send for Repr<'a>
impl<'a> Sync for Repr<'a>
impl<'a> Unpin for Repr<'a>
impl<'a> UnwindSafe for Repr<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,