mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Allow offline packet sources to register FDs.
This commit is contained in:
parent
39c3bb797c
commit
26d3a81c09
2 changed files with 9 additions and 14 deletions
|
@ -85,17 +85,11 @@ void PktSrc::Opened(const Properties& arg_props)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( props.is_live )
|
if ( props.is_live )
|
||||||
{
|
|
||||||
Info(util::fmt("listening on %s\n", props.path.c_str()));
|
Info(util::fmt("listening on %s\n", props.path.c_str()));
|
||||||
|
|
||||||
// We only register the file descriptor if we're in live
|
if ( props.selectable_fd != -1 )
|
||||||
// mode because libpcap's file descriptor for trace files
|
if ( ! iosource_mgr->RegisterFd(props.selectable_fd, this) )
|
||||||
// isn't a reliable way to know whether we actually have
|
reporter->FatalError("Failed to register pktsrc fd with iosource_mgr");
|
||||||
// data to read.
|
|
||||||
if ( props.selectable_fd != -1 )
|
|
||||||
if ( ! iosource_mgr->RegisterFd(props.selectable_fd, this) )
|
|
||||||
reporter->FatalError("Failed to register pktsrc fd with iosource_mgr");
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG_LOG(DBG_PKTIO, "Opened source %s", props.path.c_str());
|
DBG_LOG(DBG_PKTIO, "Opened source %s", props.path.c_str());
|
||||||
}
|
}
|
||||||
|
@ -104,7 +98,7 @@ void PktSrc::Closed()
|
||||||
{
|
{
|
||||||
SetClosed(true);
|
SetClosed(true);
|
||||||
|
|
||||||
if ( props.is_live && props.selectable_fd != -1 )
|
if ( props.selectable_fd != -1 )
|
||||||
iosource_mgr->UnregisterFd(props.selectable_fd, this);
|
iosource_mgr->UnregisterFd(props.selectable_fd, this);
|
||||||
|
|
||||||
DBG_LOG(DBG_PKTIO, "Closed source %s", props.path.c_str());
|
DBG_LOG(DBG_PKTIO, "Closed source %s", props.path.c_str());
|
||||||
|
|
|
@ -182,10 +182,11 @@ void PcapSource::OpenOffline()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
props.selectable_fd = fileno(pcap_file(pd));
|
// We don't register the file descriptor if we're in offline mode,
|
||||||
|
// because libpcap's file descriptor for trace files isn't a reliable
|
||||||
if ( props.selectable_fd < 0 )
|
// way to know whether we actually have data to read.
|
||||||
InternalError("OS does not support selectable pcap fd");
|
// See https://github.com/the-tcpdump-group/libpcap/issues/870
|
||||||
|
props.selectable_fd = -1;
|
||||||
|
|
||||||
props.link_type = pcap_datalink(pd);
|
props.link_type = pcap_datalink(pd);
|
||||||
props.is_live = false;
|
props.is_live = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue