IPv6 Options - Shared Option Helpers¶
pcapkit.protocols.internet.ipv6_ext.schema contains the field helpers
shared by the option schemas of
schema (HOPOPT) and
schema (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.internet.ipv6_ext.schema.rpl_opt_sub_tlv_len(pkt)[source]¶
Return RPL option sub-TLV length.
- pcapkit.protocols.internet.ipv6_ext.schema.mpl_opt_seed_id_len(pkt, *, prefix)[source]¶
Return MPL Seed-ID length.
- pcapkit.protocols.internet.ipv6_ext.schema.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 (see 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 this function makes 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.internet.ipv6_ext.schema.calipso_pad_len(pkt, *, prefix)[source]¶
Return CALIPSO option padding length.
- Parameters:
- Return type:
- Returns:
CALIPSO option padding length, or zero if the data ends before
Opt Data Len, which leaves the option to the short read.- Raises:
ProtocolError – 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.
Changed in version 1.6.0: A length the data ends before is left to the short read, and one too short raises
ProtocolErrorrather thanFieldValueError(#2727).
- pcapkit.protocols.internet.ipv6_ext.schema.mpl_opt_pad_len(pkt, *, prefix)[source]¶
Return MPL option padding length.
- Parameters:
- Return type:
- Returns:
MPL option padding length, or zero if the data ends before
Opt Data Len, which leaves the option to the short read.- Raises:
ProtocolError – 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.
Changed in version 1.6.0: A length the data ends before is left to the short read, and one too short raises
ProtocolErrorrather thanFieldValueError(#2727).
- pcapkit.protocols.internet.ipv6_ext.schema.smf_dpd_data_selector(pkt, *, prefix, base)[source]¶
Selector function for the
datafield of anSMF_DPDoption.- Parameters:
- Return type:
- Returns:
The field for the option data, chosen by the DPD mode.
If
modeis0, returns aSchemaFieldwrappedSMFIdentificationBasedDPDOptioninstance.If
modeis1, returns aSchemaFieldwrappedSMFHashBasedDPDOptioninstance.
- Raises:
ProtocolError – If
Opt Data Lenis0on the wire.FieldValueError – 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.Where the data ends before
Opt Data Len, the forward match reads it as zero, and the option is the short read of the schema chosen by the mode bit, likewise zero.Changed in version 1.6.0: A length the data ends before is left to the short read, and a zero on the wire raises
ProtocolErrorrather thanFieldValueError(#2727).
- pcapkit.protocols.internet.ipv6_ext.schema.smf_i_dpd_tid_selector(pkt, *, prefix)[source]¶
Selector function for the
tidfield of an SMF I-DPD option.- Parameters:
- Return type:
- Returns:
The field for the TaggerId, chosen by its type.
If
tid_typeis0(NULL), returns aNoValueFieldinstance.If
tid_typeis2(IPv4), returns anIPv4AddressFieldinstance.If
tid_typeis3(IPv6), returns anIPv6AddressFieldinstance.Otherwise, returns a
BytesFieldinstance.
- Raises:
FieldValueError – If
tid_lendoes not match the length of theNULL,IPv4orIPv6TaggerID type.
- pcapkit.protocols.internet.ipv6_ext.schema.smf_i_dpd_id_len(pkt, *, prefix)[source]¶
Return SMF I-DPD identifier length.
- Parameters:
- Return type:
- Returns:
SMF I-DPD identifier length, or zero if the data ends before
Opt Data Len, which leaves the option to the short read.- Raises:
ProtocolError – If
Opt Data Lenon the wire is too short to hold the TaggerID it declares, which would otherwise underflow the identifier length below zero.
Changed in version 1.6.0: A length the data ends before is left to the short read, and one too short raises
ProtocolErrorrather thanFieldValueError(#2727).
- pcapkit.protocols.internet.ipv6_ext.schema.quick_start_data_selector(pkt, *, base, unassigned)[source]¶
Selector function for the
datafield of aQuick_Startoption.- Parameters:
- Return type:
- Returns:
The field for the option data, chosen by the QS function.
If
funcis0, returns aSchemaFieldwrappedQuickStartRequestOptioninstance.If
funcis8, returns aSchemaFieldwrappedQuickStartReportOptioninstance.Otherwise, returns a
SchemaFieldwrappedunassignedinstance, sized by the option’s ownOpt Data Len.
Footnotes