mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 03:58:20 +00:00
Fix PktSrc setting next_timestamp even when no packet available
When pcap_next failed to return packet data, such as when a live packet capture interface has no traffic, the next_timestamp member would still be set to possibly uninitialized or meaningless data. Maybe addresses #611.
This commit is contained in:
parent
928baf4b66
commit
73dcdbcfc5
1 changed files with 4 additions and 1 deletions
|
@ -21,6 +21,7 @@ PktSrc::PktSrc()
|
|||
{
|
||||
interface = readfile = 0;
|
||||
data = last_data = 0;
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
hdr_size = 0;
|
||||
datalink = 0;
|
||||
netmask = 0xffffff00;
|
||||
|
@ -75,6 +76,8 @@ int PktSrc::ExtractNextPacket()
|
|||
}
|
||||
|
||||
data = last_data = pcap_next(pd, &hdr);
|
||||
|
||||
if ( data )
|
||||
next_timestamp = hdr.ts.tv_sec + double(hdr.ts.tv_usec) / 1e6;
|
||||
|
||||
if ( pseudo_realtime )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue