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.
- pcapkit.protocols.schema.internet.ipv6_option.mpl_opt_seed_id_len(pkt, *, prefix)[source]¶
Return MPL Seed-ID length.
- pcapkit.protocols.schema.internet.ipv6_option.pad_opt_data_len(pkt)[source]¶
Return the length of the padding data of a padding option.
- Parameters:
- Return type:
- Returns:
Number of padding octets carried after the option header, i.e. the value of the
Opt Data Lenfield of aPadNoption, and zero for aPad1option, which carries no such field.
Note
A
Pad1option is a single octet with neither anOpt Data Lenfield nor any option data (c.f. RFC 8200 Section 4.2), which is why the option’slenfield is declared as aConditionalFieldand is skipped for it. A skipped conditional field is recorded in the packet data asNO_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 thatNoValueTypestraight toPaddingField, where it becomes an unusablestructtemplate and surfaces much later as an opaquestruct.error, which is how aPad1option would fail to parse.
- pcapkit.protocols.schema.internet.ipv6_option.calipso_pad_len(pkt, *, prefix)[source]¶
Return CALIPSO option padding length.
- Parameters:
- Return type:
- Returns:
CALIPSO option padding length.
- Raises:
FieldValueError – If
Opt Data Lenon the wire is too short to hold the fixed header and the compartment bitmap declared bycmpt_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:
- Return type:
- Returns:
MPL option padding length.
- Raises:
FieldValueError – If
Opt Data Lenon the wire is too short to hold the fixed header and the Seed-ID declared byflags.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
datafield of anSMF_DPDoption.- Parameters:
- Return type:
- Returns:
If
modeis0, returns aSchemaFieldwrappedSMFIdentificationBasedDPDOptioninstance.If
modeis1, returns aSchemaFieldwrappedSMFHashBasedDPDOptioninstance.
- Raises:
FieldValueError – If
Opt Data Lenis0, or if no schema is registered for the DPD mode.
Note
The field is sized
Opt Data Len + 2rather thanOpt Data Len.Opt Data Lencounts only what follows the option header [RFC 8200 Section 4.2], while both schemas this may return inherit the option’stypeandlenfields and so parse those two octets themselves. Sizing the field atOpt Data Lenwould hand them an area two octets short of the option they read, whichOptionFieldwould 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
tidfield of an SMF I-DPD option.- Parameters:
- Return type:
- Returns:
If
tid_typeis0(NULL), returns aNoValueFieldinstance.If
tid_typeis2(IPv4), returns aIPv4AddressFieldinstance.If
tid_typeis3(IPv6), returns aIPv6AddressFieldinstance.Otherwise, returns a
BytesFieldinstance.
- Raises:
FieldValueError – If
tid_lendoes not match the length of theNULL,IPv4orIPv6TaggerID type.
- pcapkit.protocols.schema.internet.ipv6_option.smf_i_dpd_id_len(pkt, *, prefix)[source]¶
Return SMF I-DPD identifier length.
- Parameters:
- Return type:
- Returns:
SMF I-DPD identifier length.
- Raises:
FieldValueError – If
Opt Data Lenon 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
datafield of aQuick_Startoption.- Parameters:
- Return type:
- Returns:
If
funcis0, returns aSchemaFieldwrappedQuickStartRequestOptioninstance.If
funcis8, returns aSchemaFieldwrappedQuickStartReportOptioninstance.Otherwise, returns a
SchemaFieldwrappedunassignedinstance, sized by the option’s ownOpt Data Len.
Footnotes