1PCAP_FINDALLDEVS(3PCAP) PCAP_FINDALLDEVS(3PCAP)
2
3
4
6 pcap_findalldevs - get a list of capture devices
7
9 #include <pcap/pcap.h>
10
11 char errbuf[PCAP_ERRBUF_SIZE];
12
13 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
14
16 pcap_findalldevs() constructs a list of network devices that can be
17 opened with pcap_create() and pcap_activate() or with pcap_open_live().
18 (Note that there may be network devices that cannot be opened by the
19 process calling pcap_findalldevs(), because, for example, that process
20 might not have sufficient privileges to open them for capturing; if so,
21 those devices will not appear on the list.) alldevsp is set to point
22 to the first element of the list; each element of the list is of type
23 pcap_if_t, and has the following members:
24
25 next if not NULL, a pointer to the next element in the list;
26 NULL for the last element of the list
27
28 name a pointer to a string giving a name for the device to
29 pass to pcap_open_live()
30
31 description
32 if not NULL, a pointer to a string giving a human-read‐
33 able description of the device
34
35 addresses
36 a pointer to the first element of a list of addresses for
37 the interface
38
39 flags interface flags:
40
41 PCAP_IF_LOOPBACK
42 set if the interface is a loopback interface
43
44 Each element of the list of addresses is of type pcap_addr_t, and has
45 the following members:
46
47 next if not NULL, a pointer to the next element in the list;
48 NULL for the last element of the list
49
50 addr a pointer to a struct sockaddr containing an address
51
52 netmask
53 if not NULL, a pointer to a struct sockaddr that contains
54 the netmask corresponding to the address pointed to by
55 addr
56
57 broadaddr
58 if not NULL, a pointer to a struct sockaddr that contains
59 the broadcast address corresponding to the address
60 pointed to by addr; may be null if the interface doesn't
61 support broadcasts
62
63 dstaddr
64 if not NULL, a pointer to a struct sockaddr that contains
65 the destination address corresponding to the address
66 pointed to by addr; may be null if the interface isn't a
67 point-to-point interface
68
69 Note that not all the addresses in the list of addresses are necessar‐
70 ily IPv4 or IPv6 addresses - you must check the sa_family member of the
71 struct sockaddr before interpreting the contents of the address.
72
73 The list of devices must be freed with pcap_freealldevs().
74
76 pcap_findalldevs() returns 0 on success and -1 on failure. If -1 is
77 returned, errbuf is filled in with an appropriate error message.
78 errbuf is assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.
79
81 pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
82 pcap_open_live(3PCAP), pcap_freealldevs(3PCAP)
83
84
85
86 5 April 2008 PCAP_FINDALLDEVS(3PCAP)