2 * gtp_stat 2008 Kari Tiirikainen
3 * Largely based on ldap_stat by Ronnie Sahlberg, all mistakes added by KTi
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include <epan/packet_info.h>
33 #include <epan/epan.h>
34 #include <epan/value_string.h>
36 #include <epan/dissectors/packet-gtp.h>
38 #include "ui/simple_dialog.h"
40 #include "../stat_menu.h"
42 #include "ui/gtk/gui_utils.h"
43 #include "ui/gtk/dlg_utils.h"
44 #include "ui/gtk/service_response_time_table.h"
45 #include "ui/gtk/tap_param_dlg.h"
46 #include "ui/gtk/gtkglobals.h"
47 #include "ui/gtk/main.h"
49 #include "ui/gtk/old-gtk-compat.h"
51 /* used to keep track of the statistics for an entire program interface */
52 typedef struct _gtpstat_t
{
54 srt_stat_table gtp_srt_table
;
58 gtpstat_set_title(gtpstat_t
*gtp
)
60 set_window_title(gtp
->win
, "GTP Control Plane Response Time statistics");
64 gtpstat_reset(void *pgtp
)
66 gtpstat_t
*gtp
=(gtpstat_t
*)pgtp
;
68 reset_srt_table_data(>p
->gtp_srt_table
);
69 gtpstat_set_title(gtp
);
73 gtpstat_packet(void *pgtp
, packet_info
*pinfo
, epan_dissect_t
*edt _U_
, const void *psi
)
75 const gtp_msg_hash_t
*gtp
=(gtp_msg_hash_t
*)psi
;
76 gtpstat_t
*fs
=(gtpstat_t
*)pgtp
;
79 /* we are only interested in reply packets */
83 /* if we have not seen the request, just ignore it */
88 /* Only use the commands we know how to handle, this is not a comprehensive list */
89 /* Redoing the message indexing is bit reduntant, */
90 /* but using message type as such would yield a long gtp_srt_table. */
91 /* Only a fraction of the messages are matchable req/resp pairs, */
92 /* it just doesn't feel feasible. */
95 case GTP_MSG_ECHO_REQ
: idx
=0;
97 case GTP_MSG_CREATE_PDP_REQ
: idx
=1;
99 case GTP_MSG_UPDATE_PDP_REQ
: idx
=2;
101 case GTP_MSG_DELETE_PDP_REQ
: idx
=3;
107 add_srt_table_data(&fs
->gtp_srt_table
, idx
, >p
->req_time
, pinfo
);
115 gtpstat_draw(void *pgtp
)
117 gtpstat_t
*gtp
=(gtpstat_t
*)pgtp
;
119 draw_srt_table_data(>p
->gtp_srt_table
);
124 win_destroy_cb(GtkWindow
*win _U_
, gpointer data
)
126 gtpstat_t
*gtp
=(gtpstat_t
*)data
;
128 remove_tap_listener(gtp
);
130 free_srt_table_data(>p
->gtp_srt_table
);
136 gtk_gtpstat_init(const char *opt_arg
, void *userdata _U_
)
139 const char *filter
=NULL
;
142 GString
*error_string
;
147 if(!strncmp(opt_arg
,"gtp,",4)){
150 filter
="gtp"; /*NULL doesn't work here like in LDAP. Too little time/lazy to find out why ?*/
153 gtp
=(gtpstat_t
*)g_malloc(sizeof(gtpstat_t
));
155 gtp
->win
= dlg_window_new("gtp-stat"); /* transient_for top_level */
156 gtk_window_set_destroy_with_parent (GTK_WINDOW(gtp
->win
), TRUE
);
158 gtk_window_set_default_size(GTK_WINDOW(gtp
->win
), 550, 400);
159 gtpstat_set_title(gtp
);
161 vbox
=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL
, 3, FALSE
);
162 gtk_container_add(GTK_CONTAINER(gtp
->win
), vbox
);
163 gtk_container_set_border_width(GTK_CONTAINER(vbox
), 12);
165 label
=gtk_label_new("GTP Service Response Time statistics");
166 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 0);
168 filter_string
= g_strdup_printf("Filter: %s", filter
? filter
: "");
169 label
=gtk_label_new(filter_string
);
170 g_free(filter_string
);
171 gtk_label_set_line_wrap(GTK_LABEL(label
), TRUE
);
172 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 0);
174 label
=gtk_label_new("GTP Requests");
175 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 0);
177 /* We must display TOP LEVEL Widget before calling init_srt_table() */
178 gtk_widget_show_all(gtp
->win
);
180 init_srt_table(>p
->gtp_srt_table
, 4, vbox
, NULL
);
181 init_srt_table_row(>p
->gtp_srt_table
, 0, "Echo");
182 init_srt_table_row(>p
->gtp_srt_table
, 1, "Create PDP context");
183 init_srt_table_row(>p
->gtp_srt_table
, 2, "Update PDP context");
184 init_srt_table_row(>p
->gtp_srt_table
, 3, "Delete PDP context");
186 error_string
=register_tap_listener("gtp", gtp
, filter
, 0, gtpstat_reset
, gtpstat_packet
, gtpstat_draw
);
188 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
, "%s", error_string
->str
);
189 g_string_free(error_string
, TRUE
);
195 bbox
= dlg_button_row_new(GTK_STOCK_CLOSE
, NULL
);
196 gtk_box_pack_end(GTK_BOX(vbox
), bbox
, FALSE
, FALSE
, 0);
198 close_bt
= (GtkWidget
*)g_object_get_data(G_OBJECT(bbox
), GTK_STOCK_CLOSE
);
199 window_set_cancel_button(gtp
->win
, close_bt
, window_cancel_button_cb
);
201 g_signal_connect(gtp
->win
, "delete_event", G_CALLBACK(window_delete_event_cb
), NULL
);
202 g_signal_connect(gtp
->win
, "destroy", G_CALLBACK(win_destroy_cb
), gtp
);
204 gtk_widget_show_all(gtp
->win
);
205 window_present(gtp
->win
);
207 cf_retap_packets(&cfile
);
208 gdk_window_raise(gtk_widget_get_window(gtp
->win
));
211 static tap_param gtp_stat_params
[] = {
212 { PARAM_FILTER
, "Filter", NULL
}
215 static tap_param_dlg gtp_stat_dlg
= {
216 "GTP Control Plane Response Time Statistics",
220 G_N_ELEMENTS(gtp_stat_params
),
225 register_tap_listener_gtkgtpstat(void)
227 register_param_stat(>p_stat_dlg
, "GTP",
228 REGISTER_STAT_GROUP_RESPONSE_TIME
);