PCAP_SET_PROTOCOL_LINUX(3PCAP)
π PCAP_SET_PROTOCOL_LINUX π
okay bestie, welcome to the 3PCAP section of the manual, this is pcap_set_protocol_linux and it's literally the most niche little Linux-only baddie you'll ever meet π§β¨
β¨ NAME β¨
pcap_set_protocol_linux β set the capture protocol for a capture handle that hasn't been activated yet π
πΈ SYNOPSIS πΈ
#include <pcap/pcap.h>
int pcap_set_protocol_linux(pcap_t *p, int protocol);
π¦ DESCRIPTION π¦
so here's the tea β On network interface devices on Linux, pcap_set_protocol_linux() sets the protocol that's gonna be used in the socket(2) call when your capture socket gets created at activation time. The argument is a link-layer protocol value β like the values chillin' in the <linux/if_ether.h> header file β and you gotta specify it in host byte order, no cap.
If protocol is non-zero, then packets of that protocol get captured when the handle is activated. Otherwise? all the packets get captured, every single one, she's not picky π
This function is only provided on Linux, and if you use it on any device that isn't a network interface, it's just gonna have no effect β it'll sit there looking pretty for nothing π
β οΈ It should not be used in portable code. Like, at all. Instead, specify a filter with pcap_setfilter(3PCAP). That's the move, bestie.
okay now here's the deep lore, pay attention π If a given network interface provides a standard link-layer header, with a standard packet type, but provides some packet types with a different socket-layer protocol type from the one in the link-layer header, then that packet type cannot be filtered with a filter specified with pcap_setfilter(). BUT β¨ it can be filtered by specifying the socket-layer protocol type using pcap_set_protocol_linux(). iconic behaviour honestly.
π« RETURN VALUE π«
pcap_set_protocol_linux()returns0on success π- or
PCAP_ERROR_ACTIVATEDif you called it on a capture handle that's already been activated π like girl she's awake, too late
π BACKWARD COMPATIBILITY π
This function became available in libpcap release 1.9.0 β so if you're on something older, she simply does not exist, sorry babe π
π SEE ALSO π
pcap(3PCAP)pcap_create(3PCAP)pcap_activate(3PCAP)
mwah π that's the whole page, written back on 22 August 2018 and filed under PCAP_SET_PROTOCOL_LINUX in the 3PCAP manual, from the libpcap girlies π«Ά go forth and capture responsibly, ily β¨
π¦ where this page comes from
- alpine 3.22: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.23: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- alpine 3.24: libpcap-doc 1.10.7-r0 Β· BSD-3-Clause
- arch rolling: libpcap 1.11.0-1 Β· BSD-3-Clause
- centos-stream 10: libpcap-devel 14:1.10.4-8.el10 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- centos-stream 9: libpcap-devel 14:1.10.0-5.el9 Β· BSD with advertising
- centos-stream 9: libpcap-devel 14:1.10.0-5.el9 Β· BSD with advertising
- debian bookworm: libpcap0.8-dev 1.10.3-1
- debian trixie: libpcap0.8-dev 1.10.5-2
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.5-3.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 43: libpcap-devel 14:1.10.7-1.fc43 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.6-2.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- fedora 44: libpcap-devel 14:1.10.7-1.fc44 Β· ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC
- nixos 26.05: libpcap 1.10.7
- nixpkgs unstable: libpcap 146
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libpcap-devel 1.10.5-160000.5.1 Β· BSD-3-Clause
- ubuntu jammy: libpcap0.8-dev 1.10.1-4build1
- ubuntu jammy: libpcap0.8-dev 1.10.1-4ubuntu1.22.04.2
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3
- ubuntu noble: libpcap0.8-dev 1.10.4-4.1ubuntu3.1
- ubuntu questing: libpcap0.8-dev 1.10.5-2ubuntu2
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1 Β· BSD-3-clause-var3
- ubuntu resolute: libpcap0.8-dev 1.10.6-1ubuntu1.1 Β· BSD-3-clause-var3
- ubuntu stonking: libpcap0.8-dev 1.10.7-1ubuntu1 Β· BSD-3-clause-var3
- Copyright (c) 1994, 1996, 1997 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms