aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/protocol/icmprd.h
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-02-11 23:50:45 +0100
committerMauro Sardara <msardara@cisco.com>2019-02-12 13:15:47 +0000
commitfbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b (patch)
treee65187748120c945e39256084d5614ed127b8383 /lib/src/protocol/icmprd.h
parentf126f86da5acf088f24e97ecb32f9ba5a1789aa4 (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/icmprd.h')
-rw-r--r--lib/src/protocol/icmprd.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/src/protocol/icmprd.h b/lib/src/protocol/icmprd.h
index c2f27d673..aa1fa01ae 100644
--- a/lib/src/protocol/icmprd.h
+++ b/lib/src/protocol/icmprd.h
@@ -21,21 +21,46 @@
#define HICN_PROTOCOL_ICMPRD_H
#include "../common.h"
+#include "ipv4.h"
-typedef struct __attribute__ ((__packed__))
+/*
+ * The length of the ICMPRD4 header struct must be 92 bytes.
+ */
+#define EXPECTED_ICMPRD4_HDRLEN 92
+
+typedef struct
{
+ u8 type;
+ u8 code;
+ u16 csum;
ip4_address_t ip;
_ipv4_header_t iph;
u8 data[64];
} _icmprd4_header_t;
-typedef struct __attribute__ ((__packed__))
+#define ICMPRD4_HDRLEN sizeof(_icmprd4_header_t)
+static_assert (EXPECTED_ICMPRD4_HDRLEN == ICMPRD4_HDRLEN,
+ "Size of ICMPWLDR struct does not match its expected size.");
+
+/*
+ * The length of the ICMPRD header struct must be 40 bytes.
+ */
+#define EXPECTED_ICMPRD_HDRLEN 40
+
+typedef struct
{
+ u8 type;
+ u8 code;
+ u16 csum;
u32 res;
ip6_address_t tgt;
ip6_address_t dst;
} _icmprd_header_t;
+#define ICMPRD_HDRLEN sizeof(_icmprd_header_t)
+static_assert (EXPECTED_ICMPRD_HDRLEN == ICMPRD_HDRLEN,
+ "Size of ICMPWLDR struct does not match its expected size.");
+
#endif /* HICN_PROTOCOL_ICMPRD_H */
/*