From 2bb8255e29e26c7c14f7a83ce33b41f9af18501e Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 16 Dec 2014 14:36:04 -0800 Subject: Consolidate RTP stream structs. Consolidate the three different RTP stream structs in ui/rtp_stream.h, ui/gtk/rtp_player.c, and ui/voip_calls.c into one. Make the member names a bit more consistent. Document what each GList contains. Use nstime_t for timestamps since that's what we get from the frame data. Use g_new0 to initialize our structs. Change-Id: I2b3f8f2051394a6a98a5c7bc49c117f07161d031 Reviewed-on: https://code.wireshark.org/review/5843 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/tap-rtp-common.c | 97 +++++++++++++++++++---------------------------------- 1 file changed, 34 insertions(+), 63 deletions(-) (limited to 'ui/tap-rtp-common.c') diff --git a/ui/tap-rtp-common.c b/ui/tap-rtp-common.c index b998a4fc95..3ed3186537 100644 --- a/ui/tap-rtp-common.c +++ b/ui/tap-rtp-common.c @@ -134,8 +134,8 @@ void rtp_write_header(rtp_stream_info_t *strinfo, FILE *file) ep_address_to_display(&(strinfo->dest_addr)), strinfo->dest_port); - start_sec = g_htonl(strinfo->start_sec); - start_usec = g_htonl(strinfo->start_usec); + start_sec = g_htonl(strinfo->start_fd->abs_ts.secs); + start_usec = g_htonl(strinfo->start_fd->abs_ts.nsecs / 1000000); /* rtpdump only accepts guint32 as source, will be fake for IPv6 */ memset(&source, 0, sizeof source); sourcelen = strinfo->src_addr.len; @@ -186,95 +186,67 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con { rtpstream_tapinfo_t *tapinfo = (rtpstream_tapinfo_t *)arg; const struct _rtp_info *rtpinfo = (const struct _rtp_info *)arg2; - rtp_stream_info_t tmp_strinfo; - rtp_stream_info_t *strinfo = NULL; + rtp_stream_info_t new_stream_info; + rtp_stream_info_t *stream_info = NULL; GList* list; rtp_sample_t sample; struct _rtp_conversation_info *p_conv_data = NULL; /* gather infos on the stream this packet is part of */ - COPY_ADDRESS(&(tmp_strinfo.src_addr), &(pinfo->src)); - tmp_strinfo.src_port = pinfo->srcport; - COPY_ADDRESS(&(tmp_strinfo.dest_addr), &(pinfo->dst)); - tmp_strinfo.dest_port = pinfo->destport; - tmp_strinfo.ssrc = rtpinfo->info_sync_src; - tmp_strinfo.pt = rtpinfo->info_payload_type; - tmp_strinfo.info_payload_type_str = rtpinfo->info_payload_type_str; + memset(&new_stream_info, 0, sizeof(rtp_stream_info_t)); + COPY_ADDRESS(&(new_stream_info.src_addr), &(pinfo->src)); + new_stream_info.src_port = pinfo->srcport; + COPY_ADDRESS(&(new_stream_info.dest_addr), &(pinfo->dst)); + new_stream_info.dest_port = pinfo->destport; + new_stream_info.ssrc = rtpinfo->info_sync_src; + new_stream_info.payload_type = rtpinfo->info_payload_type; + new_stream_info.payload_type_name = g_strdup(rtpinfo->info_payload_type_str); if (tapinfo->mode == TAP_ANALYSE) { /* check whether we already have a stream with these parameters in the list */ list = g_list_first(tapinfo->strinfo_list); while (list) { - if (rtp_stream_info_cmp(&tmp_strinfo, (rtp_stream_info_t*)(list->data))==0) + if (rtp_stream_info_cmp(&new_stream_info, (rtp_stream_info_t*)(list->data))==0) { - strinfo = (rtp_stream_info_t*)(list->data); /*found!*/ + stream_info = (rtp_stream_info_t*)(list->data); /*found!*/ break; } list = g_list_next(list); } /* not in the list? then create a new entry */ - if (!strinfo) { - tmp_strinfo.npackets = 0; - tmp_strinfo.first_frame_num = pinfo->fd->num; - tmp_strinfo.start_sec = (guint32) pinfo->fd->abs_ts.secs; - tmp_strinfo.start_usec = pinfo->fd->abs_ts.nsecs/1000; - tmp_strinfo.start_rel_sec = (guint32) pinfo->rel_ts.secs; - tmp_strinfo.start_rel_usec = pinfo->rel_ts.nsecs/1000; - tmp_strinfo.tag_vlan_error = 0; - tmp_strinfo.tag_diffserv_error = 0; - tmp_strinfo.vlan_id = 0; - tmp_strinfo.problem = FALSE; + if (!stream_info) { + new_stream_info.start_fd = pinfo->fd; + new_stream_info.start_rel_time = pinfo->rel_ts; /* reset RTP stats */ - tmp_strinfo.rtp_stats.first_packet = TRUE; - tmp_strinfo.rtp_stats.max_delta = 0; - tmp_strinfo.rtp_stats.max_jitter = 0; - tmp_strinfo.rtp_stats.mean_jitter = 0; - tmp_strinfo.rtp_stats.delta = 0; - tmp_strinfo.rtp_stats.diff = 0; - tmp_strinfo.rtp_stats.jitter = 0; - tmp_strinfo.rtp_stats.bandwidth = 0; - tmp_strinfo.rtp_stats.total_bytes = 0; - tmp_strinfo.rtp_stats.bw_start_index = 0; - tmp_strinfo.rtp_stats.bw_index = 0; - tmp_strinfo.rtp_stats.timestamp = 0; - tmp_strinfo.rtp_stats.max_nr = 0; - tmp_strinfo.rtp_stats.total_nr = 0; - tmp_strinfo.rtp_stats.sequence = 0; - tmp_strinfo.rtp_stats.start_seq_nr = 0; - tmp_strinfo.rtp_stats.stop_seq_nr = 0; - tmp_strinfo.rtp_stats.cycles = 0; - tmp_strinfo.rtp_stats.under = FALSE; - tmp_strinfo.rtp_stats.start_time = 0; - tmp_strinfo.rtp_stats.time = 0; - tmp_strinfo.rtp_stats.reg_pt = PT_UNDEFINED; + new_stream_info.rtp_stats.first_packet = TRUE; + new_stream_info.rtp_stats.reg_pt = PT_UNDEFINED; /* Get the Setup frame number who set this RTP stream */ p_conv_data = (struct _rtp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_get_id_by_filter_name("rtp"), 0); if (p_conv_data) - tmp_strinfo.setup_frame_number = p_conv_data->frame_number; + new_stream_info.setup_frame_number = p_conv_data->frame_number; else - tmp_strinfo.setup_frame_number = 0xFFFFFFFF; + new_stream_info.setup_frame_number = 0xFFFFFFFF; - strinfo = g_new(rtp_stream_info_t,1); - *strinfo = tmp_strinfo; /* memberwise copy of struct */ - tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, strinfo); + stream_info = g_new(rtp_stream_info_t,1); + *stream_info = new_stream_info; /* memberwise copy of struct */ + tapinfo->strinfo_list = g_list_append(tapinfo->strinfo_list, stream_info); } /* get RTP stats for the packet */ - rtp_packet_analyse(&(strinfo->rtp_stats), pinfo, rtpinfo); - if (strinfo->rtp_stats.flags & STAT_FLAG_WRONG_TIMESTAMP - || strinfo->rtp_stats.flags & STAT_FLAG_WRONG_SEQ) - strinfo->problem = TRUE; + rtp_packet_analyse(&(stream_info->rtp_stats), pinfo, rtpinfo); + if (stream_info->rtp_stats.flags & STAT_FLAG_WRONG_TIMESTAMP + || stream_info->rtp_stats.flags & STAT_FLAG_WRONG_SEQ) + stream_info->problem = TRUE; /* increment the packets counter for this stream */ - ++(strinfo->npackets); - strinfo->stop_rel_sec = (guint32) pinfo->rel_ts.secs; - strinfo->stop_rel_usec = pinfo->rel_ts.nsecs/1000; + ++(stream_info->packet_count); + stream_info->stop_rel_time = pinfo->rel_ts; /* increment the packets counter of all streams */ ++(tapinfo->npackets); @@ -282,12 +254,11 @@ int rtpstream_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, con return 1; /* refresh output */ } else if (tapinfo->mode == TAP_SAVE) { - if (rtp_stream_info_cmp(&tmp_strinfo, tapinfo->filter_stream_fwd)==0) { + if (rtp_stream_info_cmp(&new_stream_info, tapinfo->filter_stream_fwd)==0) { /* XXX - what if rtpinfo->info_all_data_present is FALSE, so that we don't *have* all the data? */ - sample.header.rec_time = - (pinfo->fd->abs_ts.nsecs/1000 + 1000000 - tapinfo->filter_stream_fwd->start_usec)/1000 - + (guint32) (pinfo->fd->abs_ts.secs - tapinfo->filter_stream_fwd->start_sec - 1)*1000; + sample.header.rec_time = nstime_to_msec(&pinfo->fd->abs_ts) - + nstime_to_msec(&tapinfo->filter_stream_fwd->start_fd->abs_ts); sample.header.frame_length = rtpinfo->info_data_len; sample.frame = rtpinfo->info_data; rtp_write_sample(&sample, tapinfo->save_file); @@ -587,7 +558,7 @@ int rtp_packet_analyse(tap_rtp_stat_t *statinfo, if(rtpinfo->info_payload_rate !=0){ clock_rate = rtpinfo->info_payload_rate; }else{ - clock_rate = get_dyn_pt_clock_rate(rtpinfo-> info_payload_type_str); + clock_rate = get_dyn_pt_clock_rate(rtpinfo->info_payload_type_str); } } }else{ -- cgit v1.2.1