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>
45 #include <epan/prefs-int.h>
47 #include "../register.h"
48 #include "../timestats.h"
49 #include "../simple_dialog.h"
51 #include "../globals.h"
52 #include "../stat_menu.h"
54 #include "gtk/gui_stat_util.h"
55 #include "gtk/dlg_utils.h"
56 #include "gtk/tap_dfilter_dlg.h"
57 #include "gtk/gui_utils.h"
60 #include "tap-megaco-common.h"
65 megacostat_reset(void *pms)
67 megacostat_t *ms=(megacostat_t *)pms;
70 for(i=0;i<NUM_TIMESTATS;i++) {
74 ms->rtd[i].min.secs=0;
75 ms->rtd[i].min.nsecs=0;
76 ms->rtd[i].max.secs=0;
77 ms->rtd[i].max.nsecs=0;
78 ms->rtd[i].tot.secs=0;
79 ms->rtd[i].tot.nsecs=0;
89 megacostat_draw(void *pms)
91 megacostat_t *ms=(megacostat_t *)pms;
97 /* clear list before printing */
98 store = GTK_LIST_STORE(gtk_tree_view_get_model(ms->table));
99 gtk_list_store_clear(store);
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], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min)));
108 g_snprintf(str[1], sizeof(char[256]), "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max)));
109 g_snprintf(str[2], sizeof(char[256]), "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num));
110 gtk_list_store_append(store, &iter);
111 gtk_list_store_set(store, &iter,
112 0, val_to_str(i,megaco_message_type,"Other"),
117 5, ms->rtd[i].min_num,
118 6, ms->rtd[i].max_num,
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 stat_column titles[]={
140 {G_TYPE_STRING, LEFT, "Type" },
141 {G_TYPE_UINT, RIGHT, "Messages" },
142 {G_TYPE_STRING, RIGHT, "Min SRT" },
143 {G_TYPE_STRING, RIGHT, "Max SRT" },
144 {G_TYPE_STRING, RIGHT, "Avg SRT" },
145 {G_TYPE_UINT, RIGHT, "Min in Frame" },
146 {G_TYPE_UINT, RIGHT, "Max in Frame" }
150 gtk_megacostat_init(const char *optarg, void *userdata _U_)
153 GString *error_string;
156 pref_t *megaco_ctx_track,*h248_ctx_track;
158 megaco_ctx_track = prefs_find_preference(prefs_find_module("megaco"),"ctx_info");
159 h248_ctx_track = prefs_find_preference(prefs_find_module("h248"),"ctx_info");
161 if (!*megaco_ctx_track->varp.boolp || !*h248_ctx_track->varp.boolp) {
162 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", "Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences has to be set to true to enable measurement of service reponse times.");
166 ms=g_malloc(sizeof(megacostat_t));
168 if(strncmp(optarg,"megaco,srt,",11) == 0){
169 ms->filter=g_strdup(optarg+11);
174 megacostat_reset(ms);
176 ms->win = dlg_window_new("MEGACO SRT"); /* transient_for top_level */
177 gtk_window_set_destroy_with_parent (GTK_WINDOW(ms->win), TRUE);
179 gtk_window_set_default_size(GTK_WINDOW(ms->win), 550, 150);
181 ms->vbox=gtk_vbox_new(FALSE, 3);
183 init_main_stat_window(ms->win, ms->vbox, "MEGACO Service Response Time (SRT) Statistics", ms->filter);
185 /* init a scrolled window*/
186 ms->scrolled_window = scrolled_window_new(NULL, NULL);
188 ms->table = create_stat_table(ms->scrolled_window, ms->vbox, 7, titles);
190 error_string=register_tap_listener("megaco", ms, ms->filter, 0, megacostat_reset, megacostat_packet, megacostat_draw);
192 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
193 g_string_free(error_string, TRUE);
200 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
201 gtk_box_pack_start(GTK_BOX(ms->vbox), bbox, FALSE, FALSE, 0);
203 bt_close = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
204 window_set_cancel_button(ms->win, bt_close, window_cancel_button_cb);
206 g_signal_connect(ms->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
207 g_signal_connect(ms->win, "destroy", G_CALLBACK(win_destroy_cb), ms);
209 gtk_widget_show_all(ms->win);
210 window_present(ms->win);
212 cf_retap_packets(&cfile);
213 gdk_window_raise(ms->win->window);
216 static tap_dfilter_dlg megaco_srt_dlg = {
217 "MEGACO Service Response Time (SRT) Statistics",
224 register_tap_listener_gtkmegacostat(void)
226 /* We don't register this tap, if we don't have the megaco plugin loaded.*/
227 if (find_tap_id("megaco")) {
228 register_dfilter_stat(&megaco_srt_dlg, "MEGACO",
229 REGISTER_STAT_GROUP_RESPONSE_TIME);