Skip to content

protocols: add DLT_NULL and DLT_RAW link-layer handlers #839

Description

@JarryShaw

Split out of #838 on the maintainer's instruction: "let's add the handlers (protocols) for DLT_NULL and DLT_RAW as part of wave 2/3 work in the work tracker then."

pcapkit/protocols/misc/pcap/frame.py:93-95 registers exactly three link types:

Enum_LinkType.ETHERNET: ModuleDescriptor('pcapkit.protocols.link', 'Ethernet'),
Enum_LinkType.IPV4:     ModuleDescriptor('pcapkit.protocols.internet', 'IPv4'),
Enum_LinkType.IPV6:     ModuleDescriptor('pcapkit.protocols.internet', 'IPv6'),

LinkType.NULL (0, DLT_NULL, BSD loopback — a 4-byte host-order AF_ family field ahead of the IP header) and LinkType.RAW (101, DLT_RAW — a bare IP packet, no link header at all) are genuine DLTs with no handler. That is what makes them unusable as a fallback for an unknown link-layer name, which is the ruling recorded on #838.

Scope: a handler per DLT, registered into Frame.__proto__, plus tests. DLT_NULL's family field decides IPv4 vs IPv6 and is written in the capturing host's byte order, so it cannot be read as fixed-endian. DLT_RAW needs the IP version nibble to pick IPv4 vs IPv6.

Not blocking #838 — that PR raises rather than guessing, which is correct with or without these handlers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssues requesting a new capability (set by the feature request template)featPull requests that add a new capability (feat: subject prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions