diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2024-09-08 13:28:20 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2024-09-11 13:28:20 +0200 |
commit | 9ef17b7bd810cf46b9432345fa872b82d5e50d92 (patch) | |
tree | b6a455035a5e8e3748c24a8e6544a5ed3a241caa /nDPId.c | |
parent | 1c9aa854851c4daf479c988ce8a064ae2accbaab (diff) |
Added some static assertion based sanity checks.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'nDPId.c')
-rw-r--r-- | nDPId.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -17,6 +17,9 @@ #include <pthread.h> #include <signal.h> #include <stdarg.h> +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#include <stddef.h> +#endif #include <stdio.h> #include <stdlib.h> #include <sys/ioctl.h> @@ -221,6 +224,10 @@ struct nDPId_flow_extended unsigned long long int total_l4_payload_len[FD_COUNT]; struct ndpi_proto detected_l7_protocol; }; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +_Static_assert(offsetof(struct nDPId_flow_extended, flow_basic) == 0, + "Offset of flow_basic is not zero any more. nDPId won't work anymore w/o changing it's core!"); +#endif /* * Skipped flows need at least some information. @@ -229,6 +236,10 @@ struct nDPId_flow_skipped { struct nDPId_flow_basic flow_basic; // Do not move this element! }; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +_Static_assert(offsetof(struct nDPId_flow_skipped, flow_basic) == 0, + "Offset of flow_basic is not zero any more. nDPId won't work anymore w/o changing it's core!"); +#endif /* * Structure which is important for the detection process. @@ -265,6 +276,10 @@ struct nDPId_flow } finished; }; }; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +_Static_assert(offsetof(struct nDPId_flow, flow_extended) == 0, + "Offset of flow_extended is not zero any more. nDPId won't work anymore w/o changing it's core!"); +#endif struct nDPId_workflow { |