@@ -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;
}
@@ -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);