diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-02-11 23:50:45 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-02-12 13:15:47 +0000 |
commit | fbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b (patch) | |
tree | e65187748120c945e39256084d5614ed127b8383 /lib/src/protocol/tcp.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/tcp.h')
-rw-r--r-- | lib/src/protocol/tcp.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/src/protocol/tcp.h b/lib/src/protocol/tcp.h index 68f4bf8f9..3a15a93b3 100644 --- a/lib/src/protocol/tcp.h +++ b/lib/src/protocol/tcp.h @@ -21,11 +21,16 @@ #include "../name.h" /* + * The length of the TCP header struct must be 20 bytes. + */ +#define EXPECTED_TCP_HDRLEN 20 + +/* * NOTE: bitfields are problematic for portability reasons. There are provided * here for reference and documentation purposes, we might just provide a macro * to disable and use it instead of __BYTE_ORDER__. */ -typedef struct __attribute__ ((packed)) +typedef struct { u16 sport; u16 dport; @@ -120,6 +125,8 @@ typedef struct __attribute__ ((packed)) } _tcp_header_t; #define TCP_HDRLEN sizeof(_tcp_header_t) +static_assert (EXPECTED_TCP_HDRLEN == TCP_HDRLEN, + "Size of TCP struct does not match its expected size."); #ifndef HICN_VPP_PLUGIN |