aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2015-10-26 01:34:39 +0100
committerLuca Deri <deri@ntop.org>2015-10-26 01:34:39 +0100
commit8edd6289734c4e45b53eb942b16e54d1c7010de1 (patch)
treefdb7023a54951c8b80205ecb06d4b1f1b630a447 /src
parent50e7e959fe93e18872df17335ae7ea7a5293ee39 (diff)
Minor core reorganization
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_main.c12
-rw-r--r--src/lib/protocols/http.c25
2 files changed, 19 insertions, 18 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 7f93d9be7..e9fbeb49d 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2021,7 +2021,7 @@ void ndpi_set_bitmask_protocol_detection( char * label,
}
/*
- Set funcition and index protocol within proto_default strcuture for port protocol detection
+ Set function and index protocol within proto_default strcuture for port protocol detection
and callback_buffer function for DPI protocol detection
*/
ndpi_struct->proto_defaults[ndpi_protocol_id].protoIdx = idx;
@@ -2596,7 +2596,8 @@ static u_int8_t ndpi_iph_is_valid_and_not_fragmented(const struct ndpi_iphdr *ip
}
static u_int8_t ndpi_detection_get_l4_internal(struct ndpi_detection_module_struct *ndpi_struct,
- const u_int8_t * l3, u_int16_t l3_len, const u_int8_t ** l4_return, u_int16_t * l4_len_return,
+ const u_int8_t * l3, u_int16_t l3_len,
+ const u_int8_t ** l4_return, u_int16_t * l4_len_return,
u_int8_t * l4_protocol_return, u_int32_t flags)
{
const struct ndpi_iphdr *iph = NULL;
@@ -3048,8 +3049,7 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
ndpi_struct->callback_buffer[proto_index].excluded_protocol_bitmask) == 0
&& NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer[proto_index].detection_bitmask,
detection_bitmask) != 0
- && (ndpi_struct->callback_buffer[proto_index].ndpi_selection_bitmask
- & *ndpi_selection_packet) == ndpi_struct->callback_buffer[proto_index].ndpi_selection_bitmask) {
+ && (ndpi_struct->callback_buffer[proto_index].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_struct->callback_buffer[proto_index].ndpi_selection_bitmask) {
if((flow->guessed_protocol_id != NDPI_PROTOCOL_UNKNOWN)
&& (ndpi_struct->proto_defaults[flow->guessed_protocol_id].func != NULL))
ndpi_struct->proto_defaults[flow->guessed_protocol_id].func(ndpi_struct, flow),
@@ -3059,8 +3059,7 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) {
for(a = 0; a < ndpi_struct->callback_buffer_size_tcp_payload; a++) {
if((func != ndpi_struct->callback_buffer_tcp_payload[a].func)
- && (ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
- & *ndpi_selection_packet) == ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
+ && (ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_struct->callback_buffer_tcp_payload[a].ndpi_selection_bitmask
&& NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask,
ndpi_struct->callback_buffer_tcp_payload[a].excluded_protocol_bitmask) == 0
&& NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_tcp_payload[a].detection_bitmask,
@@ -3262,7 +3261,6 @@ ndpi_protocol ndpi_detection_process_packet(struct ndpi_detection_module_struct
}
#if 0
-
/* Swap protocols in case of success */
if(ret.master_protocol != NDPI_PROTOCOL_UNKNOWN) {
u_int16_t t = ret.master_protocol;
diff --git a/src/lib/protocols/http.c b/src/lib/protocols/http.c
index 583adb341..9314dba65 100644
--- a/src/lib/protocols/http.c
+++ b/src/lib/protocols/http.c
@@ -204,16 +204,16 @@ static void parseHttpSubprotocol(struct ndpi_detection_module_struct *ndpi_struc
NOTE
If http_dont_dissect_response = 1 dissection of HTTP response
- mime types won't happen
+ mime types won't happen
*/
if(!ndpi_struct->http_dont_dissect_response) {
if(flow->http.url && flow->http_detected)
- ndpi_match_host_subprotocol(ndpi_struct, flow, (char *)&flow->http.url[7],
+ ndpi_match_host_subprotocol(ndpi_struct, flow, (char *)&flow->http.url[7],
strlen((const char *)&flow->http.url[7]),
NDPI_PROTOCOL_HTTP);
} else
- ndpi_match_host_subprotocol(ndpi_struct, flow, (char *)flow->host_server_name,
+ ndpi_match_host_subprotocol(ndpi_struct, flow, (char *)flow->host_server_name,
strlen((const char *)flow->host_server_name),
NDPI_PROTOCOL_HTTP);
}
@@ -247,7 +247,7 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
if(flow->http.url) {
strncpy(flow->http.url, "http://", 7);
strncpy(&flow->http.url[7], (char*)packet->host_line.ptr, packet->host_line.len);
- strncpy(&flow->http.url[7+packet->host_line.len], (char*)packet->http_url_name.ptr,
+ strncpy(&flow->http.url[7+packet->host_line.len], (char*)packet->http_url_name.ptr,
packet->http_url_name.len);
flow->http.url[len-1] = '\0';
}
@@ -282,8 +282,8 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
flow->http.content_type = ndpi_malloc(len);
if(flow->http.content_type) {
- strncpy(flow->http.content_type, (char*)packet->content_line.ptr,
- packet->content_line.len);
+ strncpy(flow->http.content_type, (char*)packet->content_line.ptr,
+ packet->content_line.len);
flow->http.content_type[packet->content_line.len] = '\0';
}
}
@@ -352,8 +352,8 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
#if 0
if((ndpi_struct->http_dont_dissect_response) || flow->http_detected)
- ndpi_match_content_subprotocol(ndpi_struct, flow,
- (char*)packet->user_agent_line.ptr,
+ ndpi_match_content_subprotocol(ndpi_struct, flow,
+ (char*)packet->user_agent_line.ptr,
packet->user_agent_line.len,
NDPI_PROTOCOL_HTTP);
#endif
@@ -367,11 +367,11 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
packet->host_line.len, packet->host_line.ptr);
if((ndpi_struct->http_dont_dissect_response) || flow->http_detected)
- ndpi_match_host_subprotocol(ndpi_struct, flow,
- (char*)packet->host_line.ptr,
+ ndpi_match_host_subprotocol(ndpi_struct, flow,
+ (char*)packet->host_line.ptr,
packet->host_line.len,
NDPI_PROTOCOL_HTTP);
-
+
/* Copy result for nDPI apps */
len = ndpi_min(packet->host_line.len, sizeof(flow->host_server_name)-1);
strncpy((char*)flow->host_server_name, (char*)packet->host_line.ptr, len);
@@ -771,6 +771,8 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct
struct ndpi_packet_struct *packet = &flow->packet;
u_int16_t filename_start;
+ packet->packet_lines_parsed_complete = 0;
+
/* Check if we so far detected the protocol in the request or not. */
if(flow->l4.tcp.http_stage == 0) {
flow->http_detected = 0;
@@ -911,6 +913,7 @@ static void ndpi_check_http_tcp(struct ndpi_detection_module_struct *ndpi_struct
"HTTP START Found in 2. packet, we will look further for the response....\n");
flow->http_detected = 1;
}
+
return;
}