pcap_lookupnet(3)

pcap_lookupnet3

Find the ipv4 network number and netmask for a device

Usage

#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);

Overview

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. errbuf is a buffer large enough to hold at least PCAP_ERRBUF_SIZE chars.

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.

Releases

39 releases since FreeBSD 8.0-RELEASE; the text changed 9 times.

  1. 8.0–8.4
  2. 9.0–10.4
  3. 11.0
  4. 11.1–11.3
  5. 11.4
  6. 12.0–12.1
  7. 12.2–13.4
  8. 13.5
  9. 14.0–14.1
  10. 14.2–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's man source.