Linux “Cooked” Capture Encapsulation¶
pcapkit.protocols.link.linux_sll1 contains
LinuxSLL1
only, which implements the extractor for the Linux “cooked” capture
encapsulation [*] of LINKTYPE_LINUX_SLL – the header every
tcpdump -i any capture on Linux uses – whose structure is described as
below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Packet Type |
2 |
16 |
|
ARP Hardware Type |
4 |
32 |
|
Link-Layer Address Length |
6 |
48 |
|
Link-Layer Address (padded) |
14 |
112 |
|
Protocol (Internet Layer) |
Next-layer dispatch is shared with
LinuxSLL2; see
linux_sll. Its
id() is
('LinuxSLL1',), and its
alias is 'LINUX_SLL1';
see Selecting a Version.
- class pcapkit.protocols.link.linux_sll1.LinuxSLL1(file=None, length=None, **kwargs)[source]¶
Bases:
LinuxSLL[LinuxSLL1,LinuxSLL1]Linux “cooked” capture encapsulation v1 (
LINUX_SLL).protocol_typeis dispatched as an EtherType, unlessarphrd_typeis a key ofLinuxSLL.__proto__, which dispatches it instead; with no dissector registered either way, the payload isRaw.- read(length=None, **kwargs)[source]¶
Read Linux “cooked” capture encapsulation.
Structure of the
LINUX_SLLheader: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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Packet Type | ARPHRD Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Link-Layer Addr Length | Link-Layer Address... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ...Link-Layer Address (padded) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Protocol Type | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(packet_type=0, arphrd_type=Hardware.Ethernet, link_addr=b'', link_addr_length=None, protocol_type=EtherType.Internet_Protocol_version_4, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
packet_type (
int) – Packet type (direction).arphrd_type (
Hardware|int) – ARP hardware type of the interface the packet was seen on.link_addr (
bytes|bytearray) – Link-layer address, at most 8 octets; padded withNULoctets to 8 if shorter.link_addr_length (
int|None) – Length of the address actually in use, by defaultlen(link_addr); may exceed 8, up to0xFFFF.protocol_type (
EtherType|int) – Protocol (internet layer); an EtherType unlessarphrd_typeis a key ofLinuxSLL.__proto__.payload (
bytes|ProtocolBase|Schema) – Payload data.**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If
link_addrdoes not fit in 8 octets, orlink_addr_lengthis given outside0to0xFFFF; or ifarphrd_typeorprotocol_typeis a name, abool, or a member or code its field cannot carry.
Header Schemas¶
- class pcapkit.protocols.schema.link.linux_sll1.LinuxSLL1(packet_type=NO_VALUE, arphrd_type=NO_VALUE, link_addr_length=NO_VALUE, link_addr=NO_VALUE, protocol_type=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for Linux “cooked” capture encapsulation (
LINUX_SLL, v1).protocol_typeis kept as its raw 2 octets here; whether it is anEtherTypedepends onarphrd_type, seeLinuxSLL1.- arphrd_type: Hardware = <EnumField arphrd_type>¶
ARP hardware type of the interface the packet was seen on.
- link_addr_length: int = <UInt16Field link_addr_length>¶
Link-layer address length actually in use; may exceed 8.
Data Models¶
- class pcapkit.protocols.data.link.linux_sll1.LinuxSLL1(packet_type, arphrd_type, link_addr_length, link_addr, protocol_type)[source]¶
Bases:
ProtocolData model for Linux “cooked” capture encapsulation (
LINUX_SLL, v1).protocol_typeis anEtherTypefor everyarphrd_typeexcept a few – seeLinuxSLL1; it is kept as its raw wire value here regardless.- packet_type: int¶
Packet type (direction), where
0is to us,1broadcast,2multicast,3sent to another host promiscuously and4sent by us.
- link_addr: bytes¶
Link-layer address, padded to 8 octets as captured; only the first
link_addr_lengthof them are meaningful.
Footnotes