---
name: "pcap_lookupnet"
section: "3pcap"
platform: "macos"
package: "libpcap"
version: "146"
release: "macOS 26.5"
platforms: ["linux", "macos"]
url: "https://new.carta.tech/pcap_lookupnet/3pcap"
---

# pcap\_lookupnet(3pcap)

find the IPv4 network number and netmask for a device

## NAME

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

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

**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.

## 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. *errbuf* is assumed to be able to hold at least **PCAP\_ERRBUF\_SIZE** chars.

## SEE ALSO

**pcap**(3PCAP)
