diff options
author | Varsha Rao <rvarsha016@gmail.com> | 2017-06-16 14:54:06 +0530 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2017-06-18 11:23:00 +0200 |
commit | 35f6cd327c2ec46296adf464f981cd6cddfec27b (patch) | |
tree | 7341c05e6f7499fa3da18a4e50dd9db0ca36339b /src/meta.c | |
parent | 509671dfa03365bba727b8be5e522b737da93a6f (diff) |
src: Pass stateless, numeric, ip2name and handle variables as structure members.
libnftables library will be created soon. So declare numeric_output,
stateless_output, ip2name_output and handle_output as members of
structure output_ctx, instead of global variables. Rename these
variables as following,
numeric_output -> numeric
stateless_output -> stateless
ip2name_output -> ip2name
handle_output -> handle
Also add struct output_ctx *octx as member of struct netlink_ctx.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/meta.c')
-rw-r--r-- | src/meta.c | 36 |
1 files changed, 19 insertions, 17 deletions
@@ -47,9 +47,9 @@ static void __exit realm_table_exit(void) rt_symbol_table_free(realm_tbl); } -static void realm_type_print(const struct expr *expr) +static void realm_type_print(const struct expr *expr, struct output_ctx *octx) { - return symbolic_constant_print(realm_tbl, expr, true); + return symbolic_constant_print(realm_tbl, expr, true, octx); } static struct error_record *realm_type_parse(const struct expr *sym, @@ -70,7 +70,8 @@ static const struct datatype realm_type = { .flags = DTYPE_F_PREFIX, }; -static void tchandle_type_print(const struct expr *expr) +static void tchandle_type_print(const struct expr *expr, + struct output_ctx *octx) { uint32_t handle = mpz_get_uint32(expr->value); @@ -149,7 +150,7 @@ static const struct datatype tchandle_type = { .parse = tchandle_type_parse, }; -static void ifindex_type_print(const struct expr *expr) +static void ifindex_type_print(const struct expr *expr, struct output_ctx *octx) { char name[IFNAMSIZ]; int ifindex; @@ -222,11 +223,11 @@ const struct datatype arphrd_type = { .sym_tbl = &arphrd_tbl, }; -static void uid_type_print(const struct expr *expr) +static void uid_type_print(const struct expr *expr, struct output_ctx *octx) { struct passwd *pw; - if (numeric_output < NUMERIC_ALL) { + if (octx->numeric < NUMERIC_ALL) { uint32_t uid = mpz_get_uint32(expr->value); pw = getpwuid(uid); @@ -236,7 +237,7 @@ static void uid_type_print(const struct expr *expr) printf("%d", uid); return; } - expr_basetype(expr)->print(expr); + expr_basetype(expr)->print(expr, octx); } static struct error_record *uid_type_parse(const struct expr *sym, @@ -274,11 +275,11 @@ static const struct datatype uid_type = { .parse = uid_type_parse, }; -static void gid_type_print(const struct expr *expr) +static void gid_type_print(const struct expr *expr, struct output_ctx *octx) { struct group *gr; - if (numeric_output < NUMERIC_ALL) { + if (octx->numeric < NUMERIC_ALL) { uint32_t gid = mpz_get_uint32(expr->value); gr = getgrgid(gid); @@ -288,7 +289,7 @@ static void gid_type_print(const struct expr *expr) printf("%u", gid); return; } - expr_basetype(expr)->print(expr); + expr_basetype(expr)->print(expr, octx); } static struct error_record *gid_type_parse(const struct expr *sym, @@ -338,9 +339,9 @@ static const struct symbol_table pkttype_type_tbl = { }, }; -static void pkttype_type_print(const struct expr *expr) +static void pkttype_type_print(const struct expr *expr, struct output_ctx *octx) { - return symbolic_constant_print(&pkttype_type_tbl, expr, false); + return symbolic_constant_print(&pkttype_type_tbl, expr, false, octx); } static const struct datatype pkttype_type = { @@ -365,9 +366,10 @@ static void __exit devgroup_table_exit(void) rt_symbol_table_free(devgroup_tbl); } -static void devgroup_type_print(const struct expr *expr) +static void devgroup_type_print(const struct expr *expr, + struct output_ctx *octx) { - return symbolic_constant_print(devgroup_tbl, expr, true); + return symbolic_constant_print(devgroup_tbl, expr, true, octx); } static struct error_record *devgroup_type_parse(const struct expr *sym, @@ -464,7 +466,7 @@ static bool meta_key_is_qualified(enum nft_meta_keys key) } } -static void meta_expr_print(const struct expr *expr) +static void meta_expr_print(const struct expr *expr, struct output_ctx *octx) { if (meta_key_is_qualified(expr->meta.key)) printf("meta %s", meta_templates[expr->meta.key].token); @@ -591,14 +593,14 @@ struct expr *meta_expr_alloc(const struct location *loc, enum nft_meta_keys key) return expr; } -static void meta_stmt_print(const struct stmt *stmt) +static void meta_stmt_print(const struct stmt *stmt, struct output_ctx *octx) { if (meta_key_is_qualified(stmt->meta.key)) printf("meta %s set ", meta_templates[stmt->meta.key].token); else printf("%s set ", meta_templates[stmt->meta.key].token); - expr_print(stmt->meta.expr); + expr_print(stmt->meta.expr, octx); } static const struct stmt_ops meta_stmt_ops = { |