ICMPv6 - Internet Control Message Protocol for IPv6¶
pcapkit.protocols.internet.icmpv6.protocol contains
ICMPv6 only,
which implements the extractor for Internet Control
Message Protocol for IPv6 (ICMPv6) [*], whose structure
is:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Type |
1 |
8 |
|
Code |
2 |
16 |
|
Checksum |
4 |
32 |
|
Message Body |
Added in version 1.6.0.
- class pcapkit.protocols.internet.icmpv6.protocol.ICMPv6(file, length=None, /, *, version=None, layer=None, protocol=None, context=None)[source]¶
-
This class implements Internet Control Message Protocol for IPv6.
This class parses the following ICMPv6 message types, which are registered in the
self.__type__attribute:Type
Data Parser
Data Constructor
Destination Unreachable
Packet Too Big
Time Exceeded
Parameter Problem
Echo Request / Echo Reply
Multicast Listener Query
Multicast Listener Report / Multicast Listener Done
Version 2 Multicast Listener Report
Any other type, including Neighbor Discovery (RFC 4861), is kept as its raw message body, see
_read_data_type_none()and_make_data_type_none().Changed in version 1.6.0: The checksum is computed when
make()is given none, over thepseudoit is given or by the enclosing IPv6 layer, and verified by that layer underCHECKSUM_VERIFY(#2470).Changed in version 1.7.0: Decodes Multicast Listener Discovery, MLDv1 (RFC 2710) and MLDv2 (RFC 9777).
Defaults
- __type__: DefaultDict[Type | int, str | tuple[Callable[[ICMPv6Type, ICMPv6, int], ICMPv6], Callable[[Type, ICMPv6 | None, Any], ICMPv6Type]]]¶
Type code to method mapping. A
strvalue names the methods_read_data_type_${name}and_make_data_type_${name}, falling back to_read_data_type_none/_make_data_type_nonewhen they do not exist; any other value is a(parser, constructor)pair of callables.
Properties
Methods
- read(length=None, *, __packet__=None, **kwargs)[source]¶
Read Internet Control Message Protocol for IPv6 (ICMPv6).
Structure of ICMPv6 header [RFC 4443]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + Message Body + | |
- make(*, type=Type.Echo_Request, code=0, checksum=None, body=b'\x00\x00\x00\x00', pseudo=None, **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
code (
int) – ICMPv6 code; meaning is entirelytype-dependent.checksum (
bytes|None) – Checksum; ifNoneandCHECKSUM_COMPUTEis on, computed overpseudo(RFC 4443 Section 2.3), or left to an IPv6 layer this message is the payload of; zero otherwise.body (
bytes|ICMPv6|ICMPv6Type|dict[str,Any]) – Message body.bytesis parsed againsttype’s own schema; adictor aICMPv6data model is handed to that type’s own constructor method (see__type__); any otherICMPv6Typeis used as is.pseudo (
IP_Pseudo|None) – Pseudo-header of the enclosing IPv6 layer; its length is replaced by this message’s own.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
typeis a name, abool, or a member or code that does not fit in one octet; ifbodyisbytesthat do not parse as the message body oftype, or is of none of the accepted types; or ifchecksumis not two octets.
- classmethod register_type(code, meth)[source]¶
Register a message body parser.
- Parameters:
- Warns:
RegistryWarning– If a different entry is already registered forcode; it is overwritten.
Data Models
Utilities
- _read_data_type_destination_unreachable(schema, *, header, length)[source]¶
Read ICMPv6 Destination Unreachable message.
Structure of ICMPv6 Destination Unreachable message [RFC 4443]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | As much of invoking packet | | as will fit without the ICMPv6 | | packet exceeding the minimum IPv6 MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
DestinationUnreachable) – parsed message body schemaheader (
ICMPv6) – parsed ICMPv6 header schemalength (
int) – total length of the current ICMPv6 message
- Return type:
- Returns:
Parsed message data.
- _read_data_type_packet_too_big(schema, *, header, length)[source]¶
Read ICMPv6 Packet Too Big message.
Structure of ICMPv6 Packet Too Big message [RFC 4443]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | As much of invoking packet | | as will fit without the ICMPv6 | | packet exceeding the minimum IPv6 MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
PacketTooBig) – parsed message body schemaheader (
ICMPv6) – parsed ICMPv6 header schemalength (
int) – total length of the current ICMPv6 message
- Return type:
- Returns:
Parsed message data.
- _read_data_type_time_exceeded(schema, *, header, length)[source]¶
Read ICMPv6 Time Exceeded message.
Structure of ICMPv6 Time Exceeded message [RFC 4443] is identical to that of
_read_data_type_destination_unreachable(), but for the type code.- Parameters:
schema (
TimeExceeded) – parsed message body schemaheader (
ICMPv6) – parsed ICMPv6 header schemalength (
int) – total length of the current ICMPv6 message
- Return type:
- Returns:
Parsed message data.
- _read_data_type_parameter_problem(schema, *, header, length)[source]¶
Read ICMPv6 Parameter Problem message.
Structure of ICMPv6 Parameter Problem message [RFC 4443]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | As much of invoking packet | | as will fit without the ICMPv6 | | packet exceeding the minimum IPv6 MTU | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
ParameterProblem) – parsed message body schemaheader (
ICMPv6) – parsed ICMPv6 header schemalength (
int) – total length of the current ICMPv6 message
- Return type:
- Returns:
Parsed message data.
- _read_data_type_echo(schema, *, header, length)[source]¶
Read ICMPv6 Echo Request/Reply message.
Structure of ICMPv6 Echo Request/Reply message [RFC 4443]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Identifier | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + Data + | |
- _read_data_type_mld_query(schema, *, header, length)[source]¶
Read MLD Multicast Listener Query message.
Structure of MLDv2 Multicast Listener Query message [RFC 9777], whose first 24 octets are the whole of an MLDv1 Query [RFC 2710]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 130 | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Maximum Response Code | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | * Multicast Address * | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Flags |S| QRV | QQIC | Number of Sources (N) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | * Source Address [1..N] * | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A Query of 28 or more octets is MLDv2’s, and one of fewer MLDv1’s (RFC 9777 Section 8.1), see
mldv2_query_present().- Parameters:
- Returns:
MLDv1’s or MLDv2’s.
- Return type:
- _read_data_type_mldv1(schema, *, header, length)[source]¶
Read MLDv1 Multicast Listener Report/Done message.
Structure of MLDv1 message [RFC 2710]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type | Code | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Maximum Response Delay | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | + + | | + Multicast Address + | | + + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- _read_data_type_mldv2_report(schema, *, header, length)[source]¶
Read MLDv2 Version 2 Multicast Listener Report message.
Structure of MLDv2 Report message [RFC 9777]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Type = 143 | Reserved | Checksum | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Flags |Nr of Mcast Address Records (M)| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | . Multicast Address Record [1..M] . | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Each record has the shape of an IGMPv3 group record (RFC 3376 Section 4.2.4), with IPv6 addresses:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Record Type | Aux Data Len | Number of Sources (N) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | * Multicast Address * | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | * Source Address [1..N] * | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | . Auxiliary Data . | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
MLDv2Report) – parsed message body schemaheader (
ICMPv6) – parsed ICMPv6 header schemalength (
int) – total length of the current ICMPv6 message
- Return type:
- Returns:
Parsed message data.
- _make_data_type_none(type, message=None, *, data=b'', **kwargs)[source]¶
Make ICMPv6 message of unknown type.
- _make_data_type_destination_unreachable(type, message=None, *, unused=b'\x00\x00\x00\x00', data=b'', **kwargs)[source]¶
Make ICMPv6 Destination Unreachable message.
- Parameters:
- Return type:
- Returns:
Constructed message body schema.
- Raises:
ProtocolError – If
unusedis not four octets.
- _make_data_type_packet_too_big(type, message=None, *, mtu=0, data=b'', **kwargs)[source]¶
Make ICMPv6 Packet Too Big message.
- Parameters:
- Return type:
- Returns:
Constructed message body schema.
- _make_data_type_time_exceeded(type, message=None, *, unused=b'\x00\x00\x00\x00', data=b'', **kwargs)[source]¶
Make ICMPv6 Time Exceeded message.
- Parameters:
- Return type:
- Returns:
Constructed message body schema.
- Raises:
ProtocolError – If
unusedis not four octets.
- _make_data_type_parameter_problem(type, message=None, *, pointer=0, data=b'', **kwargs)[source]¶
Make ICMPv6 Parameter Problem message.
- Parameters:
- Return type:
- Returns:
Constructed message body schema.
- _make_data_type_echo(type, message=None, *, id=0, seq=0, data=b'', **kwargs)[source]¶
Make ICMPv6 Echo Request/Reply message.
- Parameters:
- Return type:
- Returns:
Constructed message body schema.
- _make_data_type_mld_query(type, message=None, *, version=None, max_resp_code=None, max_resp_delay=0, reserved=b'\x00\x00', multicast_address='::', flags=None, s_flag=None, qrv=None, qqic=None, qqi=None, num_sources=None, sources=None, data=b'', **kwargs)[source]¶
Make MLD Multicast Listener Query message.
- Parameters:
type (
Type) – ICMPv6 type.message (
MLDv1|MLDv2Query|None) – message data, whoseversionpicks the version built.version (
int|None) – MLD version,1(RFC 2710) or2(RFC 9777), which type 130 is shared by; no field picks it.max_resp_code (
int|None) – MLDv2’s Maximum Response Code, as on the wire; encoded frommax_resp_delaywhen not given.max_resp_delay (
int) – Maximum Response Delay, in milliseconds; MLDv1’s field, or what MLDv2’smax_resp_codeencodes.reserved (
bytes) – the two reserved octets.multicast_address (
IPv6Address|str|bytes|int) – multicast address queried,::for a General Query.flags (
int|None) – MLDv2’s four flag bits, zero when not given.s_flag (
bool|None) – MLDv2’s Suppress Router-Side Processing flag, clear when not given.qrv (
int|None) – MLDv2’s Querier’s Robustness Variable, zero when not given.qqic (
int|None) – MLDv2’s Querier’s Query Interval Code, as on the wire; encoded fromqqiwhen not given.qqi (
int|None) – MLDv2’s Querier’s Query Interval, in seconds.num_sources (
int|None) – MLDv2’s number of sources, the length ofsourceswhen not given; a count above it is written as given, as on a Query the capture cut inside its sources.sources (
Iterable[IPv6Address|str|bytes|int] |None) – MLDv2’s source addresses.data (
bytes) – octets past the fields of the version built; fewer than four for MLDv1, since a Query of 28 or more octets is MLDv2’s.**kwargs (
Any) – arbitrary keyword arguments.
- Return type:
- Returns:
Constructed message body schema.
- Raises:
ProtocolError – If
versionis neither1nor2; if an MLDv1 Query is given a field only MLDv2 takes, or four or more octets ofdata; if a field does not fit its width, ornum_sourcesis below the length ofsources; or ifreservedis not two octets.
- _make_data_type_mldv1(type, message=None, *, max_resp_delay=0, reserved=b'\x00\x00', multicast_address='::', data=b'', **kwargs)[source]¶
Make MLDv1 Multicast Listener Report/Done message.
- Parameters:
type (
Type) – ICMPv6 type.max_resp_delay (
int) – Maximum Response Delay, in milliseconds; zero on a conformant sender.reserved (
bytes) – the two reserved octets.multicast_address (
IPv6Address|str|bytes|int) – multicast address reported or left.data (
bytes) – octets past the 24 RFC 2710 Section 3 defines.**kwargs (
Any) – arbitrary keyword arguments.
- Return type:
- Returns:
Constructed message body schema.
- Raises:
ProtocolError – If
max_resp_delaydoes not fit 16 bits, orreservedis not two octets.
- _make_data_type_mldv2_report(type, message=None, *, flags=0, num_records=None, records=None, data=b'', **kwargs)[source]¶
Make MLDv2 Version 2 Multicast Listener Report message.
- Parameters:
type (
Type) – ICMPv6 type.message (
MLDv2Report|None) – message data.flags (
int) – the 16 flag bits.num_records (
int|None) – number of multicast address records, the length ofrecordswhen not given; a count above it is written as given, as on a Report the capture cut short.records (
Iterable[dict[str,Any] |MulticastAddressRecord] |None) – multicast address records, each aMulticastAddressRecordor adictof the keyword arguments_make_address_record()takes.data (
bytes) – additional data past the last record.**kwargs (
Any) – arbitrary keyword arguments.
- Return type:
- Returns:
Constructed message body schema.
- Raises:
ProtocolError – If
flagsdoes not fit 16 bits,num_recordsis not anintfrom the length ofrecordsto 65535, or a record is refused, see_make_address_record().
- _make_address_record(record=None, *, record_type=RecordType.MODE_IS_INCLUDE, aux_data_len=None, num_sources=None, multicast_address='::', sources=None, aux_data=b'', **kwargs)[source]¶
Make an MLDv2 multicast address record (RFC 9777 Section 5.2).
- Parameters:
record (
MulticastAddressRecord|None) – record data, taking precedence over the keyword arguments below.record_type (
RecordType|int) – record type (RFC 9777 Section 5.2.13).aux_data_len (
int|None) – auxiliary data length, in 32-bit words; derived fromaux_datawhen not given.num_sources (
int|None) – number of source addresses, the length ofsourceswhen not given; a count above it is written as given, as on a record the capture cut inside its sources.multicast_address (
IPv6Address|str|bytes|int) – multicast address the record pertains to.sources (
Iterable[IPv6Address|str|bytes|int] |None) – source addresses.aux_data (
bytes) – auxiliary data; RFC 9777 Section 5.2.11 has an MLDv2 sender leave it empty.**kwargs (
Any) – arbitrary keyword arguments.
- Return type:
- Returns:
Constructed record schema.
- Raises:
ProtocolError – If
record_typeis a name, abool, or a member or code outside 0 to 255; ifaux_data_lenornum_sourcesdoes not fit its width, ornum_sourcesis below the length ofsources; or ifaux_data_lenis not given andaux_datais no whole number of 32-bit words.
Header Schemas¶
- class pcapkit.protocols.internet.icmpv6.schema.ICMPv6(type=NO_VALUE, code=NO_VALUE, checksum=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for ICMPv6 packet.
- data: ICMPv6Type = <SwitchField data>¶
Message body, selected by
type.
- class pcapkit.protocols.internet.icmpv6.schema.ICMPv6Type(*args, **kwargs)[source]¶
Bases:
EnumSchema[Type]Header schema for ICMPv6 type-specific message body.
- class pcapkit.protocols.internet.icmpv6.schema.Unknown(data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 message of unknown type.
- class pcapkit.protocols.internet.icmpv6.schema.DestinationUnreachable(unused=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 Destination Unreachable message.
- class pcapkit.protocols.internet.icmpv6.schema.PacketTooBig(mtu=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 Packet Too Big message.
- class pcapkit.protocols.internet.icmpv6.schema.TimeExceeded(unused=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 Time Exceeded message.
- class pcapkit.protocols.internet.icmpv6.schema.ParameterProblem(pointer=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 Parameter Problem message.
- class pcapkit.protocols.internet.icmpv6.schema.Echo(id=NO_VALUE, seq=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for ICMPv6 Echo Request/Reply message.
- class pcapkit.protocols.internet.icmpv6.schema.MLDQuery(max_resp_code=NO_VALUE, reserved=NO_VALUE, multicast_address=NO_VALUE, ext=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for an MLD Multicast Listener Query message.
Its first 20 octets are those of an MLDv1 Query (RFC 2710 Section 3);
extholds what an MLDv2 Query adds (RFC 9777 Section 5.1), seemldv2_query_present().Added in version 1.7.0.
- max_resp_code: int = <UInt16Field max_resp_code>¶
Maximum Response Delay of MLDv1, or Maximum Response Code of MLDv2.
- multicast_address: IPv6Address = <IPv6AddressField multicast_address>¶
Multicast address.
- ext: MLDv2QueryExtension | None = <ConditionalField ext>¶
Fields an MLDv2 Query adds,
Noneon an MLDv1 Query.
- class pcapkit.protocols.internet.icmpv6.schema.MLDv2QueryExtension(flags=NO_VALUE, qqic=NO_VALUE, num_sources=NO_VALUE, sources=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for the fields an MLDv2 Query adds (RFC 9777 Section 5.1).
They follow the 24 octets of an MLDv1 Query (RFC 2710 Section 3).
Added in version 1.7.0.
- flags: MLDv2QueryFlags = <BitField flags>¶
Flags, S Flag and QRV.
- qqic: int = <UInt8Field qqic>¶
Querier’s Query Interval Code (RFC 9777 Section 5.1.9).
- sources: list[IPv6Address] = <ListField sources>¶
Source addresses (RFC 9777 Section 5.1.11).
- data: bytes = <PayloadField data>¶
Additional data (RFC 9777 Section 5.1.12), empty for a conformant sender. What the message leaves, as a trailer takes it, so a cut ends in the field it falls in.
- class pcapkit.protocols.internet.icmpv6.schema.MLDv1(max_resp_delay=NO_VALUE, reserved=NO_VALUE, multicast_address=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for an MLDv1 Multicast Listener Report or Done message (RFC 2710 Section 3).
Added in version 1.7.0.
- multicast_address: IPv6Address = <IPv6AddressField multicast_address>¶
Multicast address.
- data: bytes = <PayloadField data>¶
Octets past the 24 RFC 2710 Section 3 defines, what the message leaves.
- class pcapkit.protocols.internet.icmpv6.schema.MLDv2Report(flags=NO_VALUE, num_records=NO_VALUE, records=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
ICMPv6TypeHeader schema for an MLDv2 Version 2 Multicast Listener Report message (RFC 9777 Section 5.2).
Note
recordsis read with the whole remaining length, since the count cannot size it in octets;post_process()keeps the firstnum_recordsand gives the rest todata, the message’s Additional Data (RFC 9777 Section 5.2.12). Where the data ends before the records counted, seemldv2_record_count().Added in version 1.7.0.
- flags: int = <UInt16Field flags>¶
Flags (RFC 9777 Section 5.2.3).
- records: list[MulticastAddressRecord] = <ListField records>¶
Multicast address records.
- class pcapkit.protocols.internet.icmpv6.schema.MulticastAddressRecord(record_type=NO_VALUE, aux_data_len=NO_VALUE, num_sources=NO_VALUE, multicast_address=NO_VALUE, sources=NO_VALUE, aux_data=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for an MLDv2 multicast address record (RFC 9777 Section 5.2).
Added in version 1.7.0.
- record_type: RecordType = <EnumField record_type>¶
Record type (RFC 9777 Section 5.2.13).
- multicast_address: IPv6Address = <IPv6AddressField multicast_address>¶
Multicast address.
- sources: list[IPv6Address] = <ListField sources>¶
Source addresses (RFC 9777 Section 5.2.10).
- aux_data: bytes = <BytesField aux_data>¶
Auxiliary data (RFC 9777 Section 5.2.11).
Auxiliary Functions¶
- pcapkit.protocols.internet.icmpv6.schema.icmpv6_data_selector(pkt)[source]¶
Selector function for
ICMPv6.datafield.- Parameters:
- Return type:
- Returns:
A
SchemaFieldwrappedICMPv6Typeinstance based onICMPv6.type.
- pcapkit.protocols.internet.icmpv6.schema.mldv2_query_present(pkt)[source]¶
Test function for
MLDQuery.ext.A Query of 28 or more octets is MLDv2’s, and one of fewer MLDv1’s (RFC 9777 Section 8.1): 28 octets leave at least 4 past the 20 read before
MLDQuery.ext, behind the 4 of the ICMPv6 header. A Query of 25 to 27 octets, which neither version defines, reads as MLDv1, the octets past its 24 kept.On the packing path
'ext'is already inpkt, and the question is whether anextvalue was given.- Parameters:
- Return type:
- Returns:
Whether
MLDQuery.extshould be parsed (unpacking) or packed (packing).
Added in version 1.7.0.
- pcapkit.protocols.internet.icmpv6.schema.mldv2_record_count(pkt)[source]¶
Count callback for
MLDv2Report.records.- Parameters:
- Return type:
- Returns:
MLDv2Report.num_records, for a message parsed on its own; otherwise-1, counting none: inside a frame its lengths say where the message ends, and on the packing path'records'is already inpkt. Records counted past the data are then a cut, whichSchema.unpackrecords.- Raises:
ProtocolError – If the records counted, at the 20 fixed octets of each, behind the 8 octets ahead of them, reach past the
IP_MAX_LENGTHoctets an IP payload holds, so the count is no cut but one the message cannot carry.
Added in version 1.7.0.
Type Stubs¶
Data Models¶
- class pcapkit.protocols.internet.icmpv6.data.ICMPv6(*args, **kwargs)[source]¶
Bases:
ProtocolData model for ICMPv6 protocol.
The fields below are the only ones every ICMPv6 message shares (RFC 4443); what follows them is read entirely differently depending on
type, which is why each message kind below adds its own fields rather than this base class growing a union of them all.- code: int¶
ICMPv6 code. Left untyped as a bare
inthere because its meaning is entirelytype-dependent; each subclass below documents which registry (if any) its owncodevalues are drawn from.
- length: int¶
Message length, in octets, header included. ICMPv6 messages carry no length field of their own – this is simply how many octets
ICMPv6.readwas handed, kept here so the whole message can be told apart from a truncated capture.
- checksum_status: ChecksumStatus¶
Outcome of verifying
checksum, present only when the enclosing IPv6 layer verified it underCHECKSUM_VERIFY.
- class pcapkit.protocols.internet.icmpv6.data.Unknown(type, code, checksum, length, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 packet of unknown type.
codecarries nopcapkit.constregistry for a type this package does not recognise, so it is read as a bareint.
- class pcapkit.protocols.internet.icmpv6.data.DestinationUnreachable(type, code, checksum, length, unused, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 Destination Unreachable message (type 1).
- unused: bytes¶
Unused (four octets, RFC 4443 Section 3.1), as captured.
- data: bytes¶
As much of the invoking packet as fits the minimum IPv6 MTU, per RFC 4443 Section 3.1, as captured.
- class pcapkit.protocols.internet.icmpv6.data.PacketTooBig(type, code, checksum, length, mtu, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 Packet Too Big message (type 2).
codeis always0(RFC 4443 Section 3.2), so it is read as a bareintrather than typed against a registry of one member.- data: bytes¶
As much of the invoking packet as fits the minimum IPv6 MTU, per RFC 4443 Section 3.2, as captured.
- class pcapkit.protocols.internet.icmpv6.data.TimeExceeded(type, code, checksum, length, unused, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 Time Exceeded message (type 3).
- unused: bytes¶
Unused (four octets, RFC 4443 Section 3.3), as captured.
- data: bytes¶
As much of the invoking packet as fits the minimum IPv6 MTU, per RFC 4443 Section 3.3, as captured.
- class pcapkit.protocols.internet.icmpv6.data.ParameterProblem(type, code, checksum, length, pointer, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 Parameter Problem message (type 4).
- pointer: int¶
Pointer, identifying the octet offset within the invoking packet where the error was detected (RFC 4443 Section 3.4).
- data: bytes¶
As much of the invoking packet as fits the minimum IPv6 MTU, per RFC 4443 Section 3.4, as captured.
- class pcapkit.protocols.internet.icmpv6.data.Echo(type, code, checksum, length, id, seq, data)[source]¶
Bases:
ICMPv6Data model for ICMPv6 Echo Request/Reply message (types 128 and 129).
codeis always0for both types (RFC 4443 Section 4.1, RFC 4443 Section 4.2), so it is read as a bareintrather than typed against a registry of one member.
- class pcapkit.protocols.internet.icmpv6.data.MLDv1(type, code, checksum, length, version, max_resp_delay, reserved, multicast_address, data)[source]¶
Bases:
ICMPv6Data model for an MLDv1 message (RFC 2710 Section 3).
A Multicast Listener Query (type 130) of fewer than 28 octets (RFC 9777 Section 8.1), a Multicast Listener Report (131) or a Multicast Listener Done (132).
codeis zero on the wire and ignored (RFC 2710 Section 3.2).Added in version 1.7.0.
- version: Literal[1]¶
MLD version, always
1. It is on no octet; it names the version the message was read as, which a Query is rebuilt by.
- max_resp_delay: int¶
Maximum Response Delay, in milliseconds (RFC 2710 Section 3.4); zero but in a Query.
- reserved: bytes¶
Reserved (RFC 2710 Section 3.5), as captured.
- multicast_address: IPv6Address¶
Multicast address (RFC 2710 Section 3.6),
::on a General Query and else the address queried, reported or left.
- data: bytes¶
Octets past the 24 RFC 2710 Section 3 defines, as captured; empty for a conformant sender.
- class pcapkit.protocols.internet.icmpv6.data.MLDv2Query(type, code, checksum, length, version, max_resp_code, max_resp_delay, reserved, multicast_address, flags, s_flag, qrv, qqic, qqi, num_sources, sources, data)[source]¶
Bases:
ICMPv6Data model for an MLDv2 Multicast Listener Query (RFC 9777 Section 5.1).
A Query (type 130) of 28 or more octets (RFC 9777 Section 8.1).
codeis zero on the wire and ignored (RFC 9777 Section 5.1.1).Added in version 1.7.0.
- version: Literal[2]¶
MLD version, always
2; seeMLDv1.version.
- max_resp_delay: int¶
Maximum Response Delay, in milliseconds, decoded from
max_resp_code: literal below 32768, else(mant | 0x1000) << (exp + 3)(RFC 9777 Section 5.1.3).
- reserved: bytes¶
Reserved (RFC 9777 Section 5.1.4), as captured.
- multicast_address: IPv6Address¶
Multicast address,
::on a General Query and else the address queried (RFC 9777 Section 5.1.5).
- flags: int¶
Flags, the 4 high-order bits of the octet holding
s_flag(RFC 9777 Section 5.1.6), as captured.
- s_flag: bool¶
Suppress Router-Side Processing flag (RFC 9777 Section 5.1.7).
- qrv: int¶
Querier’s Robustness Variable (RFC 9777 Section 5.1.8).
- qqi: int¶
Querier’s Query Interval, in seconds, decoded from
qqic(RFC 9777 Section 5.1.9).
- num_sources: int¶
Number of source addresses, as on the wire (RFC 9777 Section 5.1.10); more than
sourcesholds where the data ends inside them.
- sources: tuple[IPv6Address, ...]¶
Source addresses (RFC 9777 Section 5.1.11).
- data: bytes¶
Additional data (RFC 9777 Section 5.1.12), as captured; empty for a conformant sender.
- class pcapkit.protocols.internet.icmpv6.data.MLDv2Report(type, code, checksum, length, version, flags, num_records, records, data)[source]¶
Bases:
ICMPv6Data model for an MLDv2 Version 2 Multicast Listener Report (RFC 9777 Section 5.2).
A Report is type 143, and its
codethe Reserved octet (RFC 9777 Section 5.2.1).Added in version 1.7.0.
- version: Literal[2]¶
MLD version, always
2; seeMLDv1.version.
- flags: int¶
Flags (RFC 9777 Section 5.2.3), as captured.
- records: tuple[MulticastAddressRecord, ...]¶
Multicast address records (RFC 9777 Section 5.2.5).
- data: bytes¶
Additional data (RFC 9777 Section 5.2.12), as captured; empty for a conformant sender.
- class pcapkit.protocols.internet.icmpv6.data.MulticastAddressRecord(record_type, aux_data_len, num_sources, multicast_address, sources, aux_data)[source]¶
Bases:
DataData model for an MLDv2 multicast address record (RFC 9777 Section 5.2).
Added in version 1.7.0.
- record_type: RecordType¶
Record type (RFC 9777 Section 5.2.13).
- multicast_address: IPv6Address¶
Multicast address the record pertains to.
- sources: tuple[IPv6Address, ...]¶
Source addresses (RFC 9777 Section 5.2.10).
- aux_data: bytes¶
Auxiliary data (RFC 9777 Section 5.2.11), as captured; empty for an MLDv2 sender.
Footnotes