diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2022-07-11 09:47:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 09:47:47 +0200 |
commit | b4cb14ec1922b16a52c24324792f2bd7819f04a7 (patch) | |
tree | b3b7d8f645c8d6c910f0b3c4f80bc3f891db452a /src | |
parent | df599e5effaf1a76a89a014a1f488b27fa88cc52 (diff) |
Keep track of how many dissectors calls we made for each flow (#1657)
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_typedefs.h | 1 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 14 |
2 files changed, 8 insertions, 7 deletions
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index bfbcaddc4..c9718ddbc 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1179,6 +1179,7 @@ struct ndpi_flow_struct { u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category, guessed_header_category; u_int8_t l4_proto, protocol_id_already_guessed:1, host_already_guessed:1, fail_with_unknown:1, init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1, is_ipv6:1; + u_int16_t num_dissector_calls; ndpi_confidence_t confidence; /* ndpi_confidence_t */ /* diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index e2076a158..004283169 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -5187,7 +5187,7 @@ static u_int32_t check_ndpi_detection_func(struct ndpi_detection_module_struct * { void *func = NULL; u_int8_t is_tcp_without_payload = (callback_buffer == ndpi_str->callback_buffer_tcp_no_payload); - u_int32_t num_calls = (is_tcp_without_payload != 0 ? 1 : 0); + u_int32_t num_calls = 0; u_int16_t proto_index = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoIdx; u_int16_t proto_id = ndpi_str->proto_defaults[flow->guessed_protocol_id].protoId; NDPI_PROTOCOL_BITMASK detection_bitmask; @@ -6045,14 +6045,12 @@ static int ndpi_do_guess(struct ndpi_detection_module_struct *ndpi_str, struct n } if(flow->guessed_host_protocol_id >= NDPI_MAX_SUPPORTED_PROTOCOLS) { - //u_int32_t num_calls; NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_packet = {0}; /* This is a custom protocol and it has priority over everything else */ ret->master_protocol = flow->guessed_protocol_id, ret->app_protocol = flow->guessed_host_protocol_id; - //num_calls = - ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet); + flow->num_dissector_calls += ndpi_check_flow_func(ndpi_str, flow, &ndpi_selection_packet); //if(ndpi_str->ndpi_num_custom_protocols != 0) ndpi_fill_protocol_category(ndpi_str, flow, ret); @@ -6311,10 +6309,12 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct flow->tree_risk_checked = 1; } - ndpi_reconcile_protocols(ndpi_str, flow, &ret); - - if(num_calls == 0) + /* It is common to not trigger any dissectors for pure TCP ACK packets */ + if(num_calls == 0 && packet->payload_packet_len != 0) flow->fail_with_unknown = 1; + flow->num_dissector_calls += num_calls; + + ndpi_reconcile_protocols(ndpi_str, flow, &ret); /* Zoom cache */ if((ret.app_protocol == NDPI_PROTOCOL_ZOOM) |