PCAP_DATALINK(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

hiii bestie πŸ’– welcome to PCAP_DATALINK(3) from the Library Functions Manual β€” it’s here to spill the tea on link-layer header types, and honestly it’s kind of iconic.

✨ NAME ✨

pcap_datalink β€” get the link-layer header type πŸ‘‘

🌸 SYNOPSIS 🌸

#include <pcap/pcap.h>

int pcap_datalink(pcap_t *p);

πŸ’… DESCRIPTION πŸ’…

Okay so pcap_datalink() returns the link-layer header type for the live capture or β€œsavefile” specified by p. That’s the whole vibe. πŸ¦‹

Wait β€” important: it must not be called on a pcap descriptor created by pcap_create(3) that has not yet been activated by pcap_activate(3). Like, do not come for this function before activation, bestie. πŸ’€

The page https://www.tcpdump.org/linktypes.html lists the values pcap_datalink() can return and describes the packet formats that correspond to those values. Go look, it’s giving reference material. πŸ“šβœ¨

Do NOT assume that the packets for a given capture or β€œsavefile” will have any given link-layer header type, such as DLT_EN10MB for Ethernet. No cap. For example, the β€œany” device on Linux will have a link-layer header type of DLT_LINUX_SLL or DLT_LINUX_SLL2 even if all devices on the system at the time the β€œany” device is opened have some other data link type, such as DLT_EN10MB for Ethernet. The β€œany” device is lowkey doing its own thing. πŸ™ˆπŸ”₯

πŸ¦‹ RETURN VALUE πŸ¦‹

pcap_datalink() returns the link-layer header type on success, and PCAP_ERROR_NOT_ACTIVATED if called on a capture handle that has been created but not activated. Periodt. πŸ’…

πŸŽ€ SEE ALSO πŸŽ€


that’s the whole page, bestie 🫢 this cutie is dated 7 April 2014, and its footer tag is PCAP_DATALINK(3) πŸ’–βœ¨

πŸ“¦ where this page comes from