From 386f354f878c1a72ef3c3eba708f936261fb7e09 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Fri, 22 Dec 2017 20:05:44 -0500 Subject: [PATCH] Add Service Response Time dialog for SCSI. SCSI requires parameter data to be passed into the tap. Provide a new dialog that can handle SCSI commands. Bug: 14144 Change-Id: I4561f251ec38753a28befee33b8b994b04b92230 Reviewed-on: https://code.wireshark.org/review/24955 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-scsi.c | 3 +- epan/dissectors/packet-scsi.h | 11 ++ ui/qt/CMakeLists.txt | 2 + ui/qt/Makefile.am | 2 + ui/qt/rpc_service_response_time_dialog.cpp | 4 +- ui/qt/rpc_service_response_time_dialog.h | 6 +- ui/qt/scsi_service_response_time_dialog.cpp | 111 ++++++++++++++++++++ ui/qt/scsi_service_response_time_dialog.h | 60 +++++++++++ ui/qt/service_response_time_dialog.cpp | 5 + ui/qt/service_response_time_dialog.h | 5 +- 10 files changed, 200 insertions(+), 9 deletions(-) create mode 100644 ui/qt/scsi_service_response_time_dialog.cpp create mode 100644 ui/qt/scsi_service_response_time_dialog.h diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index f67ea79cb3..f9aca9eeaa 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -85,7 +85,6 @@ #include #include #include -#include #include #include #include "packet-scsi.h" @@ -1006,7 +1005,7 @@ scsistat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const vo return 1; } -static guint +guint scsistat_param(register_srt_t* srt, const char* opt_arg, char** err) { int pos = 0; diff --git a/epan/dissectors/packet-scsi.h b/epan/dissectors/packet-scsi.h index 3caa513be2..8d12458da3 100644 --- a/epan/dissectors/packet-scsi.h +++ b/epan/dissectors/packet-scsi.h @@ -23,7 +23,12 @@ #ifndef __PACKET_SCSI_H_ #define __PACKET_SCSI_H_ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #include +#include /* Structure containing itl nexus data : * The itlq nexus is a structure containing data specific @@ -316,6 +321,12 @@ extern value_string_ext scsi_asc_val_ext; try_end_data_offset=offset_arg; +WS_DLL_PUBLIC guint scsistat_param(register_srt_t* srt, const char* opt_arg, char** err); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index ed87d57ecb..18399a365e 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -183,6 +183,7 @@ set(WIRESHARK_QT_HEADERS rtp_audio_stream.h rtp_player_dialog.h rtp_stream_dialog.h + scsi_service_response_time_dialog.h sctp_all_assocs_dialog.h sctp_assoc_analyse_dialog.h sctp_chunk_statistics_dialog.h @@ -390,6 +391,7 @@ set(WIRESHARK_QT_SRC rtp_audio_stream.cpp rtp_player_dialog.cpp rtp_stream_dialog.cpp + scsi_service_response_time_dialog.cpp sctp_all_assocs_dialog.cpp sctp_assoc_analyse_dialog.cpp sctp_chunk_statistics_dialog.cpp diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am index 385f909d3f..0f80c08936 100644 --- a/ui/qt/Makefile.am +++ b/ui/qt/Makefile.am @@ -313,6 +313,7 @@ MOC_HDRS = \ rtp_audio_stream.h \ rtp_player_dialog.h \ rtp_stream_dialog.h \ + scsi_service_response_time_dialog.h \ sctp_all_assocs_dialog.h \ sctp_assoc_analyse_dialog.h \ search_frame.h \ @@ -633,6 +634,7 @@ WIRESHARK_QT_SRC = \ rtp_audio_stream.cpp \ rtp_player_dialog.cpp \ rtp_stream_dialog.cpp \ + scsi_service_response_time_dialog.cpp \ sctp_all_assocs_dialog.cpp \ sctp_assoc_analyse_dialog.cpp \ sctp_chunk_statistics_dialog.cpp \ diff --git a/ui/qt/rpc_service_response_time_dialog.cpp b/ui/qt/rpc_service_response_time_dialog.cpp index f47d80a8c1..3732b242cc 100644 --- a/ui/qt/rpc_service_response_time_dialog.cpp +++ b/ui/qt/rpc_service_response_time_dialog.cpp @@ -382,7 +382,7 @@ void RpcServiceResponseTimeDialog::fillVersionCombo() } } -void RpcServiceResponseTimeDialog::fillTree() +void RpcServiceResponseTimeDialog::provideParameterData() { void *tap_data = NULL; const QString program_name = program_combo_->currentText(); @@ -428,8 +428,6 @@ void RpcServiceResponseTimeDialog::fillTree() } set_srt_table_param_data(srt_, tap_data); - - ServiceResponseTimeDialog::fillTree(); } /* diff --git a/ui/qt/rpc_service_response_time_dialog.h b/ui/qt/rpc_service_response_time_dialog.h index b257c9637a..7442c272aa 100644 --- a/ui/qt/rpc_service_response_time_dialog.h +++ b/ui/qt/rpc_service_response_time_dialog.h @@ -55,13 +55,13 @@ public: void setOncRpcProgramAndVersion(int program, int version); void setRpcNameAndVersion(const QString &program_name, int version); +protected: + virtual void provideParameterData(); + public slots: void dceRpcProgramChanged(const QString &program_name); void oncRpcProgramChanged(const QString &program_name); -protected slots: - virtual void fillTree(); - private: RpcFamily dlg_type_; QComboBox *program_combo_; diff --git a/ui/qt/scsi_service_response_time_dialog.cpp b/ui/qt/scsi_service_response_time_dialog.cpp new file mode 100644 index 0000000000..9bf484dcea --- /dev/null +++ b/ui/qt/scsi_service_response_time_dialog.cpp @@ -0,0 +1,111 @@ +/* scsi_service_response_time_dialog.cpp + * + * 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 "scsi_service_response_time_dialog.h" + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +ScsiServiceResponseTimeDialog::ScsiServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, struct register_srt *srt, const QString filter) : + ServiceResponseTimeDialog(parent, cf, srt, filter) +{ + setRetapOnShow(false); + setHint(tr("Select a command and enter a filter if desired, then press Apply.")); + + QHBoxLayout *filter_layout = filterLayout(); + command_combo_ = new QComboBox(this); + + filter_layout->insertStretch(0, 1); + filter_layout->insertWidget(0, command_combo_); + filter_layout->insertWidget(0, new QLabel(tr("Command:"))); + + setWindowSubtitle(tr("SCSI Service Response Times")); + + QStringList commands; + commands << "SBC (disk)" << "SSC (tape)" << "MMC (cd/dvd)" << "SMC (tape robot)" << "OSD (object based)"; + command_combo_->addItems(commands); +} + +TapParameterDialog *ScsiServiceResponseTimeDialog::createScsiSrtDialog(QWidget &parent, const QString, const QString opt_arg, CaptureFile &cf) +{ + QString filter; + bool have_args = false; + QString command; + + // rpc,srt,scsi,command[, + QStringList args_l = QString(opt_arg).split(','); + if (args_l.length() > 0) { + command = args_l[0]; + if (args_l.length() > 1) { + filter = QStringList(args_l.mid(1)).join(","); + } + have_args = true; + } + + ScsiServiceResponseTimeDialog *scsi_dlg = new ScsiServiceResponseTimeDialog(parent, cf, get_srt_table_by_name("scsi"), filter); + + if (have_args) { + if (!command.isEmpty()) { + scsi_dlg->setScsiCommand(command.toInt()); + } + } + + return scsi_dlg; +} + +void ScsiServiceResponseTimeDialog::setScsiCommand(int command) +{ + command_combo_->setCurrentIndex(command); + fillTree(); +} + +void ScsiServiceResponseTimeDialog::provideParameterData() +{ + char* err; + QString command; + + command = QString(",%1").arg(command_combo_->currentIndex()); + + scsistat_param(srt_, command.toStdString().c_str(), &err); +} + +/* + * 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/scsi_service_response_time_dialog.h b/ui/qt/scsi_service_response_time_dialog.h new file mode 100644 index 0000000000..0ea0f5c79c --- /dev/null +++ b/ui/qt/scsi_service_response_time_dialog.h @@ -0,0 +1,60 @@ +/* scsi_service_response_time_dialog.h + * + * 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 __SCSI_SERVICE_RESPONSE_TIME_DIALOG_H__ +#define __SCSI_SERVICE_RESPONSE_TIME_DIALOG_H__ + +#include "service_response_time_dialog.h" + +class QComboBox; + +class ScsiServiceResponseTimeDialog : public ServiceResponseTimeDialog +{ + Q_OBJECT + +public: + + ScsiServiceResponseTimeDialog(QWidget &parent, CaptureFile &cf, struct register_srt *srt, const QString filter); + static TapParameterDialog *createScsiSrtDialog(QWidget &parent, const QString, const QString opt_arg, CaptureFile &cf); + + void setScsiCommand(int command); + +protected: + virtual void provideParameterData(); + +private: + QComboBox *command_combo_; +}; + +#endif // __SCSI_SERVICE_RESPONSE_TIME_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/service_response_time_dialog.cpp b/ui/qt/service_response_time_dialog.cpp index b79ce7fd10..0f10be4322 100644 --- a/ui/qt/service_response_time_dialog.cpp +++ b/ui/qt/service_response_time_dialog.cpp @@ -28,6 +28,7 @@ #include #include "rpc_service_response_time_dialog.h" +#include "scsi_service_response_time_dialog.h" #include "wireshark_application.h" #include @@ -65,6 +66,8 @@ gboolean register_service_response_tables(const void *, void *value, void*) } else if (strcmp(short_name, "RPC") == 0) { short_name = "ONC-RPC"; tpd_creator = RpcServiceResponseTimeDialog::createOncRpcSrtDialog; + } else if (strcmp(short_name, "SCSI") == 0) { + tpd_creator = ScsiServiceResponseTimeDialog::createScsiSrtDialog; } cfg_str_to_srt_[cfg_abbr] = srt; @@ -284,6 +287,8 @@ void ServiceResponseTimeDialog::fillTree() srt_data_.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); srt_data_.user_data = this; + provideParameterData(); + srt_table_dissector_init(srt_, srt_data_.srt_array, NULL, NULL); QString display_filter = displayFilter(); diff --git a/ui/qt/service_response_time_dialog.h b/ui/qt/service_response_time_dialog.h index ec953eb423..9bd41b4a9b 100644 --- a/ui/qt/service_response_time_dialog.h +++ b/ui/qt/service_response_time_dialog.h @@ -55,8 +55,11 @@ protected: // gtk:service_response_table.h:init_srt_table void addSrtTable(const struct _srt_stat_table *srt_table); + + virtual void provideParameterData() {} + protected slots: - virtual void fillTree(); + void fillTree(); private: // Callbacks for register_tap_listener