diff options
author | Patrick McHardy <kaber@trash.net> | 2009-03-20 08:12:18 +0100 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2009-03-20 08:12:18 +0100 |
commit | 5c40780440c0e8661fc7cfcec72dab48b934631d (patch) | |
tree | c6f334da0a6a2bc2fca4e48497408f477fb80fa9 /include/rule.h | |
parent | 2ae0ab5fb3eabc149bad1250c681a7a5f2aea694 (diff) |
Add support for scoping and symbol binding
As a first step towards stand-alone sets, add support for scoping and
binding symbols. This will be used for user-defined constants, as well
as declarations of modifiable (stand-alone) sets once the kernel side
is ready.
Scopes are currently limited to three nesting levels: the global scope,
table block scopes and chain block scopes.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/rule.h')
-rw-r--r-- | include/rule.h | 33 |
1 files changed, 33 insertions, 0 deletions
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; }; |