summaryrefslogtreecommitdiffstats
path: root/src/payload.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/payload.c')
-rw-r--r--src/payload.c22
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, &ethertype_tbl, res);
+}
+
+static void ethertype_print(const struct expr *expr)
+{
+ return symbolic_constant_print(&ethertype_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 = &ethertype_tbl,
+ .basefmt = "0x%.4Zx",
+ .print = ethertype_print,
+ .parse = ethertype_parse,
};
#define ETHHDR_TEMPLATE(__name, __dtype, __member) \