1 .\" Copyright (c) 1994, 1996, 1997
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that: (1) source code distributions
6 .\" retain the above copyright notice and this paragraph in its entirety, (2)
7 .\" distributions including binary code include the above copyright notice and
8 .\" this paragraph in its entirety in the documentation or other materials
9 .\" provided with the distribution, and (3) all advertising materials mentioning
10 .\" features or use of this software display the following acknowledgement:
11 .\" ``This product includes software developed by the University of California,
12 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
13 .\" the University nor the names of its contributors may be used to endorse
14 .\" or promote products derived from this software without specific prior
15 .\" written permission.
16 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 .TH PCAP_FINDALLDEVS 3PCAP "23 August 2018"
22 pcap_findalldevs, pcap_freealldevs \- get a list of capture devices, and
27 #include <pcap/pcap.h>
32 char errbuf[PCAP_ERRBUF_SIZE];
36 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
37 void pcap_freealldevs(pcap_if_t *alldevs);
41 .BR pcap_findalldevs ()
42 constructs a list of network devices that can be opened with
43 .BR pcap_create (3PCAP)
45 .BR pcap_activate (3PCAP)
47 .BR pcap_open_live (3PCAP).
48 (Note that there may be network devices that cannot be opened by the
50 .BR pcap_findalldevs (),
51 because, for example, that process does not have sufficient privileges
52 to open them for capturing; if so, those devices will not appear on the
55 .BR pcap_findalldevs ()
56 succeeds, the pointer pointed to by
58 is set to point to the first element of the list, or to
60 if no devices were found (this is considered success).
61 Each element of the list is of type
63 and has the following members:
69 a pointer to the next element in the list;
71 for the last element of the list
74 a pointer to a string giving a name for the device to pass to
80 a pointer to a string giving a human-readable description of the device
83 a pointer to the first element of a list of network addresses for the
87 if the device has no addresses
94 set if the device is a loopback interface
97 set if the device is up
100 set if the device is running
103 set if the device is a wireless interface; this includes IrDA as well as
104 radio-based networks such as IEEE 802.15.4 and IEEE 802.11, so it
105 doesn't just mean Wi-Fi
107 .B PCAP_IF_CONNECTION_STATUS
108 a bitmask for an indication of whether the adapter is connected or not;
109 for wireless interfaces, "connected" means "associated with a network"
111 The possible values for the connection status bits are:
113 .B PCAP_IF_CONNECTION_STATUS_UNKNOWN
114 it's unknown whether the adapter is connected or not
116 .B PCAP_IF_CONNECTION_STATUS_CONNECTED
117 the adapter is connected
119 .B PCAP_IF_CONNECTION_STATUS_DISCONNECTED
120 the adapter is disconnected
122 .B PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE
123 the notion of "connected" and "disconnected" don't apply to this
124 interface; for example, it doesn't apply to a loopback device
128 Each element of the list of addresses is of type
130 and has the following members:
136 a pointer to the next element in the list;
138 for the last element of the list
143 containing an address
150 that contains the netmask corresponding to the address pointed to by
158 that contains the broadcast address corresponding to the address pointed
161 may be null if the device doesn't support broadcasts
168 that contains the destination address corresponding to the address pointed
171 may be null if the device isn't a point-to-point interface
174 Note that the addresses in the list of addresses might be IPv4
175 addresses, IPv6 addresses, or some other type of addresses, so you must
180 before interpreting the contents of the address; do not assume that the
181 addresses are all IPv4 addresses, or even all IPv4 or IPv6 addresses.
182 IPv4 addresses have the value
184 IPv6 addresses have the value
186 (which older operating systems that don't support IPv6 might not
187 define), and other addresses have other values. Whether other addresses
188 are returned, and what types they might have is platform-dependent.
189 For IPv4 addresses, the
191 pointer can be interpreted as if it pointed to a
192 .BR "struct sockaddr_in" ;
193 for IPv6 addresses, it can be interpreted as if it pointed to a
194 .BR "struct sockaddr_in6".
196 The list of devices must be freed with
197 .BR pcap_freealldevs (3PCAP),
198 which frees the list pointed to by
201 .BR pcap_findalldevs ()
202 returns 0 on success and
204 on failure; as indicated, finding no
205 devices is considered success, rather than failure, so 0 will be
206 returned in that case. If
210 is filled in with an appropriate error message.
212 is assumed to be able to hold at least
215 .SH BACKWARD COMPATIBILITY
221 constants became available in libpcap release 1.6.1. The
222 .BR PCAP_IF_WIRELESS ,
223 .BR PCAP_IF_CONNECTION_STATUS ,
224 .BR PCAP_IF_CONNECTION_STATUS_UNKNOWN ,
225 .BR PCAP_IF_CONNECTION_STATUS_CONNECTED ,
226 .BR PCAP_IF_CONNECTION_STATUS_DISCONNECTED ,
228 .B PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE
229 constants became available in libpcap release 1.9.0.