OSPF - Open Shortest Path First¶
pcapkit.protocols.application.ospf contains
OSPF only,
which implements extractor for Open Shortest Path
First (OSPF) [*], whose structure is described
as below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Version Number |
1 |
8 |
|
Type |
2 |
16 |
|
Packet Length (header included) |
4 |
32 |
|
Router ID |
8 |
64 |
|
Area ID |
12 |
96 |
|
Checksum |
14 |
112 |
|
Authentication Type |
16 |
128 |
|
Authentication |
- class pcapkit.protocols.application.ospf.OSPF(file=None, length=None, **kwargs)[source]¶
Bases:
Application[OSPF,OSPF]This class implements Open Shortest Path First.
A routing protocol computes the forwarding table rather than forwarding packets, so it is a user of the stack rather than part of its forwarding path. RFC 1812 Section 7 places it accordingly, titling that chapter “APPLICATION LAYER - ROUTING PROTOCOLS” with OSPF at §7.2.2, while RFC 1812 Section 4.1 confines the internet layer to IP, ICMP and IGMP. Hence
Applicationas the base, andlayer == 'Application'. See Protocol Layer Placement.Note
The subpackage does not track the dispatch tier. OSPF is dispatched from
Internet.__proto__atOSPFIGP(IANA protocol number 89), since IP is what carries it.- read(length=None, **kwargs)[source]¶
Read Open Shortest Path First.
Structure of OSPF header [RFC 2328]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version # | Type | Packet length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Router ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Area ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | AuType | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Authentication | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Authentication | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(version=2, type=<Packet.Hello: 1>, type_default=None, type_namespace=None, type_reversed=False, router_id='0.0.0.0', area_id='0.0.0.0', checksum=b'\\x00\\x00', auth_type=<Authentication.No_Authentication: 0>, auth_type_default=None, auth_type_namespace=None, auth_type_reversed=False, auth_data=b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00', payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
version (
int) – OSPF version number.type (
Packet|IntEnum|IntEnum|str|int) – OSPF packet type.type_default (
int|None) – Default value fortypeif not specified.type_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – Namespace fortype.type_reversed (
bool) – Reverse namespace fortype.router_id (
IPv4Address|str|bytes|bytearray) – Router ID.area_id (
IPv4Address|str|bytes|bytearray) – Area ID.checksum (
bytes) – Checksum.auth_type (
Authentication|IntEnum|IntEnum|str|int) – Authentication type.auth_type_default (
int|None) – Default value forauth_typeif not specified.auth_type_namespace (
dict[str,int] |dict[int,str] |Type[IntEnum] |Type[IntEnum] |None) – Namespace forauth_type.auth_type_reversed (
bool) – Reverse namespace forauth_type.auth_data (
bytes|CrytographicAuthentication|CrytographicAuthentication) – Authentication data.payload (
bytes|ProtocolBase|Schema) – Payload data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- _read_encrypt_auth(schema)[source]¶
Read Authentication field when Cryptographic Authentication is employed, i.e.
autypeis2.Structure of Cryptographic Authentication [RFC 2328]:
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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 0 | Key ID | Auth Data Len | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Cryptographic sequence number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Parameters:
schema (
CrytographicAuthentication) – parsed authentication data- Return type:
- Returns:
Parsed packet data.
- _make_encrypt_auth(auth_data)[source]¶
Make Authentication field when Cryptographic Authentication is employed.
- Parameters:
auth_data (
bytes|CrytographicAuthentication|CrytographicAuthentication) – Authentication data.- Return type:
- Returns:
Authentication bytes.
Header Schemas¶
- class pcapkit.protocols.schema.application.ospf.OSPF(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SchemaHeader schema for OSPF packet.
- router_id: IPv4Address = <IPv4AddressField router_id>¶
Router ID.
- area_id: IPv4Address = <IPv4AddressField area_id>¶
Area ID.
- auth_type: Authentication = <EnumField auth_type>¶
Authentication type.
- auth_data: bytes | CrytographicAuthentication = <SwitchField auth_data>¶
Authentication data.
- class pcapkit.protocols.schema.application.ospf.CrytographicAuthentication(*args: _VT, **kwargs: _VT)[source]¶
Bases:
SchemaHeader schema for OSPF cryptographic authentication.
Auxiliary Functions¶
- pcapkit.protocols.schema.application.ospf.ospf_auth_data_selector(pkt)[source]¶
Selector function for
OSPF.auth_datafield.- Parameters:
- Return type:
- Returns:
If
OSPF.auth_typeis 2, aSchemaFieldwrappedCrytographicAuthenticationinstance.Otherwise, a
BytesFieldinstance.
Data Models¶
- class pcapkit.protocols.data.application.ospf.OSPF(*args: VT, **kwargs: VT)[source]¶
Bases:
ProtocolData model for OSPF packet.
- router_id: IPv4Address¶
Router ID.
- area_id: IPv4Address¶
Area ID.
- autype: Authentication¶
Authentication type.
- auth: bytes | CrytographicAuthentication¶
Authentication.
- class pcapkit.protocols.data.application.ospf.CrytographicAuthentication(*args: VT, **kwargs: VT)[source]¶
Bases:
DataData model for OSPF crytographic authentication.
Footnotes