IPv6 Options - Shared Option Helpers

pcapkit.protocols.schema.internet.ipv6_option contains the field helpers shared by the option schemas of hopopt (HOPOPT) and ipv6_opts (IPv6-Opts), since both headers carry the same IPv6 options [*]. A helper that reports an error takes the header’s name as prefix, and a selector takes the header’s option schemas. Each header module binds them in a function of the same name, which is what its fields use.

Auxiliary Functions

pcapkit.protocols.schema.internet.ipv6_option.rpl_opt_sub_tlv_len(pkt)[source]

Return RPL option sub-TLV length.

Parameters:

pkt (dict[str, Any]) – RPL option unpacked schema.

Return type:

int

Returns:

RPL option sub-TLV length, i.e. Opt Data Len less the four octets of the fixed fields. An Opt Data Len below 4 gives 0, and the reader then rejects the option.

pcapkit.protocols.schema.internet.ipv6_option.mpl_opt_seed_id_len(pkt, *, prefix)[source]

Return MPL Seed-ID length.

Parameters:
  • pkt (dict[str, Any]) – MPL option unpacked schema.

  • prefix (str) – Name of the extension header, leading the error message.

Return type:

int

Returns:

MPL Seed-ID length.

Raises:

FieldValueError – If flags.type is not a defined Seed-ID type.

pcapkit.protocols.schema.internet.ipv6_option.pad_opt_data_len(pkt)[source]

Return the length of the padding data of a padding option.

Parameters:

pkt (dict[str, Any]) – Padding option unpacked schema.

Return type:

int

Returns:

Number of padding octets carried after the option header, i.e. the value of the Opt Data Len field of a PadN option, and zero for a Pad1 option, which carries no such field.

Note

A Pad1 option is a single octet with neither an Opt Data Len field nor any option data (c.f. RFC 8200 Section 4.2), which is why the option’s len field is declared as a ConditionalField and is skipped for it. A skipped conditional field is recorded in the packet data as NO_VALUE, rather than being left out of it, so the test below has to be on the value and not on the presence of the key: pkt.get('len', 0) on its own hands that NoValueType straight to PaddingField, where it becomes an unusable struct template and surfaces much later as an opaque struct.error, which is how a Pad1 option would fail to parse.

pcapkit.protocols.schema.internet.ipv6_option.calipso_pad_len(pkt, *, prefix)[source]

Return CALIPSO option padding length.

Parameters:
  • pkt (dict[str, Any]) – CALIPSO option unpacked schema.

  • prefix (str) – Name of the extension header, leading the error message.

Return type:

int

Returns:

CALIPSO option padding length.

Raises:

FieldValueError – If Opt Data Len on the wire is too short to hold the fixed header and the compartment bitmap declared by cmpt_len, which would otherwise underflow the padding length below zero.

pcapkit.protocols.schema.internet.ipv6_option.mpl_opt_pad_len(pkt, *, prefix)[source]

Return MPL option padding length.

Parameters:
  • pkt (dict[str, Any]) – MPL option unpacked schema.

  • prefix (str) – Name of the extension header, leading the error message.

Return type:

int

Returns:

MPL option padding length.

Raises:

FieldValueError – If Opt Data Len on the wire is too short to hold the fixed header and the Seed-ID declared by flags.type, which would otherwise underflow the padding length below zero.

pcapkit.protocols.schema.internet.ipv6_option.smf_dpd_data_selector(pkt, *, prefix, base)[source]

Selector function for the data field of an SMF_DPD option.

Parameters:
  • pkt (dict[str, Any]) – Packet data.

  • prefix (str) – Name of the extension header, leading the error message.

  • base (EnumMeta) – The header’s SMFDPDOption schema, whose registry maps the DPD mode to the schema that reads the option.

Return type:

FieldBase

Returns:

  • If mode is 0, returns a SchemaField wrapped SMFIdentificationBasedDPDOption instance.

  • If mode is 1, returns a SchemaField wrapped SMFHashBasedDPDOption instance.

Raises:

FieldValueError – If Opt Data Len is 0, or if no schema is registered for the DPD mode.

Note

The field is sized Opt Data Len + 2 rather than Opt Data Len. Opt Data Len counts only what follows the option header [RFC 8200 Section 4.2], while both schemas this may return inherit the option’s type and len fields and so parse those two octets themselves. Sizing the field at Opt Data Len would hand them an area two octets short of the option they read, which OptionField would then mis-count against the option area.

pcapkit.protocols.schema.internet.ipv6_option.smf_i_dpd_tid_selector(pkt, *, prefix)[source]

Selector function for the tid field of an SMF I-DPD option.

Parameters:
  • pkt (dict[str, Any]) – Packet data.

  • prefix (str) – Name of the extension header, leading the error message.

Return type:

FieldBase

Returns:

Raises:

FieldValueError – If tid_len does not match the length of the NULL, IPv4 or IPv6 TaggerID type.

pcapkit.protocols.schema.internet.ipv6_option.smf_i_dpd_id_len(pkt, *, prefix)[source]

Return SMF I-DPD identifier length.

Parameters:
  • pkt (dict[str, Any]) – SMF identification-based DPD option unpacked schema.

  • prefix (str) – Name of the extension header, leading the error message.

Return type:

int

Returns:

SMF I-DPD identifier length.

Raises:

FieldValueError – If Opt Data Len on the wire is too short to hold the TaggerID it declares, which would otherwise underflow the identifier length below zero.

pcapkit.protocols.schema.internet.ipv6_option.quick_start_data_selector(pkt, *, base, unassigned)[source]

Selector function for the data field of a Quick_Start option.

Parameters:
  • pkt (dict[str, Any]) – Packet data.

  • base (EnumMeta) – The header’s QuickStartOption schema, whose registry maps the QS function to the schema that reads the option.

  • unassigned (Type[Schema]) – The header’s UnassignedOption schema.

Return type:

FieldBase

Returns:

  • If func is 0, returns a SchemaField wrapped QuickStartRequestOption instance.

  • If func is 8, returns a SchemaField wrapped QuickStartReportOption instance.

  • Otherwise, returns a SchemaField wrapped unassigned instance, sized by the option’s own Opt Data Len.

Footnotes