diff options
-rw-r--r-- | sharkd_session.c | 83 | ||||
-rw-r--r-- | ui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | ui/cli/tap-rtp.c | 10 | ||||
-rw-r--r-- | ui/qt/iax2_analysis_dialog.cpp | 61 | ||||
-rw-r--r-- | ui/qt/iax2_analysis_dialog.h | 11 | ||||
-rw-r--r-- | ui/qt/rtp_analysis_dialog.cpp | 273 | ||||
-rw-r--r-- | ui/qt/rtp_analysis_dialog.h | 24 | ||||
-rw-r--r-- | ui/qt/rtp_audio_stream.cpp | 19 | ||||
-rw-r--r-- | ui/qt/rtp_audio_stream.h | 6 | ||||
-rw-r--r-- | ui/qt/rtp_player_dialog.cpp | 14 | ||||
-rw-r--r-- | ui/qt/rtp_stream_dialog.cpp | 38 | ||||
-rw-r--r-- | ui/rtp_stream.c | 16 | ||||
-rw-r--r-- | ui/rtp_stream.h | 21 | ||||
-rw-r--r-- | ui/rtp_stream_id.c | 118 | ||||
-rw-r--r-- | ui/rtp_stream_id.h | 90 | ||||
-rw-r--r-- | ui/tap-rtp-common.c | 44 | ||||
-rw-r--r-- | ui/tap-rtp-common.h | 14 | ||||
-rw-r--r-- | ui/voip_calls.c | 31 |
18 files changed, 475 insertions, 400 deletions
diff --git a/sharkd_session.c b/sharkd_session.c index 3b2dee8136..13d7eec658 100644 --- a/sharkd_session.c +++ b/sharkd_session.c @@ -202,44 +202,41 @@ sharkd_session_filter_data(const char *filter) return l->filtered; } -struct sharkd_rtp_match -{ - guint32 addr_src, addr_dst; - address src_addr; - address dst_addr; - guint16 src_port; - guint16 dst_port; - guint32 ssrc; -}; - static gboolean -sharkd_rtp_match_init(struct sharkd_rtp_match *req, const char *init_str) +sharkd_rtp_match_init(rtpstream_id_t *id, const char *init_str) { gboolean ret = FALSE; char **arr; + guint32 tmp_addr_src, tmp_addr_dst; + address tmp_src_addr, tmp_dst_addr; + + memset(id, 0, sizeof(*id)); arr = g_strsplit(init_str, "_", 7); /* pass larger value, so we'll catch incorrect input :) */ if (g_strv_length(arr) != 5) goto fail; /* TODO, for now only IPv4 */ - if (!get_host_ipaddr(arr[0], &req->addr_src)) + if (!get_host_ipaddr(arr[0], &tmp_addr_src)) goto fail; - if (!ws_strtou16(arr[1], NULL, &req->src_port)) + if (!ws_strtou16(arr[1], NULL, &id->src_port)) goto fail; - if (!get_host_ipaddr(arr[2], &req->addr_dst)) + if (!get_host_ipaddr(arr[2], &tmp_addr_dst)) goto fail; - if (!ws_strtou16(arr[3], NULL, &req->dst_port)) + if (!ws_strtou16(arr[3], NULL, &id->dst_port)) goto fail; - if (!ws_hexstrtou32(arr[4], NULL, &req->ssrc)) + if (!ws_hexstrtou32(arr[4], NULL, &id->ssrc)) goto fail; - set_address(&req->src_addr, AT_IPv4, 4, &req->addr_src); - set_address(&req->dst_addr, AT_IPv4, 4, &req->addr_dst); + set_address(&tmp_src_addr, AT_IPv4, 4, &tmp_addr_src); + copy_address(&id->src_addr, &tmp_src_addr); + set_address(&tmp_dst_addr, AT_IPv4, 4, &tmp_addr_dst); + copy_address(&id->dst_addr, &tmp_dst_addr); + ret = TRUE; fail: @@ -248,21 +245,6 @@ fail: } static gboolean -sharkd_rtp_match_check(const struct sharkd_rtp_match *req, const packet_info *pinfo, const struct _rtp_info *rtp_info) -{ - if (rtp_info->info_sync_src == req->ssrc && - pinfo->srcport == req->src_port && - pinfo->destport == req->dst_port && - addresses_equal(&pinfo->src, &req->src_addr) && - addresses_equal(&pinfo->dst, &req->dst_addr)) - { - return TRUE; - } - - return FALSE; -} - -static gboolean sharkd_session_process_info_nstat_cb(const void *key, void *value, void *userdata) { stat_tap_table_ui *stat_tap = (stat_tap_table_ui *) value; @@ -1309,7 +1291,7 @@ struct sharkd_analyse_rtp_items struct sharkd_analyse_rtp { const char *tap_name; - struct sharkd_rtp_match rtp; + rtpstream_id_t id; GSList *packets; double start_time; @@ -1329,14 +1311,14 @@ static gboolean sharkd_session_packet_tap_rtp_analyse_cb(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pointer) { struct sharkd_analyse_rtp *rtp_req = (struct sharkd_analyse_rtp *) tapdata; - const struct _rtp_info *rtpinfo = (const struct _rtp_info *) pointer; + const struct _rtp_info *rtp_info = (const struct _rtp_info *) pointer; - if (sharkd_rtp_match_check(&rtp_req->rtp, pinfo, rtpinfo)) + if (rtpstream_id_equal_pinfo_rtp_info(&rtp_req->id, pinfo, rtp_info)) { tap_rtp_stat_t *statinfo = &(rtp_req->statinfo); struct sharkd_analyse_rtp_items *item; - rtppacket_analyse(statinfo, pinfo, rtpinfo); + rtppacket_analyse(statinfo, pinfo, rtp_info); item = (struct sharkd_analyse_rtp_items *) g_malloc(sizeof(struct sharkd_analyse_rtp_items)); @@ -1344,12 +1326,12 @@ sharkd_session_packet_tap_rtp_analyse_cb(void *tapdata, packet_info *pinfo, epan rtp_req->start_time = nstime_to_sec(&pinfo->abs_ts); item->frame_num = pinfo->num; - item->sequence_num = rtpinfo->info_seq_num; + item->sequence_num = rtp_info->info_seq_num; item->delta = (statinfo->flags & STAT_FLAG_FIRST) ? 0.0 : statinfo->delta; item->jitter = (statinfo->flags & STAT_FLAG_FIRST) ? 0.0 : statinfo->jitter; item->skew = (statinfo->flags & STAT_FLAG_FIRST) ? 0.0 : statinfo->skew; item->bandwidth = statinfo->bandwidth; - item->marker = rtpinfo->info_marker_set ? TRUE : FALSE; + item->marker = rtp_info->info_marker_set ? TRUE : FALSE; item->arrive_offset= nstime_to_sec(&pinfo->abs_ts) - rtp_req->start_time; item->flags = statinfo->flags; @@ -1405,7 +1387,7 @@ sharkd_session_process_tap_rtp_analyse_cb(void *tapdata) printf("{\"tap\":\"%s\",\"type\":\"rtp-analyse\"", rtp_req->tap_name); - printf(",\"ssrc\":%u", rtp_req->rtp.ssrc); + printf(",\"ssrc\":%u", rtp_req->id.ssrc); printf(",\"max_delta\":%f", statinfo->max_delta); printf(",\"max_delta_nr\":%u", statinfo->max_nr); @@ -2102,22 +2084,22 @@ sharkd_session_process_tap_rtp_cb(void *arg) char *payload; guint32 expected; - src_addr = address_to_display(NULL, &(streaminfo->src_addr)); - dst_addr = address_to_display(NULL, &(streaminfo->dest_addr)); + src_addr = address_to_display(NULL, &(streaminfo->id.src_addr)); + dst_addr = address_to_display(NULL, &(streaminfo->id.dst_addr)); if (streaminfo->payload_type_name != NULL) payload = wmem_strdup(NULL, streaminfo->payload_type_name); else payload = val_to_str_ext_wmem(NULL, streaminfo->payload_type, &rtp_payload_type_short_vals_ext, "Unknown (%u)"); - printf("%s{\"ssrc\":%u", sepa, streaminfo->ssrc); + printf("%s{\"ssrc\":%u", sepa, streaminfo->id.ssrc); printf(",\"payload\":\"%s\"", payload); printf(",\"saddr\":\"%s\"", src_addr); - printf(",\"sport\":%u", streaminfo->src_port); + printf(",\"sport\":%u", streaminfo->id.src_port); printf(",\"daddr\":\"%s\"", dst_addr); - printf(",\"dport\":%u", streaminfo->dest_port); + printf(",\"dport\":%u", streaminfo->id.dst_port); printf(",\"pkts\":%u", streaminfo->packet_count); @@ -2132,7 +2114,7 @@ sharkd_session_process_tap_rtp_cb(void *arg) printf(",\"problem\":%s", streaminfo->problem ? "true" : "false"); /* for filter */ - printf(",\"ipver\":%d", (streaminfo->src_addr.type == AT_IPv6) ? 6 : 4); + printf(",\"ipver\":%d", (streaminfo->id.src_addr.type == AT_IPv6) ? 6 : 4); wmem_free(NULL, src_addr); wmem_free(NULL, dst_addr); @@ -2443,8 +2425,9 @@ sharkd_session_process_tap(char *buf, const jsmntok_t *tokens, int count) struct sharkd_analyse_rtp *rtp_req; rtp_req = (struct sharkd_analyse_rtp *) g_malloc0(sizeof(*rtp_req)); - if (!sharkd_rtp_match_init(&rtp_req->rtp, tok_tap + 12)) + if (!sharkd_rtp_match_init(&rtp_req->id, tok_tap + 12)) { + rtpstream_id_free(&rtp_req->id); g_free(rtp_req); continue; } @@ -3787,7 +3770,7 @@ sharkd_session_process_dumpconf(char *buf, const jsmntok_t *tokens, int count) struct sharkd_download_rtp { - struct sharkd_rtp_match rtp; + rtpstream_id_t id; GSList *packets; double start_time; }; @@ -3949,7 +3932,7 @@ sharkd_session_packet_download_tap_rtp_cb(void *tapdata, packet_info *pinfo, epa if (rtp_info->info_setup_frame_num == 0) return FALSE; - if (sharkd_rtp_match_check(&req_rtp->rtp, pinfo, rtp_info)) + if (rtpstream_id_equal_pinfo_rtp_info(&req_rtp->id, pinfo, rtp_info)) { rtp_packet_t *rtp_packet; @@ -4053,7 +4036,7 @@ sharkd_session_process_download(char *buf, const jsmntok_t *tokens, int count) GString *tap_error; memset(&rtp_req, 0, sizeof(rtp_req)); - if (!sharkd_rtp_match_init(&rtp_req.rtp, tok_token + 4)) + if (!sharkd_rtp_match_init(&rtp_req.id, tok_token + 4)) { fprintf(stderr, "sharkd_session_process_download() rtp tokenizing error %s\n", tok_token); return; diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 20ab967c27..b73e73c746 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -36,6 +36,7 @@ set(NONGENERATED_UI_SRC recent.c rtp_media.c rtp_stream.c + rtp_stream_id.c service_response_time.c software_update.c ssl_key_export.c @@ -58,6 +59,7 @@ set(NONGENERATED_UI_SRC file(GLOB EXTRA_UI_HEADERS rtp_media.h rtp_stream.h + rtp_stream_id.h tap-iax2-analysis.h tap-rtp-analysis.h ) diff --git a/ui/cli/tap-rtp.c b/ui/cli/tap-rtp.c index afe688bee3..65b1b62ba6 100644 --- a/ui/cli/tap-rtp.c +++ b/ui/cli/tap-rtp.c @@ -94,14 +94,14 @@ rtp_streams_stat_draw(void *arg _U_) perc = 0; } - src_addr = address_to_display(NULL, &(strinfo->src_addr)); - dst_addr = address_to_display(NULL, &(strinfo->dest_addr)); + src_addr = address_to_display(NULL, &(strinfo->id.src_addr)); + dst_addr = address_to_display(NULL, &(strinfo->id.dst_addr)); printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n", src_addr, - strinfo->src_port, + strinfo->id.src_port, dst_addr, - strinfo->dest_port, - strinfo->ssrc, + strinfo->id.dst_port, + strinfo->id.ssrc, payload_type, strinfo->packet_count, lost, perc, diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp index 675d4b9c09..7bb3bd5cf7 100644 --- a/ui/qt/iax2_analysis_dialog.cpp +++ b/ui/qt/iax2_analysis_dialog.cpp @@ -194,10 +194,6 @@ enum { Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf), ui(new Ui::Iax2AnalysisDialog), - port_src_fwd_(0), - port_dst_fwd_(0), - port_src_rev_(0), - port_dst_rev_(0), save_payload_error_(TAP_IAX2_NO_ERROR) { ui->setupUi(this); @@ -237,10 +233,8 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : } ui->reverseTreeWidget->setHeaderLabels(header_labels); - memset(&src_fwd_, 0, sizeof(address)); - memset(&dst_fwd_, 0, sizeof(address)); - memset(&src_rev_, 0, sizeof(address)); - memset(&dst_rev_, 0, sizeof(address)); + memset(&fwd_id_, 0, sizeof(fwd_id_)); + memset(&rev_id_, 0, sizeof(rev_id_)); QList<QCheckBox *> graph_cbs = QList<QCheckBox *>() << ui->fJitterCheckBox << ui->fDiffCheckBox @@ -339,22 +333,16 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : dfilter_free(sfcode); /* ok, it is a IAX2 frame, so let's get the ip and port values */ - copy_address(&(src_fwd_), &(edt.pi.src)); - copy_address(&(dst_fwd_), &(edt.pi.dst)); - port_src_fwd_ = edt.pi.srcport; - port_dst_fwd_ = edt.pi.destport; + rtpstream_id_copy_pinfo(&(edt.pi),&(fwd_id_),FALSE); /* assume the inverse ip/port combination for the reverse direction */ - copy_address(&(src_rev_), &(edt.pi.dst)); - copy_address(&(dst_rev_), &(edt.pi.src)); - port_src_rev_ = edt.pi.destport; - port_dst_rev_ = edt.pi.srcport; + rtpstream_id_copy_pinfo(&(edt.pi),&(rev_id_),TRUE); #ifdef IAX2_RTP_STREAM_CHECK - rtpstream_tapinfot tapinfo; + rtpstream_tapinfo_t tapinfo; /* Register the tap listener */ - memset(&tapinfo, 0, sizeof(rtpstream_tapinfot)); + memset(&tapinfo, 0, sizeof(rtpstream_tapinfo_t)); tapinfo.tap_data = this; tapinfo.mode = TAP_ANALYSE; @@ -365,21 +353,14 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : int num_streams = 0; GList *filtered_list = NULL; for (GList *strinfo_list = g_list_first(tapinfo.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) { - rtp_stream_info_t * strinfo = (rtp_stream_info_t*)(strinfo_list->data); - << address_to_qstring(&strinfo->dest_addr) << address_to_qstring(&src_rev_) << address_to_qstring(&dst_rev_); - if (addresses_equal(&(strinfo->src_addr), &(src_fwd_)) - && (strinfo->src_port == port_src_fwd_) - && (addresses_equal(&(strinfo->dest_addr), &(dst_fwd_))) - && (strinfo->dest_port == port_dst_fwd_)) + rtpstream_info_t * strinfo = (rtpstream_info_t*)(strinfo_list->data); + if (rtpstream_id_equal(&(strinfo->id), &(fwd_id_),RTPSTREAM_ID_EQUAL_NONE)) { ++num_streams; filtered_list = g_list_prepend(filtered_list, strinfo); } - if (addresses_equal(&(strinfo->src_addr), &(src_rev_)) - && (strinfo->src_port == port_src_rev_) - && (addresses_equal(&(strinfo->dest_addr), &(dst_rev_))) - && (strinfo->dest_port == port_dst_rev_)) + if (rtpstream_id_equal(&(strinfo->id), &(rev_id_),RTPSTREAM_ID_EQUAL_NONE)) { ++num_streams; filtered_list = g_list_append(filtered_list, strinfo); @@ -639,18 +620,18 @@ gboolean Iax2AnalysisDialog::tapPacket(void *tapinfoptr, packet_info *pinfo, str return FALSE; /* is it the forward direction? */ - else if ((cmp_address(&(iax2_analysis_dialog->src_fwd_), &(pinfo->src)) == 0) - && (iax2_analysis_dialog->port_src_fwd_ == pinfo->srcport) - && (cmp_address(&(iax2_analysis_dialog->dst_fwd_), &(pinfo->dst)) == 0) - && (iax2_analysis_dialog->port_dst_fwd_ == pinfo->destport)) { + else if ((cmp_address(&(iax2_analysis_dialog->fwd_id_.src_addr), &(pinfo->src)) == 0) + && (iax2_analysis_dialog->fwd_id_.src_port == pinfo->srcport) + && (cmp_address(&(iax2_analysis_dialog->fwd_id_.dst_addr), &(pinfo->dst)) == 0) + && (iax2_analysis_dialog->fwd_id_.dst_port == pinfo->destport)) { iax2_analysis_dialog->addPacket(true, pinfo, iax2info); } /* is it the reversed direction? */ - else if ((cmp_address(&(iax2_analysis_dialog->src_rev_), &(pinfo->src)) == 0) - && (iax2_analysis_dialog->port_src_rev_ == pinfo->srcport) - && (cmp_address(&(iax2_analysis_dialog->dst_rev_), &(pinfo->dst)) == 0) - && (iax2_analysis_dialog->port_dst_rev_ == pinfo->destport)) { + else if ((cmp_address(&(iax2_analysis_dialog->rev_id_.src_addr), &(pinfo->src)) == 0) + && (iax2_analysis_dialog->rev_id_.src_port == pinfo->srcport) + && (cmp_address(&(iax2_analysis_dialog->rev_id_.dst_addr), &(pinfo->dst)) == 0) + && (iax2_analysis_dialog->rev_id_.dst_port == pinfo->destport)) { iax2_analysis_dialog->addPacket(false, pinfo, iax2info); } @@ -790,11 +771,11 @@ void Iax2AnalysisDialog::updateStatistics() QString stats_tables = "<html><head></head><body>\n"; stats_tables += QString("<p>%1:%2 " UTF8_LEFT_RIGHT_ARROW) - .arg(address_to_qstring(&src_fwd_, true)) - .arg(port_src_fwd_); + .arg(address_to_qstring(&fwd_id_.src_addr, true)) + .arg(fwd_id_.src_port); stats_tables += QString("<br>%1:%2</p>\n") - .arg(address_to_qstring(&dst_fwd_, true)) - .arg(port_dst_fwd_); + .arg(address_to_qstring(&fwd_id_.dst_addr, true)) + .arg(fwd_id_.dst_port); stats_tables += "<h4>Forward</h4>\n"; stats_tables += "<p><table>\n"; stats_tables += QString("<tr><th align=\"left\">Max Delta</th><td>%1 ms @ %2</td></tr>") diff --git a/ui/qt/iax2_analysis_dialog.h b/ui/qt/iax2_analysis_dialog.h index 4e27525d91..81f55875f9 100644 --- a/ui/qt/iax2_analysis_dialog.h +++ b/ui/qt/iax2_analysis_dialog.h @@ -22,6 +22,7 @@ #include <epan/address.h> #include "ui/tap-iax2-analysis.h" +#include "ui/rtp_stream_id.h" #include <QAbstractButton> #include <QMenu> @@ -80,14 +81,8 @@ private: Ui::Iax2AnalysisDialog *ui; enum StreamDirection { dir_both_, dir_forward_, dir_reverse_ }; - address src_fwd_; - guint32 port_src_fwd_; - address dst_fwd_; - guint32 port_dst_fwd_; - address src_rev_; - guint32 port_src_rev_; - address dst_rev_; - guint32 port_dst_rev_; + rtpstream_id_t fwd_id_; + rtpstream_id_t rev_id_; tap_iax2_stat_t fwd_statinfo_; tap_iax2_stat_t rev_statinfo_; diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp index 9749538868..3f3340b0c4 100644 --- a/ui/qt/rtp_analysis_dialog.cpp +++ b/ui/qt/rtp_analysis_dialog.cpp @@ -233,16 +233,6 @@ enum { RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, rtpstream_info_t *stream_fwd, rtpstream_info_t *stream_rev) : WiresharkDialog(parent, cf), ui(new Ui::RtpAnalysisDialog), - port_src_fwd_(0), - port_dst_fwd_(0), - ssrc_fwd_(0), - packet_count_fwd_(0), - setup_frame_number_fwd_(0), - port_src_rev_(0), - port_dst_rev_(0), - ssrc_rev_(0), - packet_count_rev_(0), - setup_frame_number_rev_(0), num_streams_(0), save_payload_error_(TAP_RTP_NO_ERROR) { @@ -295,12 +285,8 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, rtpstream } ui->reverseTreeWidget->setHeaderLabels(header_labels); - memset(&src_fwd_, 0, sizeof(address)); - memset(&dst_fwd_, 0, sizeof(address)); - memset(&src_rev_, 0, sizeof(address)); - memset(&dst_rev_, 0, sizeof(address)); - nstime_set_zero(&start_rel_time_fwd_); - nstime_set_zero(&start_rel_time_rev_); + memset(&fwd_statinfo_, 0, sizeof(fwd_statinfo_)); + memset(&rev_statinfo_, 0, sizeof(rev_statinfo_)); QList<QCheckBox *> graph_cbs = QList<QCheckBox *>() << ui->fJitterCheckBox << ui->fDiffCheckBox << ui->fDeltaCheckBox @@ -360,25 +346,11 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, rtpstream ui->buttonBox->button(QDialogButtonBox::Save)->setMenu(save_menu); if (stream_fwd) { // XXX What if stream_fwd == 0 && stream_rev != 0? - copy_address(&src_fwd_, &(stream_fwd->src_addr)); - port_src_fwd_ = stream_fwd->src_port; - copy_address(&dst_fwd_, &(stream_fwd->dest_addr)); - port_dst_fwd_ = stream_fwd->dest_port; - ssrc_fwd_ = stream_fwd->ssrc; - packet_count_fwd_ = stream_fwd->packet_count; - setup_frame_number_fwd_ = stream_fwd->setup_frame_number; - nstime_copy(&start_rel_time_fwd_, &stream_fwd->start_rel_time); - num_streams_++; + fwd_statinfo_ = *stream_fwd; + num_streams_=1; if (stream_rev) { - copy_address(&src_rev_, &(stream_rev->src_addr)); - port_src_rev_ = stream_rev->src_port; - copy_address(&dst_rev_, &(stream_rev->dest_addr)); - port_dst_rev_ = stream_rev->dest_port; - ssrc_rev_ = stream_rev->ssrc; - packet_count_rev_ = stream_rev->packet_count; - setup_frame_number_rev_ = stream_rev->setup_frame_number; - nstime_copy(&start_rel_time_rev_, &stream_rev->start_rel_time); - num_streams_++; + rev_statinfo_ = *stream_rev; + num_streams_=2; } } else { findStreams(); @@ -409,6 +381,8 @@ RtpAnalysisDialog::~RtpAnalysisDialog() { delete ui; // remove_tap_listener_rtpstream(&tapinfo_); + rtpstream_id_free(&(fwd_statinfo_.id)); + rtpstream_id_free(&(rev_statinfo_.id)); delete fwd_tempfile_; delete rev_tempfile_; } @@ -448,8 +422,8 @@ void RtpAnalysisDialog::updateWidgets() hint.append(tr(" G: Go to packet, N: Next problem packet")); } - bool enable_save_fwd_audio = fwd_statinfo_.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); - bool enable_save_rev_audio = rev_statinfo_.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); + bool enable_save_fwd_audio = fwd_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); + bool enable_save_rev_audio = rev_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); ui->actionSaveAudioUnsync->setEnabled(enable_save_fwd_audio && enable_save_rev_audio); ui->actionSaveForwardAudioUnsync->setEnabled(enable_save_fwd_audio); ui->actionSaveReverseAudioUnsync->setEnabled(enable_save_rev_audio); @@ -697,20 +671,12 @@ gboolean RtpAnalysisDialog::tapPacket(void *tapinfo_ptr, packet_info *pinfo, epa else if (rtpinfo->info_version != 2) return FALSE; /* is it the forward direction? */ - else if (rtp_analysis_dialog->ssrc_fwd_ == rtpinfo->info_sync_src - && (cmp_address(&(rtp_analysis_dialog->src_fwd_), &(pinfo->src)) == 0) - && (rtp_analysis_dialog->port_src_fwd_ == pinfo->srcport) - && (cmp_address(&(rtp_analysis_dialog->dst_fwd_), &(pinfo->dst)) == 0) - && (rtp_analysis_dialog->port_dst_fwd_ == pinfo->destport)) { + else if (rtpstream_id_equal_pinfo_rtp_info(&(rtp_analysis_dialog->fwd_statinfo_.id),pinfo,rtpinfo)) { rtp_analysis_dialog->addPacket(true, pinfo, rtpinfo); } /* is it the reversed direction? */ - else if (rtp_analysis_dialog->ssrc_rev_ == rtpinfo->info_sync_src - && (cmp_address(&(rtp_analysis_dialog->src_rev_), &(pinfo->src)) == 0) - && (rtp_analysis_dialog->port_src_rev_ == pinfo->srcport) - && (cmp_address(&(rtp_analysis_dialog->dst_rev_), &(pinfo->dst)) == 0) - && (rtp_analysis_dialog->port_dst_rev_ == pinfo->destport)) { + else if (rtpstream_id_equal_pinfo_rtp_info(&(rtp_analysis_dialog->rev_statinfo_.id),pinfo,rtpinfo)) { rtp_analysis_dialog->addPacket(false, pinfo, rtpinfo); } @@ -726,13 +692,13 @@ void RtpAnalysisDialog::tapDraw(void *tapinfo_ptr) void RtpAnalysisDialog::resetStatistics() { - memset(&fwd_statinfo_, 0, sizeof(tap_rtp_stat_t)); - memset(&rev_statinfo_, 0, sizeof(tap_rtp_stat_t)); + memset(&fwd_statinfo_.rtp_stats, 0, sizeof(fwd_statinfo_.rtp_stats)); + memset(&rev_statinfo_.rtp_stats, 0, sizeof(rev_statinfo_.rtp_stats)); - fwd_statinfo_.first_packet = TRUE; - rev_statinfo_.first_packet = TRUE; - fwd_statinfo_.reg_pt = PT_UNDEFINED; - rev_statinfo_.reg_pt = PT_UNDEFINED; + fwd_statinfo_.rtp_stats.first_packet = TRUE; + rev_statinfo_.rtp_stats.first_packet = TRUE; + fwd_statinfo_.rtp_stats.reg_pt = PT_UNDEFINED; + rev_statinfo_.rtp_stats.reg_pt = PT_UNDEFINED; ui->forwardTreeWidget->clear(); ui->reverseTreeWidget->clear(); @@ -760,25 +726,25 @@ void RtpAnalysisDialog::addPacket(bool forward, packet_info *pinfo, const _rtp_i // add_rtp_packet(rtpinfo, pinfo); if (forward) { - rtppacket_analyse(&fwd_statinfo_, pinfo, rtpinfo); - new RtpAnalysisTreeWidgetItem(ui->forwardTreeWidget, &fwd_statinfo_, pinfo, rtpinfo); + rtppacket_analyse(&fwd_statinfo_.rtp_stats, pinfo, rtpinfo); + new RtpAnalysisTreeWidgetItem(ui->forwardTreeWidget, &fwd_statinfo_.rtp_stats, pinfo, rtpinfo); - fwd_time_vals_.append(fwd_statinfo_.time / 1000); - fwd_jitter_vals_.append(fwd_statinfo_.jitter); - fwd_diff_vals_.append(fwd_statinfo_.diff); - fwd_delta_vals_.append(fwd_statinfo_.delta); + fwd_time_vals_.append(fwd_statinfo_.rtp_stats.time / 1000); + fwd_jitter_vals_.append(fwd_statinfo_.rtp_stats.jitter); + fwd_diff_vals_.append(fwd_statinfo_.rtp_stats.diff); + fwd_delta_vals_.append(fwd_statinfo_.rtp_stats.delta); - savePayload(fwd_tempfile_, &fwd_statinfo_, pinfo, rtpinfo); + savePayload(fwd_tempfile_, &fwd_statinfo_.rtp_stats, pinfo, rtpinfo); } else { - rtppacket_analyse(&rev_statinfo_, pinfo, rtpinfo); - new RtpAnalysisTreeWidgetItem(ui->reverseTreeWidget, &rev_statinfo_, pinfo, rtpinfo); + rtppacket_analyse(&rev_statinfo_.rtp_stats, pinfo, rtpinfo); + new RtpAnalysisTreeWidgetItem(ui->reverseTreeWidget, &rev_statinfo_.rtp_stats, pinfo, rtpinfo); - rev_time_vals_.append(rev_statinfo_.time / 1000); - rev_jitter_vals_.append(rev_statinfo_.jitter); - rev_diff_vals_.append(rev_statinfo_.diff); - rev_delta_vals_.append(rev_statinfo_.delta); + rev_time_vals_.append(rev_statinfo_.rtp_stats.time / 1000); + rev_jitter_vals_.append(rev_statinfo_.rtp_stats.jitter); + rev_diff_vals_.append(rev_statinfo_.rtp_stats.diff); + rev_delta_vals_.append(rev_statinfo_.rtp_stats.delta); - savePayload(rev_tempfile_, &rev_statinfo_, pinfo, rtpinfo); + savePayload(rev_tempfile_, &rev_statinfo_.rtp_stats, pinfo, rtpinfo); } } @@ -875,29 +841,29 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta void RtpAnalysisDialog::updateStatistics() { - unsigned int f_clock_rate = fwd_statinfo_.clock_rate; - unsigned int r_clock_rate = rev_statinfo_.clock_rate; - unsigned int f_expected = (fwd_statinfo_.stop_seq_nr + fwd_statinfo_.cycles*65536) - - fwd_statinfo_.start_seq_nr + 1; - unsigned int r_expected = (rev_statinfo_.stop_seq_nr + rev_statinfo_.cycles*65536) - - rev_statinfo_.start_seq_nr + 1; - unsigned int f_total_nr = fwd_statinfo_.total_nr; - unsigned int r_total_nr = rev_statinfo_.total_nr; + unsigned int f_clock_rate = fwd_statinfo_.rtp_stats.clock_rate; + unsigned int r_clock_rate = rev_statinfo_.rtp_stats.clock_rate; + unsigned int f_expected = (fwd_statinfo_.rtp_stats.stop_seq_nr + fwd_statinfo_.rtp_stats.cycles*65536) + - fwd_statinfo_.rtp_stats.start_seq_nr + 1; + unsigned int r_expected = (rev_statinfo_.rtp_stats.stop_seq_nr + rev_statinfo_.rtp_stats.cycles*65536) + - rev_statinfo_.rtp_stats.start_seq_nr + 1; + unsigned int f_total_nr = fwd_statinfo_.rtp_stats.total_nr; + unsigned int r_total_nr = rev_statinfo_.rtp_stats.total_nr; int f_lost = f_expected - f_total_nr; int r_lost = r_expected - r_total_nr; - double f_sumt = fwd_statinfo_.sumt; - double f_sumTS = fwd_statinfo_.sumTS; - double f_sumt2 = fwd_statinfo_.sumt2; - double f_sumtTS = fwd_statinfo_.sumtTS; - double r_sumt = rev_statinfo_.sumt; - double r_sumTS = rev_statinfo_.sumTS; - double r_sumt2 = rev_statinfo_.sumt2; - double r_sumtTS = rev_statinfo_.sumtTS; + double f_sumt = fwd_statinfo_.rtp_stats.sumt; + double f_sumTS = fwd_statinfo_.rtp_stats.sumTS; + double f_sumt2 = fwd_statinfo_.rtp_stats.sumt2; + double f_sumtTS = fwd_statinfo_.rtp_stats.sumtTS; + double r_sumt = rev_statinfo_.rtp_stats.sumt; + double r_sumTS = rev_statinfo_.rtp_stats.sumTS; + double r_sumt2 = rev_statinfo_.rtp_stats.sumt2; + double r_sumtTS = rev_statinfo_.rtp_stats.sumtTS; double f_perc, r_perc; double f_clock_drift = 1.0; double r_clock_drift = 1.0; - double f_duration = fwd_statinfo_.time - fwd_statinfo_.start_time; - double r_duration = rev_statinfo_.time - rev_statinfo_.start_time; + double f_duration = fwd_statinfo_.rtp_stats.time - fwd_statinfo_.rtp_stats.start_time; + double r_duration = rev_statinfo_.rtp_stats.time - rev_statinfo_.rtp_stats.start_time; if (f_clock_rate == 0) { f_clock_rate = 1; @@ -927,24 +893,24 @@ void RtpAnalysisDialog::updateStatistics() QString stats_tables = "<html><head><style>td{vertical-align:bottom;}</style></head><body>\n"; stats_tables += QString("<p>%1:%2 " UTF8_LEFT_RIGHT_ARROW) - .arg(address_to_qstring(&src_fwd_, true)) - .arg(port_src_fwd_); + .arg(address_to_qstring(&fwd_statinfo_.id.src_addr, true)) + .arg(fwd_statinfo_.id.src_port); stats_tables += QString("<br>%1:%2</p>\n") - .arg(address_to_qstring(&dst_fwd_, true)) - .arg(port_dst_fwd_); + .arg(address_to_qstring(&fwd_statinfo_.id.dst_addr, true)) + .arg(fwd_statinfo_.id.dst_port); stats_tables += "<h4>Forward</h4>\n"; stats_tables += "<p><table>\n"; stats_tables += QString("<tr><th align=\"left\">SSRC</th><td>%1</td></tr>") - .arg(int_to_qstring(ssrc_fwd_, 8, 16)); + .arg(int_to_qstring(fwd_statinfo_.id.ssrc, 8, 16)); stats_tables += QString("<tr><th align=\"left\">Max Delta</th><td>%1 ms @ %2</td></tr>") - .arg(fwd_statinfo_.max_delta, 0, 'f', 2) - .arg(fwd_statinfo_.max_nr); + .arg(fwd_statinfo_.rtp_stats.max_delta, 0, 'f', 2) + .arg(fwd_statinfo_.rtp_stats.max_nr); stats_tables += QString("<tr><th align=\"left\">Max Jitter</th><td>%1 ms</td></tr>") - .arg(fwd_statinfo_.max_jitter, 0, 'f', 2); + .arg(fwd_statinfo_.rtp_stats.max_jitter, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Mean Jitter</th><td>%1 ms</td></tr>") - .arg(fwd_statinfo_.mean_jitter, 0, 'f', 2); + .arg(fwd_statinfo_.rtp_stats.mean_jitter, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Max Skew</th><td>%1 ms</td></tr>") - .arg(fwd_statinfo_.max_skew, 0, 'f', 2); + .arg(fwd_statinfo_.rtp_stats.max_skew, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">RTP Packets</th><td>%1</td></tr>") .arg(f_total_nr); stats_tables += QString("<tr><th align=\"left\">Expected</th><td>%1</td></tr>") @@ -952,10 +918,10 @@ void RtpAnalysisDialog::updateStatistics() stats_tables += QString("<tr><th align=\"left\">Lost</th><td>%1 (%2 %)</td></tr>") .arg(f_lost).arg(f_perc, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Seq Errs</th><td>%1</td></tr>") - .arg(fwd_statinfo_.sequence); + .arg(fwd_statinfo_.rtp_stats.sequence); stats_tables += QString("<tr><th align=\"left\">Start at</th><td>%1 s @ %2</td></tr>") - .arg(fwd_statinfo_.start_time / 1000.0, 0, 'f', 6) - .arg(fwd_statinfo_.first_packet_num); + .arg(fwd_statinfo_.rtp_stats.start_time / 1000.0, 0, 'f', 6) + .arg(fwd_statinfo_.rtp_stats.first_packet_num); stats_tables += QString("<tr><th align=\"left\">Duration</th><td>%1 s</td></tr>") .arg(f_duration / 1000.0, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Clock Drift</th><td>%1 ms</td></tr>") @@ -967,16 +933,16 @@ void RtpAnalysisDialog::updateStatistics() stats_tables += "<h4>Reverse</h4>\n"; stats_tables += "<p><table>\n"; stats_tables += QString("<tr><th align=\"left\">SSRC</th><td>%1</td></tr>") - .arg(int_to_qstring(ssrc_rev_, 8, 16)); + .arg(int_to_qstring(rev_statinfo_.id.ssrc, 8, 16)); stats_tables += QString("<tr><th align=\"left\">Max Delta</th><td>%1 ms @ %2</td></tr>") - .arg(rev_statinfo_.max_delta, 0, 'f', 2) - .arg(rev_statinfo_.max_nr); + .arg(rev_statinfo_.rtp_stats.max_delta, 0, 'f', 2) + .arg(rev_statinfo_.rtp_stats.max_nr); stats_tables += QString("<tr><th align=\"left\">Max Jitter</th><td>%1 ms</td></tr>") - .arg(rev_statinfo_.max_jitter, 0, 'f', 2); + .arg(rev_statinfo_.rtp_stats.max_jitter, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Mean Jitter</th><td>%1 ms</td></tr>") - .arg(rev_statinfo_.mean_jitter, 0, 'f', 2); + .arg(rev_statinfo_.rtp_stats.mean_jitter, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Max Skew</th><td>%1 ms</td></tr>") - .arg(rev_statinfo_.max_skew, 0, 'f', 2); + .arg(rev_statinfo_.rtp_stats.max_skew, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">RTP Packets</th><td>%1</td></tr>") .arg(r_total_nr); stats_tables += QString("<tr><th align=\"left\">Expected</th><td>%1</td></tr>") @@ -984,10 +950,10 @@ void RtpAnalysisDialog::updateStatistics() stats_tables += QString("<tr><th align=\"left\">Lost</th><td>%1 (%2 %)</td></tr>") .arg(r_lost).arg(r_perc, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Seq Errs</th><td>%1</td></tr>") - .arg(rev_statinfo_.sequence); + .arg(rev_statinfo_.rtp_stats.sequence); stats_tables += QString("<tr><th align=\"left\">Start at</th><td>%1 s @ %2</td></tr>") - .arg(rev_statinfo_.start_time / 1000.0, 0, 'f', 6) - .arg(rev_statinfo_.first_packet_num); + .arg(rev_statinfo_.rtp_stats.start_time / 1000.0, 0, 'f', 6) + .arg(rev_statinfo_.rtp_stats.first_packet_num); stats_tables += QString("<tr><th align=\"left\">Duration</th><td>%1 s</td></tr>") .arg(r_duration / 1000.0, 0, 'f', 2); stats_tables += QString("<tr><th align=\"left\">Clock Drift</th><td>%1 ms</td></tr>") @@ -995,10 +961,10 @@ void RtpAnalysisDialog::updateStatistics() stats_tables += QString("<tr><th align=\"left\">Freq Drift</th><td>%1 Hz (%2 %)</td></tr>") // XXX Terminology? .arg(r_clock_drift * r_clock_rate, 0, 'f', 0).arg(100.0 * (r_clock_drift - 1.0), 0, 'f', 2); stats_tables += "</table></p>"; - if (rev_statinfo_.total_nr) { + if (rev_statinfo_.rtp_stats.total_nr) { stats_tables += QString("<h4>Forward to reverse<br/>start diff %1 s @ %2</h4>") - .arg((rev_statinfo_.start_time - fwd_statinfo_.start_time) / 1000.0, 0, 'f', 6) - .arg((gint64)rev_statinfo_.first_packet_num - (gint64)fwd_statinfo_.first_packet_num); + .arg((rev_statinfo_.rtp_stats.start_time - fwd_statinfo_.rtp_stats.start_time) / 1000.0, 0, 'f', 6) + .arg((gint64)rev_statinfo_.rtp_stats.first_packet_num - (gint64)fwd_statinfo_.rtp_stats.first_packet_num); } stats_tables += "</body></html>\n"; @@ -1042,26 +1008,19 @@ void RtpAnalysisDialog::showPlayer() // XXX We might want to create an "rtp_stream_id_t" struct with only // addresses, ports & SSRC. memset(&stream_info, 0, sizeof(stream_info)); - copy_address(&(stream_info.src_addr), &src_fwd_); - stream_info.src_port = port_src_fwd_; - copy_address(&(stream_info.dest_addr), &dst_fwd_); - stream_info.dest_port = port_dst_fwd_; - stream_info.ssrc = ssrc_fwd_; - stream_info.packet_count = packet_count_fwd_; - stream_info.setup_frame_number = setup_frame_number_fwd_; - nstime_copy(&stream_info.start_rel_time, &start_rel_time_fwd_); + rtpstream_id_copy(&fwd_statinfo_.id, &stream_info.id); + stream_info.packet_count = fwd_statinfo_.packet_count; + stream_info.setup_frame_number = fwd_statinfo_.setup_frame_number; + nstime_copy(&stream_info.start_rel_time, &fwd_statinfo_.start_rel_time); rtp_player_dialog.addRtpStream(&stream_info); if (num_streams_ > 1) { - copy_address(&(stream_info.src_addr), &src_rev_); - stream_info.src_port = port_src_rev_; - copy_address(&(stream_info.dest_addr), &dst_rev_); - stream_info.dest_port = port_dst_rev_; - stream_info.ssrc = ssrc_rev_; - stream_info.packet_count = packet_count_rev_; - stream_info.setup_frame_number = setup_frame_number_rev_; + memset(&stream_info, 0, sizeof(stream_info)); + rtpstream_id_copy(&rev_statinfo_.id, &stream_info.id); + stream_info.packet_count = rev_statinfo_.packet_count; + stream_info.setup_frame_number = rev_statinfo_.setup_frame_number; + nstime_copy(&stream_info.start_rel_time, &rev_statinfo_.start_rel_time); rtp_player_dialog.addRtpStream(&stream_info); - nstime_copy(&stream_info.start_rel_time, &start_rel_time_rev_); } connect(&rtp_player_dialog, SIGNAL(goToPacket(int)), this, SIGNAL(goToPacket(int))); @@ -1244,10 +1203,10 @@ gboolean RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_f header_end=save_file->pos(); - bool two_channels = rev_statinfo_.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); - double t_min = MIN(fwd_statinfo_.start_time, rev_statinfo_.start_time); - double t_fwd_diff = fwd_statinfo_.start_time - t_min; - double t_rev_diff = rev_statinfo_.start_time - t_min; + bool two_channels = rev_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); + double t_min = MIN(fwd_statinfo_.rtp_stats.start_time, rev_statinfo_.rtp_stats.start_time); + double t_fwd_diff = fwd_statinfo_.rtp_stats.start_time - t_min; + double t_rev_diff = rev_statinfo_.rtp_stats.start_time - t_min; size_t fwd_samples_diff = 0; size_t rev_samples_diff = 0; size_t bidir_samples_diff = 0; @@ -1292,12 +1251,12 @@ gboolean RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_f switch (direction) { /* Only forward direction */ case dir_forward_: { - fwd_total_len = guint32_wraparound_diff(fwd_statinfo_.timestamp, fwd_statinfo_.first_timestamp) + fwd_statinfo_.last_payload_len; + fwd_total_len = guint32_wraparound_diff(fwd_statinfo_.rtp_stats.timestamp, fwd_statinfo_.rtp_stats.first_timestamp) + fwd_statinfo_.rtp_stats.last_payload_len; if (! saveAudioAUSilence(fwd_total_len + fwd_samples_diff + bidir_samples_diff, save_file, stop_flag)) { return FALSE; } - if (! saveAudioAUUnidir(fwd_statinfo_, fwd_tempfile_, save_file, header_end, stop_flag, FALSE, fwd_samples_diff + bidir_samples_diff)) + if (! saveAudioAUUnidir(fwd_statinfo_.rtp_stats, fwd_tempfile_, save_file, header_end, stop_flag, FALSE, fwd_samples_diff + bidir_samples_diff)) { return FALSE; } @@ -1305,12 +1264,12 @@ gboolean RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_f } /* Only reverse direction */ case dir_reverse_: { - rev_total_len = guint32_wraparound_diff(rev_statinfo_.timestamp, rev_statinfo_.first_timestamp) + rev_statinfo_.last_payload_len; + rev_total_len = guint32_wraparound_diff(rev_statinfo_.rtp_stats.timestamp, rev_statinfo_.rtp_stats.first_timestamp) + rev_statinfo_.rtp_stats.last_payload_len; if (! saveAudioAUSilence(rev_total_len + rev_samples_diff + bidir_samples_diff, save_file, stop_flag)) { return FALSE; } - if (! saveAudioAUUnidir(rev_statinfo_, rev_tempfile_, save_file, header_end, stop_flag, FALSE, rev_samples_diff + bidir_samples_diff)) + if (! saveAudioAUUnidir(rev_statinfo_.rtp_stats, rev_tempfile_, save_file, header_end, stop_flag, FALSE, rev_samples_diff + bidir_samples_diff)) { return FALSE; } @@ -1318,14 +1277,14 @@ gboolean RtpAnalysisDialog::saveAudioAU(StreamDirection direction, QFile *save_f } /* Both directions */ case dir_both_: { - fwd_total_len = guint32_wraparound_diff(fwd_statinfo_.timestamp, fwd_statinfo_.first_timestamp) + fwd_statinfo_.last_payload_len; - rev_total_len = guint32_wraparound_diff(rev_statinfo_.timestamp, rev_statinfo_.first_timestamp) + rev_statinfo_.last_payload_len; + fwd_total_len = guint32_wraparound_diff(fwd_statinfo_.rtp_stats.timestamp, fwd_statinfo_.rtp_stats.first_timestamp) + fwd_statinfo_.rtp_stats.last_payload_len; + rev_total_len = guint32_wraparound_diff(rev_statinfo_.rtp_stats.timestamp, rev_statinfo_.rtp_stats.first_timestamp) + rev_statinfo_.rtp_stats.last_payload_len; total_len = MAX(fwd_total_len + fwd_samples_diff, rev_total_len + rev_samples_diff); if (! saveAudioAUSilence((total_len + bidir_samples_diff) * 2, save_file, stop_flag)) { return FALSE; } - if (! saveAudioAUBidir(fwd_statinfo_, rev_statinfo_, fwd_tempfile_, rev_tempfile_, save_file, header_end, stop_flag, fwd_samples_diff + bidir_samples_diff, rev_samples_diff + bidir_samples_diff)) + if (! saveAudioAUBidir(fwd_statinfo_.rtp_stats, rev_statinfo_.rtp_stats, fwd_tempfile_, rev_tempfile_, save_file, header_end, stop_flag, fwd_samples_diff + bidir_samples_diff, rev_samples_diff + bidir_samples_diff)) { return FALSE; } @@ -1445,8 +1404,8 @@ void RtpAnalysisDialog::saveAudio(RtpAnalysisDialog::StreamDirection direction, ui->progressFrame->showProgress(true, true, &stop_flag); if (save_format == save_audio_au_) { /* au format */ - if ((fwd_statinfo_.clock_rate != 8000) || - ((rev_statinfo_.clock_rate != 0) && (rev_statinfo_.clock_rate != 8000)) + if ((fwd_statinfo_.rtp_stats.clock_rate != 8000) || + ((rev_statinfo_.rtp_stats.clock_rate != 0) && (rev_statinfo_.rtp_stats.clock_rate != 8000)) ) { QMessageBox::warning(this, tr("Warning"), tr("Can save audio with 8000 Hz clock rate only")); } else { @@ -1619,16 +1578,10 @@ void RtpAnalysisDialog::findStreams() dfilter_free(sfcode); /* OK, it is an RTP frame. Let's get the IP and port values */ - copy_address(&(src_fwd_), &(edt.pi.src)); - copy_address(&(dst_fwd_), &(edt.pi.dst)); - port_src_fwd_ = edt.pi.srcport; - port_dst_fwd_ = edt.pi.destport; + rtpstream_id_copy_pinfo(&(edt.pi),&(fwd_statinfo_.id),FALSE); /* assume the inverse ip/port combination for the reverse direction */ - copy_address(&(src_rev_), &(edt.pi.dst)); - copy_address(&(dst_rev_), &(edt.pi.src)); - port_src_rev_ = edt.pi.destport; - port_dst_rev_ = edt.pi.srcport; + rtpstream_id_copy_pinfo(&(edt.pi),&(rev_statinfo_.id),TRUE); /* now we need the SSRC value of the current frame */ GPtrArray *gp = proto_get_finfo_ptr_array(edt.tree, hfid_rtp_ssrc); @@ -1639,7 +1592,7 @@ void RtpAnalysisDialog::findStreams() updateWidgets(); return; } - ssrc_fwd_ = fvalue_get_uinteger(&((field_info *)gp->pdata[0])->value); + fwd_statinfo_.id.ssrc = fvalue_get_uinteger(&((field_info *)gp->pdata[0])->value); /* Register the tap listener */ memset(&tapinfo_, 0, sizeof(rtpstream_tapinfo_t)); @@ -1652,28 +1605,22 @@ void RtpAnalysisDialog::findStreams() for (GList *strinfo_list = g_list_first(tapinfo_.strinfo_list); strinfo_list; strinfo_list = g_list_next(strinfo_list)) { rtpstream_info_t * strinfo = (rtpstream_info_t*)(strinfo_list->data); - if (addresses_equal(&(strinfo->src_addr), &(src_fwd_)) - && (strinfo->src_port == port_src_fwd_) - && (addresses_equal(&(strinfo->dest_addr), &(dst_fwd_))) - && (strinfo->dest_port == port_dst_fwd_)) + if (rtpstream_id_equal(&(strinfo->id), &(fwd_statinfo_.id),RTPSTREAM_ID_EQUAL_NONE)) { - packet_count_fwd_ = strinfo->packet_count; - setup_frame_number_fwd_ = strinfo->setup_frame_number; - nstime_copy(&start_rel_time_fwd_, &strinfo->start_rel_time); + fwd_statinfo_.packet_count = strinfo->packet_count; + fwd_statinfo_.setup_frame_number = strinfo->setup_frame_number; + nstime_copy(&fwd_statinfo_.start_rel_time, &strinfo->start_rel_time); num_streams_++; } - if (addresses_equal(&(strinfo->src_addr), &(src_rev_)) - && (strinfo->src_port == port_src_rev_) - && (addresses_equal(&(strinfo->dest_addr), &(dst_rev_))) - && (strinfo->dest_port == port_dst_rev_)) + if (rtpstream_id_equal(&(strinfo->id), &(rev_statinfo_.id),RTPSTREAM_ID_EQUAL_NONE)) { - packet_count_rev_ = strinfo->packet_count; - setup_frame_number_rev_ = strinfo->setup_frame_number; - nstime_copy(&start_rel_time_rev_, &strinfo->start_rel_time); + rev_statinfo_.packet_count = strinfo->packet_count; + rev_statinfo_.setup_frame_number = strinfo->setup_frame_number; + nstime_copy(&rev_statinfo_.start_rel_time, &strinfo->start_rel_time); num_streams_++; - if (ssrc_rev_ == 0) { - ssrc_rev_ = strinfo->ssrc; + if (rev_statinfo_.id.ssrc == 0) { + rev_statinfo_.id.ssrc = strinfo->id.ssrc; } } } diff --git a/ui/qt/rtp_analysis_dialog.h b/ui/qt/rtp_analysis_dialog.h index a65b2e9845..87f92920c1 100644 --- a/ui/qt/rtp_analysis_dialog.h +++ b/ui/qt/rtp_analysis_dialog.h @@ -82,30 +82,10 @@ private: enum StreamDirection { dir_both_, dir_forward_, dir_reverse_ }; enum SyncType { sync_unsync_, sync_sync_stream_, sync_sync_file_ }; - // XXX These are copied to and from rtp_stream_info_t structs. Should - // we just have a pair of those instead? - address src_fwd_; - guint32 port_src_fwd_; - address dst_fwd_; - guint32 port_dst_fwd_; - guint32 ssrc_fwd_; - guint32 packet_count_fwd_; - guint32 setup_frame_number_fwd_; - nstime_t start_rel_time_fwd_; - - address src_rev_; - guint32 port_src_rev_; - address dst_rev_; - guint32 port_dst_rev_; - guint32 ssrc_rev_; - guint32 packet_count_rev_; - guint32 setup_frame_number_rev_; - nstime_t start_rel_time_rev_; - int num_streams_; - tap_rtp_stat_t fwd_statinfo_; - tap_rtp_stat_t rev_statinfo_; + rtpstream_info_t fwd_statinfo_; + rtpstream_info_t rev_statinfo_; QPushButton *player_button_; diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp index 2f3f0830af..a54e61aaef 100644 --- a/ui/qt/rtp_audio_stream.cpp +++ b/ui/qt/rtp_audio_stream.cpp @@ -53,11 +53,7 @@ RtpAudioStream::RtpAudioStream(QObject *parent, rtpstream_info_t *rtp_stream) : jitter_buffer_size_(50), timing_mode_(RtpAudioStream::JitterBuffer) { - copy_address(&src_addr_, &rtp_stream->src_addr); - src_port_ = rtp_stream->src_port; - copy_address(&dst_addr_, &rtp_stream->dest_addr); - dst_port_ = rtp_stream->dest_port; - ssrc_ = rtp_stream->ssrc; + rtpstream_id_copy(&rtp_stream->id, &id_); // We keep visual samples in memory. Make fewer of them. visual_resampler_ = speex_resampler_init(1, default_audio_sample_rate_, @@ -82,16 +78,13 @@ RtpAudioStream::~RtpAudioStream() g_hash_table_destroy(decoders_hash_); if (audio_resampler_) speex_resampler_destroy (audio_resampler_); speex_resampler_destroy (visual_resampler_); + rtpstream_id_free(&id_); } bool RtpAudioStream::isMatch(const rtpstream_info_t *rtp_stream) const { if (rtp_stream - && addresses_equal(&rtp_stream->src_addr, &src_addr_) - && rtp_stream->src_port == src_port_ - && addresses_equal(&rtp_stream->dest_addr, &dst_addr_) - && rtp_stream->dest_port == dst_port_ - && rtp_stream->ssrc == ssrc_) + && rtpstream_id_equal(&id_, &(rtp_stream->id), RTPSTREAM_ID_EQUAL_SSRC)) return true; return false; } @@ -99,11 +92,7 @@ bool RtpAudioStream::isMatch(const rtpstream_info_t *rtp_stream) const bool RtpAudioStream::isMatch(const _packet_info *pinfo, const _rtp_info *rtp_info) const { if (pinfo && rtp_info - && addresses_equal(&pinfo->src, &src_addr_) - && pinfo->srcport == src_port_ - && addresses_equal(&pinfo->dst, &dst_addr_) - && pinfo->destport == dst_port_ - && rtp_info->info_sync_src == ssrc_) + && rtpstream_id_equal_pinfo_rtp_info(&id_, pinfo, rtp_info)) return true; return false; } diff --git a/ui/qt/rtp_audio_stream.h b/ui/qt/rtp_audio_stream.h index 7bed8ff249..fd6020235d 100644 --- a/ui/qt/rtp_audio_stream.h +++ b/ui/qt/rtp_audio_stream.h @@ -141,11 +141,7 @@ public slots: private: // Used to identify unique streams. // The GTK+ UI also uses the call number + current channel. - address src_addr_; - quint16 src_port_; - address dst_addr_; - quint16 dst_port_; - quint32 ssrc_; + rtpstream_id_t id_; QVector<struct _rtp_packet *>rtp_packets_; QTemporaryFile *tempfile_; diff --git a/ui/qt/rtp_player_dialog.cpp b/ui/qt/rtp_player_dialog.cpp index 67fec148ba..513b1bf372 100644 --- a/ui/qt/rtp_player_dialog.cpp +++ b/ui/qt/rtp_player_dialog.cpp @@ -376,11 +376,11 @@ void RtpPlayerDialog::addRtpStream(rtpstream_info_t *rtp_stream) audio_stream->setColor(ColorUtils::graphColor(tli_count)); QTreeWidgetItem *ti = new QTreeWidgetItem(ui->streamTreeWidget); - ti->setText(src_addr_col_, address_to_qstring(&rtp_stream->src_addr)); - ti->setText(src_port_col_, QString::number(rtp_stream->src_port)); - ti->setText(dst_addr_col_, address_to_qstring(&rtp_stream->dest_addr)); - ti->setText(dst_port_col_, QString::number(rtp_stream->dest_port)); - ti->setText(ssrc_col_, int_to_qstring(rtp_stream->ssrc, 8, 16)); + ti->setText(src_addr_col_, address_to_qstring(&rtp_stream->id.src_addr)); + ti->setText(src_port_col_, QString::number(rtp_stream->id.src_port)); + ti->setText(dst_addr_col_, address_to_qstring(&rtp_stream->id.dst_addr)); + ti->setText(dst_port_col_, QString::number(rtp_stream->id.dst_port)); + ti->setText(ssrc_col_, int_to_qstring(rtp_stream->id.ssrc, 8, 16)); ti->setText(first_pkt_col_, QString::number(rtp_stream->setup_frame_number)); ti->setText(num_pkts_col_, QString::number(rtp_stream->packet_count)); @@ -776,8 +776,8 @@ const QString RtpPlayerDialog::streamKey(const rtpstream_info_t *rtp_stream) const QString stream_key = QString(stream_key_tmpl_) .arg(address_to_display_qstring(&rtp_stream->src_addr)) .arg(rtp_stream->src_port) - .arg(address_to_display_qstring(&rtp_stream->dest_addr)) - .arg(rtp_stream->dest_port) + .arg(address_to_display_qstring(&rtp_stream->dst_addr)) + .arg(rtp_stream->dst_port) .arg(rtp_stream->ssrc, 0, 16); return stream_key; } diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp index e0674ead3a..3951e2c4e0 100644 --- a/ui/qt/rtp_stream_dialog.cpp +++ b/ui/qt/rtp_stream_dialog.cpp @@ -86,11 +86,11 @@ public: if (!stream_info_) { return; } - setText(src_addr_col_, address_to_display_qstring(&stream_info_->src_addr)); - setText(src_port_col_, QString::number(stream_info_->src_port)); - setText(dst_addr_col_, address_to_display_qstring(&stream_info_->dest_addr)); - setText(dst_port_col_, QString::number(stream_info_->dest_port)); - setText(ssrc_col_, QString("0x%1").arg(stream_info_->ssrc, 0, 16)); + setText(src_addr_col_, address_to_display_qstring(&stream_info_->id.src_addr)); + setText(src_port_col_, QString::number(stream_info_->id.src_port)); + setText(dst_addr_col_, address_to_display_qstring(&stream_info_->id.dst_addr)); + setText(dst_port_col_, QString::number(stream_info_->id.dst_port)); + setText(ssrc_col_, QString("0x%1").arg(stream_info_->id.ssrc, 0, 16)); if (stream_info_->payload_type_name != NULL) { setText(payload_col_, stream_info_->payload_type_name); @@ -139,11 +139,11 @@ public: case payload_col_: // XXX Return numeric value? return text(col); case src_port_col_: - return stream_info_->src_port; + return stream_info_->id.src_port; case dst_port_col_: - return stream_info_->dest_port; + return stream_info_->id.dst_port; case ssrc_col_: - return stream_info_->ssrc; + return stream_info_->id.ssrc; case packets_col_: return stream_info_->packet_count; case lost_col_: @@ -169,15 +169,15 @@ public: switch (treeWidget()->sortColumn()) { case src_addr_col_: - return cmp_address(&(stream_info_->src_addr), &(other_rstwi.stream_info_->src_addr)) < 0; + return cmp_address(&(stream_info_->id.src_addr), &(other_rstwi.stream_info_->id.src_addr)) < 0; case src_port_col_: - return stream_info_->src_port < other_rstwi.stream_info_->src_port; + return stream_info_->id.src_port < other_rstwi.stream_info_->id.src_port; case dst_addr_col_: - return cmp_address(&(stream_info_->dest_addr), &(other_rstwi.stream_info_->dest_addr)) < 0; + return cmp_address(&(stream_info_->id.dst_addr), &(other_rstwi.stream_info_->id.dst_addr)) < 0; case dst_port_col_: - return stream_info_->dest_port < other_rstwi.stream_info_->dest_port; + return stream_info_->id.dst_port < other_rstwi.stream_info_->id.dst_port; case ssrc_col_: - return stream_info_->ssrc < other_rstwi.stream_info_->ssrc; + return stream_info_->id.ssrc < other_rstwi.stream_info_->id.ssrc; case payload_col_: return stream_info_->payload_type < other_rstwi.stream_info_->payload_type; // XXX Compare payload_type_name instead? case packets_col_: @@ -599,14 +599,14 @@ void RtpStreamDialog::on_actionPrepareFilter_triggered() RtpStreamTreeWidgetItem *rsti = static_cast<RtpStreamTreeWidgetItem*>(ti); rtpstream_info_t *stream_info = rsti->streamInfo(); if (stream_info) { - QString ip_proto = stream_info->src_addr.type == AT_IPv6 ? "ipv6" : "ip"; + QString ip_proto = stream_info->id.src_addr.type == AT_IPv6 ? "ipv6" : "ip"; stream_filters << QString("(%1.src==%2 && udp.srcport==%3 && %1.dst==%4 && udp.dstport==%5 && rtp.ssrc==0x%6)") .arg(ip_proto) // %1 - .arg(address_to_qstring(&stream_info->src_addr)) // %2 - .arg(stream_info->src_port) // %3 - .arg(address_to_qstring(&stream_info->dest_addr)) // %4 - .arg(stream_info->dest_port) // %5 - .arg(stream_info->ssrc, 0, 16); + .arg(address_to_qstring(&stream_info->id.src_addr)) // %2 + .arg(stream_info->id.src_port) // %3 + .arg(address_to_qstring(&stream_info->id.dst_addr)) // %4 + .arg(stream_info->id.dst_port) // %5 + .arg(stream_info->id.ssrc, 0, 16); } } if (stream_filters.length() > 0) { diff --git a/ui/rtp_stream.c b/ui/rtp_stream.c index fb28942391..d66ead5d7b 100644 --- a/ui/rtp_stream.c +++ b/ui/rtp_stream.c @@ -121,22 +121,6 @@ gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rt } /****************************************************************************/ -/* compare the endpoints of two RTP streams */ -gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b) -{ - if (stream_a == NULL || stream_b == NULL) - return FALSE; - - if ((addresses_equal(&(stream_a->src_addr), &(stream_b->dest_addr))) - && (stream_a->src_port == stream_b->dest_port) - && (addresses_equal(&(stream_a->dest_addr), &(stream_b->src_addr))) - && (stream_a->dest_port == stream_b->src_port)) - return TRUE; - else - return FALSE; -} - -/****************************************************************************/ /* mark packets in stream_fwd or stream_rev */ void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream_fwd, rtpstream_info_t* stream_rev) { diff --git a/ui/rtp_stream.h b/ui/rtp_stream.h index 3e906483af..835f6bd09c 100644 --- a/ui/rtp_stream.h +++ b/ui/rtp_stream.h @@ -32,13 +32,11 @@ extern "C" { #include <epan/address.h> #include <epan/tap.h> +#include "ui/rtp_stream_id.h" + /** Defines an rtp stream */ typedef struct _rtpstream_info { - address src_addr; - guint32 src_port; - address dest_addr; - guint32 dest_port; - guint32 ssrc; + rtpstream_id_t id; guint8 payload_type; /**< Numeric payload type */ gchar *payload_type_name; /**< Payload type name */ @@ -84,14 +82,14 @@ struct _rtpstream_tapinfo { rtpstream_tap_reset_cb tap_reset; /**< tap reset callback */ rtpstream_tap_draw_cb tap_draw; /**< tap draw callback */ tap_mark_packet_cb tap_mark_packet; /**< packet marking callback */ - void *tap_data; /**< data for tap callbacks */ + void *tap_data; /**< data for tap callbacks */ int nstreams; /**< number of streams in the list */ GList *strinfo_list; /**< list of rtp_stream_info_t* */ int npackets; /**< total number of rtp packets of all streams */ /* used while tapping. user shouldn't modify these */ tap_mode_t mode; - rtpstream_info_t *filter_stream_fwd; /**< used as filter in some tap modes */ - rtpstream_info_t *filter_stream_rev; /**< used as filter in some tap modes */ + rtpstream_info_t *filter_stream_fwd; /**< used as filter in some tap modes */ + rtpstream_info_t *filter_stream_rev; /**< used as filter in some tap modes */ FILE *save_file; gboolean is_registered; /**< if the tap listener is currently registered or not */ }; @@ -142,13 +140,6 @@ void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream, const gchar *filename); /** -* Compares the endpoints of two RTP streams. -* -* @return TRUE if the -*/ -gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b); - -/** * Marks all packets belonging to either of stream_fwd or stream_rev. * (both can be NULL) * (redissects all packets) diff --git a/ui/rtp_stream_id.c b/ui/rtp_stream_id.c new file mode 100644 index 0000000000..d50c52c14c --- /dev/null +++ b/ui/rtp_stream_id.c @@ -0,0 +1,118 @@ +/* rtp_stream_id.c + * RTP stream id functions for Wireshark + * + * Copyright 2003, Alcatel Business Systems + * By Lars Ruoff <lars.ruoff@gmx.net> + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" + +#include <stdlib.h> +#include <string.h> + +#include "file.h" + +#include "ui/rtp_stream_id.h" +#include "epan/dissectors/packet-rtp.h" + +/****************************************************************************/ +/* rtpstream id functions */ +/****************************************************************************/ + +/****************************************************************************/ +/* deep copy of id */ +void rtpstream_id_copy(const rtpstream_id_t *src, rtpstream_id_t *dest) +{ + copy_address(&(dest->src_addr), &(src->src_addr)); + dest->src_port=src->src_port; + copy_address(&(dest->dst_addr), &(src->dst_addr)); + dest->dst_port=src->dst_port; + dest->ssrc=src->ssrc; +} + +/****************************************************************************/ +/* deep copy of id from packet_info */ +void rtpstream_id_copy_pinfo(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst) +{ + if (!swap_src_dst) + { + copy_address(&(dest->src_addr), &(pinfo->src)); + dest->src_port=pinfo->srcport; + copy_address(&(dest->dst_addr), &(pinfo->dst)); + dest->dst_port=pinfo->destport; + } + else + { + copy_address(&(dest->src_addr), &(pinfo->dst)); + dest->src_port=pinfo->destport; + copy_address(&(dest->dst_addr), &(pinfo->src)); + dest->dst_port=pinfo->srcport; + } +} + +/****************************************************************************/ +/* free memory allocated for id */ +void rtpstream_id_free(rtpstream_id_t *id) +{ + free_address(&(id->src_addr)); + free_address(&(id->dst_addr)); + memset(id, 0, sizeof(*id)); +} + +/****************************************************************************/ +/* compare two ids by flags */ +gboolean rtpstream_id_equal(const rtpstream_id_t *id1, const rtpstream_id_t *id2, guint flags) +{ + if (addresses_equal(&(id1->src_addr), &(id2->src_addr)) + && id1->src_port == id2->src_port + && addresses_equal(&(id1->dst_addr), &(id2->dst_addr)) + && id1->dst_port == id2->dst_port) + { + gboolean equal = TRUE; + + if ((flags & RTPSTREAM_ID_EQUAL_SSRC) + && id1->ssrc != id2->ssrc) + { + equal = FALSE; + } + + return equal; + } + + return FALSE; +} + +/****************************************************************************/ +/* compare two ids, one in pinfo */ +gboolean rtpstream_id_equal_pinfo_rtp_info(const rtpstream_id_t *id, const packet_info *pinfo, const struct _rtp_info *rtp_info) +{ + if (addresses_equal(&(id->src_addr), &(pinfo->src)) + && id->src_port == pinfo->srcport + && addresses_equal(&(id->dst_addr), &(pinfo->dst)) + && id->dst_port == pinfo->destport + && id->ssrc == rtp_info->info_sync_src) + { + return TRUE; + } + + return FALSE; +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/rtp_stream_id.h b/ui/rtp_stream_id.h new file mode 100644 index 0000000000..a303beb865 --- /dev/null +++ b/ui/rtp_stream_id.h @@ -0,0 +1,90 @@ +/* rtp_stream_id.h + * RTP stream id functions for Wireshark + * + * Copyright 2003, Alcatel Business Systems + * By Lars Ruoff <lars.ruoff@gmx.net> + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __RTP_STREAM_ID_H__ +#define __RTP_STREAM_ID_H__ + +/** @file + * "RTP Streams" dialog box common routines. + * @ingroup main_ui_group + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <epan/address.h> + +/* forward */ +struct _rtp_info; + +/** Defines an rtp stream identification */ +typedef struct _rtpstream_id { + address src_addr; + guint16 src_port; + address dst_addr; + guint16 dst_port; + guint32 ssrc; +} rtpstream_id_t; + +/** + * Copy rtp_stream_id_t structure + */ +void rtpstream_id_copy(const rtpstream_id_t *src, rtpstream_id_t *dest); + +/** + * Copy addresses and ports from pinfo + */ +void rtpstream_id_copy_pinfo(const packet_info *pinfo, rtpstream_id_t *dest, gboolean swap_src_dst); + +/** + * Free memory allocated for id + * it releases address items only, do not release whole structure! + */ +void rtpstream_id_free(rtpstream_id_t *id); + +/** + * Check if two rtpstream_id_t are equal + * - compare src_addr, dest_addr, src_port, dest_port + * - compare other items when requested + * Note: ssrc is the only other item now, but it is expected it will be extended later + */ +#define RTPSTREAM_ID_EQUAL_NONE 0x0000 +#define RTPSTREAM_ID_EQUAL_SSRC 0x0001 +gboolean rtpstream_id_equal(const rtpstream_id_t *id1, const rtpstream_id_t *id2, guint flags); + +/** + * Check if rtpstream_id_t is equal to pinfo + * - compare src_addr, dest_addr, src_port, dest_port with pinfo + * - compare ssrc with rtp_info + */ +gboolean rtpstream_id_equal_pinfo_rtp_info(const rtpstream_id_t *id, const packet_info *pinfo, const struct _rtp_info *rtp_info); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __RTP_STREAM_ID_H__ */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/tap-rtp-common.c b/ui/tap-rtp-common.c index e18c847bc1..d2439c3449 100644 --- a/ui/tap-rtp-common.c +++ b/ui/tap-rtp-common.c @@ -45,7 +45,7 @@ typedef struct st_rtpdump_info { /****************************************************************************/ /* GCompareFunc style comparison function for rtp_stream_info_t */ -static gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb) +gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb) { const rtpstream_info_t* a = (const rtpstream_info_t*)aa; const rtpstream_info_t* b = (const rtpstream_info_t*)bb; @@ -54,16 +54,27 @@ static gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb) return 0; if (a==NULL || b==NULL) return 1; - if (addresses_equal(&(a->src_addr), &(b->src_addr)) - && (a->src_port == b->src_port) - && addresses_equal(&(a->dest_addr), &(b->dest_addr)) - && (a->dest_port == b->dest_port) - && (a->ssrc == b->ssrc)) + if (rtpstream_id_equal(&(a->id),&(b->id),RTPSTREAM_ID_EQUAL_SSRC)) return 0; else return 1; } +/****************************************************************************/ +/* compare the endpoints of two RTP streams */ +gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b) +{ + if (stream_a == NULL || stream_b == NULL) + return FALSE; + + if ((addresses_equal(&(stream_a->id.src_addr), &(stream_b->id.dst_addr))) + && (stream_a->id.src_port == stream_b->id.dst_port) + && (addresses_equal(&(stream_a->id.dst_addr), &(stream_b->id.src_addr))) + && (stream_a->id.dst_port == stream_b->id.src_port)) + return TRUE; + else + return FALSE; +} /****************************************************************************/ /* when there is a [re]reading of packet's */ @@ -130,22 +141,22 @@ void rtp_write_header(rtpstream_info_t *strinfo, FILE *file) size_t sourcelen; guint16 port; /* UDP port */ guint16 padding; /* 2 padding bytes */ - char* addr_str = address_to_display(NULL, &(strinfo->dest_addr)); + char* addr_str = address_to_display(NULL, &(strinfo->id.dst_addr)); fprintf(file, "#!rtpplay%s %s/%u\n", RTPFILE_VERSION, addr_str, - strinfo->dest_port); + strinfo->id.dst_port); wmem_free(NULL, addr_str); 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; + sourcelen = strinfo->id.src_addr.len; if (sourcelen > sizeof source) sourcelen = sizeof source; - memcpy(&source, strinfo->src_addr.data, sourcelen); - port = g_htons(strinfo->src_port); + memcpy(&source, strinfo->id.src_addr.data, sourcelen); + port = g_htons(strinfo->id.src_port); padding = 0; if (fwrite(&start_sec, 4, 1, file) == 0) @@ -199,11 +210,8 @@ int rtpstream_packet_cb(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, /* gather infos on the stream this packet is part of. * Addresses and strings are read-only and must be duplicated if copied. */ memset(&new_stream_info, 0, sizeof(rtpstream_info_t)); - copy_address_shallow(&(new_stream_info.src_addr), &(pinfo->src)); - new_stream_info.src_port = pinfo->srcport; - copy_address_shallow(&(new_stream_info.dest_addr), &(pinfo->dst)); - new_stream_info.dest_port = pinfo->destport; - new_stream_info.ssrc = rtpinfo->info_sync_src; + rtpstream_id_copy_pinfo(pinfo,&(new_stream_info.id),FALSE); + new_stream_info.id.ssrc = rtpinfo->info_sync_src; new_stream_info.payload_type = rtpinfo->info_payload_type; new_stream_info.payload_type_name = (char *)rtpinfo->info_payload_type_str; @@ -238,8 +246,8 @@ int rtpstream_packet_cb(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, stream_info = g_new(rtpstream_info_t,1); /* Deep clone of contents. */ - copy_address(&(new_stream_info.src_addr), &(new_stream_info.src_addr)); - copy_address(&(new_stream_info.dest_addr), &(new_stream_info.dest_addr)); + copy_address(&(new_stream_info.id.src_addr), &(new_stream_info.id.src_addr)); + copy_address(&(new_stream_info.id.dst_addr), &(new_stream_info.id.dst_addr)); new_stream_info.payload_type_name = g_strdup(new_stream_info.payload_type_name); *stream_info = new_stream_info; /* memberwise copy of struct */ tapinfo->strinfo_list = g_list_prepend(tapinfo->strinfo_list, stream_info); diff --git a/ui/tap-rtp-common.h b/ui/tap-rtp-common.h index ef27caacfb..28db22476b 100644 --- a/ui/tap-rtp-common.h +++ b/ui/tap-rtp-common.h @@ -43,6 +43,20 @@ typedef struct _tap_rtp_save_info_t { gboolean saved; } tap_rtp_save_info_t; +/** + * Compares two RTP stream infos (GCompareFunc style comparison function) + * + * @return -1,0,1 + */ +gint rtpstream_info_cmp(gconstpointer aa, gconstpointer bb); + +/** +* Compares the endpoints of two RTP streams. +* +* @return TRUE if the +*/ +gboolean rtpstream_info_is_reverse(const rtpstream_info_t *stream_a, rtpstream_info_t *stream_b); + void rtpstream_reset_cb(void*); void rtp_write_header(rtpstream_info_t*, FILE*); int rtpstream_packet_cb(void*, packet_info*, epan_dissect_t *, const void *); diff --git a/ui/voip_calls.c b/ui/voip_calls.c index b2fa541d36..e1790b9a34 100644 --- a/ui/voip_calls.c +++ b/ui/voip_calls.c @@ -602,7 +602,7 @@ rtp_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, void c { tmp_listinfo=(rtpstream_info_t *)list->data; if ( (tmp_listinfo->setup_frame_number == rtp_info->info_setup_frame_num) - && (tmp_listinfo->ssrc == rtp_info->info_sync_src) && (tmp_listinfo->end_stream == FALSE)) { + && (tmp_listinfo->id.ssrc == rtp_info->info_sync_src) && (tmp_listinfo->end_stream == FALSE)) { /* if the payload type has changed, we mark the stream as finished to create a new one this is to show multiple payload changes in the Graph for example for DTMF RFC2833 */ if ( tmp_listinfo->payload_type != rtp_info->info_payload_type ) { @@ -631,11 +631,8 @@ rtp_packet(void *tap_offset_ptr, packet_info *pinfo, epan_dissect_t *edt, void c /* not in the list? then create a new entry */ if (strinfo==NULL) { strinfo = (rtpstream_info_t *)g_malloc0(sizeof(rtpstream_info_t)); - copy_address(&(strinfo->src_addr), &(pinfo->src)); - strinfo->src_port = pinfo->srcport; - copy_address(&(strinfo->dest_addr), &(pinfo->dst)); - strinfo->dest_port = pinfo->destport; - strinfo->ssrc = rtp_info->info_sync_src; + rtpstream_id_copy_pinfo(pinfo,&(strinfo->id),FALSE); + strinfo->id.ssrc = rtp_info->info_sync_src; strinfo->payload_type = rtp_info->info_payload_type; strinfo->is_srtp = rtp_info->info_is_srtp; /* if it is dynamic payload, let use the conv data to see if it is defined */ @@ -718,14 +715,14 @@ rtp_draw(void *tap_offset_ptr) g_free(gai->comment); gai->comment = g_strdup_printf(comment_fmt, (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->packet_count, - duration/1000,(duration%1000), rtp_listinfo->ssrc); + duration/1000,(duration%1000), rtp_listinfo->id.ssrc); } else { new_gai = (seq_analysis_item_t *)g_malloc0(sizeof(seq_analysis_item_t)); new_gai->frame_number = rtp_listinfo->start_fd->num; - copy_address(&(new_gai->src_addr),&(rtp_listinfo->src_addr)); - copy_address(&(new_gai->dst_addr),&(rtp_listinfo->dest_addr)); - new_gai->port_src = rtp_listinfo->src_port; - new_gai->port_dst = rtp_listinfo->dest_port; + copy_address(&(new_gai->src_addr),&(rtp_listinfo->id.src_addr)); + copy_address(&(new_gai->dst_addr),&(rtp_listinfo->id.dst_addr)); + new_gai->port_src = rtp_listinfo->id.src_port; + new_gai->port_dst = rtp_listinfo->id.dst_port; duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_rel_time) - nstime_to_msec(&rtp_listinfo->start_rel_time)); new_gai->frame_label = g_strdup_printf("%s (%s) %s%s%s", (rtp_listinfo->is_srtp)?"SRTP":"RTP", @@ -737,7 +734,7 @@ rtp_draw(void *tap_offset_ptr) ); new_gai->comment = g_strdup_printf(comment_fmt, (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->packet_count, - duration/1000,(duration%1000), rtp_listinfo->ssrc); + duration/1000,(duration%1000), rtp_listinfo->id.ssrc); new_gai->conv_num = conv_num; set_fd_time(tapinfo->session, rtp_listinfo->start_fd, time_str); new_gai->time_str = g_strdup(time_str); @@ -795,7 +792,7 @@ rtp_packet_draw(void *tap_offset_ptr) g_free(gai->comment); gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X", (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets, - duration/1000,(duration%1000), rtp_listinfo->ssrc); + duration/1000,(duration%1000), rtp_listinfo->id.ssrc); break; } @@ -808,9 +805,9 @@ rtp_packet_draw(void *tap_offset_ptr) new_gai = g_malloc0(sizeof(seq_analysis_item_t)); new_gai->frame_number = rtp_listinfo->start_fd->num; copy_address(&(new_gai->src_addr),&(rtp_listinfo->src_addr)); - copy_address(&(new_gai->dst_addr),&(rtp_listinfo->dest_addr)); - new_gai->port_src = rtp_listinfo->src_port; - new_gai->port_dst = rtp_listinfo->dest_port; + copy_address(&(new_gai->dst_addr),&(rtp_listinfo->dst_addr)); + new_gai->port_src = rtp_listinfo->id.src_port; + new_gai->port_dst = rtp_listinfo->id.dst_port; new_gai->protocol = g_strdup(port_type_to_str(pinfo->ptype)); duration = (guint32)(nstime_to_msec(&rtp_listinfo->stop_fd->rel_ts) - nstime_to_msec(&rtp_listinfo->start_fd->rel_ts)); new_gai->frame_label = g_strdup_printf("%s (%s) %s", @@ -820,7 +817,7 @@ rtp_packet_draw(void *tap_offset_ptr) "":val_to_str_ext_const(rtp_listinfo->rtp_event, &rtp_event_type_values_ext, "Unknown RTP Event")); new_gai->comment = g_strdup_printf("%s Num packets:%u Duration:%u.%03us SSRC:0x%X", (rtp_listinfo->is_srtp)?"SRTP":"RTP", rtp_listinfo->npackets, - duration/1000,(duration%1000), rtp_listinfo->ssrc); + duration/1000,(duration%1000), rtp_listinfo->id.ssrc); new_gai->conv_num = conv_num; set_fd_time(cfile.epan, rtp_listinfo->start_fd, time_str); new_gai->time_str = g_strdup(time_str); |