summaryrefslogtreecommitdiff
path: root/ring_rx.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-08-24 21:37:03 +0300
committerTobias Klauser <tklauser@distanz.ch>2015-08-25 11:14:42 +0200
commit5f94671f31c040f7cb78e56ac2524e84f703769c (patch)
tree8134a0da6d94405449fdb223d11d97184e269a11 /ring_rx.c
parentd84a6b7139f3c6d0eb70615543cf368350000e5b (diff)
netsniff-ng: Show total rx stats for multi pcap mode
Allow to collect rx stats for multiple pcap mode, by storing them in separated variables before switch to the next pcap file. It allows to have the one approach when dump for single or multiple pcap(s) mode. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'ring_rx.c')
-rw-r--r--ring_rx.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/ring_rx.c b/ring_rx.c
index 32d3f6d..11d1d08 100644
--- a/ring_rx.c
+++ b/ring_rx.c
@@ -59,7 +59,7 @@ static inline size_t rx_ring_get_size(struct ring *ring, bool v3)
return v3 ? ring->layout3.tp_block_size : ring->layout.tp_frame_size;
}
-static int get_rx_net_stats(int sock, uint64_t *packets, uint64_t *drops, bool v3)
+int get_rx_net_stats(int sock, uint64_t *packets, uint64_t *drops, bool v3)
{
int ret;
union {
@@ -101,7 +101,8 @@ static inline size_t rx_ring_get_size(struct ring *ring, bool v3 __maybe_unused)
return ring->layout.tp_frame_size;
}
-static int get_rx_net_stats(int sock, uint64_t *packets, uint64_t *drops, bool v3 __maybe_unused)
+int get_rx_net_stats(int sock, uint64_t *packets, uint64_t *drops,
+ bool v3 __maybe_unused)
{
int ret;
struct tpacket_stats stats;
@@ -238,21 +239,3 @@ void ring_rx_setup(struct ring *ring, int sock, size_t size, int ifindex,
join_fanout_group(sock, fanout_group, fanout_type);
prepare_polling(sock, poll);
}
-
-void sock_rx_net_stats(int sock, unsigned long seen)
-{
- int ret;
- uint64_t packets, drops;
- bool v3 = is_tpacket_v3(sock);
-
- ret = get_rx_net_stats(sock, &packets, &drops, v3);
- if (ret == 0) {
- printf("\r%12"PRIu64" packets incoming (%"PRIu64" unread on exit)\n",
- v3 ? (uint64_t)seen : packets, v3 ? packets - seen : 0);
- printf("\r%12"PRIu64" packets passed filter\n", packets - drops);
- printf("\r%12"PRIu64" packets failed filter (out of space)\n", drops);
- if (packets > 0)
- printf("\r%12.4lf%% packet droprate\n",
- (1.0 * drops / packets) * 100.0);
- }
-}