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/header.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/header.h')
-rw-r--r-- | lib/src/header.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/src/header.h b/lib/src/header.h index 3864064f2..b21fe5c84 100644 --- a/lib/src/header.h +++ b/lib/src/header.h @@ -16,15 +16,20 @@ /** * @file header.h * @brief hICN header data structures. - * details. + * + * NOTE: These structures are used as convenient facade for accessing + * the encapsulated headers. They are not written taking compiler padding + * into account, then a sizeof() on these struct could not give the expected + * result. For accessing the size of the hicn headers use the macros at the end of + * this file. */ + #ifndef HICN_HEADER_H #define HICN_HEADER_H #include "common.h" #include "protocol.h" - typedef struct { _ipv6_header_t ip; @@ -94,6 +99,25 @@ typedef union hicn_protocol_t protocol; } hicn_header_t; + +#define HICN_V6_TCP_HDRLEN (IPV6_HDRLEN + TCP_HDRLEN) +#define HICN_V6_ICMP_HDRLEN (IPV6_HDRLEN + ICMP_HDRLEN) +#define HICN_V6_WLDR_HDRLEN (IPV6_HDRLEN + ICMPWLDR_HDRLEN) + +#define HICN_V6_TCP_AH_HDRLEN (HICN_V6_TCP_HDRLEN + AH_HDRLEN) +#define HICN_V6_ICMP_AH_HDRLEN (HICN_V6_ICMP_HDRLEN + AH_HDRLEN) + + +#define HICN_V4_TCP_HDRLEN (IPV4_HDRLEN + TCP_HDRLEN) +#define HICN_V4_ICMP_HDRLEN (IPV4_HDRLEN + ICMP_HDRLEN) +#define HICN_V4_WLDR_HDRLEN (IPV4_HDRLEN + ICMPWLDR_HDRLEN) + +#define HICN_V4_TCP_AH_HDRLEN (HICN_V4_TCP_HDRLEN + AH_HDRLEN) +#define HICN_V4_ICMP_AH_HDRLEN (HICN_V4_ICMP_HDRLEN + AH_HDRLEN) + + + + #endif /* HICN_HEADER_H */ /* |