summaryrefslogtreecommitdiffstats
path: root/src/parser_bison.y
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2019-10-30 21:45:39 +0100
committerPhil Sutter <phil@nwl.cc>2019-11-07 12:46:16 +0100
commit332325e3c3fab4c25bb5f387f9663205f63748dc (patch)
treeb9e616a69a3b87829c4f6531a6677119d9af6275 /src/parser_bison.y
parent856c78d4fdc73ac746ef1473f08d78cf2ebcbc4c (diff)
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 <phil@nwl.cc> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r--src/parser_bison.y6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 6f525d5b..3f283256 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -42,13 +42,13 @@
#include "parser_bison.h"
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)
{
memset(state, 0, sizeof(*state));
- init_list_head(&state->top_scope.symbols);
state->msgs = msgs;
state->cmds = cmds;
- state->scopes[0] = scope_init(&state->top_scope, NULL);
+ state->scopes[0] = scope_init(top_scope, NULL);
init_list_head(&state->indesc_list);
}