dhcpkit.ipv6.extensions.timezone module

Implementation of timezone options as specified in RFC 4833.

class dhcpkit.ipv6.extensions.timezone.PosixTimezoneOption(timezone: str = None)[source]

Bases: dhcpkit.ipv6.options.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_NEW_POSIX_TIMEZONE    |         option-length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       TZ POSIX String                         |
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
option-code:
OPTION_NEW_POSIX_TIMEZONE(41)
option-length:
the number of octets of the TZ POSIX String Index described below:

TZ POSIX string is a string suitable for the TZ variable as specified by IEEE 1003.1 in Section 8.3, with the exception that a string may not begin with a colon (“:”). This string is NOT terminated by an ASCII NULL.

Here is an example: EST5EDT4,M3.2.0/02:00,M11.1.0/02:00

In this case, the string is interpreted as a timezone that is normally five hours behind UTC, and four hours behind UTC during DST, which runs from the second Sunday in March at 02:00 local time through the first Sunday in November at 02:00 local time. Normally the timezone is abbreviated “EST” but during DST it is abbreviated “EDT”.

Clients and servers implementing other timezone options MUST support this option for basic compatibility.

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 = 41
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.timezone.TZDBTimezoneOption(timezone: str = None)[source]

Bases: dhcpkit.ipv6.options.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_NEW_TZDB_TIMEZONE     |          option-length        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            TZ Name                            |
|                              ...                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
option-code:
OPTION_NEW_TZDB_TIMEZONE(42)
option-length:
the number of octets of the TZ Database String Index described below.

TZ Name is the name of a Zone entry in the database commonly referred to as the TZ database. Specifically, in the database’s textual form, the string refers to the name field of a zone line. In order for this option to be useful, the client must already have a copy of the database. This string is NOT terminated with an ASCII NULL.

An example string is: Europe/Zurich.

Clients must already have a copy of the TZ Database for this option to be useful. Configuration of the database is beyond the scope of this document. A client that supports this option SHOULD prefer this option to POSIX string if it recognizes the TZ Name that was returned. If it doesn’t recognize the TZ Name, the client MUST ignore this 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 = 42
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.