struct stmt *stmt;
struct expr *expr;
struct set *set;
+ const struct datatype *datatype;
}
%token TOKEN_EOF 0 "end of file"
%type <string> identifier string comment_spec
%destructor { xfree($$); } identifier string comment_spec
+%type <val> type_identifier
+%type <datatype> data_type
+
%type <cmd> line
%destructor { cmd_free($$); } line
set_block : /* empty */ { $$ = $<set>-1; }
| set_block common_block
| set_block stmt_seperator
- | set_block TYPE identifier stmt_seperator
+ | set_block TYPE data_type stmt_seperator
{
- $1->keytype = datatype_lookup_byname($3);
- if ($1->keytype == NULL) {
- erec_queue(error(&@3, "unknown datatype %s", $3),
- state->msgs);
- YYERROR;
- }
+ $1->keytype = $3;
$$ = $1;
}
| set_block FLAGS set_flag_list stmt_seperator
| map_block common_block
| map_block stmt_seperator
| map_block TYPE
- identifier COLON identifier
+ data_type COLON data_type
stmt_seperator
{
- $1->keytype = datatype_lookup_byname($3);
- if ($1->keytype == NULL) {
- erec_queue(error(&@3, "unknown datatype %s", $3),
- state->msgs);
- YYERROR;
- }
-
- $1->datatype = datatype_lookup_byname($5);
- if ($1->datatype == NULL) {
- erec_queue(error(&@5, "unknown datatype %s", $5),
- state->msgs);
- YYERROR;
- }
-
+ $1->keytype = $3;
+ $1->datatype = $5;
$$ = $1;
}
| map_block FLAGS set_flag_list stmt_seperator
| MEMORY { $$ = NFT_SET_POL_MEMORY; }
;
+data_type : type_identifier
+ {
+ if ($1 & ~TYPE_MASK)
+ $$ = concat_type_alloc($1);
+ else
+ $$ = datatype_lookup($1);
+ }
+ ;
+
+type_identifier : identifier
+ {
+ const struct datatype *dtype = datatype_lookup_byname($1);
+ if (dtype == NULL) {
+ erec_queue(error(&@1, "unknown datatype %s", $1),
+ state->msgs);
+ YYERROR;
+ }
+ $$ = dtype->type;
+ }
+ | type_identifier DOT identifier
+ {
+ const struct datatype *dtype = datatype_lookup_byname($3);
+ if (dtype == NULL) {
+ erec_queue(error(&@3, "unknown datatype %s", $3),
+ state->msgs);
+ YYERROR;
+ }
+ $$ <<= TYPE_BITS;
+ $$ |= dtype->type;
+ }
+ ;
+
hook_spec : TYPE STRING HOOK STRING PRIORITY NUM
{
$<chain>0->type = chain_type_name_lookup($2);