PCAP(3PCAP)
π NAME π
okay so bestie, this is PCAP(3PCAP) β the Packet Capture library β and it is literally the moment. no cap.
β¨ SYNOPSIS β¨
#include <pcap/pcap.h>
π¦ DESCRIPTION π¦
The Packet Capture library gives you a high level interface to packet capture systems. Every single packet on the network β even the ones destined for other hosts β is accessible through this mechanism. Like, all of it. π
It also supports saving captured packets to a <pink>savefile</pink>, and reading packets from a <pink>savefile</pink>. Both directions, we contain multitudes.
πΈ Initializing πΈ
pcap_init() initializes the library. It takes an argument giving options, and currently the options are:
PCAP_CHAR_ENC_LOCALβ treat all strings supplied as arguments, and return all strings to the caller, as being in the local character encoding.PCAP_CHAR_ENC_UTF_8β treat all strings supplied as arguments, and return all strings to the caller, as being in UTF-8.
On UNIX-like systems, the local character encoding is assumed to be UTF-8, so no character encoding transformations are done. Slay, no work needed.
On Windows, the local character encoding is the local ANSI code page. π
If pcap_init() is called, the deprecated pcap_lookupdev() routine always fails, so it should not be used, and, on Windows, pcap_create() does not attempt to handle UTF-16LE strings.
If pcap_init() is not called, strings are treated as being in the local ANSI code page on Windows, pcap_lookupdev() will succeed if there is a device on which to capture, and pcap_create() makes an attempt to check whether the string passed as an argument is a UTF-16LE string β note that this attempt is unsafe, as it may run past the end of the string β to handle pcap_lookupdev() returning a UTF-16LE string. Programs that don't call pcap_init() should, on Windows, call pcap_wsockinit() to initialize Winsock; this is not necessary if pcap_init() is called, as pcap_init() will initialize Winsock itself on Windows.
β οΈ bestie that "unsafe, may run past the end of the string" bit is not a vibe, it's a real warning. treat it with respect fr fr.
π Routines π
pcap_init(3PCAP)β initialize the library
π Opening a capture handle for reading π
To open a handle for a live capture, given the name of the network or other interface on which the capture should be done, call pcap_create(), set the appropriate options on the handle, and then activate it with pcap_activate(). If pcap_activate() fails, the handle should be closed with pcap_close(). periodt.
To obtain a list of devices that can be opened for a live capture, call pcap_findalldevs(); to free the list returned by pcap_findalldevs(), call pcap_freealldevs(). pcap_lookupdev() will return the first device on that list that is not a <pink>loopback</pink> network interface.
To open a handle for a <pink>savefile</pink> from which to read packets, given the pathname of the <pink>savefile</pink>, call pcap_open_offline(); to set up a handle for a <pink>savefile</pink>, given a FILE * referring to a file already opened for reading, call pcap_fopen_offline().
In order to get a <pink>fake</pink> pcap_t for use in routines that require a pcap_t as an argument β such as routines to open a <pink>savefile</pink> for writing and to compile a filter expression β call pcap_open_dead().
pcap_create(), pcap_open_offline(), pcap_fopen_offline(), and pcap_open_dead() return a pointer to a pcap_t, which is the handle used for reading packets from the capture stream or the <pink>savefile</pink>, and for finding out information about the capture stream or <pink>savefile</pink>. To close a handle, use pcap_close().
The options that can be set on a capture handle include:
β snapshot length β
If, when capturing, you capture the entire contents of the packet, that requires more CPU time to copy the packet to your application, more disk and possibly network bandwidth to write the packet data to a file, and more disk space to save the packet. If you don't need the entire contents of the packet β for example, if you are only interested in the TCP headers of packets β you can set the "snapshot length" for the capture to an appropriate value. If the snapshot length is set to snaplen, and snaplen is less than the size of a packet that is captured, only the first snaplen bytes of that packet will be captured and provided as packet data.
A snapshot length of 65535 should be sufficient, on most if not all networks, to capture all the data available from the packet. π«Ά
The snapshot length is set with pcap_set_snaplen().
β promiscuous mode β
On broadcast LANs such as Ethernet, if the network isn't switched, or if the adapter is connected to a "mirror port" on a switch to which all packets passing through the switch are sent, a network adapter receives all packets on the LAN, including unicast or multicast packets not sent to a network address that the network adapter isn't configured to recognize.
Normally, the adapter will discard those packets; however, many network adapters support "promiscuous mode", which is a mode in which all packets β even if they are not sent to an address that the adapter recognizes β are provided to the host. This is useful for passively capturing traffic between two or more other hosts for analysis. π iconic behavior honestly.
Note that even if an application does not set promiscuous mode, the adapter could well be in promiscuous mode for some other reason.
For now, this doesn't work on the "any" device; if an argument of "any" or NULL is supplied, the setting of promiscuous mode is ignored.
Promiscuous mode is set with pcap_set_promisc().
β monitor mode β
On IEEE 802.11 wireless LANs, even if an adapter is in promiscuous mode, it will supply to the host only frames for the network with which it's associated. It might also supply only data frames, not management or control frames, and might not provide the 802.11 header or radio information pseudo-header for those frames.
In "monitor mode", sometimes also called "rfmon mode" (for "Radio Frequency MONitor"), the adapter will supply all frames that it receives, with 802.11 headers, and might supply a pseudo-header with radio information about the frame as well. π¦
π real talk: note that in monitor mode the adapter might disassociate from the network with which it's associated, so that you will not be able to use any wireless networks with that adapter. This could prevent accessing files on a network server, or resolving host names or network addresses, if you are capturing in monitor mode and are not connected to another network with another adapter. plan accordingly bestie.
Monitor mode is set with pcap_set_rfmon(), and pcap_can_set_rfmon() can be used to determine whether an adapter can be put into monitor mode.
β packet buffer timeout β
If, when capturing, packets are delivered as soon as they arrive, the application capturing the packets will be woken up for each packet as it arrives, and might have to make one or more calls to the operating system to fetch each packet.
If, instead, packets are not delivered as soon as they arrive, but are delivered after a short delay (called a "packet buffer timeout"), more than one packet can be accumulated before the packets are delivered, so that a single wakeup would be done for multiple packets, and each set of calls made to the operating system would supply multiple packets, rather than a single packet. This reduces the per-packet CPU overhead if packets are arriving at a high rate, increasing the number of packets per second that can be captured. highkey a glow-up for performance. π₯
The packet buffer timeout is required so that an application won't wait for the operating system's capture buffer to fill up before packets are delivered; if packets are arriving slowly, that wait could take an arbitrarily long period of time.
Not all platforms support a packet buffer timeout; on platforms that don't, the packet buffer timeout is ignored. A zero value for the timeout, on platforms that support a packet buffer timeout, will cause a read to wait forever to allow enough packets to arrive, with no timeout. A negative value is invalid; the result of setting the timeout to a negative value is unpredictable. π
β οΈ NOTE: the packet buffer timeout cannot be used to cause calls that read packets to return within a limited period of time, because, on some platforms, the packet buffer timeout isn't supported, and, on other platforms, the timer doesn't start until at least one packet arrives. This means that the packet buffer timeout should NOT be used, for example, in an interactive application to allow the packet capture loop to<pink>poll</pink>for user input periodically, as there's no guarantee that a call reading packets will return after the timeout expires even if no packets have arrived. like, don't do it. π ββοΈ
The packet buffer timeout is set with pcap_set_timeout().
β immediate mode β
In immediate mode, packets are always delivered as soon as they arrive, with no buffering. Immediate mode is set with pcap_set_immediate_mode().
β buffer size β
Packets that arrive for a capture are stored in a buffer, so that they do not have to be read by the application as soon as they arrive. On some platforms, the buffer's size can be set; a size that's too small could mean that, if too many packets are being captured and the snapshot length doesn't limit the amount of data that's buffered, packets could be dropped if the buffer fills up before the application can read packets from it, while a size that's too large could use more non-pageable operating system memory than is necessary to prevent packets from being dropped. it's giving β¨balanceβ¨.
The buffer size is set with pcap_set_buffer_size().
β timestamp type β
On some platforms, the time stamp given to packets on live captures can come from different sources that can have different resolutions or that can have different relationships to the time values for the current time supplied by routines on the native operating system. See pcap-tstamp(7) for a list of time stamp types.
The time stamp type is set with pcap_set_tstamp_type().
Reading packets from a network interface may require that you have special privileges:
- Under SunOS 3.x or 4.x with NIT or BPF: You must have read access to
/dev/nitor/dev/bpf*.
π iykyk β privileges are the whole game here, so check before you come crying that nothing's capturing. π
βοΈ Under Solaris with DLPI:
okay so bestie, you need read/write access to the network pseudo device, like /dev/le β wait, no, exactly /dev/le? Yes: /dev/le. On at least some versions of Solaris, thatβs lowkey not enough to let tcpdump capture in promiscuous mode π. On those versions, you must be root, or the app capturing packets must be installed setuid to root, to capture in promiscuous mode. And heads up: on many (maybe all) interfaces, if you donβt capture in promiscuous mode, you wonβt see any outgoing packets β so a capture not done in promiscuous mode may not be very useful. Not the vibe.
In newer Solaris versions, you must have been given the net_rawaccess privilege β itβs both necessary and sufficient to give you access to the network pseudo-device, and there is no need to change the privileges on that device. A user can get that privilege by, for example, adding it to the userβs defaultpriv key with the usermod(8) command. Slay.
π Under HP-UX with DLPI:
You must be root, or the application capturing packets must be installed setuid to root. Thatβs the whole tea. π
π¦ Under IRIX with snoop:
You must be root, or the application capturing packets must be installed setuid to root. Same energy, different OS. β¨
π§ Under Linux:
You must be root, or the application capturing packets must be installed setuid to root β unless your distribution has a kernel that supports capability bits such as CAP_NET_RAW and code to allow those capability bits to be given to particular accounts and to cause those bits to be set on a userβs initial processes when they log in. In that case, you must have CAP_NET_RAW in order to capture. iykyk π₯
π¦ Under ULTRIX and Digital UNIX/Tru64 UNIX:
Any user may capture network traffic. But β and this is a big but β no user (not even the super-user) can capture in promiscuous mode on an interface unless the super-user has enabled promiscuous-mode operation on that interface using pfconfig(8). And no user (not even the super-user) can capture unicast traffic received by or sent by the machine on an interface unless the super-user has enabled copy-all-mode operation on that interface using pfconfig. So useful packet capture on an interface <highkey>probably requires</highkey> that either promiscuous-mode or copy-all-mode operation, or both modes of operation, be enabled on that interface. πΈ
π Under BSD (this includes macOS):
You must have read access to /dev/bpf* on systems that donβt have a cloning BPF device, or to /dev/bpf on systems that do. On BSDs with a devfs (this includes macOS), this might involve more than just having somebody with super-user access setting the ownership or permissions on the BPF devices β it might involve configuring devfs to set the ownership or permissions every time the system is booted, if the system even supports that; if it doesnβt support that, you might have to find some other way to make that happen at boot time. Annoying? Yes. Iconic? Also yes. π
Reading a saved packet file doesnβt require special privileges. We love a low-effort moment. π«Ά
The packets read from the handle may include a pseudo-header containing various forms of packet meta-data, and probably includes a link-layer header whose contents can differ for different network interfaces. To determine the format of the packets supplied by the handle, call pcap_datalink(); https://www.tcpdump.org/linktypes.html lists the values it returns and describes the packet formats that correspond to those values. β¨
Do NOT assume that the packets for a given capture orsavefilewill have any given link-layer header type, such asDLT_EN10MBfor Ethernet. For example, the"any"device on Linux will have a link-layer header type ofDLT_LINUX_SLLorDLT_LINUX_SLL2even if all devices on the system at the time the"any"device is opened have some other data link type, such asDLT_EN10MBfor Ethernet. Periodt, donβt get caught lacking. π
To obtain the FILE * corresponding to a pcap_t opened for a savefile, call pcap_file(). Easy. π
π§° Routines
okay so hereβs the whole routine menu, no skips, no cap:
pcap_create(3PCAP)β get apcap_tfor live capturepcap_activate(3PCAP)β activate apcap_tfor live capturepcap_findalldevs(3PCAP)β get a list of devices that can be opened for a live capturepcap_freealldevs(3PCAP)β free list of devicespcap_lookupdev(3PCAP)β get first non-loopback device on that listpcap_open_offline(3PCAP)β open apcap_tfor asavefile, given a pathnamepcap_open_offline_with_tstamp_precision(3PCAP)β open apcap_tfor asavefile, given a pathname, and specify the precision to provide for packet time stampspcap_fopen_offline(3PCAP)β open apcap_tfor asavefile, given aFILE *pcap_fopen_offline_with_tstamp_precision(3PCAP)β open apcap_tfor asavefile, given aFILE *, and specify the precision to provide for packet time stampspcap_open_dead(3PCAP)β create afakepcap_tpcap_close(3PCAP)β close apcap_tpcap_set_snaplen(3PCAP)β set the snapshot length for a not-yet-activatedpcap_tfor live capturepcap_snapshot(3PCAP)β get the snapshot length for apcap_tpcap_set_promisc(3PCAP)β set promiscuous mode for a not-yet-activatedpcap_tfor live capturepcap_set_protocol_linux(3PCAP)β set capture protocol for a not-yet-activatedpcap_tfor live capture (Linux only)pcap_set_rfmon(3PCAP)β set monitor mode for a not-yet-activatedpcap_tfor live capturepcap_can_set_rfmon(3PCAP)β determine whether monitor mode can be set for apcap_tfor live capturepcap_set_timeout(3PCAP)β set packet buffer timeout for a not-yet-activatedpcap_tfor live capturepcap_set_immediate_mode(3PCAP)β set immediate mode for a not-yet-activatedpcap_tfor live capturepcap_set_buffer_size(3PCAP)β set buffer size for a not-yet-activatedpcap_tfor live capturepcap_set_tstamp_type(3PCAP)β set time stamp type for a not-yet-activatedpcap_tfor live capturepcap_list_tstamp_types(3PCAP)β get list of available time stamp types for a not-yet-activatedpcap_tfor live capturepcap_free_tstamp_types(3PCAP)β free list of available time stamp typespcap_tstamp_type_val_to_name(3PCAP)β get name for a time stamp typepcap_tstamp_type_val_to_description(3PCAP)β get description for a time stamp typepcap_tstamp_type_name_to_val(3PCAP)β get time stamp type corresponding to a namepcap_set_tstamp_precision(3PCAP)β set time stamp precision for a not-yet-activatedpcap_tfor live capturepcap_get_tstamp_precision(3PCAP)β get the time stamp precision of apcap_tfor live capturepcap_datalink(3PCAP)β get link-layer header type for apcap_tpcap_file(3PCAP)β get theFILE *for apcap_topened for asavefilepcap_is_swapped(3PCAP)β determine whether asavefilebeing read came from a machine with the opposite byte orderpcap_major_version(3PCAP)/pcap_minor_version(3PCAP)β get the major and minor version of the file format version for asavefile
π Selecting a link-layer header type for a live capture
Some devices may provide more than one link-layer header type. To obtain a list of all link-layer header types provided by a device, call pcap_list_datalinks() on an activated pcap_t for the device. To free a list of link-layer header types, call pcap_free_datalinks(). To set the link-layer header type for a device, call pcap_set_datalink(). This should be done after the device has been activated but before any packets are read and before any filters are compiled or installed. Order matters, bestie. π
π§° Routines
pcap_list_datalinks(3PCAP)β get a list of link-layer header types for a devicepcap_free_datalinks(3PCAP)β free list of link-layer header typespcap_set_datalink(3PCAP)β set link-layer header type for a devicepcap_datalink_val_to_name(3PCAP)β get name for a link-layer header typepcap_datalink_val_to_description(3PCAP)/pcap_datalink_val_to_description_or_dlt(3PCAP)β get description for a link-layer header typepcap_datalink_name_to_val(3PCAP)β get link-layer header type corresponding to a name
π Reading packets
Packets are read with pcap_dispatch() or pcap_loop(), which process one or more packets, calling a callback routine for each packet, or with pcap_next() or pcap_next_ex(), which return the next packet. The callback for pcap_dispatch() and pcap_loop() is supplied a pointer to a struct pcap_pkthdr, which includes the following members:
tsβ astruct timevalcontaining the time when the packet was capturedcaplenβ abpf_u_int32giving the number of bytes of the packet that are available from the capturelenβ abpf_u_int32giving the length of the packet, in bytes (which might be more than the number of bytes available from the capture, if the length of the packet is larger than the maximum number of bytes to capture).
The callback is also supplied a const u_char pointer to the first caplen (as given in the struct pcap_pkthdr mentioned above) bytes of data from the packet. This wonβt necessarily be the entire packet; to capture the entire packet, you will have to provide a value for snaplen in your call to pcap_set_snaplen() that is sufficiently large to get all of the packetβs data β a value of 65535 should be sufficient on most if not all networks). When reading from a savefile, the snapshot length specified when the capture was performed will limit the amount of packet data available. π¦
Okay so bestie, pcap_next() gets one argument: a pointer to a struct pcap_pkthdr structure. It fills that struct in with the time stamp and length values for the packet, and on success it returns a const u_char * to the first caplen bytes of the packet. On error? NULL. π
pcap_next_ex() gets two pointer arguments: one points to a struct pcap_pkthdr * and the other points to a const u_char *. It sets the first pointer to point to a struct pcap_pkthdr structure with the time stamp and length values for the packet, and sets the second pointer to point to the first caplen bytes of the packet. β¨
To force the loop in pcap_dispatch() or pcap_loop() to terminate, call pcap_breakloop(). π
By default, when reading packets from an interface opened for a live capture, pcap_dispatch(), pcap_next(), and pcap_next_ex() will, if no packets are currently available to be read, block waiting for packets to become available. On some, but not all, platforms, if a packet buffer timeout was specified, the wait will terminate after the packet buffer timeout expires; applications should be prepared for this, as it happens on some platforms, but should not rely on it, as it does not happen on other platforms. Note that the wait might, or might not, terminate even if no packets are available; applications should be prepared for this to happen, but must not rely on it happening. π«
A handle can be put into non-blocking mode, so that those routines will, rather than blocking, return an indication that no packets are available to read. Call pcap_setnonblock() to put a handle into non-blocking mode or to take it out of non-blocking mode; call pcap_getnonblock() to determine whether a handle is in non-blocking mode.
π¨ Note that non-blocking mode does not work correctly in Mac OS X 10.6.
Non-blocking mode is often combined with routines such as select(2) or poll(2) or other routines a platform offers to wait for any of a set of descriptors to be ready to read. To obtain, for a handle, a descriptor that can be used in those routines, call pcap_get_selectable_fd(). If the routine indicates that data is available to read on the descriptor, an attempt should be made to read from the device. π
Not all handles have such a descriptor available; pcap_get_selectable_fd() will return -1 if no such descriptor is available. If no such descriptor is available, this may be because the device must be polled periodically for packets; in that case, pcap_get_required_select_timeout() will return a pointer to a struct timeval whose value can be used as a timeout in those routines. When the routine returns, an attempt should be made to read packets from the device. If pcap_get_required_select_timeout() returns NULL, no such timeout is available, and those routines cannot be used with the device. π
In addition, for various reasons, one or more of those routines will not work properly with the descriptor; the documentation for pcap_get_selectable_fd() gives details. Note that, just as an attempt to read packets from a pcap_t may not return any packets if the packet buffer timeout expires, a select(), poll(), or other such call may, if the packet buffer timeout expires, indicate that a descriptor is ready to read even if there are no packets available to read. π
β¨ Routines β¨
pcap_dispatch(3PCAP)β read a bufferful of packets from apcap_topen for a live capture or the full set of packets from apcap_topen for asavefilepcap_loop(3PCAP)β read packets from apcap_tuntil an interrupt or error occurspcap_next(3PCAP)β read the next packet from apcap_twithout an indication whether an error occurredpcap_next_ex(3PCAP)β read the next packet from apcap_twith an error indication on an errorpcap_breakloop(3PCAP)β prematurely terminate the loop inpcap_dispatch()orpcap_loop()pcap_setnonblock(3PCAP)β set or clear non-blocking mode on apcap_tpcap_getnonblock(3PCAP)β get the state of non-blocking mode for apcap_tpcap_get_selectable_fd(3PCAP)β attempt to get a descriptor for apcap_tthat can be used in calls such asselect()andpoll()pcap_get_required_select_timeout(3PCAP)β attempt to get a timeout required for using apcap_tin calls such asselect()andpoll()
π¦ Filters π¦
In order to cause only certain packets to be returned when reading packets, a filter can be set on a handle. For a live capture, the filtering will be performed in kernel mode, if possible, to avoid copying uninteresting packets from the kernel to user mode. πΈ
A filter can be specified as a text string; the syntax and semantics of the string are as described by pcap-filter(7). A filter string is compiled into a program in a pseudo-machine-language by pcap_compile() and the resulting program can be made a filter for a handle with pcap_setfilter(). The result of pcap_compile() can be freed with a call to pcap_freecode(). pcap_compile() may require a network mask for certain expressions in the filter string; pcap_lookupnet() can be used to find the network address and network mask for a given capture device. π
A compiled filter can also be applied directly to a packet that has been read using pcap_offline_filter(). β¨
β¨ Routines β¨
pcap_compile(3PCAP)β compile filter expression to a pseudo-machine-language code programpcap_freecode(3PCAP)β free a filter programpcap_setfilter(3PCAP)β set filter for apcap_tpcap_lookupnet(3PCAP)β get network address and network mask for a capture devicepcap_offline_filter(3PCAP)β apply a filter program to a packet
π Incoming and outgoing packets π
By default, libpcap will attempt to capture both packets sent by the machine and packets received by the machine. To limit it to capturing only packets received by the machine or, if possible, only packets sent by the machine, call pcap_setdirection(). π«Ά
β¨ Routines β¨
pcap_setdirection(3PCAP)β specify whether to capture incoming packets, outgoing packets, or both
π Capture statistics π
To get statistics about packets received and dropped in a live capture, call pcap_stats(). π
β¨ Routines β¨
pcap_stats(3PCAP)β get capture statistics
π Opening a handle for writing captured packets π
To open a savefile to which to write packets, given the pathname the savefile should have, call pcap_dump_open(). To open a savefile to which to write packets, given the pathname the savefile should have, call pcap_dump_open(); to set up a handle for a savefile, given a FILE * referring to a file already opened for writing, call pcap_dump_fopen(). They each return pointers to a pcap_dumper_t, which is the handle used for writing packets to the savefile. If it succeeds, it will have created the file if it doesn't exist and truncated the file if it does exist. To close a pcap_dumper_t, call pcap_dump_close(). π
β¨ Routines β¨
pcap_dump_open(3PCAP)β open apcap_dumper_tfor asavefile, given a pathname, replacing any existing datapcap_dump_open_append(3PCAP)β open apcap_dumper_tfor asavefile, given a pathname, appending to the existing datapcap_dump_fopen(3PCAP)β open apcap_dumper_tfor asavefile, given aFILE *, assuming an empty filepcap_dump_close(3PCAP)β close apcap_dumper_tpcap_dump_file(3PCAP)β get theFILE *for apcap_dumper_topened for asavefile
βοΈ Writing packets βοΈ
To write a packet to a pcap_dumper_t, call pcap_dump(). Packets written with pcap_dump() may be buffered, rather than being immediately written to the savefile. Closing the pcap_dumper_t will cause all buffered-but-not-yet-written packets to be written to the savefile. To force all packets written to the pcap_dumper_t, and not yet written to the savefile because they're buffered by the pcap_dumper_t, to be written to the savefile, without closing the pcap_dumper_t, call pcap_dump_flush(). π₯
β¨ Routines β¨
pcap_dump(3PCAP)β write packet to apcap_dumper_tpcap_dump_flush(3PCAP)β flush buffered packets written to apcap_dumper_tto thesavefilepcap_dump_ftell(3PCAP)β get current file position for apcap_dumper_t
π Injecting packets π
If you have the required privileges, you can inject packets onto a network with a pcap_t for a live capture, using pcap_inject() or pcap_sendpacket(). (The two routines exist for compatibility with both OpenBSD and WinPcap/Npcap; they perform the same function, but have different return values.) π€
β¨ Routines β¨
pcap_inject(3PCAP),pcap_sendpacket(3PCAP)β transmit a packet
π¨ Reporting errors π¨
Some routines return error or warning status codes; to convert them to a string, use pcap_statustostr(). π«‘
β¨ Routines β¨
pcap_statustostr(3PCAP)β get a string for an error or warning status code
π·οΈ Getting library version information π·οΈ
To get a string giving version information about libpcap, call pcap_lib_version(). π
β¨ Routines β¨
pcap_lib_version(3PCAP)β get library version string
π°οΈ BACKWARD COMPATIBILITY π°οΈ
In versions of libpcap prior to 1.0, the pcap.h header file was not in a pcap directory on most platforms; if you are writing an application that must work on versions of libpcap prior to 1.0, include <pcap.h>, which will include <pcap/pcap.h> for you, rather than including <pcap/pcap.h>. π§
pcap_create() and pcap_activate() were not available in versions of libpcap prior to 1.0; if you are writing an application that must work on versions of libpcap prior to 1.0, either use pcap_open_live() to get a handle for a live capture or, if you want to be able to use the additional capabilities offered by using pcap_create() and pcap_activate(), use an autoconf(1) script or some other configuration script to check whether the libpcap 1.0 APIs are available and use them only if they are. π
π SEE ALSO π
autoconf(1)tcpdump(8)tcpslice(8)pcap-filter(7)pfconfig(8)usermod(8)
π AUTHORS π
Okay so bestie, let's give credit where credit is due, because these three literally built the foundation we're all standing on. The original authors of libpcap are:
- Van Jacobson
- Craig Leres
- Steven McCanne
All three are from the Lawrence Berkeley National Laboratory, University of California, Berkeley, CA. Academic royalty, honestly. π
And the current version? It's available from "The Tcpdump Group"'s Web site at:
https://www.tcpdump.org/
Go bookmark it. I'll wait. π¦
π BUGS π
Found something cursed? Here's the vibe check on how to handle it:
- Security issue? π± Do not just drop it in a public issue β send an e-mail to
security@tcpdump.orginstead. Responsible disclosure is main character energy, periodt. - Bugs and other problems, contributing patches, requesting a feature, providing generic feedback, etc.? See the file
CONTRIBUTING.mdin thelibpcapsource tree root. It's all laid out there for you, bestie. π«Ά
fr fr though β security stuff goes to the e-mail, everything else goes through CONTRIBUTING.md. Don't mix 'em up. π
β¨ and that's the whole page, bestie β¨
This gorgeous little manual is from libpcap, dated 9 September 2020, page PCAP(3PCAP). Go forth and capture some packets β you're gonna slay. πΈππ
π¦ where this page comes from
- 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
- Copyright (c) 1994, 1996, 1997 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms