diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-23 12:45:56 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2011-12-23 12:45:56 +0100 |
commit | 8466748bf1b0752c8623fe8686667739373a017d (patch) | |
tree | f309007c423b6f559fb7c0bc2cb0cc88299f35a9 | |
parent | e6bf11428303c18c681603fd5030d724296955cf (diff) |
examples: nfacct-get allows to zero counters with `-z' option
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | examples/nfacct-get.c | 14 |
1 files changed, 12 insertions, 2 deletions
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 <stdlib.h> +#include <string.h> #include <time.h> #include <libmnl/libmnl.h> #include <libnetfilter_acct/libnetfilter_acct.h> -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); |