PCAP_SET_DATALINK(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

okay bestie, this is a 3PCAP moment, and literally the whole point is switching up which link-layer header type your capture device is rocking. no cap, it's giving "main character changes her whole vibe" energy ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <pcap/pcap.h>

int pcap_set_datalink(pcap_t *p, int dlt);

🌸 DESCRIPTION 🌸

so pcap_set_datalink() is the icon that sets the current link-layer header type of the pcap descriptor over to whatever you dropped in the dlt cutie. that's it. that's the whole slay. πŸŽ€


✨ RETURN VALUE ✨

here's the vibe check on what comes back:

  • 0 β€” success, she ate, no notes πŸ’–
  • PCAP_ERROR_NOT_ACTIVATED β€” you called it on a capture handle that's been created but not activated yet, bestie 😭 activate her first
  • PCAP_ERROR β€” any other oopsie

and if you do get PCAP_ERROR, don't just spiral β€” you can call pcap_geterr(3PCAP) or pcap_perror(3PCAP) with p as the argument to fetch or display the error text. iykyk 🫢


πŸ”₯ SEE ALSO πŸ”₯

  • pcap(3PCAP)
  • pcap_datalink_name_to_val(3PCAP)

mwah πŸ’‹ that's the teardown, bestie β€” libpcap said 5 March 2022 and honestly? iconic date behavior. go set some datalinks πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from