PCAP_CREATE(3)

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

✨ PCAP_CREATE(3): create a live capture handle ✨

okay bestie, this is the PCAP_CREATE(3) page from the Library Functions Manual, and we're about to make a live capture handle. stay with me β€” it's giving low-level networking but make it cute. πŸ’–


🌸 NAME 🌸

pcap_create β€” create a live capture handle, no cap.

πŸŽ€ SYNOPSIS πŸŽ€

#include <pcap/pcap.h>

char errbuf[PCAP_ERRBUF_SIZE];

pcap_t *pcap_create(const char *source, char *errbuf);

πŸ¦‹ DESCRIPTION πŸ¦‹

pcap_create() is literally there to create a packet capture handle so you can look at packets on the network. The source is a string that specifies the network device to open. On Linux systems with 2.2 or later kernels, you can use a source argument of "any" or NULL to capture packets from all interfaces β€” yes, all of them, iykyk. 🌈

The errbuf is a buffer large enough to hold at least PCAP_ERRBUF_SIZE chars. give it room to breathe, bestie. πŸ’…

okay so the handle it returns is not ready yet! You must activate it with pcap_activate(3) before packets can be captured with it. Before activating it, you can set options for the capture on the handle, such as promiscuous mode. set the vibe first, then activate. periodt. ✨

πŸ’– RETURN VALUE πŸ’–

pcap_create() returns a pcap_t * on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. so if it flops, your errbuf is spilling the tea about why. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

  • pcap(3) β€” the main character. 🫢

Signed with love from the Library Functions Manual girlies: this is PCAP_CREATE(3), dated 30 November 2023. 🫢✨

πŸ“¦ where this page comes from