From: Guy Harris Date: Mon, 11 Dec 2017 08:08:25 +0000 (-0800) Subject: Add some new nd_ types for use in structures for packet layouts. X-Git-Tag: tcpdump-4.99-bp~1650 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/e1dd70a1b6754ba6946095cdbdb7850c08541117 Add some new nd_ types for use in structures for packet layouts. Note that nd_ipv4 is used for IPv4 netmasks as well as IPv4 addresses. --- diff --git a/netdissect.h b/netdissect.h index 69d61ccc..4c98164a 100644 --- a/netdissect.h +++ b/netdissect.h @@ -57,12 +57,14 @@ typedef unsigned char nd_uint64_t[8]; typedef signed char nd_int8_t[1]; /* - * Use this for IPv4 addresses. It's defined as an array of octets, so - * that it's not aligned on its "natural" boundary, and it's defined as - * a structure in the hopes that this makes it harder to naively use - * EXTRACT_BE_U_4() to extract the value - in many cases you just want - * to use UNALIGNED_MEMCPY() to copy its value, so that it remains in - * network byte order. + * Use this for IPv4 addresses and netmasks. + * + * It's defined as an array of octets, so that it's not guaranteed to + * be aligned on its "natural" boundary (in some packet formats, it + * *isn't* so aligned), and it's defined as a structure in the hopes + * that this makes it harder to naively use EXTRACT_BE_U_4() to extract + * the value - in many cases you just want to use UNALIGNED_MEMCPY() to + * copy its value, so that it remains in network byte order. * * (Among other things, we don't want somebody thinking "IPv4 addresses, * they're in network byte order, so we want EXTRACT_BE_U_4(), right?" @@ -78,6 +80,25 @@ typedef struct { unsigned char bytes[4]; } nd_ipv4; +/* + * Use this for IPv6 addresses and netmasks. + */ +typedef struct { + unsigned char bytes[16]; +} nd_ipv6; + +/* + * Use this for MAC addresses. + */ +typedef struct { + unsigned char bytes[6]; +} nd_mac_addr; + +/* + * Use this for blobs of bytes; make them arrays of nd_byte. + */ +typedef unsigned char nd_byte; + /* snprintf et al */ #include