1 /* sctp_assoc_analyse_dialog.cpp
3 * Copyright 2021 Thomas Dreibholz <dreibh [AT] iem.uni-due.de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "epan/to_str.h"
14 #include "sctp_assoc_analyse_dialog.h"
15 #include <ui_sctp_assoc_analyse_dialog.h>
17 #include <ui/qt/utils/qt_ui_utils.h>
18 #include "sctp_graph_dialog.h"
19 #include "sctp_graph_arwnd_dialog.h"
20 #include "sctp_graph_byte_dialog.h"
21 #include "sctp_chunk_statistics_dialog.h"
23 SCTPAssocAnalyseDialog::SCTPAssocAnalyseDialog(QWidget
*parent
, const sctp_assoc_info_t
*assoc
,
26 ui(new Ui::SCTPAssocAnalyseDialog
),
30 selected_assoc_id
= assoc
->assoc_id
;
33 ui
->SCTPAssocAnalyseTab
->setCurrentWidget(ui
->Statistics
);
34 Qt::WindowFlags flags
= Qt::Window
| Qt::WindowSystemMenuHint
35 | Qt::WindowMinimizeButtonHint
36 | Qt::WindowCloseButtonHint
;
37 this->setWindowFlags(flags
);
39 this->setWindowTitle(tr("SCTP Analyse Association: %1 Port1 %2 Port2 %3")
40 .arg(gchar_free_to_qstring(cf_get_display_name(cap_file_
))).arg(assoc
->port1
).arg(assoc
->port2
));
44 SCTPAssocAnalyseDialog::~SCTPAssocAnalyseDialog()
49 const sctp_assoc_info_t
* SCTPAssocAnalyseDialog::findAssocForPacket(capture_file
* cf
)
52 GList
*list
, *framelist
;
53 const sctp_assoc_info_t
*assoc
;
54 bool frame_found
= false;
56 fdata
= cf
->current_frame
;
57 if (sctp_stat_get_info()->is_registered
== false) {
58 register_tap_listener_sctp_stat();
59 /* (redissect all packets) */
62 list
= g_list_first(sctp_stat_get_info()->assoc_info_list
);
65 assoc
= gxx_list_data(const sctp_assoc_info_t
*, list
);
67 framelist
= g_list_first(assoc
->frame_numbers
);
70 fn
= GPOINTER_TO_UINT(framelist
->data
);
71 if (fn
== fdata
->num
) {
75 framelist
= gxx_list_next(framelist
);
80 list
= gxx_list_next(list
);
86 msgBox
.setText(tr("No Association found for this packet."));
92 const _sctp_assoc_info
* SCTPAssocAnalyseDialog::findAssoc(QWidget
*parent
, uint16_t assoc_id
)
94 const sctp_assoc_info_t
* result
= get_sctp_assoc_info(assoc_id
);
95 if (result
) return result
;
97 QMessageBox::warning(parent
, tr("Warning"), tr("Could not find SCTP Association with id: %1")
102 void SCTPAssocAnalyseDialog::fillTabs(const sctp_assoc_info_t
* selected_assoc
)
104 Q_ASSERT(selected_assoc
);
108 ui
->checksumLabel
->setText(selected_assoc
->checksum_type
);
109 ui
->data12Label
->setText(QStringLiteral("%1").arg(selected_assoc
->n_data_chunks_ep1
));
110 ui
->bytes12Label
->setText(QStringLiteral("%1").arg(selected_assoc
->n_data_bytes_ep1
));
111 ui
->data21Label
->setText(QStringLiteral("%1").arg(selected_assoc
->n_data_chunks_ep2
));
112 ui
->bytes21Label
->setText(QStringLiteral("%1").arg(selected_assoc
->n_data_bytes_ep2
));
116 if (selected_assoc
->init
)
117 ui
->labelEP1
->setText(tr("Complete list of IP addresses from INIT Chunk:"));
118 else if ((selected_assoc
->initack
) && (selected_assoc
->initack_dir
== 1))
119 ui
->labelEP1
->setText(tr("Complete list of IP addresses from INIT_ACK Chunk:"));
121 ui
->labelEP1
->setText(tr("List of Used IP Addresses"));
123 if (selected_assoc
->addr1
!= Q_NULLPTR
) {
126 list
= g_list_first(selected_assoc
->addr1
);
130 store
= gxx_list_data(address
*, list
);
131 if (store
->type
!= AT_NONE
) {
132 if ((store
->type
== AT_IPv4
) || (store
->type
== AT_IPv6
)) {
133 ui
->listWidgetEP1
->addItem(address_to_qstring(store
));
136 list
= gxx_list_next(list
);
142 ui
->label_221
->setText(QStringLiteral("%1").arg(selected_assoc
->port1
));
143 ui
->label_222
->setText(QStringLiteral("0x%1").arg(selected_assoc
->verification_tag1
, 0, 16));
145 if ((selected_assoc
->init
) ||
146 ((selected_assoc
->initack
) && (selected_assoc
->initack_dir
== 1))) {
147 ui
->label_213
->setText(tr("Requested Number of Inbound Streams:"));
148 ui
->label_223
->setText(QStringLiteral("%1").arg(selected_assoc
->instream1
));
149 ui
->label_214
->setText(tr("Minimum Number of Inbound Streams:"));
150 ui
->label_224
->setText(QStringLiteral("%1").arg(((selected_assoc
->instream1
> selected_assoc
->outstream2
) ?
151 selected_assoc
->outstream2
: selected_assoc
->instream1
)));
152 ui
->label_215
->setText(tr("Provided Number of Outbound Streams:"));
153 ui
->label_225
->setText(QStringLiteral("%1").arg(selected_assoc
->outstream1
));
154 ui
->label_216
->setText(tr("Minimum Number of Outbound Streams:"));
155 ui
->label_226
->setText(QStringLiteral("%1").arg(((selected_assoc
->outstream1
> selected_assoc
->instream2
) ?
156 selected_assoc
->instream2
: selected_assoc
->outstream1
)));
158 ui
->label_213
->setText(tr("Used Number of Inbound Streams:"));
159 ui
->label_223
->setText(QStringLiteral("%1").arg(selected_assoc
->instream1
));
160 ui
->label_214
->setText(tr("Used Number of Outbound Streams:"));
161 ui
->label_224
->setText(QStringLiteral("%1").arg(selected_assoc
->outstream1
));
162 ui
->label_215
->setText(QString(""));
163 ui
->label_225
->setText(QString(""));
164 ui
->label_216
->setText(QString(""));
165 ui
->label_226
->setText(QString(""));
170 if ((selected_assoc
->initack
) && (selected_assoc
->initack_dir
== 2))
171 ui
->labelEP2
->setText(tr("Complete list of IP addresses from INIT_ACK Chunk:"));
173 ui
->labelEP2
->setText(tr("List of Used IP Addresses"));
175 if (selected_assoc
->addr2
!= Q_NULLPTR
) {
178 list
= g_list_first(selected_assoc
->addr2
);
182 store
= gxx_list_data(address
*, list
);
183 if (store
->type
!= AT_NONE
) {
184 if ((store
->type
== AT_IPv4
) || (store
->type
== AT_IPv6
)) {
185 ui
->listWidgetEP2
->addItem(address_to_qstring(store
));
188 list
= gxx_list_next(list
);
194 ui
->label_321
->setText(QStringLiteral("%1").arg(selected_assoc
->port2
));
195 ui
->label_322
->setText(QStringLiteral("0x%1").arg(selected_assoc
->verification_tag2
, 0, 16));
197 if (selected_assoc
->initack
) {
198 ui
->label_313
->setText(tr("Requested Number of Inbound Streams:"));
199 ui
->label_323
->setText(QStringLiteral("%1").arg(selected_assoc
->instream2
));
200 ui
->label_314
->setText(tr("Minimum Number of Inbound Streams:"));
201 ui
->label_324
->setText(QStringLiteral("%1").arg(((selected_assoc
->instream2
> selected_assoc
->outstream1
) ?
202 selected_assoc
->outstream1
: selected_assoc
->instream2
)));
203 ui
->label_315
->setText(tr("Provided Number of Outbound Streams:"));
204 ui
->label_325
->setText(QStringLiteral("%1").arg(selected_assoc
->outstream2
));
205 ui
->label_316
->setText(tr("Minimum Number of Outbound Streams:"));
206 ui
->label_326
->setText(QStringLiteral("%1").arg(((selected_assoc
->outstream2
> selected_assoc
->instream1
) ?
207 selected_assoc
->instream1
: selected_assoc
->outstream2
)));
209 ui
->label_313
->setText(tr("Used Number of Inbound Streams:"));
210 ui
->label_323
->setText(QStringLiteral("%1").arg(selected_assoc
->instream2
));
211 ui
->label_314
->setText(tr("Used Number of Outbound Streams:"));
212 ui
->label_324
->setText(QStringLiteral("%1").arg(selected_assoc
->outstream2
));
213 ui
->label_315
->setText(QString(""));
214 ui
->label_325
->setText(QString(""));
215 ui
->label_316
->setText(QString(""));
216 ui
->label_326
->setText(QString(""));
220 void SCTPAssocAnalyseDialog::openGraphDialog(int direction
)
222 const sctp_assoc_info_t
* selected_assoc
= SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id
);
223 if (!selected_assoc
) return;
225 SCTPGraphDialog
*sctp_dialog
= new SCTPGraphDialog(this, selected_assoc
, cap_file_
, direction
);
227 if (sctp_dialog
->isMinimized() == true) {
228 sctp_dialog
->showNormal();
233 sctp_dialog
->raise();
234 sctp_dialog
->activateWindow();
237 void SCTPAssocAnalyseDialog::on_GraphTSN_2_clicked()
242 void SCTPAssocAnalyseDialog::on_GraphTSN_1_clicked()
247 void SCTPAssocAnalyseDialog::on_chunkStatisticsButton_clicked()
249 const sctp_assoc_info_t
* selected_assoc
= SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id
);
250 if (!selected_assoc
) return;
252 SCTPChunkStatisticsDialog
*sctp_dialog
= new SCTPChunkStatisticsDialog(this, selected_assoc
, cap_file_
);
254 if (sctp_dialog
->isMinimized() == true) {
255 sctp_dialog
->showNormal();
260 sctp_dialog
->raise();
261 sctp_dialog
->activateWindow();
264 void SCTPAssocAnalyseDialog::on_setFilterButton_clicked()
266 QString newFilter
= QStringLiteral("sctp.assoc_index==%1").arg(selected_assoc_id
);
267 emit
filterPackets(newFilter
, false);
270 void SCTPAssocAnalyseDialog::openGraphByteDialog(int direction
)
272 const sctp_assoc_info_t
* selected_assoc
= SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id
);
273 if (!selected_assoc
) return;
275 SCTPGraphByteDialog
*sctp_dialog
= new SCTPGraphByteDialog(this, selected_assoc
, cap_file_
, direction
);
277 if (sctp_dialog
->isMinimized() == true) {
278 sctp_dialog
->showNormal();
283 sctp_dialog
->raise();
284 sctp_dialog
->activateWindow();
287 void SCTPAssocAnalyseDialog::on_GraphBytes_1_clicked()
289 openGraphByteDialog(1);
292 void SCTPAssocAnalyseDialog::on_GraphBytes_2_clicked()
294 openGraphByteDialog(2);
297 void SCTPAssocAnalyseDialog::openGraphArwndDialog(int direction
)
299 const sctp_assoc_info_t
* selected_assoc
= SCTPAssocAnalyseDialog::findAssoc(this, selected_assoc_id
);
300 if (!selected_assoc
) return;
302 SCTPGraphArwndDialog
*sctp_dialog
= new SCTPGraphArwndDialog(this, selected_assoc
, cap_file_
, direction
);
304 if (sctp_dialog
->isMinimized() == true) {
305 sctp_dialog
->showNormal();
310 sctp_dialog
->raise();
311 sctp_dialog
->activateWindow();
314 void SCTPAssocAnalyseDialog::on_GraphArwnd_1_clicked()
316 openGraphArwndDialog(1);
319 void SCTPAssocAnalyseDialog::on_GraphArwnd_2_clicked()
321 openGraphArwndDialog(2);