diff options
author | 2019-02-11 23:50:45 +0100 | |
---|---|---|
committer | 2019-02-12 13:15:47 +0000 | |
commit | fbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b (patch) | |
tree | e65187748120c945e39256084d5614ed127b8383 /lib/src/protocol/ipv6.h | |
parent | f126f86da5acf088f24e97ecb32f9ba5a1789aa4 (diff) |
[HICN-51] Add static assert for ensuring correct struct size in libhicn definitions.
Change-Id: Ib41e9cbdd2ea84a40eb4e7b01da131cbad9575c4
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'lib/src/protocol/ipv6.h')
-rw-r--r-- | lib/src/protocol/ipv6.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/src/protocol/ipv6.h b/lib/src/protocol/ipv6.h index 28a1aa47f..5a83abcae 100644 --- a/lib/src/protocol/ipv6.h +++ b/lib/src/protocol/ipv6.h @@ -18,6 +18,11 @@ #include "../common.h" +/* + * The length of the IPV6 header struct must be 40 bytes. + */ +#define EXPECTED_IPV6_HDRLEN 40 + typedef struct { union @@ -35,8 +40,14 @@ typedef struct ip6_address_t daddr; /* destination address */ } _ipv6_header_t; - #define IPV6_HDRLEN sizeof(_ipv6_header_t) +static_assert (EXPECTED_IPV6_HDRLEN == IPV6_HDRLEN, + "Size of IPV6 struct does not match its expected size."); + +/* + * The length of the IPV6 pseudo header struct must be 40 bytes. + */ +#define EXPECTED_IPV6_PSHDRLEN 40 typedef struct { @@ -49,6 +60,8 @@ typedef struct } ipv6_pseudo_header_t; #define IPV6_PSHDRLEN sizeof(ipv6_pseudo_header_t) +static_assert (EXPECTED_IPV6_PSHDRLEN == IPV6_PSHDRLEN, + "Size of IPV6_PSHDR struct does not match its expected size."); /* Default field values */ #define IPV6_DEFAULT_VERSION 6 |