From 4494bd9c7d30d770502134d4684ec506c21fee1d Mon Sep 17 00:00:00 2001 From: Simon Nicolussi Date: Mon, 21 Sep 2015 22:12:20 +0200 Subject: [PATCH] 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. --- tcpdump.c | 5 +++++ 1 file changed, 5 insertions(+) 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); } -- 2.39.5