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/f_ct.c | |
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/f_ct.c')
-rw-r--r-- | src/f_ct.c | 23 |
1 files changed, 20 insertions, 3 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); } |