PCAP\_LOOKUPNET(3PCAP) PCAP\_LOOKUPNET(3PCAP)

# [NAME](#NAME)

pcap\_lookupnet - find the IPv4 network number and netmask for a device

# [SYNOPSIS](#SYNOPSIS)

```
#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](#DESCRIPTION)

**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, on success both values will be set in network byte order. *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**(3PCAP)](/man/os/libpcap/pcap_findalldevs.3PCAP) for a more elaborate solution to the problem.

# [RETURN VALUE](#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](#SEE_ALSO)

[**pcap**(3PCAP)](/man/os/libpcap/pcap.3PCAP)

31 January 2025

---

Document: pcap_lookupnet(3pcap) from libpcap 1.11.0-r0 (Chainguard OS)
Source: https://github.com/the-tcpdump-group/libpcap.git
