PCAP_LOOKUPNET(3PCAP)

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

okay so bestie, welcome to the PCAP_LOOKUPNET(3PCAP) page πŸ’…βœ¨ it’s literally all about one function and we’re gonna get you comfy with it.

🌸 NAME 🌸

  • pcap_lookupnet β€” find the IPv4 network number and netmask for a device πŸŽ€

✨ SYNOPSIS ✨

first, the receipts πŸ“œ:

#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() is used to determine the IPv4 network number and mask associated with the network device device πŸ‘‘ both netp and maskp are bpf_u_int32 pointers, and errbuf is a buffer large enough to hold at least PCAP_ERRBUF_SIZE chars πŸ’–

Windows girlies, this one is not available on Windows πŸ™ˆ

it supports neither IPv6 nor multiple IPv4 addresses per interface, which obviously is not practical in modern networks 😭 for a more elaborate solution to the problem, see pcap_findalldevs(3PCAP) 🫢


πŸ’€ 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 ✨


🌈 SEE ALSO 🌈

  • pcap(3PCAP)

okay that’s the whole page, bestie 🫢 this one’s from the PCAP_LOOKUPNET(3PCAP) manual, dated 13 March 2024 β€” mwah πŸ’‹πŸ’–

πŸ“¦ where this page comes from