OSPF - Open Shortest Path First

pcapkit.protocols.link.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

ospf.version

Version Number

0

0

ospf.type

Type

0

1

ospf.len

Packet Length (header included)

0

2

ospf.router_id

Router ID

0

4

ospf.area_id

Area ID

0

6

ospf.chksum

Checksum

0

7

ospf.autype

Authentication Type

1

8

ospf.auth

Authentication


class pcapkit.protocols.link.ospf.OSPF(file=None, length=None, **kwargs)[source]

Bases: pcapkit.protocols.link.link.Link

This class implements Open Shortest Path First.

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

__length_hint__()[source]

Return an estimated length for the object.

Return type

Literal[24]

_read_encrypt_auth()[source]

Read Authentication field when Cryptographic Authentication is employed, i.e. autype is 2.

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

length (int) – packet length

Returns

Parsed packet data.

class Auth(TypedDict):

”””Cryptographic authentication.”””

#: key ID key_id: int #: authentication data length len: int #: cryptographic sequence number seq: int

Return type

DataType_Auth

_read_id_numbers()[source]

Read router and area IDs.

Returns

Parsed IDs as an IPv4 address.

Return type

IPv4Address

make(**kwargs)[source]

Make (construct) packet data.

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

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                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

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

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_OSPF

property alias

Acronym of current protocol.

Return type

str

property length

Header length of current protocol.

Return type

Literal[24]

property name

Name of current protocol.

Return type

str

property type

OSPF packet type.

Return type

pcapkit.const.ospf.packet.Packet

Data Structure

Important

Following classes are only for documentation purpose. They do NOT exist in the pcapkit module.

class pcapkit.protocols.link.ospf.DataType_OSPF
Bases

TypedDict

OSPF header.

version: int

version number

type: pcapkit.const.ospf.packet.Packet

type

len: int

packet length (header included)

router_id: ipaddress.IPv4Address

router ID

area_id: ipaddress.IPv4Address

area ID

chksum: bytes

checksum

autype: pcapkit.const.ospf.authentication.Authentication

authentication type

auth: Union[bytes, DataType_Auth]

authentication

Cryptographic Authentication Information

For cryptographic authentication information as described in RFC 2328, its structure is described as below:

Octets

Bits

Name

Description

0

0

Reserved (must be zero \x00)

0

0

ospf.auth.key_id

Key ID

0

1

ospf.auth.len

Authentication Data Length

0

2

ospf.auth.seq

Cryptographic Sequence Number


class pcapkit.protocols.link.ospf.DataType_Auth
Bases

TypedDict

Cryptographic authentication.

key_id: int

key ID

len: int

authentication data length

seq: int

cryptographic sequence number


*

https://en.wikipedia.org/wiki/Open_Shortest_Path_First