summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/parser.h8
-rw-r--r--include/rule.h33
2 files changed, 41 insertions, 0 deletions
diff --git a/include/parser.h b/include/parser.h
index a47bd0f0..f5dd6f4b 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -2,6 +2,7 @@
#define NFTABLES_PARSER_H
#include <list.h>
+#include <rule.h> // FIXME
#define MAX_INCLUDE_DEPTH 16
#define TABSIZE 8
@@ -10,12 +11,19 @@
#define YYLTYPE_IS_TRIVIAL 0
#define YYENABLE_NLS 0
+#define SCOPE_NEST_MAX 3
+
struct parser_state {
struct input_descriptor *indesc;
struct input_descriptor indescs[MAX_INCLUDE_DEPTH];
unsigned int indesc_idx;
struct list_head *msgs;
+
+ struct scope top_scope;
+ struct scope *scopes[SCOPE_NEST_MAX];
+ unsigned int scope;
+
struct list_head cmds;
};
diff --git a/include/rule.h b/include/rule.h
index 991d1125..4e5da064 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -24,6 +24,37 @@ extern void handle_merge(struct handle *dst, const struct handle *src);
extern void handle_free(struct handle *h);
/**
+ * struct scope
+ *
+ * @parent: pointer to parent scope
+ * @symbols: symbols bound in the scope
+ */
+struct scope {
+ const struct scope *parent;
+ struct list_head symbols;
+};
+
+extern struct scope *scope_init(struct scope *scope, const struct scope *parent);
+
+/**
+ * struct symbol
+ *
+ * @list: scope symbol list node
+ * @identifier: identifier
+ * @expr: initializer
+ */
+struct symbol {
+ struct list_head list;
+ const char *identifier;
+ struct expr *expr;
+};
+
+extern void symbol_bind(struct scope *scope, const char *identifier,
+ struct expr *expr);
+extern struct symbol *symbol_lookup(const struct scope *scope,
+ const char *identifier);
+
+/**
* struct table - nftables table
*
* @list: list node
@@ -33,6 +64,7 @@ extern void handle_free(struct handle *h);
struct table {
struct list_head list;
struct handle handle;
+ struct scope scope;
struct list_head chains;
};
@@ -55,6 +87,7 @@ struct chain {
struct handle handle;
unsigned int hooknum;
unsigned int priority;
+ struct scope scope;
struct list_head rules;
};