diff options
author | Ali Abdulkadir <autostart.ini@gmail.com> | 2017-10-21 13:06:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 13:06:58 +0300 |
commit | 9307be5f1961c5f913d6ab6e3be22b97c4c337a8 (patch) | |
tree | 91c50033e20ae066f818d52610187fc9feef7cc9 /pcap-rdmasniff.c | |
parent | d950121cdbaa5ad3177817bc63c69174ea34f2d3 (diff) | |
parent | 34505e5206e0fda856c016964c4fc1371f5372d8 (diff) |
Merge branch 'master' into man
Diffstat (limited to 'pcap-rdmasniff.c')
-rw-r--r-- | pcap-rdmasniff.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/pcap-rdmasniff.c b/pcap-rdmasniff.c index 6759ed83..512d8431 100644 --- a/pcap-rdmasniff.c +++ b/pcap-rdmasniff.c @@ -59,8 +59,21 @@ struct pcap_rdmasniff { u_char * oneshot_buffer; unsigned port_num; int cq_event; + u_int packets_recv; }; +static int +rdmasniff_stats(pcap_t *handle, struct pcap_stat *stat) +{ + struct pcap_rdmasniff *priv = handle->priv; + + stat->ps_recv = priv->packets_recv; + stat->ps_drop = 0; + stat->ps_ifdrop = 0; + + return 0; +} + static void rdmasniff_cleanup(pcap_t *handle) { @@ -109,8 +122,14 @@ rdmasniff_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u int count = 0; if (!priv->cq_event) { - if (ibv_get_cq_event(priv->channel, &ev_cq, &ev_ctx) < 0) { - return 0; + while (ibv_get_cq_event(priv->channel, &ev_cq, &ev_ctx) < 0) { + if (errno != EINTR) { + return PCAP_ERROR; + } + if (handle->break_loop) { + handle->break_loop = 0; + return PCAP_ERROR_BREAK; + } } ibv_ack_cq_events(priv->cq, 1); ibv_req_notify_cq(priv->cq, 0); @@ -139,6 +158,7 @@ rdmasniff_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u if (handle->fcode.bf_insns == NULL || bpf_filter(handle->fcode.bf_insns, pktd, pkth.len, pkth.caplen)) { callback(user, &pkth, pktd); + ++priv->packets_recv; ++count; } @@ -285,6 +305,7 @@ rdmasniff_activate(pcap_t *handle) handle->offset = 0; handle->read_op = rdmasniff_read; + handle->stats_op = rdmasniff_stats; handle->cleanup_op = rdmasniff_cleanup; handle->setfilter_op = install_bpf_program; handle->setdirection_op = NULL; |