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>
41 #include <epan/conversation.h>
42 #include <epan/dissectors/packet-scsi.h>
43 #include <epan/dissectors/packet-fc.h>
45 #include "../register.h"
46 #include "../timestats.h"
47 #include "../simple_dialog.h"
49 #include "../globals.h"
50 #include "../stat_menu.h"
52 #include "gtk/gui_utils.h"
53 #include "gtk/dlg_utils.h"
54 #include "gtk/filter_dlg.h"
55 #include "gtk/service_response_time_table.h"
56 #include "gtk/tap_dfilter_dlg.h"
57 #include "gtk/gtkglobals.h"
61 /* used to keep track of the statistics for an entire program interface */
62 typedef struct _fcstat_t {
64 srt_stat_table fc_srt_table;
68 fcstat_set_title(fcstat_t *fc)
72 title = g_strdup_printf("Fibre Channel Service Response Time statistics: %s",
73 cf_get_display_name(&cfile));
74 gtk_window_set_title(GTK_WINDOW(fc->win), title);
79 fcstat_reset(void *pfc)
81 fcstat_t *fc=(fcstat_t *)pfc;
83 reset_srt_table_data(&fc->fc_srt_table);
88 fcstat_packet(void *pfc, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi)
91 fcstat_t *fs=(fcstat_t *)pfc;
93 /* we are only interested in reply packets */
94 if(!(fc->fctl&FC_FCTL_EXCHANGE_RESPONDER)){
97 /* if we havnt seen the request, just ignore it */
98 if( (!fc->itlq) || (fc->itlq->first_exchange_frame==0) ){
102 add_srt_table_data(&fs->fc_srt_table, fc->type, &fc->itlq->fc_time, pinfo);
110 fcstat_draw(void *pfc)
112 fcstat_t *fc=(fcstat_t *)pfc;
114 draw_srt_table_data(&fc->fc_srt_table);
119 win_destroy_cb(GtkWindow *win _U_, gpointer data)
121 fcstat_t *fc=(fcstat_t *)data;
123 protect_thread_critical_region();
124 remove_tap_listener(fc);
125 unprotect_thread_critical_region();
127 free_srt_table_data(&fc->fc_srt_table);
133 gtk_fcstat_init(const char *optarg, void *userdata _U_)
136 const char *filter=NULL;
139 GString *error_string;
145 if(!strncmp(optarg,"fc,srt,",7)){
151 fc=g_malloc(sizeof(fcstat_t));
153 fc->win=window_new(GTK_WINDOW_TOPLEVEL, "fc-stat");
154 gtk_window_set_default_size(GTK_WINDOW(fc->win), 550, 400);
155 fcstat_set_title(fc);
157 vbox=gtk_vbox_new(FALSE, 3);
158 gtk_container_add(GTK_CONTAINER(fc->win), vbox);
159 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
161 label=gtk_label_new("Fibre Channel Service Response Time statistics");
162 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
164 filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
165 label=gtk_label_new(filter_string);
166 g_free(filter_string);
167 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
168 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
170 label=gtk_label_new("Fibre Channel Types");
171 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
173 /* We must display TOP LEVEL Widget before calling init_srt_table() */
174 gtk_widget_show_all(fc->win);
176 init_srt_table(&fc->fc_srt_table, 256, vbox, NULL);
178 init_srt_table_row(&fc->fc_srt_table, i, val_to_str(i, fc_fc4_val, "Unknown(0x%02x)"));
182 error_string=register_tap_listener("fc", fc, filter, 0, fcstat_reset, fcstat_packet, fcstat_draw);
184 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
185 g_string_free(error_string, TRUE);
191 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
192 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
194 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
195 window_set_cancel_button(fc->win, close_bt, window_cancel_button_cb);
197 g_signal_connect(fc->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
198 g_signal_connect(fc->win, "destroy", G_CALLBACK(win_destroy_cb), fc);
200 gtk_widget_show_all(fc->win);
201 window_present(fc->win);
203 cf_retap_packets(&cfile);
204 gdk_window_raise(fc->win->window);
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);