dhcpkit.ipv6.extensions.pd_exclude module

Implementation of the DHCPv6-PD-Exclude option as specified in RFC 4833.

class dhcpkit.ipv6.extensions.pd_exclude.PDExcludeOption(prefix_length: int = 64, subnet_id: bytes = None)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 6603#section-4.2

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       OPTION_PD_EXCLUDE       |         option-len            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  prefix-len   | IPv6 subnet ID (1 to 16 octets)               ~
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                      Prefix Exclude Option
option-code:
OPTION_PD_EXCLUDE (67).
option-len:
1 + length of IPv6 subnet ID in octets. A valid option-len is between 2 and 17.
prefix-len:
The length of the excluded prefix in bits. The prefix-len MUST be between ‘OPTION_IAPREFIX prefix-length’+1 and 128.
IPv6 subnet ID:
A variable-length IPv6 subnet ID up to 128 bits.

The IPv6 subnet ID contains prefix-len minus ‘OPTION_IAPREFIX prefix- length’ bits extracted from the excluded prefix starting from the bit position ‘OPTION_IAPREFIX prefix-length’. The extracted subnet ID MUST be left-shifted to start from a full octet boundary, i.e., left- shift of ‘OPTION_IAPREFIX prefix-length’ mod 8 bits. The subnet ID MUST be zero-padded to the next full octet boundary.

load_from(buffer: bytes, offset: int = 0, length: int = None) → int[source]

Load the internal state of this object from the given buffer. The buffer may contain more data after the structured element is parsed. This data is ignored.

Parameters:
  • buffer – The buffer to read data from
  • offset – The offset in the buffer where to start reading
  • length – The amount of data we are allowed to read from the buffer
Returns:

The number of bytes used from the buffer

option_type = 67
save() → Union[source]

Save the internal state of this object as a buffer.

Returns:The buffer with the data from this element
validate()[source]

Validate that the contents of this object conform to protocol specs.