2 * fc_stat 2003 Ronnie Sahlberg
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #ifdef HAVE_SYS_TYPES_H
30 # include <sys/types.h>
37 #include <epan/packet_info.h>
38 #include <epan/epan.h>
39 #include <epan/value_string.h>
42 #include <epan/conversation.h>
43 #include <epan/dissectors/packet-scsi.h>
44 #include <epan/dissectors/packet-fc.h>
45 #include "../register.h"
46 #include "../timestats.h"
47 #include "compat_macros.h"
48 #include "../simple_dialog.h"
49 #include "gui_utils.h"
50 #include "dlg_utils.h"
52 #include "../globals.h"
53 #include "filter_dlg.h"
54 #include "service_response_time_table.h"
55 #include "../stat_menu.h"
56 #include "../tap_dfilter_dlg.h"
57 #include "gtkglobals.h"
60 /* used to keep track of the statistics for an entire program interface */
61 typedef struct _fcstat_t {
63 srt_stat_table fc_srt_table;
67 fcstat_set_title(fcstat_t *fc)
71 title = g_strdup_printf("Fibre Channel Service Response Time statistics: %s",
72 cf_get_display_name(&cfile));
73 gtk_window_set_title(GTK_WINDOW(fc->win), title);
78 fcstat_reset(void *pfc)
80 fcstat_t *fc=(fcstat_t *)pfc;
82 reset_srt_table_data(&fc->fc_srt_table);
87 fcstat_packet(void *pfc, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi)
90 fcstat_t *fs=(fcstat_t *)pfc;
92 /* we are only interested in reply packets */
93 if(!(fc->fctl&FC_FCTL_EXCHANGE_RESPONDER)){
96 /* if we havnt seen the request, just ignore it */
97 if( (!fc->itlq) || (fc->itlq->first_exchange_frame==0) ){
101 add_srt_table_data(&fs->fc_srt_table, fc->type, &fc->itlq->fc_time, pinfo);
109 fcstat_draw(void *pfc)
111 fcstat_t *fc=(fcstat_t *)pfc;
113 draw_srt_table_data(&fc->fc_srt_table);
117 void protect_thread_critical_region(void);
118 void unprotect_thread_critical_region(void);
120 win_destroy_cb(GtkWindow *win _U_, gpointer data)
122 fcstat_t *fc=(fcstat_t *)data;
124 protect_thread_critical_region();
125 remove_tap_listener(fc);
126 unprotect_thread_critical_region();
128 free_srt_table_data(&fc->fc_srt_table);
134 gtk_fcstat_init(const char *optarg, void *userdata _U_)
137 const char *filter=NULL;
140 GString *error_string;
146 if(!strncmp(optarg,"fc,srt,",7)){
152 fc=g_malloc(sizeof(fcstat_t));
154 fc->win=window_new(GTK_WINDOW_TOPLEVEL, "fc-stat");
155 gtk_window_set_default_size(GTK_WINDOW(fc->win), 550, 400);
156 fcstat_set_title(fc);
158 vbox=gtk_vbox_new(FALSE, 3);
159 gtk_container_add(GTK_CONTAINER(fc->win), vbox);
160 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
162 label=gtk_label_new("Fibre Channel Service Response Time statistics");
163 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
165 filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
166 label=gtk_label_new(filter_string);
167 g_free(filter_string);
168 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
169 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
171 label=gtk_label_new("Fibre Channel Types");
172 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
174 /* We must display TOP LEVEL Widget before calling init_srt_table() */
175 gtk_widget_show_all(fc->win);
177 init_srt_table(&fc->fc_srt_table, 256, vbox, NULL);
179 init_srt_table_row(&fc->fc_srt_table, i, val_to_str(i, fc_fc4_val, "Unknown(0x%02x)"));
183 error_string=register_tap_listener("fc", fc, filter, fcstat_reset, fcstat_packet, fcstat_draw);
185 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
186 g_string_free(error_string, TRUE);
192 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
193 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
195 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
196 window_set_cancel_button(fc->win, close_bt, window_cancel_button_cb);
198 SIGNAL_CONNECT(fc->win, "delete_event", window_delete_event_cb, NULL);
199 SIGNAL_CONNECT(fc->win, "destroy", win_destroy_cb, fc);
201 gtk_widget_show_all(fc->win);
202 window_present(fc->win);
204 cf_retap_packets(&cfile, FALSE);
207 static tap_dfilter_dlg fc_stat_dlg = {
208 "Fibre Channel Service Response Time statistics",
215 register_tap_listener_gtkfcstat(void)
217 register_dfilter_stat(&fc_stat_dlg, "Fibre Channel",
218 REGISTER_STAT_GROUP_RESPONSE_TIME);