aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2023-01-25 11:44:09 +0100
committerGitHub <noreply@github.com>2023-01-25 11:44:09 +0100
commit29c5cc39fb7f714897c3d6a3454e696e263fb9bc (patch)
treec56dbdb0eb6a4763306adaa73171be77243a1ba9 /src/lib/ndpi_main.c
parent5849863ef91b9b6a3acc8f1799c6b3642d35f34c (diff)
Some small changes (#1869)
All dissector callbacks should not be exported by the library; make static some other local functions. The callback logic in `ndpiReader` has never been used. With internal libgcrypt, `gcry_control()` should always return no errors. We can check `categories` length at compilation time.
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index b2dd8f7d2..7c1a7ba0a 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2653,6 +2653,13 @@ static const char *categories[] = {
"Antimalware",
};
+#if !defined(NDPI_CFFI_PREPROCESSING) && defined(__linux__)
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+_Static_assert(sizeof(categories) / sizeof(char *) == NDPI_PROTOCOL_NUM_CATEGORIES,
+ "Invalid categories length. Do you need to update 'categories' array or 'ndpi_protocol_category_t'?");
+#endif
+#endif
+
/* ******************************************************************** */
struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs prefs) {
@@ -2815,13 +2822,6 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs
ndpi_str->risky_domain_automa.ac_automa = NULL; /* Initialized on demand */
ndpi_str->trusted_issuer_dn = NULL;
- if((sizeof(categories) / sizeof(char *)) != NDPI_PROTOCOL_NUM_CATEGORIES) {
- NDPI_LOG_ERR(ndpi_str, "[NDPI] invalid categories length: expected %u, got %u\n", NDPI_PROTOCOL_NUM_CATEGORIES,
- (unsigned int) (sizeof(categories) / sizeof(char *)));
- ndpi_free(ndpi_str);
- return(NULL);
- }
-
ndpi_str->custom_categories.hostnames.ac_automa = ac_automata_init(ac_domain_match_handler);
if(!ndpi_str->custom_categories.hostnames.ac_automa) {
ndpi_exit_detection_module(ndpi_str);