2 * camel Service Response Time statistics for Wireshark
3 * Copyright 2006 Florent Drouin (based on h225_ras_srt.c from Lars Roland)
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>
37 #include <epan/packet_info.h>
38 #include <epan/epan.h>
39 #include <epan/value_string.h>
41 #include <epan/packet.h>
42 #include <epan/asn1.h>
43 #include <epan/camel-persistentdata.h>
45 #include "../register.h"
46 #include "../timestats.h"
47 #include "../simple_dialog.h"
49 #include "../globals.h"
50 #include "../stat_menu.h"
53 #include "gtk/dlg_utils.h"
54 #include "gtk/gui_utils.h"
55 #include "gtk/gui_stat_util.h"
56 #include "gtk/tap_dfilter_dlg.h"
57 #include "gtk/service_response_time_table.h"
60 /* used to keep track of the statistics for an entire program interface */
63 srt_stat_table camel_srt_table;
66 static void camelsrt_set_title(struct camelsrt_t * p_camelsrt);
67 static void camelsrt_reset(void *phs);
68 static int camelsrt_packet(void *phs,
69 packet_info *pinfo _U_,
70 epan_dissect_t *edt _U_,
73 static void camelsrt_draw(void *phs);
74 static void win_destroy_cb(GtkWindow *win _U_, gpointer data);
75 static void gtk_camelsrt_init(const char *optarg, void *userdata _U_);
76 void register_tap_listener_gtk_camelsrt(void);
81 static void camelsrt_set_title(struct camelsrt_t * p_camelsrt)
84 title = g_strdup_printf("CAMEL Service Response Time statistics: %s",
85 cf_get_display_name(&cfile));
86 gtk_window_set_title(GTK_WINDOW(p_camelsrt->win), title);
90 static void camelsrt_reset(void *phs)
92 struct camelsrt_t *hs=(struct camelsrt_t *)phs;
93 reset_srt_table_data(&hs->camel_srt_table);
94 camelsrt_set_title(hs);
98 * Count the delta time between Request and Response
99 * As we can make several measurement per message, we use a boolean array for the category
100 * Then, if the measurement is provided, check if it is valid, and update the table
102 static int camelsrt_packet(void *phs,
103 packet_info *pinfo _U_,
104 epan_dissect_t *edt _U_,
107 struct camelsrt_t *hs=(struct camelsrt_t *)phs;
108 const struct camelsrt_info_t * pi=phi;
111 for (i=1; i<NB_CAMELSRT_CATEGORY; i++) {
112 if ( pi->bool_msginfo[i] &&
113 pi->msginfo[i].is_delta_time
114 && pi->msginfo[i].request_available
115 && !pi->msginfo[i].is_duplicate ) {
117 add_srt_table_data(&hs->camel_srt_table, i, &pi->msginfo[i].req_time, pinfo);
125 static void camelsrt_draw(void *phs)
127 struct camelsrt_t *hs=(struct camelsrt_t *)phs;
128 draw_srt_table_data(&hs->camel_srt_table);
132 * Routine for Display
134 static void win_destroy_cb(GtkWindow *win _U_, gpointer data)
136 struct camelsrt_t *hs=(struct camelsrt_t *)data;
138 protect_thread_critical_region();
139 remove_tap_listener(hs);
140 unprotect_thread_critical_region();
142 free_srt_table_data(&hs->camel_srt_table);
146 static void gtk_camelsrt_init(const char *optarg, void *userdata _U_)
148 struct camelsrt_t * p_camelsrt;
149 const char *filter=NULL;
151 GtkWidget *cmd_label;
152 GtkWidget *main_label;
153 GtkWidget *filter_label;
155 GString *error_string;
161 if(strncmp(optarg,"camel,srt,",10) == 0){
167 p_camelsrt=g_malloc(sizeof(struct camelsrt_t));
169 p_camelsrt->win=window_new(GTK_WINDOW_TOPLEVEL, "camel-srt");
170 gtk_window_set_default_size(GTK_WINDOW(p_camelsrt->win), 550, 400);
171 camelsrt_set_title(p_camelsrt);
173 vbox=gtk_vbox_new(FALSE, 3);
174 gtk_container_add(GTK_CONTAINER(p_camelsrt->win), vbox);
175 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
177 main_label=gtk_label_new("CAMEL Service Response Time statistics");
178 gtk_box_pack_start(GTK_BOX(vbox), main_label, FALSE, FALSE, 0);
179 gtk_widget_show(main_label);
181 filter_string = g_strdup_printf("Filter: %s",filter ? filter : "");
182 filter_label=gtk_label_new(filter_string);
183 g_free(filter_string);
184 gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
185 gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0);
186 gtk_widget_show(filter_label);
188 cmd_label=gtk_label_new("CAMEL Commands");
189 gtk_box_pack_start(GTK_BOX(vbox), cmd_label, FALSE, FALSE, 0);
190 gtk_widget_show(cmd_label);
192 /* We must display TOP LEVEL Widget before calling init_srt_table() */
193 gtk_widget_show_all(p_camelsrt->win);
195 init_srt_table(&p_camelsrt->camel_srt_table, NB_CAMELSRT_CATEGORY, vbox, NULL);
196 for(i=0 ;i<NB_CAMELSRT_CATEGORY; i++) {
197 init_srt_table_row(&p_camelsrt->camel_srt_table, i,
198 val_to_str(i,camelSRTtype_naming,"Unknown"));
201 error_string=register_tap_listener("CAMEL",
210 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
211 g_string_free(error_string, TRUE);
217 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
218 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
220 close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
221 window_set_cancel_button(p_camelsrt->win, close_bt, window_cancel_button_cb);
223 g_signal_connect(p_camelsrt->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
224 g_signal_connect(p_camelsrt->win, "destroy", G_CALLBACK(win_destroy_cb), p_camelsrt);
226 gtk_widget_show_all(p_camelsrt->win);
227 window_present(p_camelsrt->win);
228 cf_retap_packets(&cfile);
229 gdk_window_raise(p_camelsrt->win->window);
233 static tap_dfilter_dlg camel_srt_dlg = {
234 "CAMEL Service Response Time",
240 void /* Next line mandatory */
241 register_tap_listener_gtk_camelsrt(void)
243 register_dfilter_stat(&camel_srt_dlg, "CAMEL",
244 REGISTER_STAT_GROUP_RESPONSE_TIME);