Skip to main content

Module packet

Module packet 

Source
Expand description

DHCP packet parsing and encoding per RFC 2131.

A DHCP packet consists of a fixed 236-byte header followed by a 4-byte magic cookie and variable-length options. This module handles parsing incoming packets and constructing replies.

§Packet Structure

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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     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)                           |
+---------------------------------------------------------------+
|                    magic cookie (4) = 99.130.83.99            |
+---------------------------------------------------------------+
|                          options (variable)                   |
+---------------------------------------------------------------+

§References

  • RFC 2131: Dynamic Host Configuration Protocol

Structs§

DhcpPacket
A parsed DHCP packet.

Constants§

BOOTREPLY
BOOTP/DHCP operation code for server replies.
BOOTREQUEST
BOOTP/DHCP operation code for client requests.
HLEN_ETHERNET
Hardware address length for Ethernet (6 bytes).
HTYPE_ETHERNET
Hardware type for Ethernet (most common).