]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Default to first interface from pcap_findalldevs()
[tcpdump] / tcpdump.c
index 8a171c3997b81724a615b8a52e261239f7dd6037..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);
                }
@@ -2195,17 +2200,13 @@ RETSIGTYPE requestinfo(int signo _U_)
 void CALLBACK verbose_stats_dump (UINT timer_id _U_, UINT msg _U_, DWORD_PTR arg _U_,
                                  DWORD_PTR dw1 _U_, DWORD_PTR dw2 _U_)
 {
-       struct pcap_stat stat;
-
-       if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
+       if (infodelay == 0)
                fprintf(stderr, "Got %u\r", packets_captured);
 }
 #elif defined(HAVE_ALARM)
 static void verbose_stats_dump(int sig _U_)
 {
-       struct pcap_stat stat;
-
-       if (infodelay == 0 && pcap_stats(pd, &stat) >= 0)
+       if (infodelay == 0)
                fprintf(stderr, "Got %u\r", packets_captured);
        alarm(1);
 }