PCAP_CAN_SET_RFMON(3PCAP)

✨ pcap_can_set_rfmon β€” bestie, can we go monitor mode or not?? πŸ’…

okay so this is from the 3PCAP girlies (the libpcap manual, section 3) and it's literally just one function whose whole job is answering a yes/no question before you commit. no cap.


🌸 SYNOPSIS 🌸

#include <pcap/pcap.h>

int pcap_can_set_rfmon(pcap_t *p);

πŸ¦‹ DESCRIPTION πŸ¦‹

pcap_can_set_rfmon() is the vibe-check function. It checks whether monitor mode could be set on a capture handle when that handle gets activated.

key word: could. it's not doing it. it's not promising it. it's peeking. it's the "hey are we gonna be able to do this later" text, not the "we're doing this now" text. not yet activated, bestie β€” that's the whole point. πŸŽ€


πŸ‘‘ RETURN VALUE πŸ‘‘

  • 0 β€” nope, monitor mode could not be set 😭
  • 1 β€” yesss, monitor mode could be set ✨ slay
  • negative value β€” an error happened, and the specific negative number tells you which error condition it was. here's the roster:

πŸ’€ the error values πŸ’€

  • PCAP_ERROR_NO_SUCH_DEVICE β€” the capture source you specified when the handle was created straight up doesn't exist. it's giving ghosted. πŸ‘»
  • PCAP_ERROR_PERM_DENIED β€” the process doesn't have permission to even check whether monitor mode could be supported. rude, honestly. πŸ™ˆ
  • PCAP_ERROR_ACTIVATED β€” the capture handle has already been activated. too late, girlie, that ship sailed. 🚒
  • PCAP_ERROR β€” some other error happened, the catch-all. you can call pcap_geterr(3PCAP) or pcap_perror(3PCAP) with p as an argument to fetch or display a message describing the error. 🫢

⚠️ real talk: additional error codes may be added in the future. so a program should check for 0, 1, and negative return codes, and treat all negative return codes as errors. do not hardcode a list of specific negatives and think you're safe, because you are not. πŸ’€

and if you want a human-readable message for a warning or error code, you can call pcap_statustostr(3PCAP) with a warning or error code as an argument to fetch a message describing that warning or error code. cute, right?


🌈 SEE ALSO 🌈

  • pcap(3PCAP)
  • pcap_create(3PCAP)
  • pcap_activate(3PCAP)
  • pcap_set_rfmon(3PCAP)

and that's the whole page, bestie 🫢 this was PCAP_CAN_SET_RFMON(3PCAP), dated 31 July 2016, from the libpcap manual set. go forth and vibe-check your handles before you activate them. periodt. πŸ’–βœ¨

πŸ“¦ where this page comes from