aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2024-11-29 17:13:43 +0100
committerLuca Deri <deri@ntop.org>2024-11-29 17:13:43 +0100
commitb1d1f8cfe09f6ae9525e047dd54bc043a7e83520 (patch)
tree7d4d5064654fa4d2e3fd8143e30537f4d385aa34
parent74792e49c810824588c3eb6fe195b1af34674a79 (diff)
STUN counter changes
-rw-r--r--example/reader_util.c8
-rw-r--r--example/reader_util.h1
-rw-r--r--src/include/ndpi_typedefs.h3
-rw-r--r--src/lib/protocols/stun.c25
4 files changed, 10 insertions, 27 deletions
diff --git a/example/reader_util.c b/example/reader_util.c
index 9a0e7dc64..c22290025 100644
--- a/example/reader_util.c
+++ b/example/reader_util.c
@@ -1198,10 +1198,6 @@ static void process_ndpi_monitoring_info(struct ndpi_flow_info *flow) {
add_to_address_port_list(&flow->stun.peer_address, &flow->ndpi_flow->monit->protos.dtls_stun_rtp.peer_address);
add_to_address_port_list(&flow->stun.relayed_address, &flow->ndpi_flow->monit->protos.dtls_stun_rtp.relayed_address);
add_to_address_port_list(&flow->stun.response_origin, &flow->ndpi_flow->monit->protos.dtls_stun_rtp.response_origin);
- flow->stun.num_mapped_address = flow->ndpi_flow->stun.num_mapped_address;
- flow->stun.num_relayed_address = flow->ndpi_flow->stun.num_relayed_address;
- flow->stun.num_non_stun_pkts = flow->ndpi_flow->stun.num_non_stun_pkts;
- flow->stun.num_stun_transitions = flow->ndpi_flow->stun.num_stun_transitions;
flow->multimedia_flow_types |= flow->ndpi_flow->flow_multimedia_types;
}
}
@@ -1609,10 +1605,6 @@ void process_ndpi_collected_info(struct ndpi_workflow * workflow, struct ndpi_fl
add_to_address_port_list(&flow->stun.relayed_address, &flow->ndpi_flow->stun.relayed_address);
add_to_address_port_list(&flow->stun.response_origin, &flow->ndpi_flow->stun.response_origin);
add_to_address_port_list(&flow->stun.other_address, &flow->ndpi_flow->stun.other_address);
- flow->stun.num_mapped_address = flow->ndpi_flow->stun.num_mapped_address;
- flow->stun.num_relayed_address = flow->ndpi_flow->stun.num_relayed_address;
- flow->stun.num_non_stun_pkts = flow->ndpi_flow->stun.num_non_stun_pkts;
- flow->stun.num_stun_transitions = flow->ndpi_flow->stun.num_stun_transitions;
}
flow->multimedia_flow_types |= flow->ndpi_flow->flow_multimedia_types;
diff --git a/example/reader_util.h b/example/reader_util.h
index 080ea4318..5b0e36cde 100644
--- a/example/reader_util.h
+++ b/example/reader_util.h
@@ -323,7 +323,6 @@ typedef struct ndpi_flow_info {
struct {
ndpi_address_port_list mapped_address, peer_address,
relayed_address, response_origin, other_address;
- u_int8_t num_mapped_address, num_relayed_address, num_non_stun_pkts, num_stun_transitions;
} stun;
struct {
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)