This commit is contained in:
Luca Deri
2019-07-15 23:53:28 +02:00
parent 67dfddd065
commit f570eccf81
2 changed files with 26 additions and 10 deletions
+20 -8
View File
@@ -3402,7 +3402,7 @@ static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_stru
#ifdef NDPI_DETECTION_SUPPORT_IPV6
else if(iph->version == 6 && l3_len >= sizeof(struct ndpi_ipv6hdr)) {
NDPI_LOG_DBG2(ndpi_struct, "ipv6 header\n");
iph_v6 = (const struct ndpi_ipv6hdr *) iph;
iph_v6 = (const struct ndpi_ipv6hdr *) l3;
iph = NULL;
}
#endif
@@ -3906,11 +3906,17 @@ u_int16_t ndpi_guess_host_protocol_id(struct ndpi_detection_module_struct *ndpi_
u_int16_t ret = NDPI_PROTOCOL_UNKNOWN;
if(flow->packet.iph) {
/* guess host protocol */
ret = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->saddr);
struct in_addr addr;
if(ret == NDPI_PROTOCOL_UNKNOWN)
ret = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->daddr);
addr.s_addr = flow->packet.iph->saddr;
/* guess host protocol */
ret = ndpi_network_ptree_match(ndpi_struct, &addr);
if(ret == NDPI_PROTOCOL_UNKNOWN) {
addr.s_addr = flow->packet.iph->daddr;
ret = ndpi_network_ptree_match(ndpi_struct, &addr);
}
}
return(ret);
@@ -4533,9 +4539,15 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
} else {
/* guess host protocol */
if(flow->packet.iph) {
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->saddr);
if(flow->guessed_host_protocol_id == NDPI_PROTOCOL_UNKNOWN)
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->daddr);
struct in_addr addr;
addr.s_addr = flow->packet.iph->saddr;
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, &addr);
if(flow->guessed_host_protocol_id == NDPI_PROTOCOL_UNKNOWN) {
addr.s_addr = flow->packet.iph->daddr;
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, &addr);
}
}
}
}
+6 -2
View File
@@ -62,8 +62,12 @@ static u_int8_t is_google_flow(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_packet_struct *packet = &flow->packet;
if(packet->iph) {
if(google_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->saddr)
|| google_ptree_match(ndpi_struct, (struct in_addr *)&packet->iph->daddr)) {
struct in_addr saddr, daddr;
saddr.s_addr = packet->iph->saddr, daddr.s_addr = packet->iph->daddr;
if(google_ptree_match(ndpi_struct, &saddr)
|| google_ptree_match(ndpi_struct, &daddr)) {
return(1);
}
}