PCAP_ACTIVATE(3PCAP)

πŸ“¦
version 1.11.0 Β· 2 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, nixos 26.05, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

pcap_activate β€” activate a capture handle, bestie πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pcap/pcap.h>

int pcap_activate(pcap_t *p);

✨ DESCRIPTION ✨

So, pcap_activate() is the moment of truth, okay? You call it to activate a packet capture handle so it can actually start looking at packets on the network 🌐, and every single option you already set on that handle is in effect when it does. It's giving "we're live, babes" energy, fr fr.


🌈 RETURN VALUE 🌈

Here's the vibe check on what you get back, no cap:

  • 0 β€” success, zero warnings, absolutely ate ✨
  • non-zero positive value β€” success, but with warnings (she did it but she's side-eyeing you 🫀)
  • negative value β€” error, it's not happening 😭

And a non-zero return value tells you which warning or error condition went down.

⚠️ The possible warning values ⚠️

  • PCAP_WARNING_PROMISC_NOTSUP β€” you asked for promiscuous mode but the capture source literally does not support promiscuous mode. Not supported, periodt.
  • PCAP_WARNING_TSTAMP_TYPE_NOTSUP β€” the time stamp type you specified in an earlier pcap_set_tstamp_type(3PCAP) call isn't supported by the capture source (and the time stamp type just stays as the default, no drama)
  • PCAP_WARNING β€” some other warning condition happened; you can call pcap_geterr(3PCAP) or pcap_perror(3PCAP) with p as an argument to fetch or display a message describing what the warning condition is πŸ”

πŸ’€ The possible error values πŸ’€

  • PCAP_ERROR_ACTIVATED β€” the handle has already been activated. Bestie. She's already awake.
  • PCAP_ERROR_NO_SUCH_DEVICE β€” the capture source you specified when the handle was created doesn't exist 🫠
  • PCAP_ERROR_PERM_DENIED β€” the process doesn't have permission to open the capture source 🚫
  • PCAP_ERROR_PROMISC_PERM_DENIED β€” the process does have permission to open the capture source, but does not have permission to put it into promiscuous mode πŸ™ƒ
  • PCAP_ERROR_RFMON_NOTSUP β€” monitor mode was specified but the capture source doesn't support monitor mode
  • PCAP_ERROR_IFACE_NOT_UP β€” the capture source device is not up πŸ“΄
  • PCAP_ERROR_CAPTURE_NOTSUP β€” packet capture is not supported on the capture source
  • PCAP_ERROR β€” some other error occurred; pcap_geterr() or pcap_perror() may be called with p as an argument to fetch or display a message describing the error

If PCAP_WARNING_PROMISC_NOTSUP, PCAP_ERROR_NO_SUCH_DEVICE, PCAP_ERROR_PERM_DENIED, or PCAP_ERROR_CAPTURE_NOTSUP is returned, you can call pcap_geterr() or pcap_perror() with p as an argument to fetch or display a message giving additional details about the problem πŸ’¬ β€” and those deets might be genuinely useful for debugging the problem if it's unexpected. iykyk.

Heads up bestie: additional warning and error codes may be added in the future πŸ‘€. So a program should check for positive, negative, and zero return codes, and treat all positive return codes as warnings and all negative return codes as errors. Also, pcap_statustostr(3PCAP) can be called with a warning or error code as an argument to fetch a message describing that warning or error code. 🧚
Also also: if pcap_activate() fails, the pcap_t * is not closed and freed 😱 β€” you gotta close it yourself using pcap_close(3PCAP). Don't leave her hanging, okay?

πŸŽ€ SEE ALSO πŸŽ€

  • pcap(3PCAP)

And that's the whole page, angel πŸ’œ This lil 3PCAP moment landed on 3 June 2024, and it lives under the name PCAP_ACTIVATE(3PCAP). Go forth and activate responsibly 🫢✨

πŸ“¦ where this page comes from