dhcpkit.ipv6.extensions.map module

Implementation of MAP options as specified in RFC 7598.

class dhcpkit.ipv6.extensions.map.S46BROption(br_address: ipaddress.IPv6Address = None)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 7598#section-4.2

The S46 BR option (OPTION_S46_BR) is used to convey the IPv6 address of the Border Relay. Figure 3 shows the format of the OPTION_S46_BR option.

 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_S46_BR         |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      br-ipv6-address                          |
|                                                               |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                     Figure 3: S46 BR Option
option-code
OPTION_S46_BR (90)
option-length
16
br-ipv6-address
a fixed-length field of 16 octets that specifies the IPv6 address for the S46 BR.

BR redundancy can be implemented by using an anycast address for the BR IPv6 address. Multiple OPTION_S46_BR options MAY be included in the container; this document does not further explore the use of multiple BR IPv6 addresses.

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 = 90
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.

class dhcpkit.ipv6.extensions.map.S46ContainerOption(options: Iterable = None)[source]

Bases: dhcpkit.ipv6.options.Option

Common code for MAP-E, MAP-T and LW4over6 containers

get_option_of_type(*args) → Union[source]

Get the first option that is a subclass of the given class.

Parameters:args – The classes to look for
Returns:The option or None
get_options_of_type(*args) → List[source]

Get all options that are subclasses of the given class.

Parameters:args – The classes to look for
Returns:The list of options
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 = 0
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.

class dhcpkit.ipv6.extensions.map.S46DMROption(dmr_prefix: ipaddress.IPv6Network = None)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 7598#section-4.3

The S46 DMR option (OPTION_S46_DMR) is used to convey values for the Default Mapping Rule (DMR). Figure 4 shows the format of the OPTION_S46_DMR option used for conveying a DMR.

 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_S46_DMR         |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|dmr-prefix6-len|            dmr-ipv6-prefix                    |
+-+-+-+-+-+-+-+-+           (variable length)                   |
.                                                              .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 4: S46 DMR Option
option-code
OPTION_S46_DMR (91)
option-length
1 + length of dmr-ipv6-prefix specified in octets.
dmr-prefix6-len
8 bits long; expresses the bitmask length of the IPv6 prefix specified in the dmr-ipv6-prefix field. Allowed values range from 0 to 128.
dmr-ipv6-prefix
a variable-length field specifying the IPv6 prefix or address for the BR. This field is right-padded with zeros to the nearest octet boundary when dmr-prefix6-len is not divisible by 8.
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 = 91
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.

class dhcpkit.ipv6.extensions.map.S46LWContainerOption(options: Iterable = None)[source]

Bases: dhcpkit.ipv6.extensions.map.S46ContainerOption

RFC 7598#section-5.3

The S46 Lightweight 4over6 Container option (OPTION_S46_CONT_LW) specifies the container used to group all rules and optional port parameters for a specified domain.

 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_S46_CONT_LW       |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+            encapsulated-options (variable length)             .
.                                                               .
+---------------------------------------------------------------+

        Figure 9: S46 Lightweight 4over6 Container Option
option-code
OPTION_S46_CONT_LW (96)
option-length
length of encapsulated options, expressed in octets.
encapsulated-options
options associated with this Softwire46 Lightweight 4over6 domain.

The encapsulated-options field conveys options specific to the OPTION_S46_CONT_LW option. Currently, there are two options specified: OPTION_S46_V4V6BIND and OPTION_S46_BR. There MUST be at most one OPTION_S46_V4V6BIND option and at least one OPTION_S46_BR option.

option_type = 96
class dhcpkit.ipv6.extensions.map.S46MapEContainerOption(options: Iterable = None)[source]

Bases: dhcpkit.ipv6.extensions.map.S46ContainerOption

RFC 7598#section-5.1

The S46 MAP-E Container option (OPTION_S46_CONT_MAPE) specifies the container used to group all rules and optional port parameters for a specified domain.

 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_S46_CONT_MAPE   |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.            encapsulated-options (variable length)             .
.                                                               .
+---------------------------------------------------------------+

              Figure 7: S46 MAP-E Container Option
option-code
OPTION_S46_CONT_MAPE (94)
option-length
length of encapsulated options, expressed in octets.
encapsulated-options
options associated with this Softwire46 MAP-E domain.

The encapsulated-options field conveys options specific to the OPTION_S46_CONT_MAPE option. Currently, there are two encapsulated options specified: OPTION_S46_RULE and OPTION_S46_BR. There MUST be at least one OPTION_S46_RULE option and at least one OPTION_S46_BR option.

Other options applicable to a domain may be defined in the future. A DHCPv6 message MAY include multiple OPTION_S46_CONT_MAPE options (representing multiple domains).

option_type = 94
class dhcpkit.ipv6.extensions.map.S46MapTContainerOption(options: Iterable = None)[source]

Bases: dhcpkit.ipv6.extensions.map.S46ContainerOption

RFC 7598#section-5.2

The S46 MAP-T Container option (OPTION_S46_CONT_MAPT) specifies the container used to group all rules and optional port parameters for a specified domain.

 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_S46_CONT_MAPT      |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.            encapsulated-options (variable length)             .
.                                                               .
+---------------------------------------------------------------+

              Figure 8: S46 MAP-T Container Option
option-code
OPTION_S46_CONT_MAPT (95)
option-length
length of encapsulated options, expressed in octets.
encapsulated-options
options associated with this Softwire46 MAP-T domain.

The encapsulated-options field conveys options specific to the OPTION_S46_CONT_MAPT option. Currently, there are two options specified: the OPTION_S46_RULE and OPTION_S46_DMR options. There MUST be at least one OPTION_S46_RULE option and exactly one OPTION_S46_DMR option.

option_type = 95
class dhcpkit.ipv6.extensions.map.S46PortParametersOption(offset: int = 0, psid_len: int = 0, psid: int = 0)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 7598#section-4.5

The S46 Port Parameters option (OPTION_S46_PORTPARAMS) specifies optional port set information that MAY be provided to CEs.

See Section 5.1 of [RFC7597] for a description of the MAP algorithm and detailed explanation of all of the parameters.

 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_S46_PORTPARAMS     |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    offset     |   PSID-len    |             PSID              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

              Figure 6: S46 Port Parameters Option
option-code
OPTION_S46_PORTPARAMS (93)
option-length
4
offset
Port Set Identifier (PSID) offset. 8 bits long; specifies the numeric value for the S46 algorithm’s excluded port range/offset bits (a-bits), as per Section 5.1 of [RFC7597]. Allowed values are between 0 and 15. Default values for this field are specific to the softwire mechanism being implemented and are defined in the relevant specification document.
PSID-len
8 bits long; specifies the number of significant bits in the PSID field (also known as ‘k’). When set to 0, the PSID field is to be ignored. After the first ‘a’ bits, there are k bits in the port number representing the value of the PSID. Consequently, the address-sharing ratio would be 2^k.
PSID
16 bits long. The PSID value algorithmically identifies a set of ports assigned to a CE. The first k bits on the left of this field contain the PSID binary value. The remaining (16 - k) bits on the right are padding zeros.

When receiving the OPTION_S46_PORTPARAMS option with an explicit PSID, the client MUST use this explicit PSID when configuring its softwire interface. The OPTION_S46_PORTPARAMS option with an explicit PSID MUST be discarded if the S46 CE isn’t configured with a full IPv4 address (e.g., IPv4 prefix).

The OPTION_S46_PORTPARAMS option is contained within an OPTION_S46_RULE option or an OPTION_S46_V4V6BIND option.

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 = 93
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.

class dhcpkit.ipv6.extensions.map.S46RuleOption(flags: int = 0, ea_len: int = 0, ipv4_prefix: ipaddress.IPv4Network = None, ipv6_prefix: ipaddress.IPv6Network = None, options: Iterable = None)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 7598#section-4.1

Figure 1 shows the format of the S46 Rule option (OPTION_S46_RULE) used for conveying the Basic Mapping Rule (BMR) and Forwarding Mapping Rule (FMR).

This option follows behavior described in Sections 17.1.1 and 18.1.1 of [RFC3315]. Clients can send those options, encapsulated in their respective container options, with specific values as hints for the server. See Section 5 for details. Depending on the server configuration and policy, it may accept or ignore the hints. Clients MUST be able to process received values that are different than the hints it sent earlier.

 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_S46_RULE        |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     flags     |     ea-len    |  prefix4-len  | ipv4-prefix   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                  (continued)                  |  prefix6-len  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           ipv6-prefix                         |
|                       (variable length)                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                        S46_RULE-options                       .
.                                                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                    Figure 1: S46 Rule Option
option-code
OPTION_S46_RULE (89)
option-length
length of the option, excluding option-code and option-length fields, including length of all encapsulated options; expressed in octets.
flags
8 bits long; carries flags applicable to the rule. The meanings of the specific bits are explained in Figure 2.
ea-len
8 bits long; specifies the Embedded Address (EA) bit length. Allowed values range from 0 to 48.
prefix4-len
8 bits long; expresses the prefix length of the Rule IPv4 prefix specified in the ipv4-prefix field. Allowed values range from 0 to 32.
ipv4-prefix
a fixed-length 32-bit field that specifies the IPv4 prefix for the S46 rule. The bits in the prefix after prefix4-len number of bits are reserved and MUST be initialized to zero by the sender and ignored by the receiver.
prefix6-len
8 bits long; expresses the length of the Rule IPv6 prefix specified in the ipv6-prefix field. Allowed values range from 0 to 128.
ipv6-prefix
a variable-length field that specifies the IPv6 domain prefix for the S46 rule. The field is padded on the right with zero bits up to the nearest octet boundary when prefix6-len is not evenly divisible by 8.
S46_RULE-options
a variable-length field that may contain zero or more options that specify additional parameters for this S46 rule. This document specifies one such option: OPTION_S46_PORTPARAMS.

The format of the S46 Rule Flags field is:

     0 1 2 3 4 5 6 7
    +-+-+-+-+-+-+-+-+
    |Reserved     |F|
    +-+-+-+-+-+-+-+-+

Figure 2: S46 Rule Flags
Reserved
7 bits; reserved for future use as flags.
F-flag

1-bit field that specifies whether the rule is to be used for forwarding (FMR). If set, this rule is used as an FMR; if not set, this rule is a BMR only and MUST NOT be used for forwarding.

Note: A BMR can also be used as an FMR for forwarding if the F-flag is set. The BMR is determined by a longest-prefix match of the Rule IPv6 prefix against the End-user IPv6 prefix(es).

It is expected that in a typical mesh deployment scenario there will be a single BMR, which could also be designated as an FMR using the F-flag.

fmr

Extract the F flag

Returns:Whether the F flag is set
get_option_of_type(*args) → Union[source]

Get the first option that is a subclass of the given class.

Parameters:args – The classes to look for
Returns:The option or None
get_options_of_type(*args) → List[source]

Get all options that are subclasses of the given class.

Parameters:args – The classes to look for
Returns:The list of options
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 = 89
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.

class dhcpkit.ipv6.extensions.map.S46V4V6BindingOption(ipv4_address: ipaddress.IPv4Address = None, ipv6_prefix: ipaddress.IPv6Network = None, options: Iterable = None)[source]

Bases: dhcpkit.ipv6.options.Option

RFC 7598#section-4.4

The S46 IPv4/IPv6 Address Binding option (OPTION_S46_V4V6BIND) MAY be used to specify the full or shared IPv4 address of the CE. The IPv6 prefix field is used by the CE to identify the correct prefix to use for the tunnel source.

 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_S46_V4V6BIND      |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         ipv4-address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|bindprefix6-len|             bind-ipv6-prefix                  |
+-+-+-+-+-+-+-+-+             (variable length)                 |
.                                                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                      S46_V4V6BIND-options                     .
.                                                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

         Figure 5: S46 IPv4/IPv6 Address Binding Option
option-code
OPTION_S46_V4V6BIND (92)
option-length
length of the option, excluding option-code and option-length fields, including length of all encapsulated options; expressed in octets.
ipv4-address
a fixed-length field of 4 octets specifying an IPv4 address.
bindprefix6-len
8 bits long; expresses the bitmask length of the IPv6 prefix specified in the bind-ipv6-prefix field. Allowed values range from 0 to 128.
bind-ipv6-prefix
a variable-length field specifying the IPv6 prefix or address for the S46 CE. This field is right-padded with zeros to the nearest octet boundary when bindprefix6-len is not divisible by 8.
S46_V4V6BIND-options
a variable-length field that may contain zero or more options that specify additional parameters. This document specifies one such option: OPTION_S46_PORTPARAMS.
get_option_of_type(*args) → Union[source]

Get the first option that is a subclass of the given class.

Parameters:args – The classes to look for
Returns:The option or None
get_options_of_type(*args) → List[source]

Get all options that are subclasses of the given class.

Parameters:args – The classes to look for
Returns:The list of options
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 = 92
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.