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 |
|
Next Header |
1 |
8 |
|
Header Extensive Length |
2 |
16 |
|
Routing Type |
3 |
24 |
|
Segments Left |
4 |
32 |
|
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:Routing Code
Data Parser
Data Constructor
- property name: Literal['Routing Header for IPv6']#
Name of current protocol.
- 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
- classmethod register_routing(code, meth)[source]#
Register an routing data parser.
- Parameters:
code (
Routing
) – IPv6-Route data type code.meth (
str
|tuple
[Callable
[[RoutingType
,IPv6_Route
],IPv6_Route
],Callable
[[Routing
,Optional
[IPv6_Route
],Optional
[IPv6Address
],Any
],RoutingType
]]) – Method name or callable to parse and/or construct the data.
- Return type:
- 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:
- Return type:
- Returns:
Parsed packet data.
- make(dst=None, next=TransType.UDP, next_default=None, next_namespace=None, next_reversed=False, type=Routing.Source_Route, 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 (
Union
[IPv6Address
,str
,int
,bytes
,None
]) – Destination address.next (
TransType
|IntEnum
|IntEnum
|str
|int
) – Next header type.next_default (
Optional
[int
]) – Default value of next header type.next_namespace (
Union
[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.type (
Routing
|IntEnum
|IntEnum
|str
|int
) – Routing type.type_default (
Optional
[int
]) – Default value of routing type.type_namespace (
Union
[dict
[str
,int
],dict
[int
,str
],Type
[IntEnum
],Type
[IntEnum
],None
]) – Namespace of routing type.type_reversed (
bool
) – If the namespace of routing type is reversed.seg_left (
int
) – Segments left.data (
bytes
|IPv6_Route
|RoutingType
|dict
[str
,Any
]) – Routing data.payload (
ProtocolBase
|Schema
|bytes
) – Payload of current instance.**kwargs (
Any
) – Arbitrary keyword arguments.
- Return type:
- 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:
- 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 schemaheader (
IPv6_Route
) – parsed IPv6-Route header schema
- Return type:
- 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 schemaheader (
IPv6_Route
) – parsed IPv6-Route header schema
- Return type:
- 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 schemaheader (
IPv6_Route
) – parsed IPv6-Route header schema
- Return type:
- Returns:
Parsed route data.
- Raises:
ProtocolError – If
length
is NOT24
.
- _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:
- 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:
type (
Routing
) – routing typeroute (
Optional
[UnknownType
]) – route datadst (
Optional
[IPv6Address
]) – destination IPv6 address**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- 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:
type (
Routing
) – routing typeroute (
Optional
[SourceRoute
]) – route datadst (
Optional
[IPv6Address
]) – destination IPv6 addressip (
Optional
[list
[IPv6Address
|str
|bytes
|int
]]) – list of IPv6 addresses**kwargs (
Any
) – arbitrary keyword arguments
- Return type:
- Returns:
Constructed route data schema.
- _make_data_type_2(type, route=None, *, dst=None, ip='::', **kwargs)[source]#
Make IPv6-Route Type 2 data.
- _make_data_type_rpl(type, route=None, *, dst=None, ip=None, **kwargs)[source]#
Make IPv6-Route RPL Source data.
- Parameters:
- Return type:
- 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.
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.
- ip: list[IPv6Address | bytes]#
Addresses (SRH prefix compression decoded).
Type Stubs#
Auxiliary Functions#
- pcapkit.protocols.schema.internet.ipv6_route.ipv6_route_data_selector(pkt)[source]#
Selector function for
IPv6_Route.data
field.- Parameters:
- Return type:
- Returns:
A
SchemaField
wrappedRoutingType
instance based onIPv6_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