@@ -192,6 +192,7 @@ int nft_lex(void *, void *, void *);
%token DEFINE "define"
%token REDEFINE "redefine"
%token UNDEFINE "undefine"
+%token TYPEOF "typeof"
%token FIB "fib"
@@ -1844,6 +1845,10 @@ data_type_atom_expr : type_identifier
$3, NULL);
xfree($1);
}
+ | TYPEOF '(' primary_expr ')'
+ {
+ $$ = $3;
+ }
;
data_type_expr : data_type_atom_expr
@@ -243,6 +243,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"define" { return DEFINE; }
"redefine" { return REDEFINE; }
"undefine" { return UNDEFINE; }
+"typeof" { return TYPEOF; }
"describe" { return DESCRIBE; }
This allows users to specify named sets by using the expression directly, rather than having to lookup the data type to use, or the needed size via 'nft describe". Example: table filter { set allowed_dports { type typeof(tcp dport); } map nametomark { type typeof(osf name) : typeof(meta mark); } map port2helper { type ipv4_addr . inet_service : typeof(ct helper); } } Currently, listing such a table will lose the typeof() expression: nft will print the datatype instead, just as if "type inet_service" would have been used. For types with non-fixed widths, the new "type, width" format added in previous patch is used. Signed-off-by: Florian Westphal <fw@strlen.de> --- src/parser_bison.y | 5 +++++ src/scanner.l | 1 + 2 files changed, 6 insertions(+)