aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/tcp_udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/protocols/tcp_udp.c')
-rw-r--r--src/lib/protocols/tcp_udp.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/protocols/tcp_udp.c b/src/lib/protocols/tcp_udp.c
index 2c6792551..407d36b3b 100644
--- a/src/lib/protocols/tcp_udp.c
+++ b/src/lib/protocols/tcp_udp.c
@@ -24,7 +24,8 @@
/* ndpi_main.c */
extern u_int8_t ndpi_is_tor_flow(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow);
-u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct,
+u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struct,
+ struct ndpi_flow_struct *flow,
u_int8_t protocol,
u_int32_t saddr, u_int32_t daddr, /* host endianess */
u_int16_t sport, u_int16_t dport) /* host endianess */
@@ -38,12 +39,16 @@ u_int ndpi_search_tcp_or_udp_raw(struct ndpi_detection_module_struct *ndpi_struc
}
}
- host.s_addr = htonl(saddr);
- if((rc = ndpi_network_ptree_match(ndpi_struct, &host)) != NDPI_PROTOCOL_UNKNOWN)
- return (rc);
-
- host.s_addr = htonl(daddr);
- return (ndpi_network_ptree_match(ndpi_struct, &host));
+ if(flow)
+ return(flow->guessed_host_protocol_id);
+ else {
+ host.s_addr = htonl(saddr);
+ if((rc = ndpi_network_ptree_match(ndpi_struct, &host)) != NDPI_PROTOCOL_UNKNOWN)
+ return (rc);
+
+ host.s_addr = htonl(daddr);
+ return (ndpi_network_ptree_match(ndpi_struct, &host));
+ }
}
void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
@@ -66,9 +71,10 @@ void ndpi_search_tcp_or_udp(struct ndpi_detection_module_struct *ndpi_struct, st
if(packet->iph /* IPv4 Only: we need to support packet->iphv6 at some point */) {
proto = ndpi_search_tcp_or_udp_raw(ndpi_struct,
+ flow,
flow->packet.iph ? flow->packet.iph->protocol :
#ifdef NDPI_DETECTION_SUPPORT_IPV6
- flow->packet.iphv6->ip6_ctlun.ip6_un1.ip6_un1_nxt,
+ flow->packet.iphv6->ip6_hdr.ip6_un1_nxt,
#else
0,
#endif