diff options
author | Luca Deri <deri@ntop.org> | 2024-11-29 17:13:43 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2024-11-29 17:13:43 +0100 |
commit | b1d1f8cfe09f6ae9525e047dd54bc043a7e83520 (patch) | |
tree | 7d4d5064654fa4d2e3fd8143e30537f4d385aa34 /src | |
parent | 74792e49c810824588c3eb6fe195b1af34674a79 (diff) |
STUN counter changes
Diffstat (limited to 'src')
-rw-r--r-- | src/include/ndpi_typedefs.h | 3 | ||||
-rw-r--r-- | src/lib/protocols/stun.c | 25 |
2 files changed, 10 insertions, 18 deletions
diff --git a/src/include/ndpi_typedefs.h b/src/include/ndpi_typedefs.h index a07099cfc..75dada5f5 100644 --- a/src/include/ndpi_typedefs.h +++ b/src/include/ndpi_typedefs.h @@ -1371,7 +1371,8 @@ struct ndpi_flow_struct { struct { u_int8_t maybe_dtls : 1, is_turn : 1, pad : 6; ndpi_address_port mapped_address, peer_address, relayed_address, response_origin, other_address; - u_int8_t num_mapped_address, num_relayed_address, num_non_stun_pkts, last_first_byte, num_stun_transitions; /* SRTP */ + u_int8_t num_xor_relayed_addresses, num_xor_mapped_addresses; + u_int8_t num_non_stun_pkt, non_stun_pkt_len[2]; } stun; struct { diff --git a/src/lib/protocols/stun.c b/src/lib/protocols/stun.c index 0bf7ae597..369e34068 100644 --- a/src/lib/protocols/stun.c +++ b/src/lib/protocols/stun.c @@ -617,7 +617,7 @@ int is_stun(struct ndpi_detection_module_struct *ndpi_struct, &flow->stun.mapped_address, flow->monit ? &flow->monit->protos.dtls_stun_rtp.mapped_address : NULL, transaction_id, magic_cookie, 0); - flow->stun.num_mapped_address++; + flow->stun.num_xor_mapped_addresses++; } break; @@ -628,7 +628,7 @@ int is_stun(struct ndpi_detection_module_struct *ndpi_struct, &flow->stun.relayed_address, flow->monit ? &flow->monit->protos.dtls_stun_rtp.relayed_address : NULL, transaction_id, magic_cookie, 0); - flow->stun.num_relayed_address++; + flow->stun.num_xor_relayed_addresses++; } break; @@ -664,22 +664,13 @@ static int keep_extra_dissection(struct ndpi_detection_module_struct *ndpi_struc * classification doesn't change while in monitoring! */ - if(packet->payload_packet_len > 0) { - bool is_stun_pkt = true; + if((packet->payload[0] != 0x0) && (packet->payload[0] != 0x1)) { + if(flow->stun.num_non_stun_pkt < 2) { + flow->stun.non_stun_pkt_len[flow->stun.num_non_stun_pkt++] = packet->payload_packet_len; - if((packet->payload[0] != 0x0) && (packet->payload[0] != 0x1)) - flow->stun.num_non_stun_pkts++, is_stun_pkt = false; - - if(flow->packet_counter > 1) { - if((flow->stun.last_first_byte != 0x0) && (flow->stun.last_first_byte != 0x1)) { - if(is_stun_pkt) - flow->stun.num_stun_transitions++; - } else { - if(!is_stun_pkt) - flow->stun.num_stun_transitions++; - } - } - flow->stun.last_first_byte = packet->payload[0]; + if(flow->stun.num_non_stun_pkt == 2) + printf("%d %d\n", flow->stun.non_stun_pkt_len[0], flow->stun.non_stun_pkt_len[1]); + } } if(flow->monitoring) |