Simplify the report of streaming multimedia info (#2026)

The two fields `flow->flow_type` and `flow->protos.rtp.stream_type` are
pretty much identical: rename the former in `flow->flow_multimedia_type`
and remove the latter.
This commit is contained in:
Ivan Nardi
2023-06-26 12:05:16 +02:00
committed by GitHub
parent 3a1600ff26
commit 88425e0199
11 changed files with 24 additions and 95 deletions
+1 -13
View File
@@ -1363,14 +1363,6 @@ struct ndpi_risk_information {
char *info;
};
enum ndpi_rtp_stream_type {
rtp_unknown = 0,
rtp_audio,
rtp_video,
rtp_audio_video,
rtp_screen_share
};
struct ndpi_flow_struct {
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
@@ -1453,7 +1445,7 @@ struct ndpi_flow_struct {
char *nat_ip; /* Via HTTP X-Forwarded-For */
} http;
ndpi_multimedia_flow_type flow_type;
ndpi_multimedia_flow_type flow_multimedia_type;
/*
Put outside of the union to avoid issues in case the protocol
@@ -1484,10 +1476,6 @@ struct ndpi_flow_struct {
char ptr_domain_name[64 /* large enough but smaller than { } tls */];
} dns;
struct {
enum ndpi_rtp_stream_type stream_type;
} rtp;
struct {
u_int8_t request_code;
u_int8_t version;
+4 -4
View File
@@ -6097,13 +6097,13 @@ static int ndpi_reconcile_msteams_call_udp_port(struct ndpi_detection_module_str
*/
if((dport == 3478) || (dport == 3479) || ((sport >= 50000) && (sport <= 50019)))
flow->flow_type = ndpi_multimedia_audio_flow;
flow->flow_multimedia_type = ndpi_multimedia_audio_flow;
else if((dport == 3480) || ((sport >= 50020) && (sport <= 50039)))
flow->flow_type = ndpi_multimedia_video_flow;
flow->flow_multimedia_type = ndpi_multimedia_video_flow;
else if((dport == 3481) || ((sport >= 50040) && (sport <= 50059)))
flow->flow_type = ndpi_multimedia_screen_sharing_flow;
flow->flow_multimedia_type = ndpi_multimedia_screen_sharing_flow;
else {
flow->flow_type = ndpi_multimedia_unknown_flow;
flow->flow_multimedia_type = ndpi_multimedia_unknown_flow;
return(0);
}
+9 -28
View File
@@ -45,7 +45,7 @@ int is_valid_rtp_payload_type(uint8_t type)
return 1;
}
u_int8_t rtp_get_stream_type(u_int8_t payloadType, enum ndpi_rtp_stream_type *s_type)
u_int8_t rtp_get_stream_type(u_int8_t payloadType, ndpi_multimedia_flow_type *s_type)
{
switch(payloadType) {
case 0: /* G.711 u-Law */
@@ -67,7 +67,7 @@ u_int8_t rtp_get_stream_type(u_int8_t payloadType, enum ndpi_rtp_stream_type *s_
case 116: /* G.726 */
case 117: /* G.722 */
case 118: /* Comfort Noise Wideband */
*s_type = rtp_audio;
*s_type = ndpi_multimedia_audio_flow;
return(1 /* RTP */);
case 34: /* H.263 [MS-H26XPF] */
@@ -75,18 +75,18 @@ u_int8_t rtp_get_stream_type(u_int8_t payloadType, enum ndpi_rtp_stream_type *s_
case 122: /* H.264 [MS-H264PF] */
case 123: /* H.264 FEC [MS-H264PF] */
case 127: /* x-data */
*s_type = rtp_video;
*s_type = ndpi_multimedia_video_flow;
return(1 /* RTP */);
case 200: /* RTCP PACKET SENDER */
case 201: /* RTCP PACKET RECEIVER */
case 202: /* RTCP Source Description */
case 203: /* RTCP Bye */
*s_type = rtp_unknown;
*s_type = ndpi_multimedia_unknown_flow;
return(2 /* RTCP */);
default:
*s_type = rtp_unknown;
*s_type = ndpi_multimedia_unknown_flow;
return(0);
}
}
@@ -146,19 +146,19 @@ static u_int8_t isZoom(struct ndpi_flow_struct *flow,
case 30: /* Screen Share */
*is_rtp = 0;
*payload_offset = 27;
flow->flow_type = ndpi_multimedia_screen_sharing_flow;
flow->flow_multimedia_type = ndpi_multimedia_screen_sharing_flow;
break;
case 15: /* Audio */
*is_rtp = 1;
*payload_offset = 27;
flow->flow_type = ndpi_multimedia_audio_flow;
flow->flow_multimedia_type = ndpi_multimedia_audio_flow;
break;
case 16: /* Video */
*is_rtp = 1;
*payload_offset = 32;
flow->flow_type = ndpi_multimedia_video_flow;
flow->flow_multimedia_type = ndpi_multimedia_video_flow;
break;
case 33: /* RTCP */
@@ -265,25 +265,6 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
payload = &payload[payload_offset];
*/
switch(zoom_stream_type) {
case 13: /* Screen Share */
case 30: /* Screen Share */
flow->protos.rtp.stream_type = rtp_screen_share;
break;
case 15: /* Audio */
flow->protos.rtp.stream_type = rtp_audio;
break;
case 16: /* Video */
flow->protos.rtp.stream_type = rtp_video;
break;
default:
flow->protos.rtp.stream_type = rtp_unknown;
break;
}
/* printf("->>> %u\n", zoom_stream_type); */
ndpi_set_detected_protocol(ndpi_struct, flow,
@@ -312,7 +293,7 @@ static void ndpi_rtp_search(struct ndpi_detection_module_struct *ndpi_struct,
} else if(flow->l4.udp.epicgames_stage > 0) {
/* It seems that it is a EpicGames stuff; let its dissector to evaluate */
} else {
rtp_get_stream_type(payload[1] & 0x7F, &flow->protos.rtp.stream_type);
rtp_get_stream_type(payload[1] & 0x7F, &flow->flow_multimedia_type);
/* Previous pkts were STUN */
if(flow->stun.num_binding_requests > 0 ||