aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2017-09-24 22:49:07 +0200
committerLuca Deri <deri@ntop.org>2017-09-24 22:49:07 +0200
commitc115903fbb4df21c489226900a739cccd3f8f057 (patch)
tree8956a077f2c9b923f7a783a52696428801027765 /src
parent8939a72ea866d7a3aeaa86346a08f73b48d3ac4f (diff)
Patch for giving prority in case of match to custom-defined protocols
Diffstat (limited to 'src')
-rw-r--r--src/include/ndpi_api.h13
-rw-r--r--src/lib/ndpi_main.c26
2 files changed, 24 insertions, 15 deletions
diff --git a/src/include/ndpi_api.h b/src/include/ndpi_api.h
index 7d9c1bab7..ce8489829 100644
--- a/src/include/ndpi_api.h
+++ b/src/include/ndpi_api.h
@@ -233,13 +233,12 @@ extern "C" {
*
*/
void ndpi_process_extra_packet(struct ndpi_detection_module_struct *ndpi_struct,
- struct ndpi_flow_struct *flow,
- const unsigned char *packet,
- const unsigned short packetlen,
- const u_int64_t current_tick,
- struct ndpi_id_struct *src,
- struct ndpi_id_struct *dst);
-
+ struct ndpi_flow_struct *flow,
+ const unsigned char *packet,
+ const unsigned short packetlen,
+ const u_int64_t current_tick,
+ struct ndpi_id_struct *src,
+ struct ndpi_id_struct *dst);
/**
* Processes one packet and returns the ID of the detected protocol.
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 917b074ea..93a1d062b 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -3478,13 +3478,12 @@ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_st
/* ********************************************************************************* */
void ndpi_process_extra_packet(struct ndpi_detection_module_struct *ndpi_struct,
- struct ndpi_flow_struct *flow,
- const unsigned char *packet,
- const unsigned short packetlen,
- const u_int64_t current_tick_l,
- struct ndpi_id_struct *src,
- struct ndpi_id_struct *dst)
-{
+ struct ndpi_flow_struct *flow,
+ const unsigned char *packet,
+ const unsigned short packetlen,
+ const u_int64_t current_tick_l,
+ struct ndpi_id_struct *src,
+ struct ndpi_id_struct *dst) {
if(flow == NULL)
return;
@@ -3615,8 +3614,13 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
/* guess protocol */
flow->guessed_protocol_id = (int16_t) ndpi_guess_protocol_id(ndpi_struct, protocol, sport, dport, &user_defined_proto);
- if(user_defined_proto && flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
+ if(flow->guessed_protocol_id >= (NDPI_MAX_SUPPORTED_PROTOCOLS-1)) {
+ /* This is a custom protocol and it has priority over everything else */
+ ret.master_protocol = flow->guessed_protocol_id, ret.app_protocol = NDPI_PROTOCOL_UNKNOWN;
+ return(ret);
+ }
+ if(user_defined_proto && flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN) {
if(flow->packet.iph) {
/* guess host protocol */
flow->guessed_host_protocol_id = ndpi_network_ptree_match(ndpi_struct, (struct in_addr *)&flow->packet.iph->saddr);
@@ -3638,6 +3642,12 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
}
}
+ if(flow->guessed_host_protocol_id >= (NDPI_MAX_SUPPORTED_PROTOCOLS-1)) {
+ /* This is a custom protocol and it has priority over everything else */
+ ret.master_protocol = flow->guessed_host_protocol_id, ret.app_protocol = NDPI_PROTOCOL_UNKNOWN;
+ return(ret);
+ }
+
check_ndpi_flow_func(ndpi_struct, flow, &ndpi_selection_packet);
a = flow->packet.detected_protocol_stack[0];