]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Default to first interface from pcap_findalldevs() 482/head
authorSimon Nicolussi <[email protected]>
Mon, 21 Sep 2015 20:12:20 +0000 (22:12 +0200)
committerSimon Nicolussi <[email protected]>
Mon, 21 Sep 2015 22:02:49 +0000 (00:02 +0200)
Only call (deprecated) pcap_lookupdev() as a last resort, as it doesn't
necessarily agree with pcap_findalldevs() on the order of interfaces and
the -D and -i options already rely upon the latter function's behaviour.

tcpdump.c

index ca46638e1662e64fa00f09eaf1126716e30dfd68..a0c627c66361cb9cc2f2fd3f76fbc31db2fc9c98 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1291,7 +1291,12 @@ main(int argc, char **argv)
                 * We're doing a live capture.
                 */
                if (device == NULL) {
+#ifdef HAVE_PCAP_FINDALLDEVS
+                       if (pcap_findalldevs(&devpointer, ebuf) >= 0 && devpointer != NULL)
+                               device = devpointer->name;
+#else /* HAVE_PCAP_FINDALLDEVS */
                        device = pcap_lookupdev(ebuf);
+#endif
                        if (device == NULL)
                                error("%s", ebuf);
                }