TYPE_DSCP,
TYPE_ECN,
TYPE_FIB_ADDR,
+ TYPE_BOOLEAN,
__TYPE_MAX
};
#define TYPE_MAX (__TYPE_MAX - 1)
extern const struct datatype icmpv6_code_type;
extern const struct datatype icmpx_code_type;
extern const struct datatype time_type;
+extern const struct datatype boolean_type;
extern const struct datatype *concat_type_alloc(uint32_t type);
extern void concat_type_destroy(const struct datatype *dtype);
[TYPE_ICMP_CODE] = &icmp_code_type,
[TYPE_ICMPV6_CODE] = &icmpv6_code_type,
[TYPE_ICMPX_CODE] = &icmpx_code_type,
+ [TYPE_BOOLEAN] = &boolean_type,
};
void datatype_register(const struct datatype *dtype)
return NULL;
}
+
+static const struct symbol_table boolean_tbl = {
+ .base = BASE_DECIMAL,
+ .symbols = {
+ SYMBOL("exists", true),
+ SYMBOL("missing", false),
+ SYMBOL_LIST_END
+ },
+};
+
+const struct datatype boolean_type = {
+ .type = TYPE_BOOLEAN,
+ .name = "boolean",
+ .desc = "boolean type",
+ .size = 1,
+ .basetype = &integer_type,
+ .sym_tbl = &boolean_tbl,
+};
%token NOTRACK "notrack"
+%token EXISTS "exists"
+%token MISSING "missing"
+
%type <string> identifier type_identifier string comment_spec
%destructor { xfree($$); } identifier type_identifier string comment_spec
%type <val> tcp_hdr_field
%type <val> tcp_hdr_option_type tcp_hdr_option_field
+%type <expr> boolean_expr
+%destructor { expr_free($$); } boolean_expr
+%type <val> boolean_keys
+
%%
input : /* empty */
}
;
+boolean_keys : EXISTS { $$ = true; }
+ | MISSING { $$ = false; }
+ ;
+
+boolean_expr : boolean_keys
+ {
+ $$ = constant_expr_alloc(&@$, &boolean_type,
+ BYTEORDER_HOST_ENDIAN,
+ 1, &$1);
+ }
+ ;
+
primary_rhs_expr : symbol_expr { $$ = $1; }
| integer_expr { $$ = $1; }
+ | boolean_expr { $$ = $1; }
| ETHER
{
$$ = symbol_expr_alloc(&@$, SYMBOL_VALUE,
"xml" { return XML; }
"json" { return JSON; }
+"exists" { return EXISTS; }
+"missing" { return MISSING; }
+
{addrstring} {
yylval->string = xstrdup(yytext);
return STRING;