1 /* sctp_all_assocs_dialog.cpp
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "sctp_all_assocs_dialog.h"
23 #include <ui_sctp_all_assocs_dialog.h>
24 #include "sctp_assoc_analyse_dialog.h"
26 #include "qt_ui_utils.h"
27 //#include "wireshark_application.h"
29 #include "ui/qt/main_window.h"
33 #include <QFileDialog>
34 #include <QPushButton>
38 SCTPAllAssocsDialog::SCTPAllAssocsDialog(QWidget *parent, capture_file *cf) :
40 ui(new Ui::SCTPAllAssocsDialog),
44 Qt::WindowFlags flags = Qt::Window | Qt::WindowSystemMenuHint
45 | Qt::WindowMinimizeButtonHint
46 | Qt::WindowMaximizeButtonHint
47 | Qt::WindowCloseButtonHint;
48 this->setWindowFlags(flags);
49 sctp_assocs = (sctp_allassocs_info_t *)g_malloc(sizeof(sctp_allassocs_info_t));
53 SCTPAllAssocsDialog::~SCTPAllAssocsDialog()
58 void SCTPAllAssocsDialog::fillTable()
62 sctp_assoc_info_t* assinfo;
65 ui->assocList->setColumnHidden(0, true);
66 ui->assocList->setColumnWidth(1, 85);
67 ui->assocList->setColumnWidth(2, 85);
68 ui->assocList->setColumnWidth(3, 150);
69 ui->assocList->setColumnWidth(4, 150);
71 sctp_assocs = (sctp_allassocs_info_t*)sctp_stat_get_info();
72 if (sctp_stat_get_info()->is_registered == FALSE) {
73 register_tap_listener_sctp_stat();
74 /* (redissect all packets) */
75 cf_retap_packets(cap_file_);
78 ui->assocList->setRowCount(g_list_length(sctp_assocs->assoc_info_list));
80 list = g_list_first(sctp_assocs->assoc_info_list);
83 assinfo = (sctp_assoc_info_t*)(list->data);
84 ui->assocList->setItem(numAssocs, 0, new QTableWidgetItem(QString("%1").arg(assinfo->assoc_id)));
85 ui->assocList->setItem(numAssocs, 1, new QTableWidgetItem(QString("%1").arg(assinfo->port1)));
86 ui->assocList->setItem(numAssocs, 2, new QTableWidgetItem(QString("%1").arg(assinfo->port2)));
87 ui->assocList->setItem(numAssocs, 3, new QTableWidgetItem(QString("%1").arg(assinfo->n_packets)));
88 ui->assocList->setItem(numAssocs, 4, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_chunks)));
89 ui->assocList->setItem(numAssocs, 5, new QTableWidgetItem(QString("%1").arg(assinfo->n_data_bytes)));
90 list = g_list_next(list);
93 ui->analyseButton->setEnabled(false);
94 ui->setFilterButton->setEnabled(false);
95 connect(ui->assocList, SIGNAL(itemSelectionChanged()), this, SLOT(getSelectedItem()));
98 sctp_assoc_info_t* SCTPAllAssocsDialog::findSelectedAssoc()
100 QTableWidgetItem *selection;
102 sctp_assoc_info_t* assinfo;
105 selection = ui->assocList->selectedItems()[0];
106 row = selection->row();
107 selection = ui->assocList->item(row, 0);
108 id = (selection->data(0)).toInt();
109 list = g_list_first(sctp_assocs->assoc_info_list);
112 assinfo = (sctp_assoc_info_t*)(list->data);
113 if (assinfo->assoc_id == id) {
116 list = g_list_next(list);
121 void SCTPAllAssocsDialog::getSelectedItem()
123 ui->analyseButton->setEnabled(true);
124 ui->setFilterButton->setEnabled(true);
125 ui->analyseButton->setFocus(Qt::OtherFocusReason);
126 selected_assoc = findSelectedAssoc();
129 void SCTPAllAssocsDialog::on_analyseButton_clicked()
132 if (!selected_assoc) {
133 selected_assoc = findSelectedAssoc();
136 SCTPAssocAnalyseDialog *sctp_analyse = new SCTPAssocAnalyseDialog(this, selected_assoc, cap_file_, this);
137 connect(sctp_analyse, SIGNAL(filterPackets(QString&,bool)),
138 parent(), SLOT(filterPackets(QString&,bool)));
140 if (sctp_analyse->isMinimized() == true)
142 sctp_analyse->showNormal();
146 sctp_analyse->show();
149 sctp_analyse->raise();
150 sctp_analyse->activateWindow();
153 void SCTPAllAssocsDialog::on_setFilterButton_clicked()
156 if (!selected_assoc){
157 selected_assoc = findSelectedAssoc();
160 QString newFilter = QString("sctp.assoc_index==%1").arg(selected_assoc->assoc_id);
161 selected_assoc = NULL;
162 emit filterPackets(newFilter, false);
171 * indent-tabs-mode: nil
174 * ex: set shiftwidth=4 tabstop=8 expandtab:
175 * :indentSize=4:tabSize=8:noTabs=true: