3 * smb_stat 2003 Ronnie Sahlberg
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
38 #include <epan/packet_info.h>
39 #include <epan/epan.h>
40 #include <epan/value_string.h>
42 #include <epan/dissectors/packet-afp.h>
44 #include "../register.h"
45 #include "../timestats.h"
46 #include "../simple_dialog.h"
48 #include "../globals.h"
49 #include "../stat_menu.h"
51 #include "gtk/gui_utils.h"
52 #include "gtk/dlg_utils.h"
53 #include "gtk/filter_dlg.h"
54 #include "gtk/service_response_time_table.h"
55 #include "gtk/tap_dfilter_dlg.h"
59 /* used to keep track of the statistics for an entire program interface */
60 typedef struct _afpstat_t {
62 srt_stat_table afp_srt_table;
66 afpstat_set_title(afpstat_t *ss)
70 title = g_strdup_printf("AFP Service Response Time statistics: %s",
71 cf_get_display_name(&cfile));
72 gtk_window_set_title(GTK_WINDOW(ss->win), title);
77 afpstat_reset(void *pss)
79 afpstat_t *ss=(afpstat_t *)pss;
81 reset_srt_table_data(&ss->afp_srt_table);
82 afpstat_set_title(ss);
86 afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
88 afpstat_t *ss=(afpstat_t *)pss;
89 const afp_request_val *request_val=prv;
91 /* if we havnt seen the request, just ignore it */
96 add_srt_table_data(&ss->afp_srt_table, request_val->command, &request_val->req_time, pinfo);
104 afpstat_draw(void *pss)
106 afpstat_t *ss=(afpstat_t *)pss;
108 draw_srt_table_data(&ss->afp_srt_table);
113 win_destroy_cb(GtkWindow *win _U_, gpointer data)
115 afpstat_t *ss=(afpstat_t *)data;
117 protect_thread_critical_region();
118 remove_tap_listener(ss);
119 unprotect_thread_critical_region();
121 free_srt_table_data(&ss->afp_srt_table);
127 gtk_afpstat_init(const char *optarg, void *userdata _U_)
130 const char *filter=NULL;
133 GString *error_string;
139 if(!strncmp(optarg,"afp,srt,",8)){
145 ss=g_malloc(sizeof(afpstat_t));
147 ss->win=window_new(GTK_WINDOW_TOPLEVEL, "afp-stat");
148 gtk_window_set_default_size(GTK_WINDOW(ss->win), 550, 600);
149 afpstat_set_title(ss);
151 vbox=gtk_vbox_new(FALSE, 3);
152 gtk_container_add(GTK_CONTAINER(ss->win), vbox);
153 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
155 label=gtk_label_new("AFP Service Response Time statistics");
156 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
158 filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
159 label=gtk_label_new(filter_string);
160 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
161 g_free(filter_string);
162 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
164 label=gtk_label_new("AFP Commands");
165 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
167 /* We must display TOP LEVEL Widget before calling init_srt_table() */
168 gtk_widget_show_all(ss->win);
170 init_srt_table(&ss->afp_srt_table, 256, vbox, "afp.command");
172 init_srt_table_row(&ss->afp_srt_table, i, val_to_str(i, CommandCode_vals, "Unknown(%u)"));
176 error_string=register_tap_listener("afp", ss, filter, afpstat_reset, afpstat_packet, afpstat_draw);
178 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
179 g_string_free(error_string, TRUE);
185 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
186 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
188 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
189 window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
191 g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
192 g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);
194 gtk_widget_show_all(ss->win);
195 window_present(ss->win);
197 cf_retap_packets(&cfile, FALSE);
198 gdk_window_raise(ss->win->window);
201 static tap_dfilter_dlg afp_stat_dlg = {
202 "AFP SRT Statistics",
209 register_tap_listener_gtkafpstat(void)
211 register_dfilter_stat(&afp_stat_dlg, "AFP",
212 REGISTER_STAT_GROUP_RESPONSE_TIME);