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: Link[OSPF]

This class implements Open Shortest Path First.

Parameters
  • *args (Any) – Arbitrary positional arguments.

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

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

Return type

NoReturn

property name: str

Name of current protocol.

Return type

str

property alias: str

Acronym of current protocol.

Return type

str

property length: Literal[24]

Header length of current protocol.

Return type

Literal[24]

property type: Packet

OSPF packet type.

Return type

Packet

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.

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

Return type

OSPF

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

_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 – packet length

Return type

CrytographicAuthentication

Returns

Parsed packet data.

Data Structures

class pcapkit.protocols.data.link.ospf.OSPF(version, type, length, router_id, area_id, chksum, autype)[source]

Bases: Info

Data model for OSPF packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

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

Return type

Info

version: int

Version number.

type: Packet

Type.

len: int

Packet length (header included).

router_id: IPv4Address

Router ID.

area_id: IPv4Address

Area ID.

chksum: bytes

Checksum.

autype: Authentication

Authentication type.

auth: bytes | CrytographicAuthentication

Authentication.

class pcapkit.protocols.data.link.ospf.CrytographicAuthentication(key_id, len, seq)[source]

Bases: Info

Data model for OSPF crytographic authentication.

Parameters
  • *args (VT) – Arbitrary positional arguments.

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

Return type

Info

key_id: int

Key ID.

len: int

Authentication data length.

seq: int

Cryptographic sequence number.


*

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