PCAP_LOOKUPNET(3)

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

🌸 NAME 🌸

okay bestie, welcome to the pcap_lookupnet page from the Library Functions Manual πŸ’– β€” it's here to find the IPv4 network number and netmask for a device. That's the whole vibe. periodt ✨

✨ SYNOPSIS ✨

literally drop this in:

#include <pcap/pcap.h>

char errbuf[PCAP_ERRBUF_SIZE];

int pcap_lookupnet(const char *device, bpf_u_int32 *netp,
           bpf_u_int32 *maskp, char *errbuf);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so pcap_lookupnet()? It's the function that determines the IPv4 network number and mask associated with the network device device. No cap. 🫢

Both netp and maskp are bpf_u_int32 pointers. And errbuf? That's a buffer large enough to hold at least PCAP_ERRBUF_SIZE chars. Got it? Good. πŸ’…

🚨 real talk bestie: this function is not available on Windows. It supports neither IPv6 nor multiple IPv4 addresses per interface, which obviously is not practical in modern networks. See pcap_findalldevs(3) for a more elaborate solution to the problem πŸ‘€.

πŸ’… RETURN VALUE πŸ’…

pcap_lookupnet() returns 0 on success and PCAP_ERROR on failure. If PCAP_ERROR is returned, errbuf is filled in with an appropriate error message. slay, that's the contract ✨

πŸŽ€ SEE ALSO πŸŽ€

  • pcap(3) β€” go peek, bestie πŸ‘‘

mwah πŸ’‹ β€” this is the PCAP_LOOKUPNET(3) page from the Library Functions Manual, dated 13 March 2024 🌈

πŸ“¦ where this page comes from