diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-11-28 21:20:59 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2014-11-30 23:20:32 +0100 |
commit | b848ff5de4e974dd9e471fc0888ea990a86e34af (patch) | |
tree | dbe3dbb8605c38c374fa5d641f6b7b44f48e30d0 /src/meta.c | |
parent | d297735543a8c32b83e40563f01fea33e233b4ef (diff) |
datatype: relax datatype check in integer_type_parse()
Otherwise parsing with basetypes doesn't work. Now nft displays
an error when the symbolic constant is not correct:
<cmdline>:1:29-31: Error: Could not parse conntrack state
add rule test test ct state xxx accept
^^^
Use .sym_tbl instead and default on the symbol_constant_parse()
function from the ethertype and pkttype, this simplifies the code and
(more importantly) it avoids a breakage after the change in
integer_type_parse().
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/meta.c')
-rw-r--r-- | src/meta.c | 28 |
1 files changed, 1 insertions, 27 deletions
@@ -312,32 +312,6 @@ static void pkttype_type_print(const struct expr *expr) return symbolic_constant_print(&pkttype_type_tbl, expr); } -static struct error_record *pkttype_type_parse(const struct expr *sym, - struct expr **res) -{ - struct error_record *erec; - const struct symbolic_constant *s; - - for (s = pkttype_type_tbl.symbols; s->identifier != NULL; s++) { - if (!strcmp(sym->identifier, s->identifier)) { - *res = constant_expr_alloc(&sym->location, sym->dtype, - sym->dtype->byteorder, - sym->dtype->size, - &s->value); - return NULL; - } - } - - *res = NULL; - erec = sym->dtype->basetype->parse(sym, res); - if (erec != NULL) - return erec; - if (*res) - return NULL; - - return symbolic_constant_parse(sym, &pkttype_type_tbl, res); -} - static const struct datatype pkttype_type = { .type = TYPE_PKTTYPE, .name = "pkt_type", @@ -346,7 +320,7 @@ static const struct datatype pkttype_type = { .size = BITS_PER_BYTE, .basetype = &integer_type, .print = pkttype_type_print, - .parse = pkttype_type_parse, + .sym_tbl = &pkttype_type_tbl, }; static struct symbol_table *devgroup_tbl; |