From 332325e3c3fab4c25bb5f387f9663205f63748dc Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 30 Oct 2019 21:45:39 +0100 Subject: libnftables: Store top_scope in struct nft_ctx Allow for interactive sessions to make use of defines. Since parser is initialized for each line, top scope defines didn't persist although they are actually useful for stuff like: | # nft -i | define goodports = { 22, 23, 80, 443 } | add rule inet t c tcp dport $goodports accept | add rule inet t c tcp sport $goodports accept While being at it, introduce scope_alloc() and scope_free(). Signed-off-by: Phil Sutter Acked-by: Pablo Neira Ayuso --- include/parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/parser.h') diff --git a/include/parser.h b/include/parser.h index 39a75212..949284d9 100644 --- a/include/parser.h +++ b/include/parser.h @@ -22,7 +22,6 @@ struct parser_state { struct list_head *msgs; unsigned int nerrs; - struct scope top_scope; struct scope *scopes[SCOPE_NEST_MAX]; unsigned int scope; @@ -32,7 +31,8 @@ struct parser_state { struct mnl_socket; extern void parser_init(struct nft_ctx *nft, struct parser_state *state, - struct list_head *msgs, struct list_head *cmds); + struct list_head *msgs, struct list_head *cmds, + struct scope *top_scope); extern int nft_parse(struct nft_ctx *ctx, void *, struct parser_state *state); extern void *scanner_init(struct parser_state *state); -- cgit v1.2.3