2 * megaco-statistics for Wireshark
3 * Copyright 2003 Lars Roland
4 * Copyright 2008, Ericsson AB
5 * By Balint Reczey <balint.reczey@ericsson.com>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
40 #include <epan/packet_info.h>
41 #include <epan/epan.h>
42 #include <epan/value_string.h>
46 #include "../register.h"
47 #include "../timestats.h"
48 #include "../simple_dialog.h"
50 #include "../globals.h"
51 #include "../stat_menu.h"
53 #include "gtk/gui_stat_util.h"
54 #include "gtk/dlg_utils.h"
55 #include "gtk/tap_dfilter_dlg.h"
56 #include "gtk/gui_utils.h"
59 #include "tap-megaco-common.h"
64 megacostat_reset(void *pms)
66 megacostat_t *ms=(megacostat_t *)pms;
69 for(i=0;i<NUM_TIMESTATS;i++) {
73 ms->rtd[i].min.secs=0;
74 ms->rtd[i].min.nsecs=0;
75 ms->rtd[i].max.secs=0;
76 ms->rtd[i].max.nsecs=0;
77 ms->rtd[i].tot.secs=0;
78 ms->rtd[i].tot.nsecs=0;
88 megacostat_draw(void *pms)
90 megacostat_t *ms=(megacostat_t *)pms;
95 str[i]=g_malloc(sizeof(char[256]));
98 /* clear list before printing */
99 gtk_clist_clear(ms->table);
101 for(i=0;i<NUM_TIMESTATS;i++) {
102 /* nothing seen, nothing to do */
103 if(ms->rtd[i].num==0){
107 g_snprintf(str[0], 256, "%s", val_to_str(i,megaco_message_type,"Other"));
108 g_snprintf(str[1], 256, "%d", ms->rtd[i].num);
109 g_snprintf(str[2], 256, "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min)));
110 g_snprintf(str[3], 256, "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max)));
111 g_snprintf(str[4], 256, "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num));
112 g_snprintf(str[5], 256, "%6u", ms->rtd[i].min_num);
113 g_snprintf(str[6], 256, "%6u", ms->rtd[i].max_num);
114 gtk_clist_append(ms->table, str);
117 gtk_widget_show(GTK_WIDGET(ms->table));
124 win_destroy_cb(GtkWindow *win _U_, gpointer data)
126 megacostat_t *ms=(megacostat_t *)data;
128 protect_thread_critical_region();
129 remove_tap_listener(ms);
130 unprotect_thread_critical_region();
139 static const gchar *titles[]={
149 gtk_megacostat_init(const char *optarg, void *userdata _U_)
152 const char *filter=NULL;
153 GString *error_string;
157 if(strncmp(optarg,"megaco,srt,",11) == 0){
163 ms=g_malloc(sizeof(megacostat_t));
164 ms->filter=g_strdup(filter);
166 megacostat_reset(ms);
168 ms->win=window_new(GTK_WINDOW_TOPLEVEL, "MEGACO SRT");
169 gtk_window_set_default_size(GTK_WINDOW(ms->win), 550, 150);
171 ms->vbox=gtk_vbox_new(FALSE, 3);
173 init_main_stat_window(ms->win, ms->vbox, "MEGACO Service Response Time (SRT) Statistics", filter);
175 /* init a scrolled window*/
176 ms->scrolled_window = scrolled_window_new(NULL, NULL);
178 ms->table = create_stat_table(ms->scrolled_window, ms->vbox, 7, titles);
180 error_string=register_tap_listener("megaco", ms, filter, megacostat_reset, megacostat_packet, megacostat_draw);
182 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
183 g_string_free(error_string, TRUE);
190 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
191 gtk_box_pack_start(GTK_BOX(ms->vbox), bbox, FALSE, FALSE, 0);
193 bt_close = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
194 window_set_cancel_button(ms->win, bt_close, window_cancel_button_cb);
196 g_signal_connect(ms->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
197 g_signal_connect(ms->win, "destroy", G_CALLBACK(win_destroy_cb), ms);
199 gtk_widget_show_all(ms->win);
200 window_present(ms->win);
202 cf_retap_packets(&cfile, FALSE);
203 gdk_window_raise(ms->win->window);
206 static tap_dfilter_dlg megaco_srt_dlg = {
207 "MEGACO Service Response Time (SRT) Statistics",
214 register_tap_listener_gtkmegacostat(void)
216 /* We don't register this tap, if we don't have the megaco plugin loaded.*/
217 if (find_tap_id("megaco")) {
218 register_dfilter_stat(&megaco_srt_dlg, "MEGACO",
219 REGISTER_STAT_GROUP_RESPONSE_TIME);