PCAP_SETDIRECTION(3)

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

πŸ’… pcap_setdirection(3) πŸ’…

okay bestie, welcome to this page from the Library Functions Manual β€” we’re talking about pcap_setdirection, and yes, it’s lowkey iconic for telling libpcap which way packets should be flowing. πŸ¦‹


🌸 NAME 🌸

pcap_setdirection β€” set the direction for which packets will be captured ✨


✨ SYNOPSIS ✨

#include <pcap/pcap.h>

int pcap_setdirection(pcap_t *p, pcap_direction_t d);

πŸ’– DESCRIPTION πŸ’–

pcap_setdirection() is the function you call when you wanna specify a direction that packets will be captured. The d argument is one of these constants, and they are literally the whole vibe check for packet direction:

  • PCAP_D_IN β€” will only capture packets received by the device 🫢
  • PCAP_D_OUT β€” will only capture packets sent by the device πŸ’Œ
  • PCAP_D_INOUT β€” will capture packets received by or sent by the device πŸ”

And bestie, PCAP_D_INOUT is the default setting if this function is not called. no cap. πŸ‘‘

Now, fair warning: pcap_setdirection() isn’t necessarily fully supported on all platforms. Some platforms might return an error for all values, and some other platforms might not support PCAP_D_OUT. it’s giving β€œplatform-dependent situation” fr fr. 😭

Also, this operation is not supported if a ``savefile'' is being read. so don’t try it there, okay? πŸ™ˆ


🫢 RETURN VALUE 🫢

pcap_setdirection() returns 0 on success, PCAP_ERROR_NOT_ACTIVATED if called on a capture handle that has been created but not activated, or PCAP_ERROR on other errors. If PCAP_ERROR is returned, pcap_geterr(3) or pcap_perror(3) may be called with p as an argument to fetch or display the error text. πŸ’–


πŸ¦‹ SEE ALSO πŸ¦‹


and that’s the whole page, bestie β€” this cutie came from the Library Functions Manual, dated 5 March 2022, under PCAP_SETDIRECTION(3). slay. πŸ’…βœ¨

πŸ“¦ where this page comes from