diff options
author | Florian Westphal <fw@strlen.de> | 2017-02-28 00:59:05 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-02-28 00:59:38 +0100 |
commit | 2d09a04a12c8564f8044788b2e69da04671230d7 (patch) | |
tree | e5dd986c5912b0097e36d40792ec4de8438b37dc /src/ct.c | |
parent | 450653a4f0822f170cb412013aa4cf9d6ef6ce3a (diff) |
ct: refactor print function so it can be re-used for ct statement
Once directional zone support is added we also need to print the
direction of the statement, so factor the common code to re-use
this helper from the statement print function.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/ct.c')
-rw-r--r-- | src/ct.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -238,22 +238,27 @@ static const struct ct_template ct_templates[] = { BYTEORDER_HOST_ENDIAN, 16), }; -static void ct_expr_print(const struct expr *expr) +static void ct_print(enum nft_ct_keys key, int8_t dir) { const struct symbolic_constant *s; printf("ct "); - if (expr->ct.direction < 0) + if (dir < 0) goto done; for (s = ct_dir_tbl.symbols; s->identifier != NULL; s++) { - if (expr->ct.direction == (int) s->value) { + if (dir == (int)s->value) { printf("%s ", s->identifier); break; } } done: - printf("%s", ct_templates[expr->ct.key].token); + printf("%s", ct_templates[key].token); +} + +static void ct_expr_print(const struct expr *expr) +{ + ct_print(expr->ct.key, expr->ct.direction); } static bool ct_expr_cmp(const struct expr *e1, const struct expr *e2) |