From 8466748bf1b0752c8623fe8686667739373a017d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 23 Dec 2011 12:45:56 +0100 Subject: examples: nfacct-get allows to zero counters with `-z' option Signed-off-by: Pablo Neira Ayuso --- examples/nfacct-get.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/nfacct-get.c b/examples/nfacct-get.c index 2c852d3..7b22352 100644 --- a/examples/nfacct-get.c +++ b/examples/nfacct-get.c @@ -1,17 +1,27 @@ #include +#include #include #include #include -int main(void) +int main(int argc, char *argv[]) { struct mnl_socket *nl; char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; uint32_t portid, seq; int ret, full = 1; + bool zeroctr = false; - nlh = nfacct_list(buf); + if (argc > 2) { + fprintf(stderr, "Usage: %s [-z]\n", argv[0]); + exit(EXIT_FAILURE); + } + + if (argc == 2 && strncmp(argv[1], "-z", strlen("-z")) == 0) + zeroctr = true; + + nlh = nfacct_list(buf, zeroctr); seq = nlh->nlmsg_seq = time(NULL); nl = mnl_socket_open(NETLINK_NETFILTER); -- cgit v1.2.3