From: gerald Date: Fri, 22 Nov 2013 01:07:36 +0000 (+0000) Subject: Add an initial "Decode As" dialog. Currently read-only. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=71cea3b8b64bddc4e1594b683e28615cf32d2663;p=metze%2Fwireshark%2Fwip.git Add an initial "Decode As" dialog. Currently read-only. Fixup some of the Statistics menu items. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@53499 f5534014-38df-0310-8fa8-9805f1628bb7 --- diff --git a/ui/gtk/decode_as_dlg.c b/ui/gtk/decode_as_dlg.c index 65dd576f7a..c9eaede917 100644 --- a/ui/gtk/decode_as_dlg.c +++ b/ui/gtk/decode_as_dlg.c @@ -290,12 +290,12 @@ decode_build_show_list (const gchar *table_name, ftenum_t selector_type, g_assert(user_data); g_assert(value); - current = (dissector_handle_t)dtbl_entry_get_handle((dtbl_entry_t *)value); + current = dtbl_entry_get_handle((dtbl_entry_t *)value); if (current == NULL) current_proto_name = "(none)"; else current_proto_name = dissector_handle_get_short_name(current); - initial = (dissector_handle_t)dtbl_entry_get_initial_handle((dtbl_entry_t *)value); + initial = dtbl_entry_get_initial_handle((dtbl_entry_t *)value); if (initial == NULL) initial_proto_name = "(none)"; else diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index e1412ef494..587600bc22 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -37,6 +37,7 @@ set(WIRESHARK_QT_HEADERS color_dialog.h color_utils.h column_preferences_frame.h + decode_as_dialog.h display_filter_combo.h display_filter_edit.h elided_label.h @@ -102,6 +103,7 @@ set(WIRESHARK_QT_SRC color_utils.cpp capture_preferences_frame.cpp column_preferences_frame.cpp + decode_as_dialog.cpp display_filter_combo.cpp display_filter_edit.cpp elided_label.cpp @@ -167,6 +169,7 @@ set(DIRTY_FILES set(WIRESHARK_QT_UI capture_preferences_frame.ui column_preferences_frame.ui + decode_as_dialog.ui export_object_dialog.ui file_set_dialog.ui filter_expressions_preferences_frame.ui diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am index 36b3946668..855dea6074 100644 --- a/ui/qt/Makefile.am +++ b/ui/qt/Makefile.am @@ -128,6 +128,8 @@ capture_preferences_frame.cpp capture_preferences_frame.h: ui_capture_preference column_preferences_frame.cpp column_preferences_frame.h: ui_column_preferences_frame.h +decode_as_dialog.cpp decode_as_dialog.h: ui_decode_as_dialog.h + export_object_dialog.cpp export_object_dialog.h: ui_export_object_dialog.h file_set_dialog.cpp file_set_dialog.h: ui_file_set_dialog.h diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common index 73d6f9870e..62c5aa5f0a 100644 --- a/ui/qt/Makefile.common +++ b/ui/qt/Makefile.common @@ -33,6 +33,7 @@ GENERATED_HEADER_FILES = NODIST_GENERATED_HEADER_FILES = \ ui_capture_preferences_frame.h \ ui_column_preferences_frame.h \ + ui_decode_as_dialog.h \ ui_export_object_dialog.h \ ui_file_set_dialog.h \ ui_filter_expressions_preferences_frame.h \ @@ -106,6 +107,7 @@ MOC_HDRS = \ color_utils.h \ capture_preferences_frame.h \ column_preferences_frame.h \ + decode_as_dialog.h \ display_filter_combo.h \ display_filter_edit.h \ elided_label.h \ @@ -159,6 +161,7 @@ MOC_HDRS = \ UI_FILES = \ capture_preferences_frame.ui \ column_preferences_frame.ui \ + decode_as_dialog.ui \ export_object_dialog.ui \ file_set_dialog.ui \ filter_expressions_preferences_frame.ui \ @@ -247,6 +250,7 @@ WIRESHARK_QT_SRC = \ color_utils.cpp \ capture_preferences_frame.cpp \ column_preferences_frame.cpp \ + decode_as_dialog.cpp \ display_filter_combo.cpp \ display_filter_edit.cpp \ elided_label.cpp \ diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro index b571c27d7c..7e0a7a2e8f 100644 --- a/ui/qt/QtShark.pro +++ b/ui/qt/QtShark.pro @@ -224,6 +224,7 @@ HEADERS_WS_C = \ FORMS += \ capture_preferences_frame.ui \ column_preferences_frame.ui \ + decode_as_dialog.ui \ export_object_dialog.ui \ file_set_dialog.ui \ filter_expressions_preferences_frame.ui \ @@ -254,6 +255,7 @@ HEADERS += $$HEADERS_WS_C \ accordion_frame.h \ capture_preferences_frame.h \ column_preferences_frame.h \ + decode_as_dialog.h \ elided_label.h \ export_dissection_dialog.h \ export_object_dialog.h \ @@ -549,6 +551,7 @@ SOURCES += \ color_dialog.cpp \ color_utils.cpp \ column_preferences_frame.cpp \ + decode_as_dialog.cpp \ display_filter_combo.cpp \ display_filter_edit.cpp \ elided_label.cpp \ diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp new file mode 100644 index 0000000000..9e6c65b1d8 --- /dev/null +++ b/ui/qt/decode_as_dialog.cpp @@ -0,0 +1,167 @@ +/* stats_tree_dialog.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "decode_as_dialog.h" +#include "ui_decode_as_dialog.h" + +#include "epan/decode_as.h" +#include "epan/dissectors/packet-dcerpc.h" + +#include "wireshark_application.h" + +#include + +#include + +const int field_col_ = 0; +const int value_col_ = 1; +const int default_col_ = 2; +const int current_col_ = 3; + +DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf) : + QDialog(parent), + ui(new Ui::DecodeAsDialog), + cap_file_(cf) +{ + ui->setupUi(this); + + connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(fillTable())); + fillTable(); +} + +DecodeAsDialog::~DecodeAsDialog() +{ + delete ui; +} + +void DecodeAsDialog::setCaptureFile(capture_file *cf) +{ + cap_file_ = cf; + fillTable(); +} + +void DecodeAsDialog::fillTable() +{ + ui->decodeAsTreeWidget->clear(); + dissector_all_tables_foreach_changed(buildChangedList, this); + decode_dcerpc_add_show_list(buildDceRpcChangedList, this); +} + +void DecodeAsDialog::buildChangedList(const gchar *table_name, ftenum_t selector_type, gpointer key, gpointer value, gpointer user_data) +{ + DecodeAsDialog *da_dlg = (DecodeAsDialog *)user_data; + if (!da_dlg) return; + + dissector_handle_t default_dh, current_dh; + QString value_str; + QString default_proto_name = "(none)", current_proto_name = "(none)"; + QTreeWidgetItem *ti = new QTreeWidgetItem(); + + current_dh = dtbl_entry_get_handle((dtbl_entry_t *)value); + if (current_dh) { + current_proto_name = dissector_handle_get_short_name(current_dh); + } + default_dh = dtbl_entry_get_initial_handle((dtbl_entry_t *)value); + if (default_dh) { + default_proto_name = dissector_handle_get_short_name(default_dh); + } + + switch (selector_type) { + + case FT_UINT8: + case FT_UINT16: + case FT_UINT24: + case FT_UINT32: + switch (get_dissector_table_base(table_name)) { + + case BASE_DEC: + value_str = QString::number(GPOINTER_TO_UINT(key)); + break; + + case BASE_HEX: + switch (get_dissector_table_selector_type(table_name)) { + + case FT_UINT8: + value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 2, 16, QChar('0')); + break; + + case FT_UINT16: + value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 4, 16, QChar('0')); + break; + + case FT_UINT24: + value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 6, 16, QChar('0')); + break; + + case FT_UINT32: + value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 8, 16, QChar('0')); + break; + + default: + g_assert_not_reached(); + break; + } + break; + + case BASE_OCT: + value_str = QString::number(GPOINTER_TO_UINT(key), 8); + break; + } + break; + + case FT_STRING: + case FT_STRINGZ: + value_str = (char *)key; + break; + + default: + g_assert_not_reached(); + break; + } + + ti->setText(field_col_, get_dissector_table_ui_name(table_name)); + ti->setText(value_col_, value_str); + ti->setText(default_col_, default_proto_name); + ti->setText(current_col_, current_proto_name); + + da_dlg->ui->decodeAsTreeWidget->addTopLevelItem(ti); +} + +void DecodeAsDialog::buildDceRpcChangedList(gpointer data, gpointer user_data) +{ + decode_dcerpc_bind_values_t *binding = (decode_dcerpc_bind_values_t *)data; + qDebug() << "=bdcecl" << binding->ifname; +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/decode_as_dialog.h b/ui/qt/decode_as_dialog.h new file mode 100644 index 0000000000..207214355a --- /dev/null +++ b/ui/qt/decode_as_dialog.h @@ -0,0 +1,76 @@ +/* stats_tree_dialog.h + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef DECODE_AS_DIALOG_H +#define DECODE_AS_DIALOG_H + +#include "config.h" + +#include + +#include "cfile.h" + +#include + +namespace Ui { +class DecodeAsDialog; +} + +class DecodeAsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DecodeAsDialog(QWidget *parent = 0, capture_file *cf = NULL); + ~DecodeAsDialog(); + +public slots: + void setCaptureFile(capture_file *cf); + +private: + Ui::DecodeAsDialog *ui; + + capture_file *cap_file_; + + static void buildChangedList(const gchar *table_name, ftenum_t selector_type, + gpointer key, gpointer value, gpointer user_data); + static void buildDceRpcChangedList(gpointer data, gpointer user_data); + +private slots: + void fillTable(); +}; + +#endif // DECODE_AS_DIALOG_H + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/ui/qt/decode_as_dialog.ui b/ui/qt/decode_as_dialog.ui new file mode 100644 index 0000000000..ad6eee0617 --- /dev/null +++ b/ui/qt/decode_as_dialog.ui @@ -0,0 +1,170 @@ + + + DecodeAsDialog + + + + 0 + 0 + 750 + 600 + + + + Wireshark: Decode As + + + + + + + Field + + + + + Value + + + + + Default + + + + + Current + + + + + + + + + + Create a new profile using default settings. + + + + + + + :/stock/plus-8.png:/stock/plus-8.png + + + + + + + Remove this profile. + + + + :/stock/minus-8.png:/stock/minus-8.png + + + + + + + Copy this profile. + + + + + + + :/stock/copy-8.png:/stock/copy-8.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 1 + 0 + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + true + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + + + + + + ElidedLabel + QLabel +
elided_label.h
+
+
+ + + + buttonBox + accepted() + DecodeAsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DecodeAsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index c6ac5219ca..a296680a4d 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -277,6 +277,8 @@ private slots: void on_actionAnalyzePAFAndNotSelected_triggered(); void on_actionAnalyzePAFOrNotSelected_triggered(); + void on_actionAnalyzeDecodeAs_triggered(); + void openFollowStreamDialog(follow_type_t type); void on_actionAnalyzeFollowTCPStream_triggered(); void on_actionAnalyzeFollowUDPStream_triggered(); diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui index 92574efde4..c6fcb5cb38 100644 --- a/ui/qt/main_window.ui +++ b/ui/qt/main_window.ui @@ -309,6 +309,8 @@ + + @@ -349,17 +351,17 @@ - - + + - + @@ -1360,7 +1362,7 @@ - Flow Graph... + Flow Graph Flow sequence diagram @@ -1494,6 +1496,14 @@ UCP message statistics + + + Decode &As... + + + Change the way packets are dissected + + diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index d03511a15c..9e30d8953b 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -70,6 +70,7 @@ #endif #include "capture_file_dialog.h" +#include "decode_as_dialog.h" #include "export_object_dialog.h" #include "packet_comment_dialog.h" #include "preferences_dialog.h" @@ -1740,6 +1741,14 @@ void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered() matchSelectedFilter(MatchSelectedOrNot, false, false); } +void MainWindow::on_actionAnalyzeDecodeAs_triggered() +{ + DecodeAsDialog *da_dialog = new DecodeAsDialog(this, cap_file_); + connect(this, SIGNAL(setCaptureFile(capture_file*)), + da_dialog, SLOT(setCaptureFile(capture_file*))); + da_dialog->show(); +} + void MainWindow::openFollowStreamDialog(follow_type_t type) { FollowStreamDialog *fsd = new FollowStreamDialog(this, type, cap_file_); connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool))); diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp index 92c22e80de..4dd0b0eac5 100644 --- a/ui/qt/wireshark_application.cpp +++ b/ui/qt/wireshark_application.cpp @@ -25,6 +25,7 @@ #include "wsutil/filesystem.h" +#include "epan/decode_as.h" #include "epan/disabled_protos.h" #include "epan/tap.h" #include "epan/timestamp.h" @@ -652,6 +653,9 @@ e_prefs * WiresharkApplication::readConfigurationFiles(char **gdp_path, char **d int pf_open_errno, pf_read_errno; e_prefs *prefs_p; + /* load the decode as entries of this profile */ + load_decode_as_entries(); + /* Read the preference files. */ prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path, &pf_open_errno, &pf_read_errno, &pf_path);