mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Replace use of deprecated pcap_lookupdev()
libpcap 1.9.0 has started deprecating this function in favor of pcap_findalldevs()
This commit is contained in:
parent
7521fec5b3
commit
6af1bf18ac
1 changed files with 30 additions and 7 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue