diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-20 11:51:40 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-20 11:52:19 +0200 |
commit | 787bf5a86e122765d7594151e32a891aed7361ac (patch) | |
tree | 5b0a8146985f25a517d30d33a7e7b6f05e47bd84 /src | |
parent | e733be6f42e93a5dfeb5cb95e01a131dd2c32442 (diff) |
payload: accept ethertype in hexadecimal
You can use the symbols ip, ip6, arp and vlan, or alternatively
the ethertype protocol number.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/payload.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/payload.c b/src/payload.c index bcbc0d43..942bc857 100644 --- a/src/payload.c +++ b/src/payload.c @@ -930,6 +930,24 @@ static const struct symbol_table ethertype_tbl = { }, }; +static struct error_record *ethertype_parse(const struct expr *sym, + struct expr **res) +{ + struct error_record *erec; + + erec = sym->dtype->basetype->parse(sym, res); + if (erec != NULL) + return erec; + if (*res) + return NULL; + return symbolic_constant_parse(sym, ðertype_tbl, res); +} + +static void ethertype_print(const struct expr *expr) +{ + return symbolic_constant_print(ðertype_tbl, expr); +} + const struct datatype ethertype_type = { .type = TYPE_ETHERTYPE, .name = "ethertype", @@ -937,7 +955,9 @@ const struct datatype ethertype_type = { .byteorder = BYTEORDER_HOST_ENDIAN, .size = 2 * BITS_PER_BYTE, .basetype = &integer_type, - .sym_tbl = ðertype_tbl, + .basefmt = "0x%.4Zx", + .print = ethertype_print, + .parse = ethertype_parse, }; #define ETHHDR_TEMPLATE(__name, __dtype, __member) \ |