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

icmpv6.type

Type

1

8

icmpv6.code

Code

2

16

icmpv6.checksum

Checksum

4

32

icmpv6.data

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]

Bases: ICMP[ICMPv6, ICMPv6]

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:

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 the pseudo it is given or by the enclosing IPv6 layer, and verified by that layer under CHECKSUM_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 str value names the methods _read_data_type_${name} and _make_data_type_${name}, falling back to _read_data_type_none / _make_data_type_none when they do not exist; any other value is a (parser, constructor) pair of callables.

Properties

property name: Literal['Internet Control Message Protocol for IPv6']

Name of current protocol.

property alias: Literal['ICMPv6']

Acronym of corresponding protocol.

property length: int

Header length of current protocol.

Methods

classmethod id()[source]

Index ID of the protocol.

Return type:

tuple[Literal['ICMPv6']]

Returns:

Index ID of the protocol.

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                         +
|                                                               |
Parameters:
  • length (int | None) – Length of packet data.

  • __packet__ (dict[str, Any] | None) – Optional packet data, unused.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type:

ICMPv6

Returns:

Parsed packet data.

make(*, type=Type.Echo_Request, code=0, checksum=None, body=b'\x00\x00\x00\x00', pseudo=None, **kwargs)[source]

Make (construct) packet data.

Parameters:
  • type (Type | int) – ICMPv6 type.

  • code (int) – ICMPv6 code; meaning is entirely type-dependent.

  • checksum (bytes | None) – Checksum; if None and CHECKSUM_COMPUTE is on, computed over pseudo (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. bytes is parsed against type’s own schema; a dict or a ICMPv6 data model is handed to that type’s own constructor method (see __type__); any other ICMPv6Type is 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:

ICMPv6

Returns:

Constructed packet data.

Raises:

ProtocolError – If type is a name, a bool, or a member or code that does not fit in one octet; if body is bytes that do not parse as the message body of type, or is of none of the accepted types; or if checksum is not two octets.

classmethod register_type(code, meth)[source]

Register a message body parser.

Parameters:
Warns:

RegistryWarning – If a different entry is already registered for code; it is overwritten.

Data Models

__length_hint__()[source]

Return an estimated length for the object.

Return type:

Literal[4]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type:

TransType

Returns:

Numeral registry index of the protocol in IANA.

Utilities

classmethod _make_data(data)[source]

Create key-value pairs from data for protocol construction.

Parameters:

data (ICMPv6) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

_read_data_type_none(schema, *, header, length)[source]

Read ICMPv6 message of unknown type.

Parameters:
  • schema (Unknown) – parsed message body schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

Unknown

Returns:

Parsed message data.

_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 schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

DestinationUnreachable

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 schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

PacketTooBig

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 schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

TimeExceeded

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 schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

ParameterProblem

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                              +
|                                                               |
Parameters:
  • schema (Echo) – parsed message body schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

Echo

Returns:

Parsed message 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:
  • schema (MLDQuery) – parsed message body schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Returns:

MLDv1’s or MLDv2’s.

Return type:

MLDv1 | MLDv2Query

_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                       +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (MLDv1) – parsed message body schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

MLDv1

Returns:

Parsed message data.

_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 schema

  • header (ICMPv6) – parsed ICMPv6 header schema

  • length (int) – total length of the current ICMPv6 message

Return type:

MLDv2Report

Returns:

Parsed message data.

_make_data_type_none(type, message=None, *, data=b'', **kwargs)[source]

Make ICMPv6 message of unknown type.

Parameters:
  • type (Type) – ICMPv6 type.

  • message (Unknown | None) – message data.

  • data (bytes) – raw message body as bytes.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

Unknown

Returns:

Constructed message body schema.

_make_data_type_destination_unreachable(type, message=None, *, unused=b'\x00\x00\x00\x00', data=b'', **kwargs)[source]

Make ICMPv6 Destination Unreachable message.

Parameters:
  • type (Type) – ICMPv6 type.

  • message (DestinationUnreachable | None) – message data.

  • unused (bytes) – the four unused octets.

  • data (bytes) – as much of the invoking packet as fits the minimum IPv6 MTU.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

DestinationUnreachable

Returns:

Constructed message body schema.

Raises:

ProtocolError – If unused is 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:
  • type (Type) – ICMPv6 type.

  • message (PacketTooBig | None) – message data.

  • mtu (int) – MTU of the link that could not forward the invoking packet.

  • data (bytes) – as much of the invoking packet as fits the minimum IPv6 MTU.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

PacketTooBig

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:
  • type (Type) – ICMPv6 type.

  • message (TimeExceeded | None) – message data.

  • unused (bytes) – the four unused octets.

  • data (bytes) – as much of the invoking packet as fits the minimum IPv6 MTU.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

TimeExceeded

Returns:

Constructed message body schema.

Raises:

ProtocolError – If unused is not four octets.

_make_data_type_parameter_problem(type, message=None, *, pointer=0, data=b'', **kwargs)[source]

Make ICMPv6 Parameter Problem message.

Parameters:
  • type (Type) – ICMPv6 type.

  • message (ParameterProblem | None) – message data.

  • pointer (int) – pointer to the octet offset within the invoking packet where the error was detected.

  • data (bytes) – as much of the invoking packet as fits the minimum IPv6 MTU.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

ParameterProblem

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:
  • type (Type) – ICMPv6 type.

  • message (Echo | None) – message data.

  • id (int) – identifier.

  • seq (int) – sequence number.

  • data (bytes) – data, echoed back verbatim by a reply to the same identifier and sequence number.

  • **kwargs (Any) – arbitrary keyword arguments.

Return type:

Echo

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, whose version picks the version built.

  • version (int | None) – MLD version, 1 (RFC 2710) or 2 (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 from max_resp_delay when not given.

  • max_resp_delay (int) – Maximum Response Delay, in milliseconds; MLDv1’s field, or what MLDv2’s max_resp_code encodes.

  • 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 from qqi when not given.

  • qqi (int | None) – MLDv2’s Querier’s Query Interval, in seconds.

  • num_sources (int | None) – MLDv2’s number of sources, the length of sources when 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:

MLDQuery

Returns:

Constructed message body schema.

Raises:

ProtocolError – If version is neither 1 nor 2; if an MLDv1 Query is given a field only MLDv2 takes, or four or more octets of data; if a field does not fit its width, or num_sources is below the length of sources; or if reserved is 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.

  • message (MLDv1 | None) – message data.

  • 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:

MLDv1

Returns:

Constructed message body schema.

Raises:

ProtocolError – If max_resp_delay does not fit 16 bits, or reserved is 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:
Return type:

MLDv2Report

Returns:

Constructed message body schema.

Raises:

ProtocolError – If flags does not fit 16 bits, num_records is not an int from the length of records to 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:
Return type:

MulticastAddressRecord

Returns:

Constructed record schema.

Raises:

ProtocolError – If record_type is a name, a bool, or a member or code outside 0 to 255; if aux_data_len or num_sources does not fit its width, or num_sources is below the length of sources; or if aux_data_len is not given and aux_data is no whole number of 32-bit words.

_verify_pseudo_checksum(pseudo)[source]

Verify the checksum over the pseudo-header of the enclosing IP layer.

That layer calls this once parsed, see verify_upper().

Parameters:

pseudo (IP_Pseudo | None) – Pseudo-header, or None if the IP layer gives none.

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: Schema

Header schema for ICMPv6 packet.

type: Type = <EnumField type>

ICMPv6 type.

code: int = <UInt8Field code>

ICMPv6 code.

checksum: bytes = <BytesField checksum>

Checksum.

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: ICMPv6Type

Header schema for ICMPv6 message of unknown type.

data: bytes = <BytesField data>

Message body.

class pcapkit.protocols.internet.icmpv6.schema.DestinationUnreachable(unused=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: ICMPv6Type

Header schema for ICMPv6 Destination Unreachable message.

unused: bytes = <PaddingField unused>

Unused.

data: bytes = <BytesField data>

As much of the invoking packet as fits the minimum IPv6 MTU.

class pcapkit.protocols.internet.icmpv6.schema.PacketTooBig(mtu=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: ICMPv6Type

Header schema for ICMPv6 Packet Too Big message.

mtu: int = <UInt32Field mtu>

MTU of the link that could not forward the invoking packet.

data: bytes = <BytesField data>

As much of the invoking packet as fits the minimum IPv6 MTU.

class pcapkit.protocols.internet.icmpv6.schema.TimeExceeded(unused=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: ICMPv6Type

Header schema for ICMPv6 Time Exceeded message.

unused: bytes = <PaddingField unused>

Unused.

data: bytes = <BytesField data>

As much of the invoking packet as fits the minimum IPv6 MTU.

class pcapkit.protocols.internet.icmpv6.schema.ParameterProblem(pointer=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: ICMPv6Type

Header schema for ICMPv6 Parameter Problem message.

pointer: int = <UInt32Field pointer>

Pointer.

data: bytes = <BytesField data>

As much of the invoking packet as fits the minimum IPv6 MTU.

class pcapkit.protocols.internet.icmpv6.schema.Echo(id=NO_VALUE, seq=NO_VALUE, data=NO_VALUE, *, __packet__=None, **kwargs)[source]

Bases: ICMPv6Type

Header schema for ICMPv6 Echo Request/Reply message.

id: int = <UInt16Field id>

Identifier.

seq: int = <UInt16Field seq>

Sequence number.

data: bytes = <BytesField data>

Data.

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: ICMPv6Type

Header schema for an MLD Multicast Listener Query message.

Its first 20 octets are those of an MLDv1 Query (RFC 2710 Section 3); ext holds what an MLDv2 Query adds (RFC 9777 Section 5.1), see mldv2_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.

reserved: bytes = <BytesField reserved>

Reserved.

multicast_address: IPv6Address = <IPv6AddressField multicast_address>

Multicast address.

ext: MLDv2QueryExtension | None = <ConditionalField ext>

Fields an MLDv2 Query adds, None on an MLDv1 Query.

data: bytes = <PayloadField data>

Octets past the 24 of an MLDv1 Query, what the message leaves; empty on an MLDv2 Query, whose ext holds them.

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: Schema

Header 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).

num_sources: int = <UInt16Field num_sources>

Number of source addresses.

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: ICMPv6Type

Header schema for an MLDv1 Multicast Listener Report or Done message (RFC 2710 Section 3).

Added in version 1.7.0.

max_resp_delay: int = <UInt16Field max_resp_delay>

Maximum Response Delay, zero but in a Query.

reserved: bytes = <BytesField reserved>

Reserved.

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: ICMPv6Type

Header schema for an MLDv2 Version 2 Multicast Listener Report message (RFC 9777 Section 5.2).

Note

records is read with the whole remaining length, since the count cannot size it in octets; post_process() keeps the first num_records and gives the rest to data, the message’s Additional Data (RFC 9777 Section 5.2.12). Where the data ends before the records counted, see mldv2_record_count().

Added in version 1.7.0.

flags: int = <UInt16Field flags>

Flags (RFC 9777 Section 5.2.3).

num_records: int = <UInt16Field num_records>

Number of multicast address records, as on the wire.

records: list[MulticastAddressRecord] = <ListField records>

Multicast address records.

data: bytes = <PayloadField data>

Additional data, empty for a conformant sender.

post_process(packet)[source]

Trim records to num_records and reclaim the rest as data.

Parameters:

packet (dict[str, Any]) – Unpacked data.

Return type:

Schema

Returns:

Revised schema.

A capture that ends past the records kept ends inside data, so the short read unpack() recorded on records is moved there.

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: Schema

Header 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).

aux_data_len: int = <UInt8Field aux_data_len>

Auxiliary data length, in 32-bit words.

num_sources: int = <UInt16Field num_sources>

Number of source addresses.

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.data field.

Parameters:

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

Return type:

FieldBase

Returns:

A SchemaField wrapped ICMPv6Type instance based on ICMPv6.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 in pkt, and the question is whether an ext value was given.

Parameters:

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

Return type:

bool

Returns:

Whether MLDQuery.ext should 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:

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

Return type:

int

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 in pkt. Records counted past the data are then a cut, which Schema.unpack records.

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_LENGTH octets an IP payload holds, so the count is no cut but one the message cannot carry.

Added in version 1.7.0.

Type Stubs

class pcapkit.protocols.internet.icmpv6.schema.MLDv2QueryFlags[source]

Bases: TypedDict

MLDv2 Query flags octet.

Added in version 1.7.0.

flags: int

Flags.

s_flag: int

Suppress Router-Side Processing flag.

qrv: int

Querier’s Robustness Variable.

Data Models

class pcapkit.protocols.internet.icmpv6.data.ICMPv6(*args, **kwargs)[source]

Bases: Protocol

Data 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.

type: Type

ICMPv6 type.

code: int

ICMPv6 code. Left untyped as a bare int here because its meaning is entirely type-dependent; each subclass below documents which registry (if any) its own code values are drawn from.

checksum: bytes

Checksum.

length: int

Message length, in octets, header included. ICMPv6 messages carry no length field of their own – this is simply how many octets ICMPv6.read was 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 under CHECKSUM_VERIFY.

class pcapkit.protocols.internet.icmpv6.data.Unknown(type, code, checksum, length, data)[source]

Bases: ICMPv6

Data model for ICMPv6 packet of unknown type.

code carries no pcapkit.const registry for a type this package does not recognise, so it is read as a bare int.

data: bytes

Message body, as captured.

class pcapkit.protocols.internet.icmpv6.data.DestinationUnreachable(type, code, checksum, length, unused, data)[source]

Bases: ICMPv6

Data 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: ICMPv6

Data model for ICMPv6 Packet Too Big message (type 2).

code is always 0 (RFC 4443 Section 3.2), so it is read as a bare int rather than typed against a registry of one member.

mtu: int

MTU of the link that could not forward the invoking packet.

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: ICMPv6

Data 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: ICMPv6

Data 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: ICMPv6

Data model for ICMPv6 Echo Request/Reply message (types 128 and 129).

code is always 0 for both types (RFC 4443 Section 4.1, RFC 4443 Section 4.2), so it is read as a bare int rather than typed against a registry of one member.

id: int

Identifier.

seq: int

Sequence number.

data: bytes

Data, echoed back verbatim by a reply to the same identifier and sequence number.

class pcapkit.protocols.internet.icmpv6.data.MLDv1(type, code, checksum, length, version, max_resp_delay, reserved, multicast_address, data)[source]

Bases: ICMPv6

Data 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). code is 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: ICMPv6

Data 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). code is 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; see MLDv1.version.

max_resp_code: int

Maximum Response Code, as on the wire.

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).

qqic: int

Querier’s Query Interval Code, as on the wire.

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 sources holds 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: ICMPv6

Data model for an MLDv2 Version 2 Multicast Listener Report (RFC 9777 Section 5.2).

A Report is type 143, and its code the Reserved octet (RFC 9777 Section 5.2.1).

Added in version 1.7.0.

version: Literal[2]

MLD version, always 2; see MLDv1.version.

flags: int

Flags (RFC 9777 Section 5.2.3), as captured.

num_records: int

Number of multicast address records, as on the wire.

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: Data

Data 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).

aux_data_len: int

Auxiliary data length, in 32-bit words.

num_sources: int

Number of source addresses, as on the wire.

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