From a27538b764c85084980eef40cc7751c02a4af216 Mon Sep 17 00:00:00 2001 From: Nardi Ivan Date: Wed, 28 Sep 2022 16:44:59 +0200 Subject: Remove unused code LRU callbacks have been added in 460ff3c7a, but they have never been used and they have never been extended to the other LRU caches. `ndpi_search_tcp_or_udp()` basically returns the classification by port/ip of the flow; calling it from the dissector is useless. The same for TOR detection: ips are checked in the generic code --- src/lib/protocols/ajp.c | 5 ----- src/lib/protocols/hangout.c | 2 -- src/lib/protocols/mongodb.c | 5 ----- src/lib/protocols/stun.c | 5 ----- src/lib/protocols/tcp_udp.c | 7 ------- src/lib/protocols/websocket.c | 3 --- 6 files changed, 27 deletions(-) (limited to 'src/lib/protocols') diff --git a/src/lib/protocols/ajp.c b/src/lib/protocols/ajp.c index 97313f4a1..2f58f1c70 100644 --- a/src/lib/protocols/ajp.c +++ b/src/lib/protocols/ajp.c @@ -58,11 +58,6 @@ static void set_ajp_detected(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { - ndpi_search_tcp_or_udp(ndpi_struct, flow); - - /* If no custom protocol has been detected */ - /* if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) */ - ndpi_int_reset_protocol(flow); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AJP, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); } } diff --git a/src/lib/protocols/hangout.c b/src/lib/protocols/hangout.c index c8ae84177..70b1baba3 100644 --- a/src/lib/protocols/hangout.c +++ b/src/lib/protocols/hangout.c @@ -107,8 +107,6 @@ void ndpi_search_hangout(struct ndpi_detection_module_struct *ndpi_struct, #endif ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, NDPI_PROTOCOL_HANGOUT_DUO); - if(ndpi_struct->ndpi_notify_lru_add_handler_ptr) - ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_hangout_cache, key, NDPI_PROTOCOL_HANGOUT_DUO); } ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_HANGOUT_DUO, diff --git a/src/lib/protocols/mongodb.c b/src/lib/protocols/mongodb.c index 1404cf3ba..83235be1a 100644 --- a/src/lib/protocols/mongodb.c +++ b/src/lib/protocols/mongodb.c @@ -53,11 +53,6 @@ static void set_mongodb_detected(struct ndpi_detection_module_struct *ndpi_struc struct ndpi_flow_struct *flow) { if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { - ndpi_search_tcp_or_udp(ndpi_struct, flow); - - /* If no custom protocol has been detected */ - /* if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) */ - ndpi_int_reset_protocol(flow); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MONGODB, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); } } diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c index a09e898d6..d60270ecc 100644 --- a/src/lib/protocols/stun.c +++ b/src/lib/protocols/stun.c @@ -96,12 +96,7 @@ static void ndpi_int_stun_add_connection(struct ndpi_detection_module_struct *nd #endif ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key, app_proto); - if(ndpi_struct->ndpi_notify_lru_add_handler_ptr) - ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_stun_cache, key, app_proto); - ndpi_lru_add_to_cache(ndpi_struct->stun_cache, key_rev, app_proto); - if(ndpi_struct->ndpi_notify_lru_add_handler_ptr) - ndpi_struct->ndpi_notify_lru_add_handler_ptr(ndpi_stun_cache, key_rev, app_proto); } } } diff --git a/src/lib/protocols/tcp_udp.c b/src/lib/protocols/tcp_udp.c index dd25292f5..9aa0349f0 100644 --- a/src/lib/protocols/tcp_udp.c +++ b/src/lib/protocols/tcp_udp.c @@ -21,8 +21,6 @@ #include "ndpi_api.h" -/* ndpi_main.c */ -extern u_int8_t ndpi_is_tor_flow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow); u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, @@ -60,11 +58,6 @@ void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, st if(flow->host_server_name[0] != '\0') return; - if(ndpi_is_tor_flow(ndpi_struct, flow)) { - ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TOR, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); - return; - } - if(packet->udp) sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest); else if(packet->tcp) sport = ntohs(packet->tcp->source), dport = ntohs(packet->tcp->dest); else sport = dport = 0; diff --git a/src/lib/protocols/websocket.c b/src/lib/protocols/websocket.c index 304fa6833..421f239a6 100644 --- a/src/lib/protocols/websocket.c +++ b/src/lib/protocols/websocket.c @@ -50,9 +50,6 @@ static void set_websocket_detected(struct ndpi_detection_module_struct *ndpi_str /* If no custom protocol has been detected */ if (flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { - ndpi_search_tcp_or_udp(ndpi_struct, flow); - - ndpi_int_reset_protocol(flow); ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_WEBSOCKET, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); } } -- cgit v1.2.3