3 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
4 * In association with Telos Technology Inc.
6 * MUCH code modified from service_response_time_table.c.
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * This TAP provides statistics for the GSM A-Interface:
40 #include "epan/packet_info.h"
41 #include "epan/epan.h"
42 #include "epan/value_string.h"
43 #include <epan/stat_cmd_args.h>
45 #include <epan/dissectors/packet-bssap.h>
46 #include <epan/dissectors/packet-gsm_a_common.h>
48 #include "../stat_menu.h"
49 #include "../simple_dialog.h"
50 #include "../register.h"
51 #include "../globals.h"
53 #include "gtk/gui_stat_menu.h"
54 #include "gtk/dlg_utils.h"
55 #include "gtk/filter_dlg.h"
56 #include "gtk/gui_utils.h"
63 N_COLUMN /* The number of columns */
66 typedef struct _gsm_a_stat_dlg_t {
68 GtkWidget *scrolled_win;
72 typedef struct _gsm_a_stat_t {
73 int bssmap_message_type[0xff];
74 int dtap_mm_message_type[0xff];
75 int dtap_rr_message_type[0xff];
76 int dtap_cc_message_type[0xff];
77 int dtap_gmm_message_type[0xff];
78 int dtap_sms_message_type[0xff];
79 int dtap_sm_message_type[0xff];
80 int dtap_ss_message_type[0xff];
81 int dtap_tp_message_type[0xff];
82 int sacch_rr_message_type[0xff];
86 static gsm_a_stat_dlg_t dlg_bssmap;
87 static gsm_a_stat_dlg_t dlg_dtap_mm;
88 static gsm_a_stat_dlg_t dlg_dtap_rr;
89 static gsm_a_stat_dlg_t dlg_dtap_cc;
90 static gsm_a_stat_dlg_t dlg_dtap_gmm;
91 static gsm_a_stat_dlg_t dlg_dtap_sms;
92 static gsm_a_stat_dlg_t dlg_dtap_sm;
93 static gsm_a_stat_dlg_t dlg_dtap_ss;
94 static gsm_a_stat_dlg_t dlg_dtap_tp;
95 static gsm_a_stat_dlg_t dlg_sacch_rr;
96 static gsm_a_stat_t gsm_a_stat;
100 GtkWidget* create_list(void)
103 GtkListStore *list_store;
105 GtkTreeViewColumn *column;
106 GtkCellRenderer *renderer;
107 GtkTreeSortable *sortable;
108 GtkTreeView *list_view;
109 GtkTreeSelection *selection;
111 /* Create the store */
112 list_store = gtk_list_store_new(N_COLUMN, /* Total number of columns XXX*/
113 G_TYPE_UINT, /* IEI */
114 G_TYPE_STRING, /* Message Name */
115 G_TYPE_UINT); /* Count */
118 list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
120 list_view = GTK_TREE_VIEW(list);
121 sortable = GTK_TREE_SORTABLE(list_store);
123 #if GTK_CHECK_VERSION(2,6,0)
124 /* Speed up the list display */
125 gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
128 /* Setup the sortable columns */
129 gtk_tree_sortable_set_sort_column_id(sortable, IEI_COLUMN, GTK_SORT_ASCENDING);
130 gtk_tree_view_set_headers_clickable(list_view, FALSE);
132 /* The view now holds a reference. We can get rid of our own reference */
133 g_object_unref (G_OBJECT (list_store));
136 * Create the first column packet, associating the "text" attribute of the
137 * cell_renderer to the first column of the model
139 renderer = gtk_cell_renderer_text_new ();
140 column = gtk_tree_view_column_new_with_attributes ("IEI", renderer,
144 /* gtk_tree_view_column_set_cell_data_func(column, renderer, present_as_hex_func,
145 GINT_TO_POINTER(IEI_COLUMN), NULL);
148 gtk_tree_view_column_set_sort_column_id(column, IEI_COLUMN);
149 gtk_tree_view_column_set_resizable(column, TRUE);
150 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
151 gtk_tree_view_column_set_min_width(column, 50);
153 /* Add the column to the view. */
154 gtk_tree_view_append_column (list_view, column);
156 /* Second column.. Message Name. */
157 renderer = gtk_cell_renderer_text_new ();
158 column = gtk_tree_view_column_new_with_attributes ("Message Name", renderer,
159 "text", MSG_NAME_COLUMN,
161 gtk_tree_view_column_set_sort_column_id(column, MSG_NAME_COLUMN);
162 gtk_tree_view_column_set_resizable(column, TRUE);
163 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
164 gtk_tree_view_column_set_min_width(column, 280);
165 gtk_tree_view_append_column (list_view, column);
167 /* Third column.. Count. */
168 renderer = gtk_cell_renderer_text_new ();
169 column = gtk_tree_view_column_new_with_attributes ("Count", renderer,
170 "text", COUNT_COLUMN,
174 gtk_tree_view_column_set_sort_column_id(column, COUNT_COLUMN);
175 gtk_tree_view_column_set_resizable(column, TRUE);
176 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
177 gtk_tree_view_column_set_min_width(column, 50);
178 gtk_tree_view_append_column (list_view, column);
180 /* Now enable the sorting of each column */
181 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view), TRUE);
182 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(list_view), TRUE);
184 /* Setup the selection handler */
185 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
186 gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
195 gsm_a_stat_t *stat_p = tapdata;
197 memset(stat_p, 0, sizeof(gsm_a_stat_t));
204 packet_info *pinfo _U_,
205 epan_dissect_t *edt _U_,
208 gsm_a_stat_t *stat_p = tapdata;
209 const gsm_a_tap_rec_t *data_p = data;
211 switch (data_p->pdu_type)
213 case BSSAP_PDU_TYPE_BSSMAP:
214 stat_p->bssmap_message_type[data_p->message_type]++;
217 case BSSAP_PDU_TYPE_DTAP:
218 switch (data_p->protocol_disc)
221 stat_p->dtap_cc_message_type[data_p->message_type]++;
224 stat_p->dtap_mm_message_type[data_p->message_type]++;
227 stat_p->dtap_rr_message_type[data_p->message_type]++;
230 stat_p->dtap_gmm_message_type[data_p->message_type]++;
233 stat_p->dtap_sms_message_type[data_p->message_type]++;
236 stat_p->dtap_sm_message_type[data_p->message_type]++;
239 stat_p->dtap_ss_message_type[data_p->message_type]++;
242 stat_p->dtap_tp_message_type[data_p->message_type]++;
252 case GSM_A_PDU_TYPE_SACCH:
253 switch (data_p->protocol_disc)
256 stat_p->sacch_rr_message_type[data_p->message_type]++;
259 /* unknown Short PD */
266 * unknown PDU type !!!
277 gsm_a_stat_dlg_t *dlg_p,
279 const value_string *msg_strings)
281 GtkListStore *list_store;
286 if (dlg_p->win != NULL){
288 list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (dlg_p->table))); /* Get store */
290 while (msg_strings[i].strptr){
291 /* Creates a new row at position. iter will be changed to point to this new row.
292 * If position is larger than the number of rows on the list, then the new row will be appended to the list.
293 * The row will be filled with the values given to this function.
295 * should generally be preferred when inserting rows in a sorted list store.
297 #if GTK_CHECK_VERSION(2,6,0)
298 gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
300 gtk_list_store_append (list_store, &iter);
301 gtk_list_store_set (list_store, &iter,
303 IEI_COLUMN, msg_strings[i].value,
304 MSG_NAME_COLUMN, (char *)msg_strings[i].strptr,
305 COUNT_COLUMN, message_count[msg_strings[i].value],
316 gsm_a_stat_t *stat_p = tapdata;
318 if (!tapdata) return;
320 if (dlg_bssmap.win != NULL)
322 gsm_a_stat_draw_aux(&dlg_bssmap,
323 stat_p->bssmap_message_type,
324 gsm_a_bssmap_msg_strings);
327 if (dlg_dtap_mm.win != NULL)
329 gsm_a_stat_draw_aux(&dlg_dtap_mm,
330 stat_p->dtap_mm_message_type,
331 gsm_a_dtap_msg_mm_strings);
334 if (dlg_dtap_rr.win != NULL)
336 gsm_a_stat_draw_aux(&dlg_dtap_rr,
337 stat_p->dtap_rr_message_type,
338 gsm_a_dtap_msg_rr_strings);
341 if (dlg_dtap_cc.win != NULL)
343 gsm_a_stat_draw_aux(&dlg_dtap_cc,
344 stat_p->dtap_cc_message_type,
345 gsm_a_dtap_msg_cc_strings);
348 if (dlg_dtap_gmm.win != NULL)
350 gsm_a_stat_draw_aux(&dlg_dtap_gmm,
351 stat_p->dtap_gmm_message_type,
352 gsm_a_dtap_msg_gmm_strings);
355 if (dlg_dtap_sms.win != NULL)
357 gsm_a_stat_draw_aux(&dlg_dtap_sms,
358 stat_p->dtap_sms_message_type,
359 gsm_a_dtap_msg_sms_strings);
362 if (dlg_dtap_sm.win != NULL)
364 gsm_a_stat_draw_aux(&dlg_dtap_sm,
365 stat_p->dtap_sm_message_type,
366 gsm_a_dtap_msg_sm_strings);
369 if (dlg_dtap_ss.win != NULL)
371 gsm_a_stat_draw_aux(&dlg_dtap_ss,
372 stat_p->dtap_ss_message_type,
373 gsm_a_dtap_msg_ss_strings);
376 if (dlg_dtap_tp.win != NULL)
378 gsm_a_stat_draw_aux(&dlg_dtap_tp,
379 stat_p->dtap_tp_message_type,
380 gsm_a_dtap_msg_tp_strings);
383 if (dlg_sacch_rr.win != NULL)
385 gsm_a_stat_draw_aux(&dlg_sacch_rr,
386 stat_p->sacch_rr_message_type,
387 gsm_a_sacch_msg_rr_strings);
394 gsm_a_stat_gtk_win_destroy_cb(
396 gpointer user_data _U_)
398 memset((void *) user_data, 0, sizeof(gsm_a_stat_dlg_t));
403 gsm_a_stat_gtk_win_create(
404 gsm_a_stat_dlg_t *dlg_p,
412 dlg_p->win = window_new(GTK_WINDOW_TOPLEVEL, title);
413 gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 490, 500);
415 vbox = gtk_vbox_new(FALSE, 3);
416 gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
417 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
419 dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
420 gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
422 dlg_p->table = create_list();
423 gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
426 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
427 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
429 bt_close = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
430 window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
432 g_signal_connect(dlg_p->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
433 g_signal_connect(dlg_p->win, "destroy", G_CALLBACK(gsm_a_stat_gtk_win_destroy_cb), dlg_p);
435 gtk_widget_show_all(dlg_p->win);
436 window_present(dlg_p->win);
441 gsm_a_stat_gtk_bssmap_cb(
449 * if the window is already open, bring it to front
453 gdk_window_raise(dlg_bssmap.win->window);
457 gsm_a_stat_gtk_win_create(&dlg_bssmap, "GSM A-I/F BSSMAP Statistics");
458 gsm_a_stat_draw(&gsm_a_stat);
463 gsm_a_stat_gtk_bssmap_init(
464 const char *optarg _U_,
467 gsm_a_stat_gtk_bssmap_cb(NULL, NULL);
472 gsm_a_stat_gtk_dtap_cb(
475 gsm_a_stat_dlg_t *dlg_dtap_p,
477 const value_string *dtap_msg_strings _U_)
481 * if the window is already open, bring it to front
485 gdk_window_raise(dlg_dtap_p->win->window);
489 gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
491 gsm_a_stat_draw(&gsm_a_stat);
495 gsm_a_stat_gtk_dtap_mm_cb(
499 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
500 "GSM A-I/F DTAP Mobility Management Statistics",
501 gsm_a_dtap_msg_mm_strings);
505 gsm_a_stat_gtk_dtap_mm_init(const char *optarg _U_,
508 gsm_a_stat_gtk_dtap_mm_cb(NULL, NULL);
512 gsm_a_stat_gtk_dtap_rr_cb(
516 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
517 "GSM A-I/F DTAP Radio Resource Management Statistics",
518 gsm_a_dtap_msg_rr_strings);
522 gsm_a_stat_gtk_dtap_rr_init(const char *optarg _U_,
525 gsm_a_stat_gtk_dtap_rr_cb(NULL, NULL);
529 gsm_a_stat_gtk_dtap_cc_cb(
533 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_cc,
534 "GSM A-I/F DTAP Call Control Statistics",
535 gsm_a_dtap_msg_cc_strings);
539 gsm_a_stat_gtk_dtap_cc_init(const char *optarg _U_,
542 gsm_a_stat_gtk_dtap_cc_cb(NULL, NULL);
546 gsm_a_stat_gtk_dtap_gmm_cb(
550 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
551 "GSM A-I/F DTAP GPRS Mobility Management Statistics",
552 gsm_a_dtap_msg_gmm_strings);
556 gsm_a_stat_gtk_dtap_gmm_init(const char *optarg _U_,
559 gsm_a_stat_gtk_dtap_gmm_cb(NULL, NULL);
563 gsm_a_stat_gtk_dtap_sms_cb(
567 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
568 "GSM A-I/F DTAP Short Message Service Statistics",
569 gsm_a_dtap_msg_sms_strings);
573 gsm_a_stat_gtk_dtap_sms_init(const char *optarg _U_,
576 gsm_a_stat_gtk_dtap_sms_cb(NULL, NULL);
580 gsm_a_stat_gtk_dtap_sm_cb(
584 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
585 "GSM A-I/F DTAP GPRS Session Management Statistics",
586 gsm_a_dtap_msg_sm_strings);
590 gsm_a_stat_gtk_dtap_sm_init(const char *optarg _U_,
593 gsm_a_stat_gtk_dtap_sm_cb(NULL, NULL);
597 gsm_a_stat_gtk_dtap_ss_cb(
601 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
602 "GSM A-I/F DTAP Supplementary Services Statistics",
603 gsm_a_dtap_msg_ss_strings);
607 gsm_a_stat_gtk_dtap_ss_init(
608 const char *optarg _U_,
611 gsm_a_stat_gtk_dtap_ss_cb(NULL, NULL);
615 gsm_a_stat_gtk_dtap_tp_cb(
619 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_tp,
620 "GSM A-I/F DTAP Special Conformance Testing Functions Statistics",
621 gsm_a_dtap_msg_tp_strings);
625 gsm_a_stat_gtk_dtap_tp_init(
626 const char *optarg _U_,
629 gsm_a_stat_gtk_dtap_tp_cb(NULL, NULL);
633 gsm_a_stat_gtk_sacch_rr_cb(
639 * if the window is already open, bring it to front
641 if (dlg_sacch_rr.win)
643 gdk_window_raise(dlg_sacch_rr.win->window);
647 gsm_a_stat_gtk_win_create(&dlg_sacch_rr, "GSM A-I/F SACCH Statistics");
648 gsm_a_stat_draw(&gsm_a_stat);
653 gsm_a_stat_gtk_sacch_rr_init(
654 const char *optarg _U_,
657 gsm_a_stat_gtk_sacch_rr_cb(NULL, NULL);
661 register_tap_listener_gtkgsm_a_stat(void)
666 memset((void *) &gsm_a_stat, 0, sizeof(gsm_a_stat_t));
669 register_tap_listener("gsm_a", &gsm_a_stat, NULL,
676 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_p->str);
677 g_string_free(err_p, TRUE);
682 register_stat_menu_item("GSM/A-Interface BSSMAP", REGISTER_STAT_GROUP_TELEPHONY,
683 gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
684 register_stat_cmd_arg("gsm_a,bssmap", gsm_a_stat_gtk_bssmap_init,NULL);
686 register_stat_menu_item("GSM/A-Interface DTAP/Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
687 gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
688 register_stat_cmd_arg("gsm_a,dtap_mm", gsm_a_stat_gtk_dtap_mm_init,NULL);
690 register_stat_menu_item("GSM/A-Interface DTAP/Radio Resource Management", REGISTER_STAT_GROUP_TELEPHONY,
691 gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
692 register_stat_cmd_arg("gsm_a,dtap_rr", gsm_a_stat_gtk_dtap_rr_init,NULL);
694 register_stat_menu_item("GSM/A-Interface DTAP/Call Control", REGISTER_STAT_GROUP_TELEPHONY,
695 gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
696 register_stat_cmd_arg("gsm_a,dtap_cc", gsm_a_stat_gtk_dtap_cc_init,NULL);
698 register_stat_menu_item("GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
699 gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
700 register_stat_cmd_arg("gsm_a,dtap_gmm", gsm_a_stat_gtk_dtap_gmm_init,NULL);
702 register_stat_menu_item("GSM/A-Interface DTAP/Short Message Service", REGISTER_STAT_GROUP_TELEPHONY,
703 gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
704 register_stat_cmd_arg("gsm_a,dtap_sms", gsm_a_stat_gtk_dtap_sms_init,NULL);
706 register_stat_menu_item("GSM/A-Interface DTAP/GPRS Session Management", REGISTER_STAT_GROUP_TELEPHONY,
707 gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
708 register_stat_cmd_arg("gsm_a,dtap_sm", gsm_a_stat_gtk_dtap_sm_init,NULL);
710 register_stat_menu_item("GSM/A-Interface DTAP/Supplementary Services", REGISTER_STAT_GROUP_TELEPHONY,
711 gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);
712 register_stat_cmd_arg("gsm_a,dtap_ss", gsm_a_stat_gtk_dtap_ss_init,NULL);
714 register_stat_menu_item("GSM/A-Interface DTAP/Special Conformance Testing Functions", REGISTER_STAT_GROUP_TELEPHONY,
715 gsm_a_stat_gtk_dtap_tp_cb, NULL, NULL, NULL);
716 register_stat_cmd_arg("gsm_a,dtap_tp", gsm_a_stat_gtk_dtap_tp_init,NULL);
718 register_stat_menu_item("GSM/A-Interface SACCH", REGISTER_STAT_GROUP_TELEPHONY,
719 gsm_a_stat_gtk_sacch_rr_cb, NULL, NULL, NULL);
720 register_stat_cmd_arg("gsm_a,sacch", gsm_a_stat_gtk_sacch_rr_init,NULL);