Linux “Cooked” Capture Encapsulation v2¶
pcapkit.protocols.link.linux_sll2 contains
LinuxSLL2
only, which implements the extractor for the Linux “cooked” capture
encapsulation v2 [*] of LINKTYPE_LINUX_SLL2, whose structure is described
as below:
Octets |
Bits |
Name |
Description |
|---|---|---|---|
0 |
0 |
|
Protocol (Internet Layer) |
2 |
16 |
|
Reserved |
4 |
32 |
|
Interface Index |
8 |
64 |
|
ARP Hardware Type |
10 |
80 |
|
Packet Type |
11 |
88 |
|
Link-Layer Address Length |
12 |
96 |
|
Link-Layer Address (padded) |
Unlike v1, protocol_type comes first, interface_index is new, and
packet_type and link_addr_length are 1 octet rather than 2. See
LinuxSLL1 for v1; next-layer
dispatch is shared, see linux_sll. Its
id() is
('LinuxSLL2',), and its
alias is 'LINUX_SLL2';
see Selecting a Version.
- class pcapkit.protocols.link.linux_sll2.LinuxSLL2(file=None, length=None, **kwargs)[source]¶
Bases:
LinuxSLL[LinuxSLL2,LinuxSLL2]Linux “cooked” capture encapsulation v2 (
LINUX_SLL2).Next-layer dispatch is that of
LinuxSLL1.- read(length=None, **kwargs)[source]¶
Read Linux “cooked” capture encapsulation v2.
Structure of the
LINUX_SLL2header: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 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Protocol Type | Reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Interface Index | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ARPHRD Type |Packet Type|Link-Addr Length| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Link-Layer Address (padded) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- make(protocol_type=EtherType.Internet_Protocol_version_4, reserved=0, interface_index=0, arphrd_type=Hardware.Ethernet, packet_type=0, link_addr=b'', link_addr_length=None, payload=b'', **kwargs)[source]¶
Make (construct) packet data.
- Parameters:
protocol_type (
EtherType|int) – Protocol (internet layer); an EtherType unlessarphrd_typeis a key ofLinuxSLL.__proto__.reserved (
int) – Reserved, must be zero.interface_index (
int) – Index, in the capturing host’s own numbering, of the interface the packet was seen on.arphrd_type (
Hardware|int) – ARP hardware type of the interface the packet was seen on.packet_type (
int) – Packet type (direction).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 to0xFF.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 outside0to0xFF; or ifprotocol_typeorarphrd_typeis a name, abool, or a member or code its field cannot carry.
Header Schemas¶
- class pcapkit.protocols.schema.link.linux_sll2.LinuxSLL2(protocol_type=NO_VALUE, reserved=NO_VALUE, interface_index=NO_VALUE, arphrd_type=NO_VALUE, packet_type=NO_VALUE, link_addr_length=NO_VALUE, link_addr=NO_VALUE, payload=NO_VALUE, *, __packet__=None, **kwargs)[source]¶
Bases:
SchemaHeader schema for Linux “cooked” capture encapsulation v2 (
LINUX_SLL2).The field order and widths differ from v1 –
protocol_typemoves to the front,interface_indexis new, andpacket_type/link_addr_lengthshrink from 2 octets to 1 – seeLinuxSLL1for v1.- interface_index: int = <UInt32Field interface_index>¶
Index, in the capturing host’s own numbering, of the interface the packet was seen on.
- arphrd_type: Hardware = <EnumField arphrd_type>¶
ARP hardware type of the interface the packet was seen on.
- link_addr_length: int = <UInt8Field link_addr_length>¶
Link-layer address length actually in use; may exceed 8.
Data Models¶
- class pcapkit.protocols.data.link.linux_sll2.LinuxSLL2(protocol_type, reserved, interface_index, arphrd_type, packet_type, link_addr_length, link_addr)[source]¶
Bases:
ProtocolData model for Linux “cooked” capture encapsulation v2 (
LINUX_SLL2).protocol_typeis anEtherTypefor everyarphrd_typeexcept a few – seeLinuxSLL2; it is kept as its raw wire value here regardless.- interface_index: int¶
Index, in the capturing host’s own numbering, of the interface the packet was seen on.
- 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