Constants

There’s a lot of stuff going on behind the scenes in DHCP, and while this library tries to make it accessible, it is impossible to hide. At least, not without removing what makes the library worth using.

Keep this around as a reference when messing with internals, but most of this is used internally to do the right thing with whatever you throw at a packet. Check back when things don’t go as expected, but go with your instinct first.

DHCP fields

dhcp_types.constants.FIELD_OP

The DHCP operation type (Request or Response).

dhcp_types.constants.FIELD_HTYPE

The type of hardware involved.

dhcp_types.constants.FIELD_HLEN

The length of the hardware address.

dhcp_types.constants.FIELD_HOPS

The number of hops across which the packet has been transmitted.

dhcp_types.constants.FIELD_XID

The transaction ID.

dhcp_types.constants.FIELD_SECS

The number of seconds that have elapsed since the packet was first emitted.

dhcp_types.constants.FIELD_FLAGS

DHCP flags set on the packet.

dhcp_types.constants.FIELD_CIADDR

The client’s address.

dhcp_types.constants.FIELD_YIADDR

The issued address.

dhcp_types.constants.FIELD_SIADDR

The server’s address.

dhcp_types.constants.FIELD_GIADDR

The gateway’s address.

dhcp_types.constants.FIELD_CHADDR

The hardware address.

dhcp_types.constants.FIELD_SNAME

BOOTP server hostname.

dhcp_types.constants.FIELD_FILE

BOOTP filename.

dhcp_types.constants.DHCP_FIELDS

Byte-offset and size definitions for DHCP fields.

dhcp_types.constants.DHCP_FIELDS_SPECS

Information about how to validate basic DHCP types.

The human-readable format-name is mapped against a (fixed_length, minimum_length, multiple) tuple, which is handled by the following pseudocode:

if fixed_length == 0:
    if (
        len(value) < minimum_length or
        len(value) % (multiple * minimum_length) != 0
    ):
        fail
elif len(value) != fixed_length:
    fail
dhcp_types.constants.DHCP_FIELDS_TYPES

Maps human-readable field-names to DHCP fields specs.

Reading the source for this element is VERY strongly recommended.

DHCP options

dhcp_types.constants.DHCP_OPTIONS_TYPES

Maps DHCP option-numbers to DHCP fields specs.

All values derived from http://www.iana.org/assignments/bootp-dhcp-parameters

Reading the source for this element is VERY strongly recommended.

dhcp_types.constants.DHCP_OPTIONS

Maps human-readable DHCP option names to integer values.

Reading the source for this element is VERY strongly recommended.

dhcp_types.constants.DHCP_OPTIONS_REVERSE

Maps integer values to human-readable DHCP option names.

DHCP miscellany

dhcp_types.constants.DHCP_OP_NAMES

Mapping from DHCP operation types to human-readable names.

dhcp_types.constants.DHCP_TYPE_NAMES

Mapping from DHCP option values to human-readable names.

dhcp_types.constants.DHCP_FIELDS_TEXT

All DHCP fields for which data should be padded as needed

The DHCP magic cookie, per RFC 1048.

The DHCP magic cookie as an array of bytes.

Type-definitions

dhcp_types.constants.TYPE_IPV4

Four bytes in network-byte-order.

dhcp_types.constants.TYPE_IPV4_PLUS

At least one multiple of four bytes in network-byte-order.

dhcp_types.constants.TYPE_IPV4_MULT

Multiples of four bytes in network-byte-order.

dhcp_types.constants.TYPE_BYTE

A single byte.

dhcp_types.constants.TYPE_BYTE_PLUS

At least one byte.

dhcp_types.constants.TYPE_STRING

Any number of bytes.

dhcp_types.constants.TYPE_BOOL

A single byte, constrained to the values 0 (false) and 1 (true).

dhcp_types.constants.TYPE_INT

Two bytes in network-byte-order.

dhcp_types.constants.TYPE_INT_PLUS

At least one multiple of two bytes in network-byte-order.

dhcp_types.constants.TYPE_LONG

Four bytes in network-byte-order.

dhcp_types.constants.TYPE_LONG_PLUS

At least one multiple of four bytes in network-byte-order.

dhcp_types.constants.TYPE_IDENTIFIER

Two bytes in small-endian order.

dhcp_types.constants.TYPE_NONE

A zero-length sequence.

Table Of Contents

Previous topic

Conversion functions

Next topic

Framework overview