From fbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Mon, 11 Feb 2019 23:50:45 +0100 Subject: [HICN-51] Add static assert for ensuring correct struct size in libhicn definitions. Change-Id: Ib41e9cbdd2ea84a40eb4e7b01da131cbad9575c4 Signed-off-by: Mauro Sardara --- lib/src/header.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'lib/src/header.h') 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 */ /* -- cgit 1.2.3-korg