Base Protocol¶

pcapkit.protocols.link.link contains Link, which is a base class for link layer protocols, e.g. ARP/InARP, Ethernet, L2TP, OSPF, RARP/DRARP and etc.

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

Bases: Protocol[PT], Generic[PT]

Abstract base class for link layer protocol family.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

Index

Protocol

Address_Resolution_Protocol

pcapkit.protocols.link.arp.ARP

Reverse_Address_Resolution_Protocol

pcapkit.protocols.link.rarp.RARP

Customer_VLAN_Tag_Type

pcapkit.protocols.link.vlan.VLAN

Internet_Protocol_version_4

pcapkit.protocols.internet.ipv4.IPv4

Internet_Protocol_version_6

pcapkit.protocols.internet.ipv6.IPv6

0x8137

pcapkit.protocols.internet.ipx.IPX

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

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

Return type

Protocol[PT]

property layer: Literal['Link']¶

Protocol layer.

Return type

Literal[‘Link’]

classmethod register(code, module, class_)[source]¶

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

Parameters
  • code (EtherType) – protocol code as in EtherType

  • module (str) – module name

  • class_ (str) – class name

Return type

None

_read_protos(size)[source]¶

Read next layer protocol type.

Parameters

size (int) – buffer size

Return type

EtherType

Returns

Internet layer protocol enumeration.

__layer__: Optional[Literal['Link', 'Internet', 'Transport', 'Application']] = 'Link'¶

Layer of protocol.

__proto__: DefaultDict[int, tuple[str, str]]¶

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type

DefaultDict[int, tuple[str, str]]

PyPCAPKit

Navigation

  • Module Documentation
    • User Interface
    • Library Foundation
    • Protocol Family
    • Core Utilities
    • Compatibility Tools
    • Dump Utilities
    • Utility Functions & Classes
    • Constant Enumerations
    • Vendor Crawlers
    • Command Line Tool
    • Library Index
  • How to …
  • Help Wanted

Related Topics

  • Documentation overview
    • Module Documentation
      • Protocol Family
        • Link Layer Protocols
          • Previous: Link Layer Protocols
          • Next: Ethernet Protocol

Quick search

©2017-2023, Jarry Shaw. | Page source
Fork me on GitHub