diff --git a/monitor/pcap.c b/monitor/pcap.c index fb29eea8..b13a29f3 100644 --- a/monitor/pcap.c +++ b/monitor/pcap.c @@ -60,6 +60,7 @@ struct pcap { bool closed; uint32_t type; uint32_t snaplen; + size_t size; }; struct pcap *pcap_open(const char *pathname) @@ -152,6 +153,8 @@ struct pcap *pcap_create(const char *pathname) goto failed; } + pcap->size += len; + return pcap; failed: @@ -188,6 +191,11 @@ uint32_t pcap_get_snaplen(struct pcap *pcap) return pcap->snaplen; } +size_t pcap_get_size(struct pcap *pcap) +{ + return pcap->size; +} + bool pcap_read(struct pcap *pcap, struct timeval *tv, void *data, uint32_t size, uint32_t *len, uint32_t *real_len) { @@ -279,5 +287,7 @@ bool pcap_write(struct pcap *pcap, const struct timeval *tv, return false; } + pcap->size += written; + return true; } diff --git a/monitor/pcap.h b/monitor/pcap.h index 1705b33d..5b797cf3 100644 --- a/monitor/pcap.h +++ b/monitor/pcap.h @@ -36,6 +36,7 @@ void pcap_close(struct pcap *pcap); uint32_t pcap_get_type(struct pcap *pcap); uint32_t pcap_get_snaplen(struct pcap *pcap); +size_t pcap_get_size(struct pcap *pcap); bool pcap_read(struct pcap *pcap, struct timeval *tv, void *data, uint32_t size, uint32_t *len, uint32_t *real_len);