diff options
author | Philip Craig <philipc@snapgear.com> | 2007-09-18 01:52:59 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2007-09-18 10:37:49 (GMT) |
commit | cbe8902265ccc9f6aa6453aeb3a2a4631ed0eb01 (patch) | |
tree | bce908c48f7a1b3a4993e76a8a4bcd785b16816e /src | |
parent | 104e158bd578bceacf37ba24dd1a1a907fc53d05 (diff) | |
download | libnl-cbe8902265ccc9f6aa6453aeb3a2a4631ed0eb01.zip libnl-cbe8902265ccc9f6aa6453aeb3a2a4631ed0eb01.tar.gz libnl-cbe8902265ccc9f6aa6453aeb3a2a4631ed0eb01.tar.bz2 |
Allow filtering by name for conntrack status flags
Diffstat (limited to 'src')
-rw-r--r-- | src/f_ct.c | 23 | ||||
-rw-r--r-- | src/nf-ct-dump.c | 5 |
2 files changed, 24 insertions, 4 deletions
@@ -38,8 +38,11 @@ static void get_filter(struct nfnl_ct *ct, int argc, char **argv, int idx) nfnl_ct_set_tcp_state(ct, state); } } else if (arg_match("status")) { - if (argc > ++idx) - nfnl_ct_set_status(ct, strtoul(argv[idx++], NULL, 0)); + if (argc > ++idx) { + int status = strtoul(argv[idx++], NULL, 0); + nfnl_ct_set_status(ct, status); + nfnl_ct_unset_status(ct, ~status); + } } else if (arg_match("timeout")) { if (argc > ++idx) nfnl_ct_set_timeout(ct, strtoul(argv[idx++], NULL, 0)); @@ -130,7 +133,21 @@ static void get_filter(struct nfnl_ct *ct, int argc, char **argv, int idx) } else if (arg_match("replybytes")) { if (argc > ++idx) nfnl_ct_set_bytes(ct, 1, strtoul(argv[idx++], NULL, 0)); - } else { + } +#define MSTATUS(STR, STATUS) \ + else if (!strcasecmp(argv[idx], STR)) { \ + nfnl_ct_set_status(ct, STATUS); idx++; } +#define MNOSTATUS(STR, STATUS) \ + else if (!strcasecmp(argv[idx], STR)) { \ + nfnl_ct_unset_status(ct, STATUS); idx++; } + + MSTATUS("replied", IPS_SEEN_REPLY) + MNOSTATUS("unreplied", IPS_SEEN_REPLY) + MSTATUS("assured", IPS_ASSURED) + MNOSTATUS("unassured", IPS_ASSURED) +#undef MSTATUS +#undef MNOSTATUS + else { fprintf(stderr, "What is '%s'?\n", argv[idx]); exit(1); } diff --git a/src/nf-ct-dump.c b/src/nf-ct-dump.c index 774c91b..54ee4c7 100644 --- a/src/nf-ct-dump.c +++ b/src/nf-ct-dump.c @@ -13,6 +13,7 @@ #include "utils.h" #include <netlink/netfilter/ct.h> +#include <linux/netfilter/nf_conntrack_common.h> #include "f_ct.c" @@ -28,7 +29,9 @@ static void print_usage(void) " [origpackets PACKETS] [origbytes BYTES]\n" " [replysrc ADDR] [replydst ADDR] [replysrcport PORT] [replydstport PORT]\n" " [replyicmpid ID] [replyicmptype TYPE] [replyicmpcode CODE]\n" - " [replypackets PACKETS] [replybytes BYTES]\n"); + " [replypackets PACKETS] [replybytes BYTES]\n" + " [{ replied | unreplied }] [{ assured | unassured }]\n" + ); exit(1); } |