🐛 use protocol_was_guessed in ndpi_detection_giveup

This commit is contained in:
Leonn Paiva 2020-04-22 03:48:12 -03:00
parent 4d5ca2c473
commit 6769168d89

View file

@ -4125,10 +4125,13 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
goto check_stun_export;
else if ((flow->guessed_protocol_id == NDPI_PROTOCOL_HANGOUT_DUO) ||
(flow->guessed_protocol_id == NDPI_PROTOCOL_MESSENGER) ||
(flow->guessed_protocol_id == NDPI_PROTOCOL_WHATSAPP_CALL))
(flow->guessed_protocol_id == NDPI_PROTOCOL_WHATSAPP_CALL)) {
*protocol_was_guessed = 1;
ndpi_set_detected_protocol(ndpi_str, flow, flow->guessed_protocol_id, NDPI_PROTOCOL_UNKNOWN);
}
else if ((flow->l4.tcp.tls.hello_processed == 1) &&
(flow->protos.stun_ssl.ssl.client_requested_server_name[0] != '\0')) {
*protocol_was_guessed = 1;
ndpi_set_detected_protocol(ndpi_str, flow, NDPI_PROTOCOL_TLS, NDPI_PROTOCOL_UNKNOWN);
} else if (enable_guess) {
if ((flow->guessed_protocol_id == NDPI_PROTOCOL_UNKNOWN) && (flow->packet.l4_protocol == IPPROTO_TCP) &&
@ -4169,18 +4172,25 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
guessed_host_protocol_id = ret_match.protocol_id;
}
*protocol_was_guessed = 1;
ndpi_int_change_protocol(ndpi_str, flow, guessed_host_protocol_id, guessed_protocol_id);
}
}
} else if (enable_guess) {
if (flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
if (flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
*protocol_was_guessed = 1;
flow->detected_protocol_stack[1] = flow->guessed_protocol_id;
}
if (flow->guessed_host_protocol_id != NDPI_PROTOCOL_UNKNOWN)
if (flow->guessed_host_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
*protocol_was_guessed = 1;
flow->detected_protocol_stack[0] = flow->guessed_host_protocol_id;
}
if (flow->detected_protocol_stack[1] == flow->detected_protocol_stack[0])
if (flow->detected_protocol_stack[1] == flow->detected_protocol_stack[0]) {
*protocol_was_guessed = 1;
flow->detected_protocol_stack[1] = flow->guessed_host_protocol_id;
}
}
if ((flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) &&
@ -4188,6 +4198,7 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
check_stun_export:
if (flow->protos.stun_ssl.stun.num_processed_pkts || flow->protos.stun_ssl.stun.num_udp_pkts) {
// if(/* (flow->protos.stun_ssl.stun.num_processed_pkts >= NDPI_MIN_NUM_STUN_DETECTION) */
*protocol_was_guessed = 1;
ndpi_set_detected_protocol(ndpi_str, flow, flow->guessed_host_protocol_id, NDPI_PROTOCOL_STUN);
}
}
@ -4199,16 +4210,18 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
ret.app_protocol = NDPI_PROTOCOL_MESSENGER;
else if (ret.app_protocol == NDPI_PROTOCOL_GOOGLE) {
/*
As Google has recently introduced Duo,
we need to distinguish between it and hangout
thing that should be handled by the STUN dissector
*/
As Google has recently introduced Duo,
we need to distinguish between it and hangout
thing that should be handled by the STUN dissector
*/
ret.app_protocol = NDPI_PROTOCOL_HANGOUT_DUO;
}
}
if (ret.app_protocol != NDPI_PROTOCOL_UNKNOWN)
if (ret.app_protocol != NDPI_PROTOCOL_UNKNOWN) {
*protocol_was_guessed = 1;
ndpi_fill_protocol_category(ndpi_str, flow, &ret);
}
return (ret);
}