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 "../timestats.h"
45 #include "../simple_dialog.h"
47 #include "../stat_menu.h"
49 #include "ui/gtk/gui_utils.h"
50 #include "ui/gtk/dlg_utils.h"
51 #include "ui/gtk/service_response_time_table.h"
52 #include "ui/gtk/tap_param_dlg.h"
53 #include "ui/gtk/main.h"
55 #include "ui/gtk/old-gtk-compat.h"
57 /* used to keep track of the statistics for an entire program interface */
58 typedef struct _afpstat_t {
60 srt_stat_table afp_srt_table;
64 afpstat_set_title(afpstat_t *ss)
68 title = g_strdup_printf("AFP Service Response Time statistics: %s",
69 cf_get_display_name(&cfile));
70 gtk_window_set_title(GTK_WINDOW(ss->win), title);
75 afpstat_reset(void *pss)
77 afpstat_t *ss=(afpstat_t *)pss;
79 reset_srt_table_data(&ss->afp_srt_table);
80 afpstat_set_title(ss);
84 afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
86 afpstat_t *ss=(afpstat_t *)pss;
87 const afp_request_val *request_val=prv;
89 /* if we havnt seen the request, just ignore it */
94 add_srt_table_data(&ss->afp_srt_table, request_val->command, &request_val->req_time, pinfo);
102 afpstat_draw(void *pss)
104 afpstat_t *ss=(afpstat_t *)pss;
106 draw_srt_table_data(&ss->afp_srt_table);
111 win_destroy_cb(GtkWindow *win _U_, gpointer data)
113 afpstat_t *ss=(afpstat_t *)data;
115 protect_thread_critical_region();
116 remove_tap_listener(ss);
117 unprotect_thread_critical_region();
119 free_srt_table_data(&ss->afp_srt_table);
125 gtk_afpstat_init(const char *optarg, void *userdata _U_)
128 const char *filter=NULL;
131 GString *error_string;
137 if(!strncmp(optarg,"afp,srt,",8)){
143 ss=g_malloc(sizeof(afpstat_t));
145 ss->win=dlg_window_new("afp-stat"); /* transient_for top_level */
146 gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
147 gtk_window_set_default_size(GTK_WINDOW(ss->win), 550, 600);
148 afpstat_set_title(ss);
150 vbox=gtk_vbox_new(FALSE, 3);
151 gtk_container_add(GTK_CONTAINER(ss->win), vbox);
152 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
154 label=gtk_label_new("AFP Service Response Time statistics");
155 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
157 filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
158 label=gtk_label_new(filter_string);
159 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
160 g_free(filter_string);
161 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
163 label=gtk_label_new("AFP Commands");
164 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
166 /* We must display TOP LEVEL Widget before calling init_srt_table() */
167 gtk_widget_show_all(ss->win);
169 init_srt_table(&ss->afp_srt_table, 256, vbox, "afp.command");
171 init_srt_table_row(&ss->afp_srt_table, i, val_to_str_ext(i, &CommandCode_vals_ext, "Unknown(%u)"));
175 error_string=register_tap_listener("afp", ss, filter, 0, afpstat_reset, afpstat_packet, afpstat_draw);
177 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
178 g_string_free(error_string, TRUE);
184 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
185 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
187 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
188 window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
190 g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
191 g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);
193 gtk_widget_show_all(ss->win);
194 window_present(ss->win);
196 cf_retap_packets(&cfile);
197 gdk_window_raise(gtk_widget_get_window(ss->win));
200 static tap_param afp_stat_params[] = {
201 { PARAM_FILTER, "Filter", NULL }
204 static tap_param_dlg afp_stat_dlg = {
205 "AFP SRT Statistics",
209 G_N_ELEMENTS(afp_stat_params),
214 register_tap_listener_gtkafpstat(void)
216 register_dfilter_stat(&afp_stat_dlg, "AFP",
217 REGISTER_STAT_GROUP_RESPONSE_TIME);
220 void afp_srt_stat_cb(GtkAction *action, gpointer user_data _U_)
222 tap_param_dlg_cb(action, &afp_stat_dlg);