the list for the interface, and try to open the interface only if we
don't already have an interface, so if you have multiple addresses for
an interface, you don't open the interface for each of them. (See
Wireshark bug 1151:
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1151
for the reason to do this; pcap_findalldevs() spent a *lot* of time and
energy opening en0 over and over again for all 64K-128K(!) addresses.)
#ifndef lint
static const char rcsid[] _U_ =
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.69 2006-01-21 10:45:18 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.70 2006-10-10 07:09:14 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
pcap_if_t *curdev, *prevdev, *nextdev;
int this_instance;
pcap_if_t *curdev, *prevdev, *nextdev;
int this_instance;
- /*
- * Can we open this interface for live capture?
- *
- * We do this check so that interfaces that ae supplied
- * by the interface enumeration mechanism we're using
- * but that don't support packet capture aren't included
- * in the list. An example of this is loopback interfaces
- * on Solaris; we don't just omit loopback interfaces
- * becaue you *can* capture on loopback interfaces on some
- * OSes.
- */
- p = pcap_open_live(name, 68, 0, 0, errbuf);
- if (p == NULL) {
- /*
- * No. Don't bother including it.
- * Don't treat this as an error, though.
- */
- *curdev_ret = NULL;
- return (0);
- }
- pcap_close(p);
-
/*
* Is there already an entry in the list for this interface?
*/
/*
* Is there already an entry in the list for this interface?
*/
if (strcmp(name, curdev->name) == 0)
break; /* yes, we found it */
}
if (strcmp(name, curdev->name) == 0)
break; /* yes, we found it */
}
if (curdev == NULL) {
/*
* No, we didn't find it.
if (curdev == NULL) {
/*
* No, we didn't find it.
+ *
+ * Can we open this interface for live capture?
+ *
+ * We do this check so that interfaces that are
+ * supplied by the interface enumeration mechanism
+ * we're using but that don't support packet capture
+ * aren't included in the list. Loopback interfaces
+ * on Solaris are an example of this; we don't just
+ * omit loopback interfaces on all platforms because
+ * you *can* capture on loopback interfaces on some
+ * OSes.
+ */
+ p = pcap_open_live(name, 68, 0, 0, errbuf);
+ if (p == NULL) {
+ /*
+ * No. Don't bother including it.
+ * Don't treat this as an error, though.
+ */
+ *curdev_ret = NULL;
+ return (0);
+ }
+ pcap_close(p);
+
+ /*
+ * Yes, we can open it.
* Allocate a new entry.
*/
curdev = malloc(sizeof(pcap_if_t));
* Allocate a new entry.
*/
curdev = malloc(sizeof(pcap_if_t));