aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorIvan Nardi <12729895+IvanNardi@users.noreply.github.com>2022-09-12 19:28:41 +0200
committerGitHub <noreply@github.com>2022-09-12 19:28:41 +0200
commit4f584f78a0c11ebecfe999e6a728db24efda5e8b (patch)
treef5a80cf2548caec7c31a6557068598a165722e26 /src/lib/ndpi_main.c
parent4bb81f760978d12b4503bd3e7a23f21dbfb758ce (diff)
Fix `ndpi_do_guess()` (#1731)
Avoid a double call of `ndpi_guess_host_protocol_id()`. Some code paths work for ipv4/6 both Remove some never used code.
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c39
1 files changed, 6 insertions, 33 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 1f47daa7c..3922b0517 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -6193,42 +6193,15 @@ static int ndpi_do_guess(struct ndpi_detection_module_struct *ndpi_str, struct n
}
if(user_defined_proto && flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
- if(packet->iph) {
- if(flow->guessed_host_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
- u_int8_t protocol_was_guessed;
+ if(flow->guessed_host_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
+ u_int8_t protocol_was_guessed;
- /* ret->master_protocol = flow->guessed_protocol_id , ret->app_protocol = flow->guessed_host_protocol_id; /\* ****** *\/ */
- *ret = ndpi_detection_giveup(ndpi_str, flow, 0, &protocol_was_guessed);
- }
-
- // if(ndpi_str->ndpi_num_custom_protocols != 0)
- ndpi_fill_protocol_category(ndpi_str, flow, ret);
- return(-1);
+ /* ret->master_protocol = flow->guessed_protocol_id , ret->app_protocol = flow->guessed_host_protocol_id; /\* ****** *\/ */
+ *ret = ndpi_detection_giveup(ndpi_str, flow, 0, &protocol_was_guessed);
}
- } else {
- /* guess host protocol */
- if(packet->iph) {
- flow->guessed_host_protocol_id = ndpi_guess_host_protocol_id(ndpi_str, flow);
- /*
- We could implement a shortcut here skipping dissectors for
- protocols we have identified by other means such as with the IP
-
- However we do NOT stop here and skip invoking the dissectors
- because we want to dissect the flow (e.g. dissect the TLS)
- and extract metadata.
- */
-#if SKIP_INVOKING_THE_DISSECTORS
- if(flow->guessed_host_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
- /*
- We have identified a protocol using the IP address so
- it is not worth to dissect the traffic as we already have
- the solution
- */
- ret->master_protocol = flow->guessed_protocol_id, ret->app_protocol = flow->guessed_host_protocol_id;
- }
-#endif
- }
+ ndpi_fill_protocol_category(ndpi_str, flow, ret);
+ return(-1);
}
}