diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_main.c | 47 | ||||
-rw-r--r-- | src/lib/protocols/eaq.c | 8 |
2 files changed, 34 insertions, 21 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index 56a9bfa5d..3a420607e 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -3474,24 +3474,23 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str u_int8_t l4protocol; u_int8_t l4_result; - if(flow) { - /* reset payload_packet_len, will be set if ipv4 tcp or udp */ - flow->packet.payload_packet_len = 0; - flow->packet.l4_packet_len = 0; - flow->packet.l3_packet_len = packetlen; - - flow->packet.tcp = NULL; - flow->packet.udp = NULL; - flow->packet.generic_l4_ptr = NULL; + if (!flow) { + return 1; + } + + /* reset payload_packet_len, will be set if ipv4 tcp or udp */ + flow->packet.payload_packet_len = 0; + flow->packet.l4_packet_len = 0; + flow->packet.l3_packet_len = packetlen; + + flow->packet.tcp = NULL; + flow->packet.udp = NULL; + flow->packet.generic_l4_ptr = NULL; #ifdef NDPI_DETECTION_SUPPORT_IPV6 - flow->packet.iphv6 = NULL; + flow->packet.iphv6 = NULL; #endif /* NDPI_DETECTION_SUPPORT_IPV6 */ - } - if(flow) - ndpi_apply_flow_protocol_to_packet(flow, &flow->packet); - else - ndpi_int_reset_packet_protocol(&flow->packet); + ndpi_apply_flow_protocol_to_packet(flow, &flow->packet); l3len = flow->packet.l3_packet_len; @@ -3557,7 +3556,7 @@ static int ndpi_init_packet_header(struct ndpi_detection_module_struct *ndpi_str /* check for new tcp syn packets, here * idea: reset detection state if a connection is unknown */ - if(flow && flow->packet.tcp->syn != 0 + if(flow->packet.tcp->syn != 0 && flow->packet.tcp->ack == 0 && flow->init_finished != 0 && flow->detected_protocol_stack[0] == NDPI_PROTOCOL_UNKNOWN) { @@ -3605,6 +3604,10 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct, const struct ndpi_tcphdr *tcph = packet->tcp; const struct ndpi_udphdr *udph = flow->packet.udp; + if (!flow) { + return; + } + packet->tcp_retransmission = 0, packet->packet_direction = 0; if(ndpi_struct->direction_detect_disable) { @@ -3621,8 +3624,6 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct, } packet->packet_lines_parsed_complete = 0; - if(flow == NULL) - return; if(flow->init_finished == 0) { flow->init_finished = 1; @@ -3717,6 +3718,11 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_struct, void check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow, NDPI_SELECTION_BITMASK_PROTOCOL_SIZE *ndpi_selection_packet) { + + if (!flow) { + return; + } + void *func = NULL; u_int32_t a; u_int16_t proto_index = ndpi_struct->proto_defaults[flow->guessed_protocol_id].protoIdx; @@ -3742,10 +3748,9 @@ void check_ndpi_other_flow_func(struct ndpi_detection_module_struct *ndpi_struct if((func != ndpi_struct->callback_buffer_non_tcp_udp[a].func) && (ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask & *ndpi_selection_packet) == ndpi_struct->callback_buffer_non_tcp_udp[a].ndpi_selection_bitmask - && (flow == NULL - || + && NDPI_BITMASK_COMPARE(flow->excluded_protocol_bitmask, - ndpi_struct->callback_buffer_non_tcp_udp[a].excluded_protocol_bitmask) == 0) + ndpi_struct->callback_buffer_non_tcp_udp[a].excluded_protocol_bitmask) == 0 && NDPI_BITMASK_COMPARE(ndpi_struct->callback_buffer_non_tcp_udp[a].detection_bitmask, detection_bitmask) != 0) { diff --git a/src/lib/protocols/eaq.c b/src/lib/protocols/eaq.c index 8768cac6f..e86b83181 100644 --- a/src/lib/protocols/eaq.c +++ b/src/lib/protocols/eaq.c @@ -41,7 +41,15 @@ static void ndpi_int_eaq_add_connection(struct ndpi_detection_module_struct *ndp void ndpi_search_eaq(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { + if (!flow) { + return; + } + struct ndpi_packet_struct *packet = &flow->packet; + if (!packet) { + return; + } + u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest); NDPI_LOG_DBG(ndpi_struct, "search eaq\n"); |