DHCP¶
DHCP packet parser/serializer
-
class
ryu.lib.packet.dhcp.
dhcp
(op, chaddr, options=None, htype=1, hlen=0, hops=0, xid=None, secs=0, flags=0, ciaddr='0.0.0.0', yiaddr='0.0.0.0', siaddr='0.0.0.0', giaddr='0.0.0.0', sname='', boot_file='')¶ DHCP (RFC 2131) header encoder/decoder class.
The serialized packet would looks like the ones described in the following sections.
- RFC 2131 DHCP packet format
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description op Message op code / message type. 1 = BOOTREQUEST, 2 = BOOTREPLY htype Hardware address type (e.g. '1' = 10mb ethernet). hlen Hardware address length (e.g. '6' = 10mb ethernet). hops Client sets to zero, optionally used by relay agent when booting via a relay agent. xid Transaction ID, a random number chosen by the client, used by the client and serverto associate messages and responses between a client and a server. secs Filled in by client, seconds elapsed since client began address acquisition or renewal process. flags Flags. ciaddr Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests. yiaddr 'your' (client) IP address. siaddr IP address of next server to use in bootstrap; returned in DHCPOFFER, DHCPACK by server. giaddr Relay agent IP address, used in booting via a relay agent. chaddr Client hardware address. sname Optional server host name, null terminated string. boot_file Boot file name, null terminated string; "generic" name or null in DHCPDISCOVER, fully qualified directory-path name in DHCPOFFER. options Optional parameters field ('DHCP message type' option must be included in every DHCP message).
-
class
ryu.lib.packet.dhcp.
option
(tag, value, length=0)¶ DHCP (RFC 2132) options encoder/decoder class.
This is used with ryu.lib.packet.dhcp.dhcp.options.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description tag Option type. (except for the 'magic cookie', 'pad option' and 'end option'.) value Option's value. (set the value that has been converted to hexadecimal.) length Option's value length. (calculated automatically from the length of value.)
-
class
ryu.lib.packet.dhcp.
options
(option_list=None, options_len=0, magic_cookie='99.130.83.99')¶ DHCP (RFC 2132) options encoder/decoder class.
This is used with ryu.lib.packet.dhcp.dhcp.
An instance has the following attributes at least. Most of them are same to the on-wire counterparts but in host byte order. __init__ takes the corresponding args in this order.
Attribute Description option_list 'end option' and 'pad option' are added automatically after the option class is stored in array. options_len Option's byte length. ('magic cookie', 'end option' and 'pad option' length including.) magic_cookie The first four octets contain the decimal values 99, 130, 83 and 99.