Extension-Header Length

pcapkit.corekit.schema.extlen converts between octets and the length field of an IPv6-extension-style header, which counts 8-octet units not including the first 8 octets [RFC 6564 Section 4], for the extension headers, the Mobility Header, HIP, the jumbogram lookup and IPv6 reassembly alike.

Added in version 1.7.0.

pcapkit.corekit.schema.extlen.ext_len_to_octets(ext_len)[source]

Octets of a header whose length field is ext_len.

Parameters:

ext_len (int) – Length field, in 8-octet units not including the first 8 octets, as Hdr Ext Len [RFC 8200 Section 4.3], MH’s Header Len [RFC 6275 Section 6.1.1] and HIP’s Header Length [RFC 7401 Section 5.1] count.

Return type:

int

Returns:

(ext_len + 1) * 8.

Added in version 1.7.0.

pcapkit.corekit.schema.extlen.octets_to_ext_len(length)[source]

Length field of a header of length octets, the inverse of ext_len_to_octets().

Parameters:

length (int) – Octets of the header, the first 8 included.

Return type:

int

Returns:

length // 8 - 1, rounded down where length is not a multiple of 8; a maker that must not declare fewer octets than it packs pads length first.

Added in version 1.7.0.