From: Simon Nicolussi Date: Mon, 21 Sep 2015 20:12:20 +0000 (+0200) Subject: Default to first interface from pcap_findalldevs() X-Git-Tag: tcpdump-4.8.0~118^2 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/refs/pull/482/head Default to first interface from pcap_findalldevs() 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. --- diff --git a/tcpdump.c b/tcpdump.c index ca46638e..a0c627c6 100644 --- 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); }