From 42e2ec0198dd1408da4a32e1beefe9cbc0fdae89 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 9 Sep 2016 13:44:50 +0200 Subject: datatype: ll: use big endian byte ordering ether daddr set 00:03:2d:2b:74:ec is listed as: ether daddr set ec:74:2b:2d:03:00 (it was fine without 'set' keyword). Reason is that ether address was listed as being HOST endian. The payload expression (unlike statement) path contains a few conversion call sites for this, i.e.: if (tmp->byteorder == BYTEORDER_HOST_ENDIAN) mpz_switch_byteorder(tmp->value, tmp->len / BITS_PER_BYTE); ... it might make sense to remove those in a followup patch. Reported-by: Laura Garcia Liebana Signed-off-by: Florian Westphal Acked-by: Pablo Neira Ayuso --- src/datatype.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/datatype.c') diff --git a/src/datatype.c b/src/datatype.c index 2b1619a6..1e402879 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -348,7 +348,8 @@ static void lladdr_type_print(const struct expr *expr) uint8_t data[len]; unsigned int i; - mpz_export_data(data, expr->value, BYTEORDER_HOST_ENDIAN, len); + mpz_export_data(data, expr->value, BYTEORDER_BIG_ENDIAN, len); + for (i = 0; i < len; i++) { printf("%s%.2x", delim, data[i]); delim = ":"; @@ -374,7 +375,7 @@ static struct error_record *lladdr_type_parse(const struct expr *sym, } *res = constant_expr_alloc(&sym->location, sym->dtype, - BYTEORDER_HOST_ENDIAN, len * BITS_PER_BYTE, + BYTEORDER_BIG_ENDIAN, len * BITS_PER_BYTE, buf); return NULL; } @@ -383,7 +384,7 @@ const struct datatype lladdr_type = { .type = TYPE_LLADDR, .name = "ll_addr", .desc = "link layer address", - .byteorder = BYTEORDER_HOST_ENDIAN, + .byteorder = BYTEORDER_BIG_ENDIAN, .basetype = &integer_type, .print = lladdr_type_print, .parse = lladdr_type_parse, -- cgit v1.2.3