Format:Linux cooked capture (SLL and SLL2)
| On this wiki | Facts · Code · Notes · Topics |
|---|
The pseudo link-layer headers libpcap puts in front of packets captured on the Linux 'any' device: LINKTYPE_LINUX_SLL (113, 16-byte header) and LINKTYPE_LINUX_SLL2 (276, 20-byte header with an interface index).
Overview
When libpcap captures on the Linux any device (or on interfaces without a usable link-layer header) it cannot give real Ethernet headers, so it synthesises a cooked header. Two versions exist: SLL (LINKTYPE 113) and SLL2 (LINKTYPE 276). In libpcap's pcap-linux.c (commit ba925f7be2, read) the any device sets handle->linktype = DLT_LINUX_SLL as the default and offers a dlt_list of {DLT_LINUX_SLL, DLT_LINUX_SLL2}: SLL is the default and SLL2 must be selected by the capturing program. tcpdump selects the type with -y datalinktype (long form --linktype=; -L lists the choices) and libpcap names the SLL2 choice LINUX_SLL2 ("Linux cooked v2" in the DLT_CHOICE table of pcap.c), so tcpdump -i any -y LINUX_SLL2 captures SLL2 (tcpdump.1.in, -y; libpcap pcap.c line 3384, both read). See also Format:Pcap (libpcap savefile)#Link types.
SLL header (16 bytes)
From libpcap pcap/sll.h (read): u16 pkttype; u16 hatype; u16 halen; u8 addr[8]; u16 protocol. The comment in sll.h states: "All fields except for the link-layer address are in network byte order", so the u16 fields are big-endian.
SLL2 header (20 bytes)
u16 protocol; u16 reserved_mbz (must be zero); u32 if_index (1-based interface index); u16 hatype; u8 pkttype; u8 halen; u8 addr[8]. The protocol field comes first; the interface index tells which interface a packet crossed, which SLL cannot.
Values
pkttype (LINUX_SLL_*): 0 host, 1 broadcast, 2 multicast, 3 other host, 4 outgoing. hatype is the ARPHRD_ value (1 = ARPHRD_ETHER, include/uapi/linux/if_arp.h line 31 of torvalds/linux c03c1a1). protocol is an Ethernet type (ETH_P_IP 0x0800 and ETH_P_IPV6 0x86DD, include/uapi/linux/if_ether.h lines 52 and 74) except these special values from sll.h: 0x0001 Novell 802.3 without LLC, 0x0004 802.2 frames, 0x000C CAN, 0x000D CAN FD, 0x000E CAN XL.
Pitfalls
- No MAC header: the payload parser must start 16 or 20 bytes in.
- Unverified: captures from
anycan show a packet once per interface it crosses.
Code & repositories
- https://github.com/the-tcpdump-group/libpcap @
ba925f7be2ad4cc90ff00ea249310679094221a5· license: BSD-3-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from LICENSE; GitHub's detector did not classify it) for the repository)
libpcap: pcap/sll.h SLL and SLL2 header structs, pcap-linux.c 'any' device link types.
Tested on: source read, not run: source read, not run: read sll.h and pcap-linux.c · checked 2026-10-18; last activity 2026-10-17