diff --git a/example/reader_util.c b/example/reader_util.c index 9a0e7dc6411..c2229002518 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 080ea431888..5b0e36cde76 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 a07099cfc36..75dada5f513 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 0bf7ae597e2..369e3406867 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)