Fix packet counters (#1884)

We need to keep separete counters to keep tracks of packet numbers with
and without any payload.

Regression introduced in 5849863ef
This commit is contained in:
Ivan Nardi
2023-02-13 11:32:17 +01:00
committed by GitHub
parent 200d1d4cfc
commit f10178f8d2
46 changed files with 50 additions and 50 deletions
+3 -3
View File
@@ -1522,9 +1522,9 @@ struct ndpi_flow_struct {
/* Only packets with L5 data (ie no TCP SYN, pure ACKs, ...) */
u_int16_t packet_counter; // can be 0 - 65000
u_int16_t packet_direction_counter[2];
u_int16_t all_packets_counter; /* All packets even those without payload */
/* Every packets */
/* All packets even those without payload */
u_int16_t all_packets_counter;
u_int16_t packet_direction_complete_counter[2]; // can be 0 - 65000
/* NDPI_PROTOCOL_BITTORRENT */
+3 -3
View File
@@ -5609,7 +5609,7 @@ void ndpi_connection_tracking(struct ndpi_detection_module_struct *ndpi_str,
flow->all_packets_counter++;
if((flow->packet_direction_counter[packet->packet_direction] < MAX_PACKET_COUNTER)
/* && packet->payload_packet_len */) {
&& packet->payload_packet_len) {
flow->packet_direction_counter[packet->packet_direction]++;
}
@@ -6045,7 +6045,7 @@ static void ndpi_add_connection_as_zoom(struct ndpi_detection_module_struct *ndp
static void ndpi_check_tcp_flags(struct ndpi_detection_module_struct *ndpi_str,
struct ndpi_flow_struct *flow) {
#if 0
printf("[TOTAL] %u / %u [tot: %u]\n", flow->packet_direction_counter[0], flow->packet_direction_counter[1], flow->all_packets_counter);
printf("[TOTAL] %u / %u [tot: %u]\n", flow->packet_direction_complete_counter[0], flow->packet_direction_complete_counter[1], flow->all_packets_counter);
#endif
if((flow->l4.tcp.cli2srv_tcp_flags & TH_SYN)
@@ -6058,7 +6058,7 @@ static void ndpi_check_tcp_flags(struct ndpi_detection_module_struct *ndpi_str,
&& (flow->all_packets_counter < 5 /* Ignore connections terminated by RST but that exchanged data (3WH + RST) */)
)
ndpi_set_risk(ndpi_str, flow, NDPI_TCP_ISSUES, "Connection refused (client)");
else if((flow->l4.tcp.srv2cli_tcp_flags & TH_RST) && (flow->packet_direction_counter[1 /* server -> client */] == 1))
else if((flow->l4.tcp.srv2cli_tcp_flags & TH_RST) && (flow->packet_direction_complete_counter[1 /* server -> client */] == 1))
ndpi_set_risk(ndpi_str, flow, NDPI_TCP_ISSUES, "TCP probing attempt");
}