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 * Ethereal - Network traffic analyzer
11 * By Gerald Combs <gerald@ethereal.com>
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.h>
44 #include "stat_menu.h"
45 #include "image/clist_ascend.xpm"
46 #include "image/clist_descend.xpm"
47 #include "simple_dialog.h"
48 #include "dlg_utils.h"
50 #include "../register.h"
51 #include <epan/dissectors/packet-bssap.h>
52 #include <epan/dissectors/packet-gsm_a.h>
53 #include "../globals.h"
54 #include "filter_dlg.h"
55 #include "compat_macros.h"
59 typedef struct column_arrows {
62 GtkWidget *descend_pm;
65 typedef struct _gsm_a_stat_dlg_t {
67 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];
84 static gsm_a_stat_dlg_t dlg_bssmap;
85 static gsm_a_stat_dlg_t dlg_dtap_mm;
86 static gsm_a_stat_dlg_t dlg_dtap_rr;
87 static gsm_a_stat_dlg_t dlg_dtap_cc;
88 static gsm_a_stat_dlg_t dlg_dtap_gmm;
89 static gsm_a_stat_dlg_t dlg_dtap_sms;
90 static gsm_a_stat_dlg_t dlg_dtap_sm;
91 static gsm_a_stat_dlg_t dlg_dtap_ss;
92 static gsm_a_stat_t stat;
99 gsm_a_stat_t *stat_p = tapdata;
101 memset(stat_p, 0, sizeof(gsm_a_stat_t));
108 packet_info *pinfo _U_,
109 epan_dissect_t *edt _U_,
112 gsm_a_stat_t *stat_p = tapdata;
113 const gsm_a_tap_rec_t *data_p = data;
115 switch (data_p->pdu_type)
117 case BSSAP_PDU_TYPE_BSSMAP:
118 stat_p->bssmap_message_type[data_p->message_type]++;
121 case BSSAP_PDU_TYPE_DTAP:
122 switch (data_p->protocol_disc)
125 stat_p->dtap_cc_message_type[data_p->message_type]++;
128 stat_p->dtap_mm_message_type[data_p->message_type]++;
131 stat_p->dtap_rr_message_type[data_p->message_type]++;
134 stat_p->dtap_gmm_message_type[data_p->message_type]++;
137 stat_p->dtap_sms_message_type[data_p->message_type]++;
140 stat_p->dtap_sm_message_type[data_p->message_type]++;
143 stat_p->dtap_ss_message_type[data_p->message_type]++;
155 * unknown PDU type !!!
166 gsm_a_stat_dlg_t *dlg_p,
168 const value_string *msg_strings)
174 if (dlg_p->win != NULL)
178 while (msg_strings[i].strptr)
180 j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_p->table), (gpointer) i);
182 strp = g_strdup_printf("%d", message_count[msg_strings[i].value]);
183 gtk_clist_set_text(GTK_CLIST(dlg_p->table), j, 2, strp);
189 gtk_clist_sort(GTK_CLIST(dlg_p->table));
197 gsm_a_stat_t *stat_p = tapdata;
199 if (!tapdata) return;
201 if (dlg_bssmap.win != NULL)
203 gsm_a_stat_draw_aux(&dlg_bssmap,
204 stat_p->bssmap_message_type,
205 gsm_a_bssmap_msg_strings);
208 if (dlg_dtap_mm.win != NULL)
210 gsm_a_stat_draw_aux(&dlg_dtap_mm,
211 stat_p->dtap_mm_message_type,
212 gsm_a_dtap_msg_mm_strings);
215 if (dlg_dtap_rr.win != NULL)
217 gsm_a_stat_draw_aux(&dlg_dtap_rr,
218 stat_p->dtap_rr_message_type,
219 gsm_a_dtap_msg_rr_strings);
222 if (dlg_dtap_cc.win != NULL)
224 gsm_a_stat_draw_aux(&dlg_dtap_cc,
225 stat_p->dtap_cc_message_type,
226 gsm_a_dtap_msg_cc_strings);
229 if (dlg_dtap_gmm.win != NULL)
231 gsm_a_stat_draw_aux(&dlg_dtap_gmm,
232 stat_p->dtap_gmm_message_type,
233 gsm_a_dtap_msg_gmm_strings);
236 if (dlg_dtap_sms.win != NULL)
238 gsm_a_stat_draw_aux(&dlg_dtap_sms,
239 stat_p->dtap_sms_message_type,
240 gsm_a_dtap_msg_sms_strings);
243 if (dlg_dtap_sm.win != NULL)
245 gsm_a_stat_draw_aux(&dlg_dtap_sm,
246 stat_p->dtap_sm_message_type,
247 gsm_a_dtap_msg_sm_strings);
250 if (dlg_dtap_ss.win != NULL)
252 gsm_a_stat_draw_aux(&dlg_dtap_ss,
253 stat_p->dtap_ss_message_type,
254 gsm_a_dtap_msg_ss_strings);
260 gsm_a_stat_gtk_click_column_cb(
265 column_arrows *col_arrows = (column_arrows *) data;
269 gtk_clist_freeze(clist);
271 for (i=0; i < 3; i++)
273 gtk_widget_hide(col_arrows[i].ascend_pm);
274 gtk_widget_hide(col_arrows[i].descend_pm);
277 if (column == clist->sort_column)
279 if (clist->sort_type == GTK_SORT_ASCENDING)
281 clist->sort_type = GTK_SORT_DESCENDING;
282 gtk_widget_show(col_arrows[column].descend_pm);
286 clist->sort_type = GTK_SORT_ASCENDING;
287 gtk_widget_show(col_arrows[column].ascend_pm);
293 * Columns 0-1 sorted in descending order by default
294 * Columns 2 sorted in ascending order by default
298 clist->sort_type = GTK_SORT_ASCENDING;
299 gtk_widget_show(col_arrows[column].ascend_pm);
303 clist->sort_type = GTK_SORT_DESCENDING;
304 gtk_widget_show(col_arrows[column].descend_pm);
307 gtk_clist_set_sort_column(clist, column);
310 gtk_clist_thaw(clist);
311 gtk_clist_sort(clist);
316 gsm_a_stat_gtk_sort_column(
321 const GtkCListRow *row1 = ptr1;
322 const GtkCListRow *row2 = ptr2;
327 text1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text;
328 text2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text;
330 switch (clist->sort_column)
336 i1 = strtol(text1, NULL, 0);
337 i2 = strtol(text2, NULL, 0);
341 return(strcmp(text1, text2));
344 g_assert_not_reached();
351 gsm_a_stat_gtk_win_destroy_cb(
353 gpointer user_data _U_)
355 memset((void *) user_data, 0, sizeof(gsm_a_stat_dlg_t));
360 gsm_a_stat_gtk_win_create(
361 gsm_a_stat_dlg_t *dlg_p,
364 #define INIT_TABLE_NUM_COLUMNS 3
365 const char *default_titles[] = { "IEI", "Message Name", "Count" };
367 column_arrows *col_arrows;
368 GtkWidget *column_lb;
374 dlg_p->win = window_new(GTK_WINDOW_TOPLEVEL, title);
375 gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 490, 500);
377 vbox = gtk_vbox_new(FALSE, 3);
378 gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
379 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
381 dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
382 gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
384 dlg_p->table = gtk_clist_new(INIT_TABLE_NUM_COLUMNS);
387 (column_arrows *) g_malloc(sizeof(column_arrows) * INIT_TABLE_NUM_COLUMNS);
389 for (i = 0; i < INIT_TABLE_NUM_COLUMNS; i++)
391 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
393 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
395 column_lb = gtk_label_new(default_titles[i]);
397 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb,
398 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
400 gtk_widget_show(column_lb);
402 col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
404 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm,
405 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
407 col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
409 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm,
410 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
414 /* default column sorting */
415 gtk_widget_show(col_arrows[i].ascend_pm);
418 gtk_clist_set_column_widget(GTK_CLIST(dlg_p->table), i, col_arrows[i].table);
419 gtk_widget_show(col_arrows[i].table);
421 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
423 gtk_clist_set_compare_func(GTK_CLIST(dlg_p->table), gsm_a_stat_gtk_sort_column);
424 gtk_clist_set_sort_column(GTK_CLIST(dlg_p->table), 0);
425 gtk_clist_set_sort_type(GTK_CLIST(dlg_p->table), GTK_SORT_ASCENDING);
427 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 0, 50);
428 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 1, 330);
429 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 2, 50);
431 gtk_clist_set_shadow_type(GTK_CLIST(dlg_p->table), GTK_SHADOW_IN);
432 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
433 gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
435 SIGNAL_CONNECT(dlg_p->table, "click-column", gsm_a_stat_gtk_click_column_cb, col_arrows);
438 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
439 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
441 bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
442 window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
444 SIGNAL_CONNECT(dlg_p->win, "delete_event", window_delete_event_cb, NULL);
445 SIGNAL_CONNECT(dlg_p->win, "destroy", gsm_a_stat_gtk_win_destroy_cb, dlg_p);
447 gtk_widget_show_all(dlg_p->win);
448 window_present(dlg_p->win);
453 * Never gets called ?
457 const char *optarg _U_)
459 /* does not appear to be called */
464 gsm_a_stat_gtk_bssmap_cb(
473 * if the window is already open, bring it to front
477 gdk_window_raise(dlg_bssmap.win->window);
481 gsm_a_stat_gtk_win_create(&dlg_bssmap, "GSM A-I/F BSSMAP Statistics");
484 while (gsm_a_bssmap_msg_strings[i].strptr)
486 g_snprintf(str, 100, "0x%02x", gsm_a_bssmap_msg_strings[i].value);
487 dlg_bssmap.entries[0] = g_strdup(str);
489 dlg_bssmap.entries[1] = g_strdup(gsm_a_bssmap_msg_strings[i].strptr);
491 dlg_bssmap.entries[2] = g_strdup("0");
493 gtk_clist_insert(GTK_CLIST(dlg_bssmap.table), i, dlg_bssmap.entries);
494 gtk_clist_set_row_data(GTK_CLIST(dlg_bssmap.table), i, (gpointer) i);
499 gsm_a_stat_draw(&stat);
504 gsm_a_stat_gtk_dtap_cb(
507 gsm_a_stat_dlg_t *dlg_dtap_p,
509 const value_string *dtap_msg_strings)
516 * if the window is already open, bring it to front
520 gdk_window_raise(dlg_dtap_p->win->window);
524 gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
527 while (dtap_msg_strings[i].strptr)
529 g_snprintf(str, 100, "0x%02x", dtap_msg_strings[i].value);
530 dlg_dtap_p->entries[0] = g_strdup(str);
532 dlg_dtap_p->entries[1] = g_strdup(dtap_msg_strings[i].strptr);
534 dlg_dtap_p->entries[2] = g_strdup("0");
536 gtk_clist_insert(GTK_CLIST(dlg_dtap_p->table), i, dlg_dtap_p->entries);
537 gtk_clist_set_row_data(GTK_CLIST(dlg_dtap_p->table), i, (gpointer) i);
542 gsm_a_stat_draw(&stat);
546 gsm_a_stat_gtk_dtap_mm_cb(
550 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
551 "GSM A-I/F DTAP Mobility Management Statistics",
552 gsm_a_dtap_msg_mm_strings);
556 gsm_a_stat_gtk_dtap_rr_cb(
560 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
561 "GSM A-I/F DTAP Radio Resource Management Statistics",
562 gsm_a_dtap_msg_rr_strings);
566 gsm_a_stat_gtk_dtap_cc_cb(
570 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_cc,
571 "GSM A-I/F DTAP Call Control Statistics",
572 gsm_a_dtap_msg_cc_strings);
576 gsm_a_stat_gtk_dtap_gmm_cb(
580 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
581 "GSM A-I/F DTAP GPRS Mobility Management Statistics",
582 gsm_a_dtap_msg_gmm_strings);
586 gsm_a_stat_gtk_dtap_sms_cb(
590 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
591 "GSM A-I/F DTAP Short Message Service Statistics",
592 gsm_a_dtap_msg_sms_strings);
596 gsm_a_stat_gtk_dtap_sm_cb(
600 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
601 "GSM A-I/F DTAP GPRS Session Management Statistics",
602 gsm_a_dtap_msg_sm_strings);
606 gsm_a_stat_gtk_dtap_ss_cb(
610 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
611 "GSM A-I/F DTAP Supplementary Services Statistics",
612 gsm_a_dtap_msg_ss_strings);
617 register_tap_listener_gtkgsm_a_stat(void)
622 register_stat_cmd_arg("gsm_a,", gsm_a_stat_gtk_init);
624 memset((void *) &stat, 0, sizeof(gsm_a_stat_t));
627 register_tap_listener("gsm_a", &stat, NULL,
634 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_p->str);
635 g_string_free(err_p, TRUE);
640 register_stat_menu_item("GSM/A-Interface BSSMAP", REGISTER_STAT_GROUP_TELEPHONY,
641 gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
643 register_stat_menu_item("GSM/A-Interface DTAP/Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
644 gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
646 register_stat_menu_item("GSM/A-Interface DTAP/Radio Resource Management", REGISTER_STAT_GROUP_TELEPHONY,
647 gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
649 register_stat_menu_item("GSM/A-Interface DTAP/Call Control", REGISTER_STAT_GROUP_TELEPHONY,
650 gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
652 register_stat_menu_item("GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
653 gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
655 register_stat_menu_item("GSM/A-Interface DTAP/Short Message Service", REGISTER_STAT_GROUP_TELEPHONY,
656 gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
658 register_stat_menu_item("GSM/A-Interface DTAP/GPRS Session Management", REGISTER_STAT_GROUP_TELEPHONY,
659 gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
661 register_stat_menu_item("GSM/A-Interface DTAP/Supplementary Services", REGISTER_STAT_GROUP_TELEPHONY,
662 gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);