dhcpkit.ipv6.extensions.ntp module¶
Implementation of NTP options as specified in RFC 5908.
-
class
dhcpkit.ipv6.extensions.ntp.
NTPMulticastAddressSubOption
(address: ipaddress.IPv6Address = None)[source]¶ Bases:
dhcpkit.ipv6.extensions.ntp.NTPSubOption
This suboption is intended to appear inside the OPTION_NTP_SERVER option. It specifies the IPv6 address of the IPv6 multicast group address used by NTP on the local network.
The format of the NTP Multicast Address Suboption is:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NTP_SUBOPTION_MC_ADDR | suboption-len = 16 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | Multicast IPv6 address | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Multicast IPv6 address
- An IPv6 address.
- suboption-code
- NTP_SUBOPTION_MC_ADDR (2).
- suboption-len
-
address
= None¶ IPv6 multicast group address
-
static
config_datatype
(value: str) → ipaddress.IPv6Address[source]¶ Convert string data from the configuration to an IPv6address.
Parameters: value – String from config file Returns: Parsed IPv6 address
-
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
-
save
() → Union[source]¶ Save the internal state of this object as a buffer.
Returns: The buffer with the data from this element
-
suboption_type
= 2¶
-
value
¶ Return a simple string representation of the value of this sub-option.
Returns: The value of this option as a string
-
class
dhcpkit.ipv6.extensions.ntp.
NTPServerAddressSubOption
(address: ipaddress.IPv6Address = None)[source]¶ Bases:
dhcpkit.ipv6.extensions.ntp.NTPSubOption
This suboption is intended to appear inside the OPTION_NTP_SERVER option. It specifies the IPv6 unicast address of an NTP server or SNTP server available to the client.
The format of the NTP Server Address Suboption is:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NTP_SUBOPTION_SRV_ADDR | suboption-len = 16 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | | | IPv6 address of NTP server | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- IPv6 address of the NTP server
- An IPv6 address.
- suboption-code
- NTP_SUBOPTION_SRV_ADDR (1).
- suboption-len
-
address
= None¶ IPv6 address of an NTP server
-
static
config_datatype
(value: str) → ipaddress.IPv6Address[source]¶ Convert string data from the configuration to an IPv6address.
Parameters: value – String from config file Returns: Parsed IPv6 address
-
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
-
save
() → Union[source]¶ Save the internal state of this object as a buffer.
Returns: The buffer with the data from this element
-
suboption_type
= 1¶
-
value
¶ Return a simple string representation of the value of this sub-option.
Returns: The value of this option as a string
-
class
dhcpkit.ipv6.extensions.ntp.
NTPServerFQDNSubOption
(fqdn: str = '')[source]¶ Bases:
dhcpkit.ipv6.extensions.ntp.NTPSubOption
This suboption is intended to appear inside the OPTION_NTP_SERVER option. It specifies the FQDN of an NTP server or SNTP server available to the client.
The format of the NTP Server FQDN Suboption is:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | NTP_SUBOPTION_SRV_FQDN | suboption-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | FQDN of NTP server | : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- suboption-code
- NTP_SUBOPTION_SRV_FQDN (3).
- suboption-len
- Length of the included FQDN field.
- FQDN
- Fully-Qualified Domain Name of the NTP server or SNTP server. This field MUST be encoded as described in RFC 3315, Section 8. Internationalized domain names are not allowed in this field.
-
static
config_datatype
(value: str) → str[source]¶ Convert string data from the configuration to, well, a string. But a validated string!
Parameters: value – String from config file Returns: Parsed fqdn
-
fqdn
= None¶ Domain name of an NTP server
-
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
-
save
() → Union[source]¶ Save the internal state of this object as a buffer.
Returns: The buffer with the data from this element
-
suboption_type
= 3¶
-
value
¶ Return a simple string representation of the value of this sub-option.
Returns: The value of this option as a string
-
class
dhcpkit.ipv6.extensions.ntp.
NTPServersOption
(options: Iterable = None)[source]¶ Bases:
dhcpkit.ipv6.options.Option
This option serves as a container for server location information related to one NTP server or Simple Network Time Protocol (SNTP) RFC 4330 server. This option can appear multiple times in a DHCPv6 message. Each instance of this option is to be considered by the NTP client or SNTP client as a server to include in its configuration.
The option itself does not contain any value. Instead, it contains one or several suboptions that carry NTP server or SNTP server location. This option MUST include one, and only one, time source suboption. The currently defined time source suboptions are NTP_OPTION_SRV_ADDR, NTP_OPTION_SRV_MC_ADDR, and NTP_OPTION_SRV_FQDN. It carries the NTP server or SNTP server location as a unicast or multicast IPv6 address or as an NTP server or SNTP server FQDN. More time source suboptions may be defined in the future. While the FQDN option offers the most deployment flexibility, resiliency as well as security, the IP address options are defined to cover cases where a DNS dependency is not desirable.
If the NTP server or SNTP server location is an IPv6 multicast address, the client SHOULD use this address as an NTP multicast group address and listen to messages sent to this group in order to synchronize its clock.
The format of the NTP Server Option is:
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_NTP_SERVER | option-len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | suboption-1 | : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | suboption-2 | : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | suboption-n | : : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- option-code
- OPTION_NTP_SERVER (56).
- option-len
- Total length of the included suboptions.
This document does not define any priority relationship between the client’s embedded configuration (if any) and the NTP or SNTP servers discovered via this option. In particular, the client is allowed to simultaneously use its own configured NTP servers or SNTP servers and the servers discovered via DHCP.
-
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
= 56¶
-
options
= None¶ List of NTP server sub-options
-
class
dhcpkit.ipv6.extensions.ntp.
NTPSubOption
[source]¶ Bases:
dhcpkit.protocol_element.ProtocolElement
-
config_datatype
= None¶
-
classmethod
determine_class
(buffer: bytes, offset: int = 0) → type[source]¶ Return the appropriate subclass from the registry, or UnknownNTPSubOption if no subclass is registered.
Parameters: - buffer – The buffer to read data from
- offset – The offset in the buffer where to start reading
Returns: The best known class for this suboption data
-
parse_suboption_header
(buffer: bytes, offset: int = 0, length: int = None) → Tuple[source]¶ Parse the option code and length from the buffer and perform some basic validation.
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 and the value of the suboption-len field
-
suboption_type
= 0¶
-
value
¶ Return a simple string representation of the value of this sub-option.
Returns: The value of this option as a string
-
-
class
dhcpkit.ipv6.extensions.ntp.
UnknownNTPSubOption
(suboption_type: int = 0, suboption_data: bytes = b'')[source]¶ Bases:
dhcpkit.ipv6.extensions.ntp.NTPSubOption
Container for raw NTP sub-option content for cases where we don’t know how to decode it.
-
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
-
save
() → Union[source]¶ Save the internal state of this object as a buffer.
Returns: The buffer with the data from this element
-
suboption_data
= None¶ Data for this sub-option
-
value
¶ Return a simple string representation of the value of this sub-option.
Returns: The value of this option as a string
-