pcap_lookupdev Subroutine

Purpose

Obtains the name of a network device on the system.

Library

pcap Library (libpcap.a)

Syntax

#include <pcap.h>

char *pcap_lookupdev(char * errbuf);

Description

The pcap_lookupdev subroutine gets a network device suitable for use with the pcap_open_live and the pcap_lookupnet subroutines. If no interface can be found, or none are configured to be up, Null is returned. In the case of multiple network devices attached to the system, the pcap_lookupdev subroutine returns the first one it finds to be up, other than the loopback interface. (Loopback is always ignored.)

Parameters

Item Description
errbuf Returns error text and is only set when the pcap_lookupdev subroutine fails.

Return Values

Upon successful completion, the pcap_lookupdev subroutine returns a pointer to the name of a network device attached to the system. If pcap_lookupdev subroutine is unsuccessful, Null is returned, and text indicating the specific error is written to errbuf.