From 56d87186f7e6d7dba042961be86d1b4b5ae9f2e3 Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Sun, 14 Jun 2020 14:42:39 +0200 Subject: Fix compilation with --enable-debug-messages flag NDPI_LOG* macros dereference ndpi_detection_module_struct object which is private to ndpi library (via NDPI_LIB_COMPILATION define). So we can't use them outside the library itself, i.e. in ndpiReader code Therefore, in files in example/, convert all (rare) uses of NDPI_LOG* macros to a new very simple macro, private to ndpiReader program. If necessary, such macro may be improved. According to a comment in ndpi_define.h, each dissector must define its own NDPI_CURRENT_PROTO macro before including ndpi_api.h file --- src/include/ndpi_api.h.in | 1 + src/include/ndpi_define.h.in | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/ndpi_api.h.in b/src/include/ndpi_api.h.in index f94091cc8..248d18cee 100644 --- a/src/include/ndpi_api.h.in +++ b/src/include/ndpi_api.h.in @@ -844,6 +844,7 @@ extern "C" { u_int ndpi_get_ndpi_num_custom_protocols(struct ndpi_detection_module_struct *ndpi_mod); u_int ndpi_get_ndpi_detection_module_size(void); void ndpi_set_log_level(struct ndpi_detection_module_struct *ndpi_mod, u_int l); + void ndpi_set_debug_bitmask(struct ndpi_detection_module_struct *ndpi_mod, NDPI_PROTOCOL_BITMASK debug_bitmask); /* LRU cache */ struct ndpi_lru_cache* ndpi_lru_cache_init(u_int32_t num_entries); diff --git a/src/include/ndpi_define.h.in b/src/include/ndpi_define.h.in index be7c21175..df28c15f3 100644 --- a/src/include/ndpi_define.h.in +++ b/src/include/ndpi_define.h.in @@ -179,6 +179,8 @@ #define NDPI_JABBER_FT_TIMEOUT 5 #define NDPI_SOULSEEK_CONNECTION_IP_TICK_TIMEOUT 600 +#include "ndpi_config.h" /* To have access to NDPI_ENABLE_DEBUG_MESSAGES */ + #ifdef NDPI_ENABLE_DEBUG_MESSAGES #define NDPI_LOG(proto, m, log_level, args...) \ { \ @@ -196,7 +198,7 @@ */ #ifndef NDPI_CURRENT_PROTO - #define NDPI_CURRENT_PROTO NDPI_PROTO_UNKNOWN + #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_UNKNOWN #endif #define NDPI_LOG_ERR(mod, args...) \ -- cgit v1.2.3