1 .\" @(#) $Header: /tcpdump/master/libpcap/pcap_findalldevs.3pcap,v 1.3 2008-04-06 02:53:22 guy Exp $
3 .\" Copyright (c) 1994, 1996, 1997
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that: (1) source code distributions
8 .\" retain the above copyright notice and this paragraph in its entirety, (2)
9 .\" distributions including binary code include the above copyright notice and
10 .\" this paragraph in its entirety in the documentation or other materials
11 .\" provided with the distribution, and (3) all advertising materials mentioning
12 .\" features or use of this software display the following acknowledgement:
13 .\" ``This product includes software developed by the University of California,
14 .\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 .\" the University nor the names of its contributors may be used to endorse
16 .\" or promote products derived from this software without specific prior
17 .\" written permission.
18 .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 .\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 .TH PCAP_FINDALLDEVS 3PCAP "22 August 2010"
24 pcap_findalldevs, pcap_freealldevs \- get a list of capture devices, and
29 #include <pcap/pcap.h>
34 char errbuf[PCAP_ERRBUF_SIZE];
38 int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf);
39 void pcap_freealldevs(pcap_if_t *alldevs);
44 constructs a list of network devices that can be opened with
49 .BR pcap_open_live() .
50 (Note that there may be network devices that cannot be opened by the
52 .BR pcap_findalldevs() ,
53 because, for example, that process does not have sufficient privileges
54 to open them for capturing; if so, those devices will not appear on the
58 succeeds, the pointer pointed to by
60 is set to point to the first element of the list, or to
62 if no devices were found (this is considered success).
63 Each element of the list is of type
65 and has the following members:
71 a pointer to the next element in the list;
73 for the last element of the list
76 a pointer to a string giving a name for the device to pass to
82 a pointer to a string giving a human-readable description of the device
85 a pointer to the first element of a list of network addresses for the
89 if the device has no addresses
96 set if the device is a loopback interface
100 Each element of the list of addresses is of type
102 and has the following members:
108 a pointer to the next element in the list;
110 for the last element of the list
115 containing an address
122 that contains the netmask corresponding to the address pointed to by
130 that contains the broadcast address corresponding to the address pointed
133 may be null if the device doesn't support broadcasts
140 that contains the destination address corresponding to the address pointed
143 may be null if the device isn't a point-to-point interface
146 Note that not all the addresses in the list of addresses are
147 necessarily IPv4 or IPv6 addresses - you must check the
151 before interpreting the contents of the address.
153 The list of devices must be freed with
154 .BR pcap_freealldevs() ,
155 whch frees the list pointed to by
158 .B pcap_findalldevs()
159 returns 0 on success and \-1 on failure; as indicated, finding no
160 devices is considered success, rather than failure, so 0 will be
161 returned in that case.
164 is filled in with an appropriate error message.
166 is assumed to be able to hold at least
170 pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP),
171 pcap_open_live(3PCAP)