diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2016-05-09 23:21:28 +0200 |
---|---|---|
committer | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2016-05-10 11:53:52 +0000 |
commit | bd030c166ffe21e113255de3fb108b70d843b4ff (patch) | |
tree | 3893f4bf3dd7fc33af24ba57dc95fbb4a7e32a6f | |
parent | 850411dd440642074ead15d5f734fa4743940de0 (diff) |
Qt: activate RTP/IAX2 analysis widget when analyzing packets with a snaplen
Only the payload save should be deactivated
Bug: 12406
Change-Id: I8dd53c0b0c1ea4568f0ff292806656bfb65a6566
Reviewed-on: https://code.wireshark.org/review/15322
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
-rw-r--r-- | ui/qt/iax2_analysis_dialog.cpp | 13 | ||||
-rw-r--r-- | ui/qt/iax2_analysis_dialog.h | 8 | ||||
-rw-r--r-- | ui/qt/rtp_analysis_dialog.cpp | 16 | ||||
-rw-r--r-- | ui/qt/rtp_analysis_dialog.h | 8 |
4 files changed, 38 insertions, 7 deletions
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp index a3f299ae5c..eb76952e35 100644 --- a/ui/qt/iax2_analysis_dialog.cpp +++ b/ui/qt/iax2_analysis_dialog.cpp @@ -209,7 +209,8 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) : port_src_fwd_(0), port_dst_fwd_(0), port_src_rev_(0), - port_dst_rev_(0) + port_dst_rev_(0), + save_payload_error_(TAP_IAX2_NO_ERROR) { ui->setupUi(this); loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5); @@ -420,7 +421,9 @@ void Iax2AnalysisDialog::updateWidgets() bool enable_tab = false; QString hint = err_str_; - if (hint.isEmpty()) { + if (hint.isEmpty() || save_payload_error_ != TAP_IAX2_NO_ERROR) { + /* We cannot save the payload but can still display the widget + or save CSV data */ enable_tab = true; } @@ -439,8 +442,8 @@ void Iax2AnalysisDialog::updateWidgets() hint.append(tr(" G: Go to packet, N: Next problem packet")); } - bool enable_save_fwd_audio = fwd_tempfile_->isOpen(); - bool enable_save_rev_audio = rev_tempfile_->isOpen(); + bool enable_save_fwd_audio = fwd_tempfile_->isOpen() && (save_payload_error_ == TAP_IAX2_NO_ERROR); + bool enable_save_rev_audio = rev_tempfile_->isOpen() && (save_payload_error_ == TAP_IAX2_NO_ERROR); ui->actionSaveAudio->setEnabled(enable_save_fwd_audio && enable_save_rev_audio); ui->actionSaveForwardAudio->setEnabled(enable_save_fwd_audio); ui->actionSaveReverseAudio->setEnabled(enable_save_rev_audio); @@ -732,6 +735,7 @@ void Iax2AnalysisDialog::savePayload(QTemporaryFile *tmpfile, packet_info *pinfo if (pinfo->fd->pkt_len != pinfo->fd->cap_len) { tmpfile->close(); err_str_ = tr("Can't save in a file: Wrong length of captured packets."); + save_payload_error_ = TAP_IAX2_WRONG_LENGTH; return; } @@ -743,6 +747,7 @@ void Iax2AnalysisDialog::savePayload(QTemporaryFile *tmpfile, packet_info *pinfo if (nchars != (iax2info->payload_len)) { /* Write error or short write */ err_str_ = tr("Can't save in a file: File I/O problem."); + save_payload_error_ = TAP_IAX2_FILE_IO_ERROR; tmpfile->close(); return; } diff --git a/ui/qt/iax2_analysis_dialog.h b/ui/qt/iax2_analysis_dialog.h index 2d867216db..0183c387c3 100644 --- a/ui/qt/iax2_analysis_dialog.h +++ b/ui/qt/iax2_analysis_dialog.h @@ -47,6 +47,13 @@ class Iax2AnalysisDialog; class QCPGraph; class QTemporaryFile; +typedef enum { + TAP_IAX2_NO_ERROR, + TAP_IAX2_WRONG_LENGTH, + TAP_IAX2_FILE_IO_ERROR +} iax2_error_type_t; + + class Iax2AnalysisDialog : public WiresharkDialog { Q_OBJECT @@ -109,6 +116,7 @@ private: QVector<double> rev_diff_vals_; QString err_str_; + iax2_error_type_t save_payload_error_; QMenu stream_ctx_menu_; QMenu graph_ctx_menu_; diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp index e2bb354b34..39a8067e3c 100644 --- a/ui/qt/rtp_analysis_dialog.cpp +++ b/ui/qt/rtp_analysis_dialog.cpp @@ -255,7 +255,8 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r ssrc_rev_(0), packet_count_rev_(0), setup_frame_number_rev_(0), - num_streams_(0) + num_streams_(0), + save_payload_error_(TAP_RTP_NO_ERROR) { ui->setupUi(this); loadGeometry(parent.width() * 4 / 5, parent.height() * 4 / 5); @@ -408,6 +409,10 @@ void RtpAnalysisDialog::updateWidgets() if (hint.isEmpty()) { enable_tab = true; hint = tr("%1 streams found.").arg(num_streams_); + } else if (save_payload_error_ != TAP_RTP_NO_ERROR) { + /* We cannot save the payload but can still display the widget + or save CSV data */ + enable_tab = true; } bool enable_nav = false; @@ -425,8 +430,8 @@ void RtpAnalysisDialog::updateWidgets() hint.append(tr(" G: Go to packet, N: Next problem packet")); } - bool enable_save_fwd_audio = fwd_tempfile_->isOpen(); - bool enable_save_rev_audio = rev_tempfile_->isOpen(); + bool enable_save_fwd_audio = fwd_tempfile_->isOpen() && (save_payload_error_ == TAP_RTP_NO_ERROR); + bool enable_save_rev_audio = rev_tempfile_->isOpen() && (save_payload_error_ == TAP_RTP_NO_ERROR); ui->actionSaveAudio->setEnabled(enable_save_fwd_audio && enable_save_rev_audio); ui->actionSaveForwardAudio->setEnabled(enable_save_fwd_audio); ui->actionSaveReverseAudio->setEnabled(enable_save_rev_audio); @@ -753,6 +758,7 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta { tmpfile->close(); err_str_ = tr("Can't save in a file: Wrong length of captured packets."); + save_payload_error_ = TAP_RTP_WRONG_LENGTH; return; } @@ -764,6 +770,7 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta { tmpfile->close(); err_str_ = tr("Can't save in a file: RTP data with padding."); + save_payload_error_ = TAP_RTP_PADDING_ERROR; return; } @@ -800,6 +807,7 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta /* Write error or short write */ tmpfile->close(); err_str_ = tr("Can't save in a file: File I/O problem."); + save_payload_error_ = TAP_RTP_FILE_IO_ERROR; return; } } @@ -816,6 +824,7 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta /* Not all the data was captured. */ tmpfile->close(); err_str_ = tr("Can't save in a file: Not all data in all packets was captured."); + save_payload_error_ = TAP_RTP_WRONG_LENGTH; return; } @@ -828,6 +837,7 @@ void RtpAnalysisDialog::savePayload(QTemporaryFile *tmpfile, tap_rtp_stat_t *sta if (nchars != (rtpinfo->info_payload_len - rtpinfo->info_padding_count)) { /* Write error or short write */ err_str_ = tr("Can't save in a file: File I/O problem."); + save_payload_error_ = TAP_RTP_FILE_IO_ERROR; tmpfile->close(); return; } diff --git a/ui/qt/rtp_analysis_dialog.h b/ui/qt/rtp_analysis_dialog.h index 43b3c7a88a..b1dfddf097 100644 --- a/ui/qt/rtp_analysis_dialog.h +++ b/ui/qt/rtp_analysis_dialog.h @@ -43,6 +43,13 @@ class RtpAnalysisDialog; class QCPGraph; class QTemporaryFile; +typedef enum { + TAP_RTP_NO_ERROR, + TAP_RTP_WRONG_LENGTH, + TAP_RTP_PADDING_ERROR, + TAP_RTP_FILE_IO_ERROR +} rtp_error_type_t; + class RtpAnalysisDialog : public WiresharkDialog { Q_OBJECT @@ -126,6 +133,7 @@ private: rtpstream_tapinfo_t tapinfo_; QString err_str_; + rtp_error_type_t save_payload_error_; QMenu stream_ctx_menu_; QMenu graph_ctx_menu_; |