aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/protocol/icmp.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/icmp.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/icmp.h')
-rw-r--r--lib/src/protocol/icmp.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/src/protocol/icmp.h b/lib/src/protocol/icmp.h
index 5a84995b6..36954bb6d 100644
--- a/lib/src/protocol/icmp.h
+++ b/lib/src/protocol/icmp.h
@@ -22,6 +22,11 @@
#include "../common.h"
+/*
+ * The length of the ICMP header struct must be 4 bytes.
+ */
+#define EXPECTED_ICMP_HDRLEN 4
+
typedef struct
{
u8 type;
@@ -29,6 +34,15 @@ typedef struct
u16 csum;
} _icmp_header_t;
+#define ICMP_HDRLEN sizeof(_icmp_header_t)
+static_assert (EXPECTED_ICMP_HDRLEN == ICMP_HDRLEN,
+ "Size of ICMP struct does not match its expected size.");
+
+/*
+ * The length of the ICMPWLDR header struct must be 4 bytes.
+ */
+#define EXPECTED_ICMPWLDR_HDRLEN 8
+
typedef struct
{
u8 type;
@@ -55,7 +69,9 @@ typedef struct
};
} _icmp_wldr_header_t;
-#define ICMP_HDRLEN sizeof(_icmp_header_t)
+#define ICMPWLDR_HDRLEN sizeof(_icmp_wldr_header_t)
+static_assert (EXPECTED_ICMPWLDR_HDRLEN == ICMPWLDR_HDRLEN,
+ "Size of ICMPWLDR struct does not match its expected size.");
#endif /* HICN_PROTOCOL_ICMP_H */