From 29c5cc39fb7f714897c3d6a3454e696e263fb9bc Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Wed, 25 Jan 2023 11:44:09 +0100 Subject: 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. --- example/ndpiReader.c | 16 ---------------- example/reader_util.c | 7 ------- example/reader_util.h | 19 ------------------- 3 files changed, 42 deletions(-) (limited to 'example') diff --git a/example/ndpiReader.c b/example/ndpiReader.c index d98754db7..66706044a 100644 --- a/example/ndpiReader.c +++ b/example/ndpiReader.c @@ -2361,17 +2361,6 @@ static void node_idle_scan_walker(const void *node, ndpi_VISIT which, int depth, /* *********************************************** */ -/** - * @brief On Protocol Discover - demo callback - */ -static void on_protocol_discovered(struct ndpi_workflow * workflow, - struct ndpi_flow_info * flow, - void * udata) { - ; -} - -/* *********************************************** */ - #if 0 /** * @brief Print debug @@ -2430,11 +2419,6 @@ static void setupDetection(u_int16_t thread_id, pcap_t * pcap_handle) { ndpi_thread_info[thread_id].workflow = ndpi_workflow_init(&prefs, pcap_handle, 1, serialization_format); - /* Preferences */ - ndpi_workflow_set_flow_detected_callback(ndpi_thread_info[thread_id].workflow, - on_protocol_discovered, - (void *)(uintptr_t)thread_id); - /* Protocols to enable/disable. Default: everything is enabled */ NDPI_BITMASK_SET_ALL(enabled_bitmask); if(_disabled_protocols != NULL) { diff --git a/example/reader_util.c b/example/reader_util.c index 67b27f70b..a3299f48b 100644 --- a/example/reader_util.c +++ b/example/reader_util.c @@ -1368,13 +1368,6 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl } if(flow->detection_completed && (!flow->check_extra_packets)) { - if(is_ndpi_proto(flow, NDPI_PROTOCOL_UNKNOWN)) { - if(workflow->__flow_giveup_callback != NULL) - workflow->__flow_giveup_callback(workflow, flow, workflow->__flow_giveup_udata); - } else { - if(workflow->__flow_detected_callback != NULL) - workflow->__flow_detected_callback(workflow, flow, workflow->__flow_detected_udata); - } flow->flow_payload = flow->ndpi_flow->flow_payload, flow->flow_payload_len = flow->ndpi_flow->flow_payload_len; flow->ndpi_flow->flow_payload = NULL; /* We'll free the memory */ diff --git a/example/reader_util.h b/example/reader_util.h index 3140a71bf..b8b249afe 100644 --- a/example/reader_util.h +++ b/example/reader_util.h @@ -353,11 +353,6 @@ typedef struct ndpi_workflow { struct ndpi_workflow_prefs prefs; struct ndpi_stats stats; - ndpi_workflow_callback_ptr __flow_detected_callback; - void * __flow_detected_udata; - ndpi_workflow_callback_ptr __flow_giveup_callback; - void * __flow_giveup_udata; - /* outside referencies */ pcap_t *pcap_handle; @@ -394,20 +389,6 @@ struct ndpi_proto ndpi_workflow_process_packet(struct ndpi_workflow * workflow, int ndpi_is_datalink_supported(int datalink_type); -/* flow callbacks for complete detected flow - (ndpi_flow_info will be freed right after) */ -static inline void ndpi_workflow_set_flow_detected_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) { - workflow->__flow_detected_callback = callback; - workflow->__flow_detected_udata = udata; -} - -/* flow callbacks for sufficient detected flow - (ndpi_flow_info will be freed right after) */ -static inline void ndpi_workflow_set_flow_giveup_callback(struct ndpi_workflow * workflow, ndpi_workflow_callback_ptr callback, void * udata) { - workflow->__flow_giveup_callback = callback; - workflow->__flow_giveup_udata = udata; -} - /* compare two nodes in workflow */ int ndpi_workflow_node_cmp(const void *a, const void *b); void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_flow_info *flow); -- cgit v1.2.3