HOPOPT - IPv6 Hop-by-Hop Options¶
pcapkit.protocols.internet.hopopt contains
HOPOPT
only, which implements extractor for IPv6 Hop-by-Hop
Options header (HOPOPT) [*], whose structure is
described as below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Next Header |
1 |
8 |
|
Header Extensive Length |
2 |
16 |
|
Options |
- class pcapkit.protocols.internet.hopopt.HOPOPT(file=None, length=None, **kwargs)[source]¶
Bases:
Internet[HOPOPT,HOPOPT]This class implements IPv6 Hop-by-Hop Options.
This class currently supports parsing of the following IPv6 Hop-by-Hop options, which are registered in the
self.__option__attribute:Option Code
Option Parser
Option Constructor
- property payload: ProtocolBase | NoReturn¶
Payload of current instance.
- Raises:
UnsupportedCall – if the protocol is used as an IPv6 extension header
- Return type:
- property protocol: str | None | NoReturn¶
Name of next layer protocol (if any).
- Raises:
UnsupportedCall – if the protocol is used as an IPv6 extension header
- property protochain: ProtoChain | NoReturn¶
Protocol chain of current instance.
- Raises:
UnsupportedCall – if the protocol is used as an IPv6 extension header
- read(length=None, *, extension=False, **kwargs)[source]¶
Read IPv6 Hop-by-Hop Options.
Structure of HOPOPT header [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Hdr Ext Len | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | . . . Options . . . | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(next=<TransType.UDP: 17>, next_default=None, next_namespace=None, next_reversed=False, options=None, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
next (
TransType|IntEnum|IntEnum|str|int) – Next header type.next_default (
int|None) – Default value of next header type.next_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – Namespace of next header type.next_reversed (
bool) – If the namespace of next header type is reversed.options (
list[Option|tuple[Option,dict[str,Any]] |bytes] |OrderedMultiDict[Option,Option] |None) – Hop-by-Hop Options.payload (
bytes|ProtocolBase|Schema) – Payload of current protocol.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- _read_hopopt_options(length)[source]¶
Read HOPOPT options.
- Positional arguments:
length: length of options
- Return type:
- Returns:
Extracted HOPOPT options
- Raises:
ProtocolError – If the threshold is NOT matching.
- _read_opt_none(schema, *, options)[source]¶
Read HOPOPT unassigned options.
Structure of HOPOPT unassigned options [RFC 8200]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - - | Option Type | Opt Data Len | Option Data +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
- Parameters:
schema (
UnassignedOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- _read_opt_pad(schema, *, options)[source]¶
Read HOPOPT padding options.
Structure of HOPOPT padding options [RFC 8200]:
Pad1option:+-+-+-+-+-+-+-+-+ | 0 | +-+-+-+-+-+-+-+-+
PadNoption:+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - - | 1 | Opt Data Len | Option Data +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
- Parameters:
schema (
PadOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
codeis NOT0or1.
Note
A
Pad1option occupies a single octet and carries noOpt Data Lenfield, so itslengthis1rather thanlen + 2. That one-octet wire shape is enforced byPadOptionitself, which sizes both the length octet and the padding data from the option type;clenis therefore always0here for a parsedPad1, and the check below only guards a schema built by hand.
- _read_opt_tun(schema, *, options)[source]¶
Read HOPOPT Tunnel Encapsulation Limit option.
Structure of HOPOPT Tunnel Encapsulation Limit option [RFC 2473]:
Option Type Opt Data Len Opt Data Len 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0 0 0 1 0 0| 1 | Tun Encap Lim | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
TunnelEncapsulationLimitOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.tun.lengthis NOT1.
- _read_opt_ra(schema, *, options)[source]¶
Read HOPOPT Router Alert option.
Structure of HOPOPT Router Alert option [RFC 2711]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
RouterAlertOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.tun.lengthis NOT2.
- _read_opt_calipso(schema, *, options)[source]¶
Read HOPOPT Common Architecture Label IPv6 Security Option (CALIPSO) option.
Structure of HOPOPT CALIPSO option [RFC 5570]:
------------------------------------------------------------ | Next Header | Hdr Ext Len | Option Type | Option Length| +-------------+---------------+-------------+--------------+ | CALIPSO Domain of Interpretation | +-------------+---------------+-------------+--------------+ | Cmpt Length | Sens Level | Checksum (CRC-16) | +-------------+---------------+-------------+--------------+ | Compartment Bitmap (Optional; variable length) | +-------------+---------------+-------------+--------------+
- Parameters:
schema (
CALIPSOOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _read_opt_smf_dpd(schema, *, options)[source]¶
Read HOPOPT Simplified Multicast Forwarding Duplicate Packet Detection (
SMF_DPD) option.Structure of HOPOPT
SMF_DPDoption [RFC 6621]:IPv6
SMF_DPDoption header in I-DPD (Identification-Based DPD) mode0 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... |0|0|0| 01000 | Opt. Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0|TidTy| TidLen| TaggerID (optional) ... | +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | Identifier ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+IPv6
SMF_DPDoption header in H-DPD (Hash-Based) mode0 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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... |0|0|0| OptType | Opt. Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Hash Assist Value (HAV) ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
SMFDPDOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _read_opt_pdm(schema, *, options)[source]¶
Read HOPOPT Performance and Diagnostic Metrics (PDM) option.
Structure of HOPOPT PDM option [RFC 8250]:
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 Type | Option Length | ScaleDTLR | ScaleDTLS | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | PSN This Packet | PSN Last Received | |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Delta Time Last Received | Delta Time Last Sent | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
PDMOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.pdm.lengthis NOT10.
- _read_opt_qs(schema, *, options)[source]¶
Read HOPOPT Quick Start option.
Structure of HOPOPT Quick-Start option [RFC 4782]:
A Quick-Start Request:
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 | Length=6 | Func. | Rate | QS TTL | | | | 0000 |Request| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QS Nonce | R | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Report of Approved Rate:
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 | Length=6 | Func. | Rate | Not Used | | | | 1000 | Report| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | QS Nonce | R | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
QuickStartOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _read_opt_rpl(schema, *, options)[source]¶
Read HOPOPT Routing Protocol for Low-Power and Lossy Networks (RPL) option.
Structure of HOPOPT RPL option [RFC 6553]:
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 Type | Opt Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |O|R|F|0|0|0|0|0| RPLInstanceID | SenderRank | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | (sub-TLVs) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
RPLOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.rpl.lengthis NOT4.
- _read_opt_mpl(schema, *, options)[source]¶
Read HOPOPT Multicast Protocol for Low-Power and Lossy Networks (MPL) option.
Structure of HOPOPT MPL option [RFC 7731]:
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 Type | Opt Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | S |M|V| rsv | sequence | seed-id (optional) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
MPLOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If the option is malformed.
- _read_opt_ilnp(schema, *, options)[source]¶
Read HOPOPT Identifier-Locator Network Protocol (ILNP) Nonce option.
Structure of HOPOPT ILNP Nonce option [RFC 6744]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Hdr Ext Len | Option Type | Option Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / Nonce Value / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
ILNPOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- _read_opt_lio(schema, *, options)[source]¶
Read HOPOPT Line-Identification option.
Structure of HOPOPT Line-Identification option [RFC 6788]:
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 Type | Option Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | LineIDLen | Line ID... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
LineIdentificationOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- _read_opt_jumbo(schema, *, options)[source]¶
Read HOPOPT Jumbo Payload option.
Structure of HOPOPT Jumbo Payload option [RFC 2675]:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option Type | Opt Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Jumbo Payload Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
JumboPayloadOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.jumbo.lengthis NOT4.
- _read_opt_home(schema, *, options)[source]¶
Read HOPOPT Home Address option.
Structure of HOPOPT Home Address option [RFC 6275]:
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 Type | Option Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Home Address + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Parameters:
schema (
HomeAddressOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.jumbo.lengthis NOT16.
- _read_opt_ip_dff(schema, *, options)[source]¶
Read HOPOPT Depth-First Forwarding (
IP_DFF) option.Structure of HOPOPT
IP_DFFoption [RFC 6971]: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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Hdr Ext Len | OptTypeDFF | OptDataLenDFF | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |VER|D|R|0|0|0|0| Sequence Number | Pad1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
IPDFFOption) – parsed parameter schemaoptions (
OrderedMultiDict[Option,Option]) – extracted HOPOPT options
- Return type:
- Returns:
Parsed option data.
- Raises:
ProtocolError – If
hopopt.ip_dff.lengthis NOT2.
- _make_hopopt_options(options)[source]¶
Make options for HOPOPT.
- Parameters:
options (
list[Option|tuple[Option,dict[str,Any]] |bytes] |OrderedMultiDict[Option,Option]) – HOPOPT options- Return type:
- Returns:
Tuple of options and total length of options.
Note
The returned length is that of the options area alone, so it is the value
make()needs forhdr_ext_len. Since the two octets of the fixed header precede it, an options area is well formed only when it is 6 octets short of a multiple of 8 – including when it holds no real options at all, in which case it is 6 octets of pure padding rather than empty.
- _make_opt_none(code, opt=None, *, data=b'', **kwargs)[source]¶
Make HOPOPT unassigned option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_pad(code, opt=None, *, length=0, **kwargs)[source]¶
Make HOPOPT pad option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
Note
Data_PadOption.lengthcounts the whole option, whereasSchema_PadOption.lenis theOpt Data Lenfield – two octets fewer, and absent altogether for aPad1.optused to be ignored here, so re-making a parsed padding option silently collapsed it to a singlePad1.
- _make_opt_tun(code, opt=None, *, limit=0, **kwargs)[source]¶
Make HOPOPT tunnel encapsulation limit option.
- Parameters:
code (
Option) – option type valueopt (
TunnelEncapsulationLimitOption|None) – option datalimit (
int) – tunnel encapsulation limit**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_ra(code, opt=None, *, alert=<RouterAlert.Datagram_contains_a_Multicast_Listener_Discovery_message: 0>, alert_default=None, alert_namespace=None, alert_reversed=False, **kwargs)[source]¶
Make HOPOPT router alert option.
- Parameters:
code (
Option) – option type valueopt (
RouterAlertOption|None) – option dataalert (
RouterAlert|IntEnum|IntEnum|str|int) – router alert valuealert_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – namespace of router alertalert_reversed (
bool) – reversed flag of router alert**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_calipso(code, opt=None, *, domain=0, level=0, checksum=b'\\x00\\x00', bitmap=None, **kwargs)[source]¶
Make HOPOPT calipso option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_smf_dpd(code, opt=None, *, mode=<SMFDPDMode.I_DPD: 0>, mode_default=None, mode_namespace=None, mode_reversed=False, tid=None, id=b'', hav=b'', **kwargs)[source]¶
Make HOPOPT SMF DPD option.
- Parameters:
code (
Option) – option type valueopt (
SMFIdentificationBasedDPDOption|SMFHashBasedDPDOption|None) – option datamode (
SMFDPDMode|IntEnum|IntEnum|str|int) – DPD modemode_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – namespace of DPD modemode_reversed (
bool) – reversed flag of DPD modetid (
bytes|IPv4Address|IPv6Address|None) – Tagger IDid (
bytes) – identifierhav (
bytes) – hash assist value (HAV)**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_pdm(code, opt=None, *, psntp=0, psnlr=0, deltatlr=0, deltatls=0, **kwargs)[source]¶
Make HOPOPT PDM option.
- Parameters:
code (
Option) – option type valuepsntp (
int) – packet sequence number (PSN) this packetpsnlr (
int) – packet sequence number (PSN) last receiveddeltatlr (
int) – delta time last received (in attoseconds)deltatls (
int) – delta time last sent (in attoseconds)**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_qs(code, opt=None, *, func=<QSFunction.Quick_Start_Request: 0>, func_default=None, func_namespace=None, func_reversed=False, rate=0, ttl=0, nonce=0, **kwargs)[source]¶
Make HOPOPT QS option.
- Parameters:
code (
Option) – option type valueopt (
QuickStartOption|None) – option datafunc (
QSFunction|IntEnum|IntEnum|str|int) – QS function typefunc_default (
int|None) – default value for QS function typefunc_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – namespace for QS function typefunc_reversed (
bool) – reversed flag for QS function typerate (
int) – rate (in kbps)nonce (
int) – nonce value**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_rpl(code, opt=None, *, down=False, rank_err=False, fwd_err=False, id=0, rank=0, **kwargs)[source]¶
Make HOPOPT RPL option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_mpl(code, opt=None, *, max=False, drop=False, seq=0, seed=None, **kwargs)[source]¶
Make HOPOPT MPL option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
- _make_opt_ilnp(code, opt=None, *, nonce=0, **kwargs)[source]¶
Make HOPOPT ILNP option.
- Parameters:
code (
Option) – option type valueopt (
ILNPOption|None) – option datanonce (
int) – ILNP nonce value**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_lio(code, opt=None, *, id=b'', **kwargs)[source]¶
Make HOPOPT LIO option.
- Parameters:
code (
Option) – option type valueopt (
LineIdentificationOption|None) – option dataid (
bytes) – line ID value**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_jumbo(code, opt=None, *, len=0, **kwargs)[source]¶
Make HOPOPT Jumbo Payload option.
- Parameters:
code (
Option) – option type valueopt (
JumboPayloadOption|None) – option datalen (
int) – jumbo payload length**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_home(code, opt=None, *, addr='::', **kwargs)[source]¶
Make HOPOPT Home Address option.
- Parameters:
code (
Option) – option type valueopt (
HomeAddressOption|None) – option dataaddr (
IPv6Address|str|bytes|int) – home address value**kwargs (
Any) – arbitrary keyword arguments
- Return type:
- Returns:
Constructured option schema.
- _make_opt_ip_dff(code, opt=None, *, version=0, dup=False, ret=False, seq=0, **kwargs)[source]¶
Make HOPOPT IP DFF option.
- Parameters:
- Return type:
- Returns:
Constructured option schema.
- __option__: DefaultDict[Option | int, str | tuple[Callable[[Option, OrderedMultiDict[Option, Option]], Option], Callable[[Option, Option | None, Any], Option]]]¶
Option code to method mapping, c.f.
_read_hopopt_options()and/or_make_hopopt_options(). Method names are expected to be referred to the class by_read_opt_${name}and/or_make_opt_${name}, and if such name not found, the value should then be a method that can parse the option by itself.
- __post_init__(file=None, length=None, *, extension=False, **kwargs)[source]¶
Post initialisation hook.
- Overloads:
self, file (IO[bytes] | bytes), length (Optional[int]), extension (bool), kwargs (Any) → None
self, kwargs (Any) → None
- Parameters:
See also
For construction argument, please refer to
make().
Header Schemas¶
- class pcapkit.protocols.schema.internet.hopopt.HOPOPT(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SchemaHeader schema for HOPOPT packet.
- class pcapkit.protocols.schema.internet.hopopt.Option(dict_=None, **kwargs)[source]¶
Bases:
EnumSchema[Option]Header schema for HOPOPT options.
- class pcapkit.protocols.schema.internet.hopopt.UnassignedOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT unassigned options.
- class pcapkit.protocols.schema.internet.hopopt.PadOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT padding options.
The two padding options do not share a wire shape: a
Pad1option is a lone type octet, whereas aPadNoption is a type octet, anOpt Data Lenoctet, and that many padding octets [RFC 8200 Section 4.2]. Both theOpt Data Lenoctet (Option.len) and the padding data (self.pad) are therefore sized from the option type, so that aPad1option consumes exactly one octet.
- class pcapkit.protocols.schema.internet.hopopt.TunnelEncapsulationLimitOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT tunnel encapsulation limit options.
- class pcapkit.protocols.schema.internet.hopopt.RouterAlertOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT router alert options.
- alert: RouterAlert = <EnumField alert>¶
Router alert.
- class pcapkit.protocols.schema.internet.hopopt.CALIPSOOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT common architecture label IPv6 security options.
- class pcapkit.protocols.schema.internet.hopopt.SMFDPDOption(dict_=None, **kwargs)[source]¶
Bases:
Option,EnumSchema[SMFDPDMode]Header schema for HOPOPT simplified multicast forwarding duplicate packet detection (
SMF_DPD) options.
- class pcapkit.protocols.schema.internet.hopopt.SMFIdentificationBasedDPDOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SMFDPDOptionHeader schema for HOPOPT SMF identification-based DPD options.
- info: TaggerIDInfo = <BitField info>¶
TaggerID information.
- tid: bytes | IPv4Address | IPv6Address = <ConditionalField tid>¶
TaggerID.
- class pcapkit.protocols.schema.internet.hopopt.SMFHashBasedDPDOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SMFDPDOptionHeader schema for HOPOPT SMF hash-based DPD options.
- class pcapkit.protocols.schema.internet.hopopt.PDMOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT performance and diagnostic metrics (PDM) options.
- class pcapkit.protocols.schema.internet.hopopt._QuickStartOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SchemaHeader schema for HOPOPT quick start options in generic representation.
- flags: QSTestFlags = <ForwardMatchField flags>¶
Flags.
- data: QuickStartRequestOption | QuickStartReportOption = <SwitchField data>¶
QS data.
- class pcapkit.protocols.schema.internet.hopopt.QuickStartOption(dict_=None, **kwargs)[source]¶
Bases:
Option,EnumSchema[QSFunction]Header schema for HOPOPT quick start options.
- flags: QuickStartFlags = <BitField flags>¶
Flags.
- class pcapkit.protocols.schema.internet.hopopt.QuickStartRequestOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
QuickStartOptionHeader schema for HOPOPT quick start request options.
- class pcapkit.protocols.schema.internet.hopopt.QuickStartReportOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
QuickStartOptionHeader schema for HOPOPT quick start report of approved rate options.
- class pcapkit.protocols.schema.internet.hopopt.RPLOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT routing protocol for low-power and lossy networks (RPL) options.
- class pcapkit.protocols.schema.internet.hopopt.MPLOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT multicast protocol for low-power and lossy networks (MPL) options.
- class pcapkit.protocols.schema.internet.hopopt.MPLFlags[source]¶
Bases:
TypedDictMPL flags.
- class pcapkit.protocols.schema.internet.hopopt.ILNPOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT identifier-locator network protocol (ILNP) options.
- class pcapkit.protocols.schema.internet.hopopt.LineIdentificationOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT line-identification options.
- class pcapkit.protocols.schema.internet.hopopt.JumboPayloadOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT jumbo payload options.
- class pcapkit.protocols.schema.internet.hopopt.HomeAddressOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT home address options.
- addr: IPv6Address = <IPv6AddressField addr>¶
Home address.
- class pcapkit.protocols.schema.internet.hopopt.IPDFFOption(*args: _VT, **kwargs: _VT)[source]¶
Bases:
OptionHeader schema for HOPOPT depth-first forwarding (
IP_DFF) options.
Type Stubs¶
- class pcapkit.protocols.schema.internet.hopopt.TaggerIDInfo[source]¶
Bases:
TypedDictTaggerID information.
- class pcapkit.protocols.schema.internet.hopopt.QuickStartFlags[source]¶
Bases:
TypedDictQuick-Start flags.
- class pcapkit.protocols.schema.internet.hopopt.RPLFlags[source]
Bases:
TypedDictRPL flags.
- down: int
Down flag.
- rank_err: int
Rank error flag.
- fwd_err: int
Forwarding error flag.
- class pcapkit.protocols.schema.internet.hopopt.MPLFlags[source]
Bases:
TypedDictMPL flags.
- type: int
Seed-ID type. Identifies the length of the Seed-ID.
- max: int
Max flag.
1indicates that the value in the sequence field is known to be the largest sequence number that was received from the MPL Seed.
- drop: int
Verification flag.
0indicates that the MPL Option conforms to this specification.
- class pcapkit.protocols.schema.internet.hopopt.DFFFlags[source]
Bases:
TypedDictIP_DFFflags.- ver: int
Version.
- dup: int
Duplicate flag.
- ret: int
Retune flag.
- class pcapkit.protocols.schema.internet.hopopt.SMFDPDTestFlag[source]¶
Bases:
TypedDictSMF_DPDtest flag.
Auxiliary Functions¶
- pcapkit.protocols.schema.internet.hopopt.mpl_opt_seed_id_len(pkt)[source]¶
Return MPL Seed-ID length.
- pcapkit.protocols.schema.internet.hopopt.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 whyOption.lenis declared as aConditionalFieldand is skipped for it. A skipped conditional field is recorded in the packet data asNoValue, 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 exactly how aPad1option used to fail to parse.
- pcapkit.protocols.schema.internet.hopopt.calipso_pad_len(pkt)[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.hopopt.mpl_opt_pad_len(pkt)[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.hopopt.smf_dpd_data_selector(pkt)[source]¶
Selector function for
_SMFDPDOption.datafield.- Parameters:
- Return type:
- Returns:
If
modeis0, returns aSchemaFieldwrappedSMFIdentificationBasedDPDOptioninstance.If
modeis1, returns aSchemaFieldwrappedSMFHashBasedDPDOptioninstance.
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 inheritOption.typeandOption.lenand so parse those two octets themselves. Sizing the field atOpt Data Lenhanded them an area two octets short of the option they read, whichOptionFieldthen mis-counted against the option area – c.f. #431.
- pcapkit.protocols.schema.internet.hopopt.smf_i_dpd_tid_selector(pkt)[source]¶
Selector function for
SMFIdentificationBasedDPDOption.tidfield.- Parameters:
- Return type:
- Returns:
If
tid_typeis0, returns aNoValueFieldinstance.If
tid_typeis1, returns aIPv4AddressFieldinstance.If
tid_typeis2, returns aIPv6AddressFieldinstance.Otherwise, returns a
BytesFieldinstance.
- pcapkit.protocols.schema.internet.hopopt.smf_i_dpd_id_len(pkt)[source]¶
Return SMF I-DPD identifier length.
- Parameters:
pkt (
dict[str,Any]) – SMF identification-based DPD option unpacked schema.- 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.hopopt.quick_start_data_selector(pkt)[source]¶
Selector function for
_QuickStartOption.datafield.- Parameters:
- Return type:
- Returns:
If
funcis0, returns aSchemaFieldwrappedQuickStartRequestOptioninstance.If
funcis8, returns aSchemaFieldwrappedQuickStartReportOptioninstance.
Data Models¶
- class pcapkit.protocols.data.internet.hopopt.HOPOPT(*args: VT, **kwargs: VT)[source]¶
Bases:
ProtocolData model for HOPOPT protocol.
- options: OrderedMultiDict[Option, Option]¶
HOPOPT options.
- class pcapkit.protocols.data.internet.hopopt.Option(dict_=None, **kwargs)[source]¶
Bases:
DataData model for HOPOPT option data.
- action: OptionAction¶
Unknown option cation.
- class pcapkit.protocols.data.internet.hopopt.UnassignedOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT unassigned option.
- class pcapkit.protocols.data.internet.hopopt.PadOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT padding options.
- class pcapkit.protocols.data.internet.hopopt.TunnelEncapsulationLimitOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT tunnel encapsulation limit option.
- class pcapkit.protocols.data.internet.hopopt.RouterAlertOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT router alter option.
- value: RouterAlert¶
Router alter value.
- class pcapkit.protocols.data.internet.hopopt.CALIPSOOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Common Architecture Label IPv6 Security Option (CALIPSO) option.
- class pcapkit.protocols.data.internet.hopopt.SMFDPDOption(dict_=None, **kwargs)[source]¶
Bases:
OptionData model for HOPOPT Simplified Multicast Forwarding Duplicate Packet Detection (
SMF_DPD) option.- dpd_type: SMFDPDMode¶
DPD type.
- class pcapkit.protocols.data.internet.hopopt.SMFIdentificationBasedDPDOption(*args: VT, **kwargs: VT)[source]¶
Bases:
SMFDPDOptionData model for HOPOPT I-DPD (Identification-Based DPD) option.
- tid: bytes | IPv4Address | IPv6Address | None¶
TaggerID.
- class pcapkit.protocols.data.internet.hopopt.SMFHashBasedDPDOption(*args: VT, **kwargs: VT)[source]¶
Bases:
SMFDPDOptionData model for HOPOPT H-DPD (Hash-Based DPD) option.
- class pcapkit.protocols.data.internet.hopopt.PDMOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Performance Diagnostic Metrics (PDM) option.
- class pcapkit.protocols.data.internet.hopopt.QuickStartOption(dict_=None, **kwargs)[source]¶
Bases:
OptionData model for HOPOPT Quick Start option.
- func: QSFunction¶
QS function.
- class pcapkit.protocols.data.internet.hopopt.RPLOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Routing Protocol for Low-Power and Lossy Networks (RPL) option.
- class pcapkit.protocols.data.internet.hopopt.RPLFlags(*args: VT, **kwargs: VT)[source]¶
Bases:
DataData model for HOPOPT RPL option flags fields.
- class pcapkit.protocols.data.internet.hopopt.MPLOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Multicast Protocol for Low-Power and Lossy Networks (MPL) option.
- class pcapkit.protocols.data.internet.hopopt.MPLFlags(*args: VT, **kwargs: VT)[source]¶
Bases:
DataData model for HOPOPT MPL option flags fields.
- class pcapkit.protocols.data.internet.hopopt.ILNPOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Identifier-Locator Network Protocol (ILNP) Nonce option.
- class pcapkit.protocols.data.internet.hopopt.LineIdentificationOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Line-Identification option.
- class pcapkit.protocols.data.internet.hopopt.JumboPayloadOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for Jumbo Payload option.
- class pcapkit.protocols.data.internet.hopopt.HomeAddressOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Home Address option.
- address: IPv6Address¶
Home address.
- class pcapkit.protocols.data.internet.hopopt.IPDFFOption(*args: VT, **kwargs: VT)[source]¶
Bases:
OptionData model for HOPOPT Depth-First Forwarding (
IP_DFF) option.
- class pcapkit.protocols.data.internet.hopopt.DFFFlags(*args: VT, **kwargs: VT)[source]¶
Bases:
DataData model for HOPOPT
IP_DFFoption flags.
Footnotes