diff options
Diffstat (limited to 'qa/ct_events_reliable.c')
-rw-r--r-- | qa/ct_events_reliable.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/qa/ct_events_reliable.c b/qa/ct_events_reliable.c index e95623a..1c8e194 100644 --- a/qa/ct_events_reliable.c +++ b/qa/ct_events_reliable.c @@ -1,35 +1,47 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <signal.h> #include <errno.h> #include <libnetfilter_conntrack/libnetfilter_conntrack.h> +static int events = 0; +static int new, update, destroy; + static int event_cb(enum nf_conntrack_msg_type type, struct nf_conntrack *ct, void *data) { - static int i = 0; - static int new, destroy; - if (type == NFCT_T_NEW) new++; + if (type == NFCT_T_UPDATE) + update++; else if (type == NFCT_T_DESTROY) destroy++; - if ((++i % 10000) == 0) - printf("%d events received (%d new, %d destroy)\n", - i, new, destroy); + if ((++events % 10000) == 0) + printf("%d events received (%d new, %d update, %d destroy)\n", + events, new, update, destroy); return NFCT_CB_CONTINUE; } +static void sighandler(int foo) +{ + printf("%d events received (%d new, %d update, %d destroy)\n", + events, new, update, destroy); + exit(EXIT_SUCCESS); +} + int main(void) { int ret; struct nfct_handle *h; int on = 1; + signal(SIGINT, sighandler); + h = nfct_open(CONNTRACK, NFCT_ALL_CT_GROUPS); if (!h) { perror("nfct_open"); |