diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2023-02-13 11:32:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-13 11:32:17 +0100 |
commit | f10178f8d29136732f879431030d163d9f751caa (patch) | |
tree | 1c710e5d3a6984c60f71d05abdfeec0bcc9e51bc /src | |
parent | 200d1d4cfcb9e8c02e91834481ffc716e796cfc3 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_typedefs.h | 6 | ||||
-rw-r--r-- | src/lib/ndpi_main.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index bd811f6a2..7a0eca9d5 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -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 */ diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c index e32f9dce8..2df9dd0cc 100644 --- a/src/lib/ndpi_main.c +++ b/src/lib/ndpi_main.c @@ -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"); } |