diff --git a/src/iosource/pcap/Source.cc b/src/iosource/pcap/Source.cc index 119280f1e5..773d31263c 100644 --- a/src/iosource/pcap/Source.cc +++ b/src/iosource/pcap/Source.cc @@ -56,15 +56,38 @@ void PcapSource::OpenLive() char tmp_errbuf[PCAP_ERRBUF_SIZE]; // Determine interface if not specified. - if ( props.path.empty() ) - props.path = pcap_lookupdev(tmp_errbuf); - if ( props.path.empty() ) { - safe_snprintf(errbuf, sizeof(errbuf), - "pcap_lookupdev: %s", tmp_errbuf); - Error(errbuf); - return; + pcap_if_t* devs; + + if ( pcap_findalldevs(&devs, tmp_errbuf) < 0 ) + { + safe_snprintf(errbuf, sizeof(errbuf), + "pcap_findalldevs: %s", tmp_errbuf); + Error(errbuf); + return; + } + + if ( devs ) + { + props.path = devs->name; + pcap_freealldevs(devs); + + if ( props.path.empty() ) + { + safe_snprintf(errbuf, sizeof(errbuf), + "pcap_findalldevs: empty device name"); + Error(errbuf); + return; + } + } + else + { + safe_snprintf(errbuf, sizeof(errbuf), + "pcap_findalldevs: no devices found"); + Error(errbuf); + return; + } } // Determine network and netmask.