pcap_lookupnet Subroutine

Purpose

Returns the network address and subnet mask for a network device.

Library

pcap Library (libpcap.a)

Syntax

#include <pcap.h>

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

Description

Use the pcap_lookupnet subroutine to determine the network address and subnet mask for the network device, device.

Parameters

Item Description
device Specifies the name of the network device to use for the network lookup, for example, en0.
errbuf Returns error text and is only set when the pcap_lookupnet subroutine fails.
maskp Holds the subnet mask associated with device.
netp Holds the network address for the device.

Return Values

Upon successful completion, the pcap_lookupnet subroutine returns 0. If the pcap_lookupnet subroutine is unsuccessful, -1 is returned, and errbuf is filled in with an appropriate error message.