mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 15:18:20 +00:00
add bytes recvd to Stats and stats.bro
use libpcap packet hdr.len to count bytes
This commit is contained in:
parent
4c2e5fc8b2
commit
3877b3e34b
5 changed files with 20 additions and 4 deletions
|
@ -180,6 +180,7 @@ bool PcapSource::ExtractNextPacket(Packet* pkt)
|
|||
last_hdr = current_hdr;
|
||||
last_data = data;
|
||||
++stats.received;
|
||||
stats.bytes += current_hdr.len;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -219,7 +220,7 @@ bool PcapSource::SetFilter(int index)
|
|||
|
||||
#ifndef HAVE_LINUX
|
||||
// Linux doesn't clear counters when resetting filter.
|
||||
stats.received = stats.dropped = stats.link = 0;
|
||||
stats.received = stats.dropped = stats.link = stats.bytes = 0;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
@ -230,7 +231,7 @@ void PcapSource::Statistics(Stats* s)
|
|||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
|
||||
if ( ! (props.is_live && pd) )
|
||||
s->received = s->dropped = s->link = 0;
|
||||
s->received = s->dropped = s->link = s->bytes = 0;
|
||||
|
||||
else
|
||||
{
|
||||
|
@ -238,7 +239,7 @@ void PcapSource::Statistics(Stats* s)
|
|||
if ( pcap_stats(pd, &pstat) < 0 )
|
||||
{
|
||||
PcapError();
|
||||
s->received = s->dropped = s->link = 0;
|
||||
s->received = s->dropped = s->link = s->bytes = 0;
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -250,6 +251,8 @@ void PcapSource::Statistics(Stats* s)
|
|||
|
||||
s->received = stats.received;
|
||||
|
||||
s->bytes = stats.bytes;
|
||||
|
||||
if ( ! props.is_live )
|
||||
s->dropped = 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue