aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasil Velichkov <vvvelichkov@gmail.com>2018-08-15 22:46:39 +0300
committerAnders Broman <a.broman58@gmail.com>2018-08-20 05:01:11 +0000
commitb7a6a11376c75f02b827a3dbd7598ecf419f6151 (patch)
treec8ef569252d22c9b1ba554ee8cd2449172892e37
parentaef622340967762e714b37286db9cf90385c17a2 (diff)
Qt: fix several crashes in the SCTP Dialogs
Store the association id instead of a pointer to the volatile "sctp_assoc_info_t" structure because it gets freed after a rescan. Bug: 14970 Change-Id: Id8fe2dfe3549bd711fc8ddef0770b217e83c2088 Fixes: v1.11.3-rc1-604-g796bf409b0 ("Add dialogs and graphs to analyse SCTP behavior similar to the GTK version.") Reviewed-on: https://code.wireshark.org/review/28711 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--ui/qt/main_window_slots.cpp8
-rw-r--r--ui/qt/sctp_all_assocs_dialog.cpp47
-rw-r--r--ui/qt/sctp_all_assocs_dialog.h4
-rw-r--r--ui/qt/sctp_assoc_analyse_dialog.cpp64
-rw-r--r--ui/qt/sctp_assoc_analyse_dialog.h14
-rw-r--r--ui/qt/sctp_chunk_statistics_dialog.cpp22
-rw-r--r--ui/qt/sctp_chunk_statistics_dialog.h10
-rw-r--r--ui/qt/sctp_graph_arwnd_dialog.cpp26
-rw-r--r--ui/qt/sctp_graph_arwnd_dialog.h9
-rw-r--r--ui/qt/sctp_graph_byte_dialog.cpp25
-rw-r--r--ui/qt/sctp_graph_byte_dialog.h7
-rw-r--r--ui/qt/sctp_graph_dialog.cpp56
-rw-r--r--ui/qt/sctp_graph_dialog.h13
-rw-r--r--ui/tap-sctp-analysis.c6
-rw-r--r--ui/tap-sctp-analysis.h2
15 files changed, 173 insertions, 140 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 4dfb0f468b..ef03920384 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -2815,7 +2815,11 @@ void MainWindow::on_actionSCTPShowAllAssociations_triggered()
void MainWindow::on_actionSCTPAnalyseThisAssociation_triggered()
{
- SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, NULL, capture_file_.capFile());
+ const sctp_assoc_info_t* assoc = SCTPAssocAnalyseDialog::findAssocForPacket(capture_file_.capFile());
+ if (!assoc) {
+ return;
+ }
+ SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, assoc, capture_file_.capFile());
connect(sctp_analyse, SIGNAL(filterPackets(QString,bool)),
this, SLOT(filterPackets(QString,bool)));
@@ -2834,7 +2838,7 @@ void MainWindow::on_actionSCTPAnalyseThisAssociation_triggered()
void MainWindow::on_actionSCTPFilterThisAssociation_triggered()
{
- sctp_assoc_info_t* assoc = SCTPAssocAnalyseDialog::findAssocForPacket(capture_file_.capFile());
+ const sctp_assoc_info_t* assoc = SCTPAssocAnalyseDialog::findAssocForPacket(capture_file_.capFile());
if (assoc) {
QString newFilter = QString("sctp.assoc_index==%1").arg(assoc->assoc_id);
assoc = NULL;
diff --git a/ui/qt/sctp_all_assocs_dialog.cpp b/ui/qt/sctp_all_assocs_dialog.cpp
index 15bd635f1f..6f9646a909 100644
--- a/ui/qt/sctp_all_assocs_dialog.cpp
+++ b/ui/qt/sctp_all_assocs_dialog.cpp
@@ -44,7 +44,7 @@ SCTPAllAssocsDialog::~SCTPAllAssocsDialog()
void SCTPAllAssocsDialog::fillTable()
{
GList *list;
- sctp_assoc_info_t* assinfo;
+ const sctp_assoc_info_t* assinfo;
int numAssocs;
ui->assocList->setColumnHidden(0, true);
@@ -54,7 +54,7 @@ void SCTPAllAssocsDialog::fillTable()
ui->assocList->setColumnWidth(4, 150);
sctp_assocs = (sctp_allassocs_info_t*)sctp_stat_get_info();
- if (sctp_stat_get_info()->is_registered == FALSE) {
+ if (sctp_assocs->is_registered == FALSE) {
register_tap_listener_sctp_stat();
/* (redissect all packets) */
cf_retap_packets(cap_file_);
@@ -65,7 +65,7 @@ void SCTPAllAssocsDialog::fillTable()
list = g_list_first(sctp_assocs->assoc_info_list);
while (list) {
- assinfo = (sctp_assoc_info_t*)(list->data);
+ assinfo = (const sctp_assoc_info_t*)(list->data);
ui->assocList->setItem(numAssocs, 0, new QTableWidgetItem(QString("%1").arg(assinfo->assoc_id)));
ui->assocList->setItem(numAssocs, 1, new QTableWidgetItem(QString("%1").arg(assinfo->port1)));
ui->assocList->setItem(numAssocs, 2, new QTableWidgetItem(QString("%1").arg(assinfo->port2)));
@@ -80,45 +80,20 @@ void SCTPAllAssocsDialog::fillTable()
connect(ui->assocList, SIGNAL(itemSelectionChanged()), this, SLOT(getSelectedItem()));
}
-sctp_assoc_info_t* SCTPAllAssocsDialog::findSelectedAssoc()
-{
- QTableWidgetItem *selection;
- GList *list;
- sctp_assoc_info_t* assinfo;
- int row, id;
-
- selection = ui->assocList->selectedItems()[0];
- row = selection->row();
- selection = ui->assocList->item(row, 0);
- id = (selection->data(0)).toInt();
- list = g_list_first(sctp_assocs->assoc_info_list);
-
- while (list) {
- assinfo = (sctp_assoc_info_t*)(list->data);
- if (assinfo->assoc_id == id) {
- return assinfo;
- }
- list = g_list_next(list);
- }
- return NULL;
-}
-
void SCTPAllAssocsDialog::getSelectedItem()
{
ui->analyseButton->setEnabled(true);
ui->setFilterButton->setEnabled(true);
ui->analyseButton->setFocus(Qt::OtherFocusReason);
- selected_assoc = findSelectedAssoc();
+ selected_assoc_id = ui->assocList->item(ui->assocList->selectedItems().at(0)->row(), 0)->data(0).toInt();
}
void SCTPAllAssocsDialog::on_analyseButton_clicked()
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
- if (!selected_assoc) {
- selected_assoc = findSelectedAssoc();
- }
-
- SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, selected_assoc, cap_file_, this);
+ SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, selected_assoc, cap_file_);
connect(sctp_analyse, SIGNAL(filterPackets(QString&,bool)),
parent(), SLOT(filterPackets(QString&,bool)));
@@ -137,13 +112,7 @@ void SCTPAllAssocsDialog::on_analyseButton_clicked()
void SCTPAllAssocsDialog::on_setFilterButton_clicked()
{
-
- if (!selected_assoc){
- selected_assoc = findSelectedAssoc();
- }
-
- QString newFilter = QString("sctp.assoc_index==%1").arg(selected_assoc->assoc_id);
- selected_assoc = NULL;
+ QString newFilter = QString("sctp.assoc_index==%1").arg(selected_assoc_id);
emit filterPackets(newFilter, false);
}
diff --git a/ui/qt/sctp_all_assocs_dialog.h b/ui/qt/sctp_all_assocs_dialog.h
index 094cacf965..7c6a106910 100644
--- a/ui/qt/sctp_all_assocs_dialog.h
+++ b/ui/qt/sctp_all_assocs_dialog.h
@@ -36,8 +36,6 @@ public:
~SCTPAllAssocsDialog();
void fillTable();
- sctp_assoc_info_t* getSelectedAssoc() { return selected_assoc; }
- sctp_assoc_info_t* findSelectedAssoc();
public slots:
void setCaptureFile(capture_file *cf) { cap_file_ = cf; }
@@ -51,7 +49,7 @@ private:
Ui::SCTPAllAssocsDialog *ui;
capture_file *cap_file_;
sctp_allassocs_info_t *sctp_assocs;
- sctp_assoc_info_t *selected_assoc;
+ guint16 selected_assoc_id;
signals:
diff --git a/ui/qt/sctp_assoc_analyse_dialog.cpp b/ui/qt/sctp_assoc_analyse_dialog.cpp
index b965c94241..9d401a0961 100644
--- a/ui/qt/sctp_assoc_analyse_dialog.cpp
+++ b/ui/qt/sctp_assoc_analyse_dialog.cpp
@@ -18,29 +18,25 @@
#include "sctp_graph_byte_dialog.h"
#include "sctp_chunk_statistics_dialog.h"
-SCTPAssocAnalyseDialog::SCTPAssocAnalyseDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf, SCTPAllAssocsDialog* caller) :
+SCTPAssocAnalyseDialog::SCTPAssocAnalyseDialog(QWidget *parent, const sctp_assoc_info_t *assoc,
+ capture_file *cf) :
QDialog(parent),
ui(new Ui::SCTPAssocAnalyseDialog),
- selected_assoc(assoc),
- cap_file_(cf),
- caller_(caller)
+ cap_file_(cf)
{
+ Q_ASSERT(assoc);
+ selected_assoc_id = assoc->assoc_id;
+
ui->setupUi(this);
ui->SCTPAssocAnalyseTab->setCurrentWidget(ui->Statistics);
- if (!selected_assoc) {
- if (sctp_stat_get_info()->is_registered == FALSE) {
- register_tap_listener_sctp_stat();
- }
- /* (redissect all packets) */
- cf_retap_packets(cap_file_);
- selected_assoc = findAssocForPacket(cap_file_);
- }
Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowCloseButtonHint;
this->setWindowFlags(flags);
- this->setWindowTitle(QString(tr("SCTP Analyse Association: %1 Port1 %2 Port2 %3")).arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(selected_assoc->port1).arg(selected_assoc->port2));
- fillTabs();
+
+ this->setWindowTitle(QString(tr("SCTP Analyse Association: %1 Port1 %2 Port2 %3"))
+ .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(assoc->port1).arg(assoc->port2));
+ fillTabs(assoc);
}
SCTPAssocAnalyseDialog::~SCTPAssocAnalyseDialog()
@@ -48,11 +44,11 @@ SCTPAssocAnalyseDialog::~SCTPAssocAnalyseDialog()
delete ui;
}
-sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file* cf)
+const sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file* cf)
{
frame_data *fdata;
GList *list, *framelist;
- sctp_assoc_info_t *assoc;
+ const sctp_assoc_info_t *assoc;
bool frame_found = false;
fdata = cf->current_frame;
@@ -64,7 +60,7 @@ sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file* cf)
list = g_list_first(sctp_stat_get_info()->assoc_info_list);
while (list) {
- assoc = (sctp_assoc_info_t*)(list->data);
+ assoc = (const sctp_assoc_info_t*)(list->data);
framelist = g_list_first(assoc->frame_numbers);
guint32 fn;
@@ -91,8 +87,20 @@ sctp_assoc_info_t* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file* cf)
return NULL;
}
-void SCTPAssocAnalyseDialog::fillTabs()
+const _sctp_assoc_info* SCTPAssocAnalyseDialog::findAssoc(QWidget *parent, guint16 assoc_id)
+{
+ const sctp_assoc_info_t* result = get_sctp_assoc_info(assoc_id);
+ if (result) return result;
+
+ QMessageBox::warning(parent, tr("Warning"), tr("Could not find SCTP Association with id: %1")
+ .arg(assoc_id));
+ return NULL;
+}
+
+void SCTPAssocAnalyseDialog::fillTabs(const sctp_assoc_info_t* selected_assoc)
{
+ Q_ASSERT(selected_assoc);
+
/* Statistics Tab */
ui->checksumLabel->setText(selected_assoc->checksum_type);
@@ -209,6 +217,9 @@ void SCTPAssocAnalyseDialog::fillTabs()
void SCTPAssocAnalyseDialog::openGraphDialog(int direction)
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
SCTPGraphDialog *sctp_dialog = new SCTPGraphDialog(this, selected_assoc, cap_file_, direction);
if (sctp_dialog->isMinimized() == true) {
@@ -235,11 +246,9 @@ void SCTPAssocAnalyseDialog::on_GraphTSN_1_clicked()
void SCTPAssocAnalyseDialog::on_chunkStatisticsButton_clicked()
{
- if (caller_ && !selected_assoc) {
- selected_assoc = caller_->findSelectedAssoc();
- } else if (!caller_ && !selected_assoc) {
- selected_assoc = findAssocForPacket(cap_file_);
- }
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
SCTPChunkStatisticsDialog *sctp_dialog = new SCTPChunkStatisticsDialog(this, selected_assoc, cap_file_);
if (sctp_dialog->isMinimized() == true) {
@@ -254,13 +263,15 @@ void SCTPAssocAnalyseDialog::on_chunkStatisticsButton_clicked()
void SCTPAssocAnalyseDialog::on_setFilterButton_clicked()
{
- QString newFilter = QString("sctp.assoc_index==%1").arg(selected_assoc->assoc_id);
- selected_assoc = NULL;
+ QString newFilter = QString("sctp.assoc_index==%1").arg(selected_assoc_id);
emit filterPackets(newFilter, false);
}
void SCTPAssocAnalyseDialog::openGraphByteDialog(int direction)
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
SCTPGraphByteDialog *sctp_dialog = new SCTPGraphByteDialog(this, selected_assoc, cap_file_, direction);
if (sctp_dialog->isMinimized() == true) {
@@ -285,6 +296,9 @@ void SCTPAssocAnalyseDialog::on_GraphBytes_2_clicked()
void SCTPAssocAnalyseDialog::openGraphArwndDialog(int direction)
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
SCTPGraphArwndDialog *sctp_dialog = new SCTPGraphArwndDialog(this, selected_assoc, cap_file_, direction);
if (sctp_dialog->isMinimized() == true) {
diff --git a/ui/qt/sctp_assoc_analyse_dialog.h b/ui/qt/sctp_assoc_analyse_dialog.h
index d893c9dcb1..8f46729836 100644
--- a/ui/qt/sctp_assoc_analyse_dialog.h
+++ b/ui/qt/sctp_assoc_analyse_dialog.h
@@ -18,7 +18,6 @@
#include <epan/dissectors/packet-sctp.h>
-#include "ui/tap-sctp-analysis.h"
#include "sctp_all_assocs_dialog.h"
#include <QDialog>
@@ -32,16 +31,20 @@ namespace Ui {
class SCTPAssocAnalyseDialog;
}
+struct _sctp_assoc_info;
+
class SCTPAssocAnalyseDialog : public QDialog
{
Q_OBJECT
public:
- explicit SCTPAssocAnalyseDialog(QWidget *parent = 0, sctp_assoc_info_t *assoc = NULL, capture_file *cf = NULL, SCTPAllAssocsDialog *caller = NULL);
+ explicit SCTPAssocAnalyseDialog(QWidget *parent = 0, const _sctp_assoc_info *assoc = NULL,
+ capture_file *cf = NULL);
~SCTPAssocAnalyseDialog();
- void fillTabs();
- static sctp_assoc_info_t* findAssocForPacket(capture_file* cf);
+ void fillTabs(const _sctp_assoc_info* selected_assoc);
+ static const _sctp_assoc_info* findAssocForPacket(capture_file* cf);
+ static const _sctp_assoc_info* findAssoc(QWidget *parent, guint16 assoc_id);
public slots:
void setCaptureFile(capture_file *cf) { cap_file_ = cf; }
@@ -60,9 +63,8 @@ private slots:
private:
Ui::SCTPAssocAnalyseDialog *ui;
- sctp_assoc_info_t *selected_assoc;
+ guint16 selected_assoc_id;
capture_file *cap_file_;
- SCTPAllAssocsDialog *caller_;
void openGraphDialog(int direction);
void openGraphByteDialog(int direction);
void openGraphArwndDialog(int direction);
diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp
index 08496f6a29..e2f37a8011 100644
--- a/ui/qt/sctp_chunk_statistics_dialog.cpp
+++ b/ui/qt/sctp_chunk_statistics_dialog.cpp
@@ -8,19 +8,24 @@
*/
#include "sctp_chunk_statistics_dialog.h"
+#include "sctp_assoc_analyse_dialog.h"
#include <ui_sctp_chunk_statistics_dialog.h>
#include "uat_dialog.h"
#include <wsutil/strtoi.h>
+#include "ui/tap-sctp-analysis.h"
#include <ui/qt/utils/qt_ui_utils.h>
-SCTPChunkStatisticsDialog::SCTPChunkStatisticsDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf) :
+SCTPChunkStatisticsDialog::SCTPChunkStatisticsDialog(QWidget *parent, const sctp_assoc_info_t *assoc,
+ capture_file *cf) :
QDialog(parent),
ui(new Ui::SCTPChunkStatisticsDialog),
- selected_assoc(assoc),
cap_file_(cf)
{
+ Q_ASSERT(assoc);
+ selected_assoc_id = assoc->assoc_id;
+
ui->setupUi(this);
Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
@@ -36,14 +41,16 @@ SCTPChunkStatisticsDialog::SCTPChunkStatisticsDialog(QWidget *parent, sctp_assoc
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
- this->setWindowTitle(QString(tr("SCTP Chunk Statistics: %1 Port1 %2 Port2 %3")).arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(selected_assoc->port1).arg(selected_assoc->port2));
+ this->setWindowTitle(QString(tr("SCTP Chunk Statistics: %1 Port1 %2 Port2 %3"))
+ .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_)))
+ .arg(assoc->port1).arg(assoc->port2));
// connect(ui->tableWidget->verticalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(on_sectionMoved(int, int, int)));
ctx_menu_.addAction(ui->actionHideChunkType);
ctx_menu_.addAction(ui->actionChunkTypePreferences);
ctx_menu_.addAction(ui->actionShowAllChunkTypes);
initializeChunkMap();
- fillTable();
+ fillTable(false, assoc);
}
SCTPChunkStatisticsDialog::~SCTPChunkStatisticsDialog()
@@ -71,8 +78,13 @@ void SCTPChunkStatisticsDialog::initializeChunkMap()
}
}
-void SCTPChunkStatisticsDialog::fillTable(bool all)
+void SCTPChunkStatisticsDialog::fillTable(bool all, const sctp_assoc_info_t *selected_assoc)
{
+ if (!selected_assoc) {
+ selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+ }
+
FILE* fp = NULL;
pref_t *pref = prefs_find_preference(prefs_find_module("sctp"),"statistics_chunk_types");
diff --git a/ui/qt/sctp_chunk_statistics_dialog.h b/ui/qt/sctp_chunk_statistics_dialog.h
index 3fdb2aae1f..09e254b6fd 100644
--- a/ui/qt/sctp_chunk_statistics_dialog.h
+++ b/ui/qt/sctp_chunk_statistics_dialog.h
@@ -24,8 +24,6 @@
#include <wsutil/filesystem.h>
#include "wireshark_application.h"
-#include "ui/tap-sctp-analysis.h"
-
#include <QTableWidgetItem>
#include <QDialog>
#include <QMenu>
@@ -35,12 +33,14 @@ namespace Ui {
class SCTPChunkStatisticsDialog;
}
+struct _sctp_assoc_info;
+
class SCTPChunkStatisticsDialog : public QDialog
{
Q_OBJECT
public:
- explicit SCTPChunkStatisticsDialog(QWidget *parent = 0, sctp_assoc_info_t *assoc = NULL, capture_file *cf = NULL);
+ explicit SCTPChunkStatisticsDialog(QWidget *parent = 0, const _sctp_assoc_info *assoc = NULL, capture_file *cf = NULL);
~SCTPChunkStatisticsDialog();
public slots:
@@ -62,7 +62,7 @@ signals:
private:
Ui::SCTPChunkStatisticsDialog *ui;
- sctp_assoc_info_t *selected_assoc;
+ guint16 selected_assoc_id;
capture_file *cap_file_;
QMenu ctx_menu_;
QPoint selected_point;
@@ -77,7 +77,7 @@ private:
QMap<int, struct chunkTypes> chunks, tempChunks;
void initializeChunkMap();
- void fillTable(bool all = false);
+ void fillTable(bool all = false, const _sctp_assoc_info *selected_assoc = NULL);
};
#endif // SCTP_CHUNK_STATISTICS_DIALOG_H
diff --git a/ui/qt/sctp_graph_arwnd_dialog.cpp b/ui/qt/sctp_graph_arwnd_dialog.cpp
index 18a6d35b2f..a1de32e669 100644
--- a/ui/qt/sctp_graph_arwnd_dialog.cpp
+++ b/ui/qt/sctp_graph_arwnd_dialog.cpp
@@ -22,32 +22,33 @@
#include <ui/qt/widgets/qcustomplot.h>
#include "sctp_graph_dialog.h"
-SCTPGraphArwndDialog::SCTPGraphArwndDialog(QWidget *parent, sctp_assoc_info_t *assoc, _capture_file *cf, int dir) :
+SCTPGraphArwndDialog::SCTPGraphArwndDialog(QWidget *parent, const sctp_assoc_info_t *assoc,
+ _capture_file *cf, int dir) :
QDialog(parent),
ui(new Ui::SCTPGraphArwndDialog),
- selected_assoc(assoc),
cap_file_(cf),
frame_num(0),
direction(dir),
startArwnd(0)
{
+ Q_ASSERT(assoc);
+ selected_assoc_id = assoc->assoc_id;
+
ui->setupUi(this);
- if (!selected_assoc) {
- selected_assoc = SCTPAssocAnalyseDialog::findAssocForPacket(cap_file_);
- }
Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowMaximizeButtonHint
| Qt::WindowCloseButtonHint;
this->setWindowFlags(flags);
- this->setWindowTitle(QString(tr("SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3")).arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(selected_assoc->port1).arg(selected_assoc->port2));
- if ((direction == 1 && selected_assoc->n_array_tsn1 == 0) || (direction == 2 && selected_assoc->n_array_tsn2 == 0)) {
+ this->setWindowTitle(QString(tr("SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3"))
+ .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(assoc->port1).arg(assoc->port2));
+ if ((direction == 1 && assoc->n_array_tsn1 == 0) || (direction == 2 && assoc->n_array_tsn2 == 0)) {
QMessageBox msgBox;
msgBox.setText(tr("No Data Chunks sent"));
msgBox.exec();
return;
} else {
- drawGraph();
+ drawGraph(assoc);
}
}
@@ -56,7 +57,7 @@ SCTPGraphArwndDialog::~SCTPGraphArwndDialog()
delete ui;
}
-void SCTPGraphArwndDialog::drawArwndGraph()
+void SCTPGraphArwndDialog::drawArwndGraph(const sctp_assoc_info_t *selected_assoc)
{
GList *listSACK = NULL, *tlist;
struct sack_chunk_header *sack_header;
@@ -126,10 +127,10 @@ void SCTPGraphArwndDialog::drawArwndGraph()
}
-void SCTPGraphArwndDialog::drawGraph()
+void SCTPGraphArwndDialog::drawGraph(const sctp_assoc_info_t *selected_assoc)
{
ui->sctpPlot->clearGraphs();
- drawArwndGraph();
+ drawArwndGraph(selected_assoc);
ui->sctpPlot->setInteractions(QCP::iRangeZoom | QCP::iRangeDrag | QCP::iSelectPlottables);
ui->sctpPlot->axisRect(0)->setRangeZoomAxes(ui->sctpPlot->xAxis, ui->sctpPlot->yAxis);
ui->sctpPlot->axisRect(0)->setRangeZoom(Qt::Horizontal);
@@ -140,6 +141,9 @@ void SCTPGraphArwndDialog::drawGraph()
void SCTPGraphArwndDialog::on_pushButton_4_clicked()
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
ui->sctpPlot->xAxis->setRange(selected_assoc->min_secs+selected_assoc->min_usecs/1000000.0, selected_assoc->max_secs+selected_assoc->max_usecs/1000000.0);
ui->sctpPlot->yAxis->setRange(0, startArwnd);
ui->sctpPlot->replot();
diff --git a/ui/qt/sctp_graph_arwnd_dialog.h b/ui/qt/sctp_graph_arwnd_dialog.h
index c682014f4b..16087c4d3d 100644
--- a/ui/qt/sctp_graph_arwnd_dialog.h
+++ b/ui/qt/sctp_graph_arwnd_dialog.h
@@ -30,7 +30,8 @@ class SCTPGraphArwndDialog : public QDialog
Q_OBJECT
public:
- explicit SCTPGraphArwndDialog(QWidget *parent = 0, struct _sctp_assoc_info *assoc = NULL, capture_file *cf = NULL, int dir = 0);
+ explicit SCTPGraphArwndDialog(QWidget *parent = 0, const _sctp_assoc_info *assoc = NULL,
+ capture_file *cf = NULL, int dir = 0);
~SCTPGraphArwndDialog();
public slots:
@@ -45,7 +46,7 @@ private slots:
private:
Ui::SCTPGraphArwndDialog *ui;
- struct _sctp_assoc_info *selected_assoc;
+ guint16 selected_assoc_id;
capture_file *cap_file_;
int frame_num;
int direction;
@@ -54,8 +55,8 @@ private:
QVector<guint32> fa;
// QVector<QString> typeStrings;
- void drawGraph();
- void drawArwndGraph();
+ void drawGraph(const _sctp_assoc_info *selected_assoc);
+ void drawArwndGraph(const _sctp_assoc_info *selected_assoc);
};
#endif // SCTP_GRAPH_DIALOG_H
diff --git a/ui/qt/sctp_graph_byte_dialog.cpp b/ui/qt/sctp_graph_byte_dialog.cpp
index 3d3753e208..7bc6b3749d 100644
--- a/ui/qt/sctp_graph_byte_dialog.cpp
+++ b/ui/qt/sctp_graph_byte_dialog.cpp
@@ -22,25 +22,26 @@
#include "sctp_graph_dialog.h"
#include "sctp_assoc_analyse_dialog.h"
-SCTPGraphByteDialog::SCTPGraphByteDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf, int dir) :
+SCTPGraphByteDialog::SCTPGraphByteDialog(QWidget *parent, const sctp_assoc_info_t *assoc,
+ capture_file *cf, int dir) :
QDialog(parent),
ui(new Ui::SCTPGraphByteDialog),
- selected_assoc(assoc),
cap_file_(cf),
frame_num(0),
direction(dir)
{
+ Q_ASSERT(assoc);
+ selected_assoc_id = assoc->assoc_id;
+
ui->setupUi(this);
- if (!selected_assoc) {
- selected_assoc = SCTPAssocAnalyseDialog::findAssocForPacket(cap_file_);
- }
Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowMaximizeButtonHint
| Qt::WindowCloseButtonHint;
this->setWindowFlags(flags);
- this->setWindowTitle(QString(tr("SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3")).arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(selected_assoc->port1).arg(selected_assoc->port2));
- if ((direction == 1 && selected_assoc->n_array_tsn1 == 0) || (direction == 2 && selected_assoc->n_array_tsn2 == 0)) {
+ this->setWindowTitle(QString(tr("SCTP Data and Adv. Rec. Window over Time: %1 Port1 %2 Port2 %3"))
+ .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(assoc->port1).arg(assoc->port2));
+ if ((direction == 1 && assoc->n_array_tsn1 == 0) || (direction == 2 && assoc->n_array_tsn2 == 0)) {
QMessageBox msgBox;
msgBox.setText(tr("No Data Chunks sent"));
msgBox.exec();
@@ -56,7 +57,7 @@ SCTPGraphByteDialog::~SCTPGraphByteDialog()
}
-void SCTPGraphByteDialog::drawBytesGraph()
+void SCTPGraphByteDialog::drawBytesGraph(const sctp_assoc_info_t *selected_assoc)
{
GList *listTSN = NULL,*tlist;
tsn_t *tsn;
@@ -126,8 +127,11 @@ void SCTPGraphByteDialog::drawBytesGraph()
void SCTPGraphByteDialog::drawGraph()
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
ui->sctpPlot->clearGraphs();
- drawBytesGraph();
+ drawBytesGraph(selected_assoc);
ui->sctpPlot->setInteractions(QCP::iRangeZoom | QCP::iRangeDrag | QCP::iSelectPlottables);
connect(ui->sctpPlot, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(graphClicked(QCPAbstractPlottable*, QMouseEvent*)));
ui->sctpPlot->replot();
@@ -136,6 +140,9 @@ void SCTPGraphByteDialog::drawGraph()
void SCTPGraphByteDialog::on_pushButton_4_clicked()
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
ui->sctpPlot->xAxis->setRange(selected_assoc->min_secs+selected_assoc->min_usecs/1000000.0, selected_assoc->max_secs+selected_assoc->max_usecs/1000000.0);
if (direction == 1) {
ui->sctpPlot->yAxis->setRange(0, selected_assoc->n_data_bytes_ep1);
diff --git a/ui/qt/sctp_graph_byte_dialog.h b/ui/qt/sctp_graph_byte_dialog.h
index f85ade9f14..dc10ce2722 100644
--- a/ui/qt/sctp_graph_byte_dialog.h
+++ b/ui/qt/sctp_graph_byte_dialog.h
@@ -30,7 +30,8 @@ class SCTPGraphByteDialog : public QDialog
Q_OBJECT
public:
- explicit SCTPGraphByteDialog(QWidget *parent = 0, struct _sctp_assoc_info *assoc = NULL, capture_file *cf = NULL, int dir = 0);
+ explicit SCTPGraphByteDialog(QWidget *parent = 0, const _sctp_assoc_info *assoc = NULL,
+ capture_file *cf = NULL, int dir = 0);
~SCTPGraphByteDialog();
public slots:
@@ -45,7 +46,7 @@ private slots:
private:
Ui::SCTPGraphByteDialog *ui;
- struct _sctp_assoc_info *selected_assoc;
+ guint16 selected_assoc_id;
capture_file *cap_file_;
int frame_num;
int direction;
@@ -53,7 +54,7 @@ private:
QVector<guint32> fb;
void drawGraph();
- void drawBytesGraph();
+ void drawBytesGraph(const _sctp_assoc_info *selected_assoc);
};
#endif // SCTP_GRAPH_DIALOG_H
diff --git a/ui/qt/sctp_graph_dialog.cpp b/ui/qt/sctp_graph_dialog.cpp
index 82bc5794b3..03201e6923 100644
--- a/ui/qt/sctp_graph_dialog.cpp
+++ b/ui/qt/sctp_graph_dialog.cpp
@@ -27,33 +27,34 @@
#include "ui/qt/widgets/wireshark_file_dialog.h"
#include "wireshark_application.h"
-SCTPGraphDialog::SCTPGraphDialog(QWidget *parent, sctp_assoc_info_t *assoc, capture_file *cf, int dir) :
+SCTPGraphDialog::SCTPGraphDialog(QWidget *parent, const sctp_assoc_info_t *assoc,
+ capture_file *cf, int dir) :
QDialog(parent),
ui(new Ui::SCTPGraphDialog),
- selected_assoc(assoc),
cap_file_(cf),
frame_num(0),
direction(dir),
relative(false),
type(1)
{
+ Q_ASSERT(assoc);
+ selected_assoc_id = assoc->assoc_id;
+
ui->setupUi(this);
- if (!selected_assoc) {
- selected_assoc = SCTPAssocAnalyseDialog::findAssocForPacket(cap_file_);
- }
Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
| Qt::WindowMinimizeButtonHint
| Qt::WindowMaximizeButtonHint
| Qt::WindowCloseButtonHint;
this->setWindowFlags(flags);
- this->setWindowTitle(QString(tr("SCTP TSNs and SACKs over Time: %1 Port1 %2 Port2 %3")).arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(selected_assoc->port1).arg(selected_assoc->port2));
- if ((direction == 1 && selected_assoc->n_array_tsn1 == 0) || (direction == 2 && selected_assoc->n_array_tsn2 == 0)) {
+ this->setWindowTitle(QString(tr("SCTP TSNs and SACKs over Time: %1 Port1 %2 Port2 %3"))
+ .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_))).arg(assoc->port1).arg(assoc->port2));
+ if ((direction == 1 && assoc->n_array_tsn1 == 0) || (direction == 2 && assoc->n_array_tsn2 == 0)) {
QMessageBox msgBox;
msgBox.setText(tr("No Data Chunks sent"));
msgBox.exec();
return;
} else {
- drawGraph();
+ drawGraph(assoc);
}
}
@@ -62,7 +63,7 @@ SCTPGraphDialog::~SCTPGraphDialog()
delete ui;
}
-void SCTPGraphDialog::drawNRSACKGraph()
+void SCTPGraphDialog::drawNRSACKGraph(const sctp_assoc_info_t* selected_assoc)
{
tsn_t *sack;
GList *list=NULL, *tlist;
@@ -129,7 +130,7 @@ void SCTPGraphDialog::drawNRSACKGraph()
}
}
-void SCTPGraphDialog::drawSACKGraph()
+void SCTPGraphDialog::drawSACKGraph(const sctp_assoc_info_t* selected_assoc)
{
GList *listSACK = NULL, *tlist;
guint16 gap_start=0, gap_end=0, nr, dup_nr;
@@ -257,7 +258,7 @@ void SCTPGraphDialog::drawSACKGraph()
}
}
-void SCTPGraphDialog::drawTSNGraph()
+void SCTPGraphDialog::drawTSNGraph(const sctp_assoc_info_t* selected_assoc)
{
GList *listTSN = NULL,*tlist;
tsn_t *tsn;
@@ -313,8 +314,13 @@ void SCTPGraphDialog::drawTSNGraph()
}
}
-void SCTPGraphDialog::drawGraph()
+void SCTPGraphDialog::drawGraph(const sctp_assoc_info_t* selected_assoc)
{
+ if (!selected_assoc) {
+ selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+ }
+
guint32 maxTSN, minTSN;
if (direction == 1) {
@@ -342,18 +348,23 @@ void SCTPGraphDialog::drawGraph()
fn.clear();
typeStrings.clear();
switch (type) {
- case 1: drawSACKGraph();
- drawNRSACKGraph();
+ case 1:
+ drawSACKGraph(selected_assoc);
+ drawNRSACKGraph(selected_assoc);
break;
- case 2: drawTSNGraph();
+ case 2:
+ drawTSNGraph(selected_assoc);
break;
- case 3: drawTSNGraph();
- drawSACKGraph();
- drawNRSACKGraph();
+ case 3:
+ drawTSNGraph(selected_assoc);
+ drawSACKGraph(selected_assoc);
+ drawNRSACKGraph(selected_assoc);
+ break;
+ default:
+ drawTSNGraph(selected_assoc);
+ drawSACKGraph(selected_assoc);
+ drawNRSACKGraph(selected_assoc);
break;
- default: drawTSNGraph();
- drawSACKGraph();
- drawNRSACKGraph();
}
// give the axes some labels:
@@ -394,6 +405,9 @@ void SCTPGraphDialog::on_pushButton_3_clicked()
void SCTPGraphDialog::on_pushButton_4_clicked()
{
+ const sctp_assoc_info_t* selected_assoc = SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id);
+ if (!selected_assoc) return;
+
ui->sctpPlot->xAxis->setRange(selected_assoc->min_secs, selected_assoc->max_secs+1);
if (relative) {
if (direction == 1) {
diff --git a/ui/qt/sctp_graph_dialog.h b/ui/qt/sctp_graph_dialog.h
index 8c9de7acc1..dc3e5b9227 100644
--- a/ui/qt/sctp_graph_dialog.h
+++ b/ui/qt/sctp_graph_dialog.h
@@ -77,7 +77,8 @@ class SCTPGraphDialog : public QDialog
Q_OBJECT
public:
- explicit SCTPGraphDialog(QWidget *parent = 0, struct _sctp_assoc_info *assoc = NULL, capture_file *cf = NULL, int dir = 0);
+ explicit SCTPGraphDialog(QWidget *parent = 0, const _sctp_assoc_info *assoc = NULL,
+ capture_file *cf = NULL, int dir = 0);
~SCTPGraphDialog();
static void save_graph(QDialog *dlg, QCustomPlot *plot);
@@ -101,7 +102,7 @@ private slots:
private:
Ui::SCTPGraphDialog *ui;
- struct _sctp_assoc_info *selected_assoc;
+ guint16 selected_assoc_id;
capture_file *cap_file_;
int frame_num;
int direction;
@@ -111,10 +112,10 @@ private:
bool relative;
int type;
- void drawGraph();
- void drawTSNGraph();
- void drawSACKGraph();
- void drawNRSACKGraph();
+ void drawGraph(const _sctp_assoc_info* selected_assoc = NULL);
+ void drawTSNGraph(const _sctp_assoc_info* selected_assoc);
+ void drawSACKGraph(const _sctp_assoc_info* selected_assoc);
+ void drawNRSACKGraph(const _sctp_assoc_info* selected_assoc);
};
#endif // SCTP_GRAPH_DIALOG_H
diff --git a/ui/tap-sctp-analysis.c b/ui/tap-sctp-analysis.c
index 8400e7ec51..3747f4df3a 100644
--- a/ui/tap-sctp-analysis.c
+++ b/ui/tap-sctp-analysis.c
@@ -1258,6 +1258,12 @@ sctp_stat_get_info(void)
return &sctp_tapinfo_struct;
}
+const sctp_assoc_info_t *
+get_sctp_assoc_info(guint16 assoc_id)
+{
+ sctp_tmp_info_t needle = { .assoc_id = assoc_id };
+ return find_assoc(&needle);
+}
void
register_tap_listener_sctp_stat(void)
diff --git a/ui/tap-sctp-analysis.h b/ui/tap-sctp-analysis.h
index 40b7f50d59..10f4afd81b 100644
--- a/ui/tap-sctp-analysis.h
+++ b/ui/tap-sctp-analysis.h
@@ -295,7 +295,7 @@ void sctp_stat_scan(void);
void remove_tap_listener_sctp_stat(void);
-
+const sctp_assoc_info_t* get_sctp_assoc_info(guint16 assoc_id);
const sctp_assoc_info_t* get_selected_assoc(void);
#ifdef __cplusplus