Optimized code to avoid multiple calls to ndpi_network_ptree_match()
HTTP-based subprotocols have not HTTP set as master_protocols
This commit is contained in:
@@ -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,15 @@ 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 {
|
||||
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,6 +70,7 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user