From ad6bfbad4d0b8ae6c0c6b2d58c68eee542110e8a Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Sun, 18 Dec 2022 09:10:57 +0100 Subject: Add protocol disabling feature (#1808) The application may enable only some protocols. Disabling a protocol means: *) don't register/use the protocol dissector code (if any) *) disable classification by-port for such a protocol *) disable string matchings for domains/certificates involving this protocol *) disable subprotocol registration (if any) This feature can be tested with `ndpiReader -B list_of_protocols_to_disable`. Custom protocols are always enabled. Technically speaking, this commit doesn't introduce any API/ABI incompatibility. However, calling `ndpi_set_protocol_detection_bitmask2()` is now mandatory, just after having called `ndpi_init_detection_module()`. Most of the diffs (and all the diffs in `/src/lib/protocols/`) are due to the removing of some function parameters. Fix the low level macro `NDPI_LOG`. This issue hasn't been detected sooner simply because almost all the code uses only the helpers `NDPI_LOG_*` --- src/include/ndpi_define.h.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/include/ndpi_define.h.in') diff --git a/src/include/ndpi_define.h.in b/src/include/ndpi_define.h.in index 3b21e5dfb..31b7a1825 100644 --- a/src/include/ndpi_define.h.in +++ b/src/include/ndpi_define.h.in @@ -167,8 +167,10 @@ #define NDPI_LOG(proto, m, log_level, args...) \ { \ struct ndpi_detection_module_struct *mod = (struct ndpi_detection_module_struct*) m; \ - if(mod != NULL && mod->ndpi_debug_printf != NULL) \ - (*(mod->ndpi_debug_printf))(proto, mod, log_level, __FILE__, __FUNCTION__, __LINE__, args); \ + if(mod && mod->ndpi_log_level >= log_level) { \ + if(mod != NULL && mod->ndpi_debug_printf != NULL) \ + (*(mod->ndpi_debug_printf))(proto, mod, log_level, __FILE__, __FUNCTION__, __LINE__, args); \ + } \ } /* We must define NDPI_CURRENT_PROTO before include ndpi_main.h !!! -- cgit v1.2.3