IPv6-Route - Routing Header for IPv6

pcapkit.protocols.internet.ipv6_route contains IPv6_Route only, which implements extractor for Routing Header for IPv6 (IPv6-Route) [*], whose structure is described as below:

Octets

Bits

Name

Description

0

0

route.next

Next Header

1

8

route.length

Header Extensive Length

2

16

route.type

Routing Type

3

24

route.seg_left

Segments Left

4

32

route.data

Type-Specific Data

class pcapkit.protocols.internet.ipv6_route.IPv6_Route(file=None, length=None, **kwargs)[source]

Bases: Internet[IPv6_Route, IPv6_Route]

This class implements Routing Header for IPv6.

This class currently supports parsing of the following Routing Header for IPv6 routing data types, which are registered in the self.__routing__ attribute:

property name: Literal['Routing Header for IPv6']

Name of current protocol.

property alias: Literal['IPv6-Route']

Acronym of corresponding protocol.

property length: int

Header length of current protocol.

property payload: Protocol | NoReturn

Payload of current instance.

Raises:

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type:

pcapkit.protocols.protocol.Protocol

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

classmethod register_routing(code, meth)[source]

Register an routing data parser.

Parameters:
Return type:

None

read(length=None, *, extension=False, **kwargs)[source]

Read Routing Header for IPv6.

Structure of IPv6-Route header [RFC 8200][RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  Routing Type | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                       type-specific data                      .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

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

Return type:

IPv6_Route

Returns:

Parsed packet data.

make(dst=None, next=<TransType.UDP: 17>, next_default=None, next_namespace=None, next_reversed=False, type=<Routing.Source_Route: 0>, type_default=None, type_namespace=None, type_reversed=False, seg_left=0, data=b'\\x00\\x00\\x00\\x00', payload=b'', **kwargs)[source]

Make (construct) packet data.

Parameters:
  • dst (Optional[IPv6Address | str | int| bytes]) – Destination address.

  • next (Enum_TransType | StdlibEnum | AenumEnum | str | int) – Next header type.

  • next_default (Optional[int]) – Default value of next header type.

  • next_namespace (Optional[dict[str, int] | dict[int, str] | Type[StdlibEnum] | Type[AenumEnum]]) – Namespace of next header type.

  • next_reversed (bool) – If the namespace of next header type is reversed.

  • type (Enum_Routing | StdlibEnum | AenumEnum | str | int) – Routing type.

  • type_default (Optional[int]) – Default value of routing type.

  • type_namespace (Optional[dict[str, int] | dict[int, str] | Type[StdlibEnum] | Type[AenumEnum]]) – Namespace of routing type.

  • type_reversed (bool) – If the namespace of routing type is reversed.

  • seg_left (int) – Segments left.

  • data (bytes | Data_IPv6_Route | Schema_RoutingType | dict[str, Any]) – Routing data.

  • payload (Protocol | Schema | bytes) – Payload of current instance.

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

Return type:

Schema_IPv6_Route

Returns:

Constructed packet data.

classmethod _make_data(data)[source]

Create key-value pairs from data for protocol construction.

Parameters:

data (IPv6_Route) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

_read_data_type_none(schema, *, header)[source]

Read IPv6-Route unknown type data.

Structure of IPv6-Route unknown type data [RFC 8200][RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  Routing Type | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                       type-specific data                      .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (UnknownType) – parsed routing data schema

  • header (IPv6_Route) – parsed IPv6-Route header schema

Return type:

UnknownType

Returns:

Parsed route data.

_read_data_type_src(schema, *, header)[source]

Read IPv6-Route Source Route data.

Structure of IPv6-Route Source Route data [RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  | Routing Type=0| Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[1]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[2]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                               .                               .
.                               .                               .
.                               .                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[n]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (SourceRoute) – parsed routing data schema

  • header (IPv6_Route) – parsed IPv6-Route header schema

Return type:

SourceRoute

Returns:

Parsed route data.

_read_data_type_2(schema, *, header)[source]

Read IPv6-Route Type 2 data.

Structure of IPv6-Route Type 2 data [RFC 6275]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  | Hdr Ext Len=2 | Routing Type=2|Segments Left=1|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Home Address                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • schema (Type2) – parsed routing data schema

  • header (IPv6_Route) – parsed IPv6-Route header schema

Return type:

Type2

Returns:

Parsed route data.

Raises:

ProtocolError – If length is NOT 24.

_read_data_type_rpl(schema, *, header)[source]

Read IPv6-Route RPL Source data.

Structure of IPv6-Route RPL Source data [RFC 6554]:

 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  | Routing Type  | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| CmprI | CmprE |  Pad  |               Reserved                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        Addresses[1..n]                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:

length – route data length

Return type:

RPL

Returns:

Parsed route data.

_make_data_type_none(type, route=None, *, dst=None, data=b'\\x00\\x00\\x00\\x00', **kwargs)[source]

Make IPv6-Route unknown type data.

Parameters:
Return type:

UnknownType

Returns:

Constructed route data schema.

_make_data_type_src(type, route=None, *, dst=None, ip=None, **kwargs)[source]

Make IPv6-Route Source Route data.

Parameters:
Return type:

SourceRoute

Returns:

Constructed route data schema.

_make_data_type_2(type, route=None, *, dst=None, ip='::', **kwargs)[source]

Make IPv6-Route Type 2 data.

Parameters:
Return type:

Type2

Returns:

Constructed route data schema.

_make_data_type_rpl(type, route=None, *, dst=None, ip=None, **kwargs)[source]

Make IPv6-Route RPL Source data.

Parameters:
Return type:

RPL

Returns:

Constructed route data schema.

__routing__: DefaultDict[Enum_Routing | int, str | tuple[TypeParser, TypeConstructor]]

Type code to method mapping. Method names are expected to be referred to the class by _read_data_type_${name} and/or _make_data_type_${name}, and if such name not found, the value should then be a method that can parse the routing type by itself.

Type:

DefaultDict[Enum_Routing, str | tuple[TypeParser, TypeConstructor]]

__post_init__(file=None, length=None, *, extension=False, **kwargs)[source]

Post initialisation hook.

Parameters:
  • file (Union[IO[bytes], bytes, None]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • src_ip – source IP address

  • dst_ip – destination IP address

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

Return type:

None

See also

For construction argument, please refer to self.make.

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type:

TransType

Returns:

Numeral registry index of the protocol in IANA.

Header Schemas

class pcapkit.protocols.schema.internet.ipv6_route.IPv6_Route(dict_=None, **kwargs)[source]

Bases: Schema

Header schema for IPv6-Route packet.

next: Enum_TransType = <EnumField next>

Next header.

length: int = <UInt8Field length>

Header extension length.

type: Enum_Routing = <EnumField type>

Routing type.

seg_left: int = <UInt8Field seg_left>

Segments left.

data: RoutingType = <SwitchField data>

Routing data.

payload: bytes = <PayloadField payload>

Payload.

class pcapkit.protocols.schema.internet.ipv6_route.RoutingType(dict_=None, **kwargs)[source]

Bases: EnumSchema[Routing]

Header schema for IPv6-Route type-specific routing data.

class pcapkit.protocols.schema.internet.ipv6_route.UnknownType(dict_=None, **kwargs)[source]

Bases: RoutingType

Header schema for IPv6-Route unknown type routing data.

data: bytes = <BytesField data>

Type-specific data.

class pcapkit.protocols.schema.internet.ipv6_route.SourceRoute(dict_=None, **kwargs)[source]

Bases: RoutingType

Header schema for IPv6-Route source route routing data.

reserved: bytes = <PaddingField reserved>

Reserved.

ip: list[IPv6Address] = <ListField ip>

Addresses.

class pcapkit.protocols.schema.internet.ipv6_route.Type2(dict_=None, **kwargs)[source]

Bases: RoutingType

Header schema for IPv6-Route type 2 routing data.

reserved: bytes = <PaddingField reserved>

Reserved.

ip: IPv6Address = <IPv6AddressField ip>

Addresses.

class pcapkit.protocols.schema.internet.ipv6_route.RPL(dict_=None, **kwargs)[source]

Bases: RoutingType

Header schema for IPv6-Route RPL routing data.

cmpr_i: int = <UInt8Field cmpr_i>

CmprI.

cmpr_e: int = <UInt8Field cmpr_e>

CmprE.

pad: PadInfo = <BitField pad>

Padding length and reserved.

addresses: bytes = <ListField addresses>

Addresses.

padding: bytes = <PaddingField padding>

Padding.

post_process(packet)[source]

Revise schema data after unpacking process.

Parameters:

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

Return type:

Schema

Returns:

Revised schema.

ip: list[IPv6Address | bytes]

Addresses (SRH prefix compression decoded).

Type Stubs

class pcapkit.protocols.schema.internet.ipv6_route.PadInfo[source]

Bases: TypedDict

Padding length and reserved.

Auxiliary Functions

pcapkit.protocols.schema.internet.ipv6_route.ipv6_route_data_selector(pkt)[source]

Selector function for IPv6_Route.data field.

Parameters:

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

Return type:

FieldBase

Returns:

A SchemaField wrapped RoutingType instance based on IPv6_Route.type.

Data Models

class pcapkit.protocols.data.internet.ipv6_route.IPv6_Route(dict_=None, **kwargs)[source]

Bases: Protocol

Data model for IPv6-Route protocol.

next: TransType

Next header.

length: int

Header extension length.

type: Routing

Routing type.

seg_left: int

Segments left.

class pcapkit.protocols.data.internet.ipv6_route.UnknownType(*args: VT, **kwargs: VT)[source]

Bases: IPv6_Route

Data model for IPv6-Route unknown type.

data: bytes

Data.

class pcapkit.protocols.data.internet.ipv6_route.SourceRoute(*args: VT, **kwargs: VT)[source]

Bases: IPv6_Route

Data model for IPv6-Route Source Route data type.

ip: tuple[IPv6Address, ...]

Source addresses.

class pcapkit.protocols.data.internet.ipv6_route.Type2(*args: VT, **kwargs: VT)[source]

Bases: IPv6_Route

Data model for IPv6-Route Type 2 data type.

ip: IPv6Address

Address.

class pcapkit.protocols.data.internet.ipv6_route.RPL(*args: VT, **kwargs: VT)[source]

Bases: IPv6_Route

Data model for RPL Source data type.

cmpr_i: int

CmprI.

cmpr_e: int

CmprE.

pad: int

Pad.

ip: tuple[IPv6Address | bytes, ...]

Addresses.

Footnotes