PCAP_SETDIRECTION(3PCAP)

πŸ“¦
version 1.10.7 Β· 3 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, centos-stream 10, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’… NAME πŸ’…

okay so this is pcap_setdirection β€” the libpcap 3 section bestie that sets the direction for which packets will be captured. that's it, that's the whole vibe. no cap.


✨ SYNOPSIS ✨

#include <pcap/pcap.h>

int pcap_setdirection(pcap_t *p, pcap_direction_t d);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, pcap_setdirection() is the function you call when you want to be picky about which way packets are going, bestie. it's used to specify a direction that packets will be captured. d is one of the constants PCAP_D_IN, PCAP_D_OUT or PCAP_D_INOUT. let me break those down for you, periodt:

  • 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 🌈

PCAP_D_INOUT is the default setting if this function is not called. so if you just... don't call it? congrats, you already have the both-ways icon behavior. main character default energy. πŸ‘‘

⚠️ okay so here's the tea: 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. so like... vibe check your platform first, ngl.
πŸ’€ and one more thing β€” this operation is not supported if a ``savefile'' is being read. literally do not even try it, it's giving undefined territory.

πŸŽ€ 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 (bestie you gotta activate it first, it's like turning the key before you drive πŸš—), or PCAP_ERROR on other errors.

if PCAP_ERROR is returned, pcap_geterr(3PCAP) or pcap_perror(3PCAP) may be called with p as an argument to fetch or display the error text. so you can actually find out what went wrong instead of just screaming into the void 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • pcap(3PCAP) β€” the mothership, go read it, iykwim πŸ’–

that's a wrap, bestie!! ✨ this lil page came from the pcap_setdirection manual, 3PCAP section, dated 5 March 2022 β€” slay, iconic, no notes πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from