Improved flow category guess
This commit is contained in:
@@ -1027,7 +1027,7 @@ struct ndpi_flow_struct {
|
|||||||
u_int16_t protocol_stack_info;
|
u_int16_t protocol_stack_info;
|
||||||
|
|
||||||
/* init parameter, internal used to set up timestamp,... */
|
/* init parameter, internal used to set up timestamp,... */
|
||||||
u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category;
|
u_int16_t guessed_protocol_id, guessed_host_protocol_id, guessed_category, guessed_header_category;
|
||||||
u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1;
|
u_int8_t protocol_id_already_guessed:1, host_already_guessed:1, init_finished:1, setup_packet_direction:1, packet_direction:1, check_extra_packets:1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
+14
-7
@@ -3744,11 +3744,10 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
#endif /* NDPI_DETECTION_SUPPORT_IPV6 */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flow) {
|
if(flow)
|
||||||
ndpi_apply_flow_protocol_to_packet(flow, &flow->packet);
|
ndpi_apply_flow_protocol_to_packet(flow, &flow->packet);
|
||||||
} else {
|
else
|
||||||
ndpi_int_reset_packet_protocol(&flow->packet);
|
ndpi_int_reset_packet_protocol(&flow->packet);
|
||||||
}
|
|
||||||
|
|
||||||
l3len = flow->packet.l3_packet_len;
|
l3len = flow->packet.l3_packet_len;
|
||||||
|
|
||||||
@@ -4186,6 +4185,7 @@ static ndpi_protocol ndpi_process_partial_detection(struct ndpi_detection_module
|
|||||||
ret.app_protocol = ret.master_protocol;
|
ret.app_protocol = ret.master_protocol;
|
||||||
|
|
||||||
ndpi_fill_protocol_category(ndpi_struct, flow, &ret);
|
ndpi_fill_protocol_category(ndpi_struct, flow, &ret);
|
||||||
|
|
||||||
ndpi_int_change_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
|
ndpi_int_change_protocol(ndpi_struct, flow, ret.app_protocol, ret.master_protocol);
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
@@ -4588,6 +4588,7 @@ int ndpi_fill_ip_protocol_category(struct ndpi_detection_module_struct *ndpi_str
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret->category = ndpi_get_proto_category(ndpi_struct, *ret);
|
ret->category = ndpi_get_proto_category(ndpi_struct, *ret);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4597,12 +4598,10 @@ void ndpi_fill_protocol_category(struct ndpi_detection_module_struct *ndpi_struc
|
|||||||
struct ndpi_flow_struct *flow,
|
struct ndpi_flow_struct *flow,
|
||||||
ndpi_protocol *ret) {
|
ndpi_protocol *ret) {
|
||||||
if(ndpi_struct->custom_categories.categories_loaded) {
|
if(ndpi_struct->custom_categories.categories_loaded) {
|
||||||
if(flow->packet.iph) {
|
if(flow->guessed_header_category != NDPI_PROTOCOL_CATEGORY_UNSPECIFIED) {
|
||||||
if(ndpi_fill_ip_protocol_category(ndpi_struct, flow->packet.iph->saddr, flow->packet.iph->daddr, ret)) {
|
flow->category = flow->guessed_header_category;
|
||||||
flow->category = ret->category;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(flow->host_server_name[0] != '\0') {
|
if(flow->host_server_name[0] != '\0') {
|
||||||
unsigned long id;
|
unsigned long id;
|
||||||
@@ -4731,6 +4730,14 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
|
|||||||
flow->guessed_protocol_id = (int16_t) ndpi_guess_protocol_id(ndpi_struct, flow, protocol, sport, dport, &user_defined_proto);
|
flow->guessed_protocol_id = (int16_t) ndpi_guess_protocol_id(ndpi_struct, flow, protocol, sport, dport, &user_defined_proto);
|
||||||
flow->guessed_host_protocol_id = ndpi_guess_host_protocol_id(ndpi_struct, flow);
|
flow->guessed_host_protocol_id = ndpi_guess_host_protocol_id(ndpi_struct, flow);
|
||||||
|
|
||||||
|
if(ndpi_struct->custom_categories.categories_loaded && flow->packet.iph) {
|
||||||
|
ndpi_protocol ret;
|
||||||
|
|
||||||
|
ndpi_fill_ip_protocol_category(ndpi_struct, flow->packet.iph->saddr, flow->packet.iph->daddr, &ret);
|
||||||
|
flow->guessed_header_category = ret.category;
|
||||||
|
} else
|
||||||
|
flow->guessed_header_category = NDPI_PROTOCOL_CATEGORY_UNSPECIFIED;
|
||||||
|
|
||||||
if(flow->guessed_protocol_id >= (NDPI_MAX_SUPPORTED_PROTOCOLS-1)) {
|
if(flow->guessed_protocol_id >= (NDPI_MAX_SUPPORTED_PROTOCOLS-1)) {
|
||||||
/* This is a custom protocol and it has priority over everything else */
|
/* This is a custom protocol and it has priority over everything else */
|
||||||
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN,
|
ret.master_protocol = NDPI_PROTOCOL_UNKNOWN,
|
||||||
|
|||||||
Reference in New Issue
Block a user