Skip to content

Commit

Permalink
Added some static assertion based sanity checks.
Browse files Browse the repository at this point in the history
Signed-off-by: Toni Uhlig <[email protected]>
  • Loading branch information
utoni committed Sep 11, 2024
1 parent 1c9aa85 commit 9ef17b7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nDPId.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 9ef17b7

Please sign in to comment.