From e8008c016944c48dbb7045628f0f6e541544c7ea Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 2 Aug 2021 11:12:31 +0200 Subject: conntrack: add shorthand mnemonic for UNREPLIED conntrack tool prints [UNREPLIED] if a conntrack entry lacks the SEEN_REPLY bit. Accept this as '-u' argument too. If requested, mask is set to SEEN_REPLY and value remains 0 (bit not set). Signed-off-by: Florian Westphal --- src/conntrack.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/conntrack.c b/src/conntrack.c index cc564a2..ef7f604 100644 --- a/src/conntrack.c +++ b/src/conntrack.c @@ -1199,6 +1199,7 @@ parse_parameter(const char *arg, unsigned int *status, int parse_type) static void parse_parameter_mask(const char *arg, unsigned int *status, unsigned int *mask, int parse_type) { + static const char unreplied[] = "UNREPLIED"; unsigned int *value; const char *comma; bool negated; @@ -1215,6 +1216,12 @@ parse_parameter_mask(const char *arg, unsigned int *status, unsigned int *mask, value = negated ? mask : status; + if (!negated && strncmp(arg, unreplied, strlen(unreplied)) == 0) { + *mask |= IPS_SEEN_REPLY; + arg = comma+1; + continue; + } + if (!do_parse_parameter(arg, comma-arg, value, parse_type)) exit_error(PARAMETER_PROBLEM,"Bad parameter `%s'", arg); arg = comma+1; @@ -1225,6 +1232,11 @@ parse_parameter_mask(const char *arg, unsigned int *status, unsigned int *mask, arg++; value = negated ? mask : status; + if (!negated && strncmp(arg, unreplied, strlen(unreplied)) == 0) { + *mask |= IPS_SEEN_REPLY; + return; + } + if (strlen(arg) == 0 || !do_parse_parameter(arg, strlen(arg), value, parse_type)) -- cgit v1.2.3