2006-04-24 23:09:34 +00:00
|
|
|
/* scsi_stat.c
|
|
|
|
* scsi_stat 2006 Ronnie Sahlberg
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-04-24 23:09:34 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2010-08-30 16:10:01 +00:00
|
|
|
*
|
2006-04-24 23:09:34 +00:00
|
|
|
* 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.
|
2010-08-30 16:10:01 +00:00
|
|
|
*
|
2006-04-24 23:09:34 +00:00
|
|
|
* 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.
|
2010-08-30 16:10:01 +00:00
|
|
|
*
|
2006-04-24 23:09:34 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-04-24 23:09:34 +00:00
|
|
|
*/
|
|
|
|
|
2010-08-30 16:10:01 +00:00
|
|
|
/* This module provides rpc call/reply SRT (Server Response Time) statistics
|
2006-05-22 07:29:40 +00:00
|
|
|
* to Wireshark.
|
2006-04-24 23:09:34 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2009-08-27 04:47:28 +00:00
|
|
|
|
2006-04-24 23:09:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <epan/packet_info.h>
|
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/conversation.h>
|
|
|
|
#include <epan/dissectors/packet-scsi.h>
|
2006-11-27 11:00:06 +00:00
|
|
|
#include <epan/dissectors/packet-scsi-sbc.h>
|
2006-11-22 10:12:59 +00:00
|
|
|
#include <epan/dissectors/packet-scsi-ssc.h>
|
2006-11-24 08:22:30 +00:00
|
|
|
#include <epan/dissectors/packet-scsi-smc.h>
|
|
|
|
#include <epan/dissectors/packet-scsi-osd.h>
|
2013-12-12 19:26:55 +00:00
|
|
|
#include <epan/dissectors/packet-scsi-mmc.h>
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
2014-07-03 20:30:12 +00:00
|
|
|
#include <epan/stat_groups.h>
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/main.h"
|
|
|
|
#include "ui/gtk/service_response_time_table.h"
|
|
|
|
#include "ui/gtk/tap_param_dlg.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
|
|
|
|
2014-01-16 07:30:22 +00:00
|
|
|
void register_tap_listener_gtkscsistat(void);
|
|
|
|
|
2006-04-24 23:09:34 +00:00
|
|
|
/* used to keep track of the statistics for an entire scsi command set */
|
|
|
|
typedef struct _scsistat_t {
|
2013-12-12 19:26:55 +00:00
|
|
|
GtkWidget *win;
|
|
|
|
srt_stat_table srt_table;
|
|
|
|
guint8 cmdset;
|
|
|
|
value_string_ext *cdbnames_ext;
|
|
|
|
const char *prog;
|
2006-04-24 23:09:34 +00:00
|
|
|
} scsistat_t;
|
|
|
|
|
2013-12-12 19:26:55 +00:00
|
|
|
static guint8 scsi_program = 0;
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2009-10-16 07:54:20 +00:00
|
|
|
enum
|
|
|
|
{
|
2013-12-12 19:26:55 +00:00
|
|
|
SCSI_STAT_PROG_LABEL_SBC,
|
|
|
|
SCSI_STAT_PROG_LABEL_SSC,
|
|
|
|
SCSI_STAT_PROG_LABEL_MMC
|
2009-10-16 07:54:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-04-24 23:09:34 +00:00
|
|
|
static char *
|
|
|
|
scsistat_gen_title(scsistat_t *rs)
|
|
|
|
{
|
2012-06-03 22:03:05 +00:00
|
|
|
char *display_name;
|
2006-04-24 23:09:34 +00:00
|
|
|
char *title;
|
|
|
|
|
2012-06-03 22:03:05 +00:00
|
|
|
display_name = cf_get_display_name(&cfile);
|
2006-04-24 23:09:34 +00:00
|
|
|
title = g_strdup_printf("SCSI Service Response Time statistics for %s: %s",
|
2012-06-03 22:03:05 +00:00
|
|
|
rs->prog, display_name);
|
|
|
|
g_free(display_name);
|
2006-04-24 23:09:34 +00:00
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scsistat_set_title(scsistat_t *rs)
|
|
|
|
{
|
|
|
|
char *title;
|
|
|
|
|
|
|
|
title = scsistat_gen_title(rs);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(rs->win), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scsistat_reset(void *arg)
|
|
|
|
{
|
2010-03-09 01:46:17 +00:00
|
|
|
scsistat_t *rs = (scsistat_t *)arg;
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
reset_srt_table_data(&rs->srt_table);
|
|
|
|
scsistat_set_title(rs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
scsistat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2)
|
|
|
|
{
|
2010-03-09 01:46:17 +00:00
|
|
|
scsistat_t *rs = (scsistat_t *)arg;
|
|
|
|
const scsi_task_data_t *ri = (const scsi_task_data_t *)arg2;
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
/* we are only interested in response packets */
|
|
|
|
if(ri->type!=SCSI_PDU_TYPE_RSP){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* we are only interested in a specific commandset */
|
2006-05-05 22:01:45 +00:00
|
|
|
if( (!ri->itl) || ((ri->itl->cmdset&SCSI_CMDSET_MASK)!=rs->cmdset) ){
|
2006-04-24 23:09:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* check that the opcode looks sane */
|
|
|
|
if( (!ri->itlq) || (ri->itlq->scsi_opcode>255) ){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_srt_table_data(&rs->srt_table, ri->itlq->scsi_opcode, &ri->itlq->fc_time, pinfo);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scsistat_draw(void *arg)
|
|
|
|
{
|
2010-03-09 01:46:17 +00:00
|
|
|
scsistat_t *rs = (scsistat_t *)arg;
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
draw_srt_table_data(&rs->srt_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
2013-12-12 19:26:55 +00:00
|
|
|
scsistat_t *rs = (scsistat_t *)data;
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
remove_tap_listener(rs);
|
|
|
|
|
|
|
|
free_srt_table_data(&rs->srt_table);
|
|
|
|
g_free(rs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* When called, this function will create a new instance of gtk2-scsistat.
|
|
|
|
*/
|
|
|
|
static void
|
2012-12-06 20:59:53 +00:00
|
|
|
gtk_scsistat_init(const char *opt_arg, void* userdata _U_)
|
2006-04-24 23:09:34 +00:00
|
|
|
{
|
|
|
|
scsistat_t *rs;
|
2013-12-12 19:26:55 +00:00
|
|
|
guint32 i;
|
|
|
|
char *title_string;
|
|
|
|
char *filter_string;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *stat_label;
|
|
|
|
GtkWidget *filter_label;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
|
|
|
int program, pos;
|
|
|
|
const char *filter = NULL;
|
|
|
|
GString *error_string;
|
|
|
|
const char *hf_name = NULL;
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
if(sscanf(opt_arg,"scsi,srt,%d,%n",&program,&pos) == 1){
|
2006-04-24 23:09:34 +00:00
|
|
|
if(pos){
|
2013-12-12 19:26:55 +00:00
|
|
|
filter = opt_arg+pos;
|
2006-04-24 23:09:34 +00:00
|
|
|
} else {
|
2013-12-12 19:26:55 +00:00
|
|
|
filter = NULL;
|
2006-04-24 23:09:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2006-05-28 17:19:08 +00:00
|
|
|
fprintf(stderr, "wireshark: invalid \"-z scsi,srt,<cmdset>[,<filter>]\" argument\n");
|
2006-04-24 23:09:34 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2013-12-12 19:26:55 +00:00
|
|
|
scsi_program = program;
|
|
|
|
rs = (scsistat_t *)g_malloc(sizeof(scsistat_t));
|
|
|
|
rs->cmdset = program;
|
|
|
|
switch(program){
|
2006-04-24 23:09:34 +00:00
|
|
|
case SCSI_DEV_SBC:
|
2013-12-12 19:26:55 +00:00
|
|
|
rs->prog = "SBC (disk)";
|
|
|
|
rs->cdbnames_ext = &scsi_sbc_vals_ext;
|
|
|
|
hf_name = "scsi_sbc.opcode";
|
2006-04-24 23:09:34 +00:00
|
|
|
break;
|
|
|
|
case SCSI_DEV_SSC:
|
2013-12-12 19:26:55 +00:00
|
|
|
rs->prog = "SSC (tape)";
|
|
|
|
rs->cdbnames_ext = &scsi_ssc_vals_ext;
|
|
|
|
hf_name = "scsi_ssc.opcode";
|
2006-04-24 23:09:34 +00:00
|
|
|
break;
|
|
|
|
case SCSI_DEV_CDROM:
|
2013-12-12 19:26:55 +00:00
|
|
|
rs->prog = "MMC (cd/dvd)";
|
|
|
|
rs->cdbnames_ext = &scsi_mmc_vals_ext;
|
|
|
|
hf_name = "scsi_mmc.opcode";
|
2006-11-24 08:22:30 +00:00
|
|
|
break;
|
|
|
|
case SCSI_DEV_SMC:
|
2013-12-12 19:26:55 +00:00
|
|
|
rs->prog = "SMC (tape robot)";
|
|
|
|
rs->cdbnames_ext = &scsi_smc_vals_ext;
|
|
|
|
hf_name = "scsi_smc.opcode";
|
2006-11-24 08:22:30 +00:00
|
|
|
break;
|
|
|
|
case SCSI_DEV_OSD:
|
2013-12-12 19:26:55 +00:00
|
|
|
rs->prog = "OSD (object based)";
|
|
|
|
rs->cdbnames_ext = &scsi_osd_vals_ext;
|
|
|
|
hf_name = "scsi_osd.opcode";
|
2006-04-24 23:09:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-06-22 15:22:37 +00:00
|
|
|
rs->win = dlg_window_new("scsi-stat"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(rs->win), TRUE);
|
Add a "Sum" column to the Service Response Time (SRT) window.
The Service Response Time (SRT) window currently provides the
columns: Index, Procedure, Calls, Min SRT, Max SRT, and Avg SRT.
A Sum column has been found useful in some customer situations
to understand the total time spent doing a set of procedures.
For example, in one case we were trying to isolate whether most
time was being spent on a client thread or in the act of making
outbound calls. We knew the start and end time of the client call,
so with the "Sum" of time spent in that period, we could isolate
a particular set of procedures driving the slow down.
Additional changes made in this patch:
* Add " (s)" to Min, Max, Avg, and Sum columns to make it clear
that times are in seconds.
* Refactor out width and height constants used in calls to
gtk_window_set_default_size in most of the SRT users into
#define SRT_PREFERRED_WIDTH and SRT_PREFERRED_HEIGHT. Also
increase the common width of 550 to 650 to account for the
additional column.
Change-Id: I20f152eecbcd0bbf69f71c6c6b9f9463e8867e23
Reviewed-on: https://code.wireshark.org/review/7047
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-10 01:20:38 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(rs->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT);
|
2006-04-24 23:09:34 +00:00
|
|
|
scsistat_set_title(rs);
|
|
|
|
|
2013-12-12 19:26:55 +00:00
|
|
|
vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
2006-04-24 23:09:34 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(rs->win), vbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
2010-08-30 16:10:01 +00:00
|
|
|
|
2006-04-24 23:09:34 +00:00
|
|
|
title_string = scsistat_gen_title(rs);
|
2013-12-12 19:26:55 +00:00
|
|
|
stat_label = gtk_label_new(title_string);
|
2006-04-24 23:09:34 +00:00
|
|
|
g_free(title_string);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0);
|
|
|
|
|
2007-11-28 03:04:09 +00:00
|
|
|
filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
|
2013-12-12 19:26:55 +00:00
|
|
|
filter_label = gtk_label_new(filter_string);
|
2007-11-28 03:04:09 +00:00
|
|
|
g_free(filter_string);
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
|
2006-04-24 23:09:34 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* We must display TOP LEVEL Widget before calling init_srt_table() */
|
|
|
|
gtk_widget_show_all(rs->win);
|
|
|
|
|
2006-05-09 20:39:59 +00:00
|
|
|
init_srt_table(&rs->srt_table, 256, vbox, hf_name);
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2013-12-12 19:26:55 +00:00
|
|
|
for(i=0; i<256; i++){
|
2015-02-03 00:58:29 +00:00
|
|
|
gchar* tmp_str = val_to_str_ext_wmem(NULL, i, rs->cdbnames_ext, "Unknown-0x%02x");
|
|
|
|
init_srt_table_row(&rs->srt_table, i, tmp_str);
|
|
|
|
wmem_free(NULL, tmp_str);
|
2006-04-24 23:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-12 19:26:55 +00:00
|
|
|
error_string = register_tap_listener("scsi", rs, filter, 0, scsistat_reset, scsistat_packet, scsistat_draw);
|
2006-04-24 23:09:34 +00:00
|
|
|
if(error_string){
|
2008-10-31 09:53:56 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2006-04-24 23:09:34 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
free_srt_table_data(&rs->srt_table);
|
|
|
|
g_free(rs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
2010-03-09 01:46:17 +00:00
|
|
|
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2006-04-24 23:09:34 +00:00
|
|
|
window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb);
|
|
|
|
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(rs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(rs->win, "destroy", G_CALLBACK(win_destroy_cb), rs);
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(rs->win);
|
|
|
|
window_present(rs->win);
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(rs->win));
|
2006-04-24 23:09:34 +00:00
|
|
|
}
|
|
|
|
|
2012-11-29 21:40:26 +00:00
|
|
|
static const enum_val_t scsi_command_sets[] = {
|
2013-12-12 19:26:55 +00:00
|
|
|
{ "sbc", "SBC (disk)", SCSI_DEV_SBC },
|
|
|
|
{ "ssc", "SSC (tape)", SCSI_DEV_SSC },
|
|
|
|
{ "mmc", "MMC (cd/dvd)", SCSI_DEV_CDROM },
|
|
|
|
{ "smc", "SMC (tape robot)", SCSI_DEV_SMC },
|
2011-06-06 01:04:56 +00:00
|
|
|
{ "osd", "OSD (object based)", SCSI_DEV_OSD },
|
|
|
|
{ NULL, NULL, 0 }
|
|
|
|
};
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2011-06-06 01:04:56 +00:00
|
|
|
static tap_param scsi_stat_params[] = {
|
2014-11-14 20:21:12 +00:00
|
|
|
{ PARAM_ENUM, "cmdset", "Command set", scsi_command_sets, FALSE },
|
|
|
|
{ PARAM_FILTER, "filter", "Filter", NULL, TRUE }
|
2011-06-06 01:04:56 +00:00
|
|
|
};
|
2006-04-24 23:09:34 +00:00
|
|
|
|
2011-06-06 01:04:56 +00:00
|
|
|
static tap_param_dlg scsi_stat_dlg = {
|
|
|
|
"SCSI SRT Statistics",
|
|
|
|
"scsi,srt",
|
|
|
|
gtk_scsistat_init,
|
|
|
|
-1,
|
|
|
|
G_N_ELEMENTS(scsi_stat_params),
|
|
|
|
scsi_stat_params
|
|
|
|
};
|
2006-04-24 23:09:34 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_gtkscsistat(void)
|
|
|
|
{
|
2013-05-24 01:10:16 +00:00
|
|
|
register_param_stat(&scsi_stat_dlg, "SCSI",
|
2011-06-06 01:04:56 +00:00
|
|
|
REGISTER_STAT_GROUP_RESPONSE_TIME);
|
2006-04-24 23:09:34 +00:00
|
|
|
}
|
2013-12-12 19:26:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|