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"
44 #include "image/clist_ascend.xpm"
45 #include "image/clist_descend.xpm"
46 #include "simple_dialog.h"
47 #include "dlg_utils.h"
49 #include "../register.h"
50 #include <epan/dissectors/packet-bssap.h>
51 #include <epan/dissectors/packet-gsm_a.h>
52 #include "../globals.h"
53 #include "filter_dlg.h"
54 #include "compat_macros.h"
58 typedef struct column_arrows {
61 GtkWidget *descend_pm;
64 typedef struct _gsm_a_stat_dlg_t {
66 GtkWidget *scrolled_win;
71 typedef struct _gsm_a_stat_t {
72 int bssmap_message_type[0xff];
73 int dtap_mm_message_type[0xff];
74 int dtap_rr_message_type[0xff];
75 int dtap_cc_message_type[0xff];
76 int dtap_gmm_message_type[0xff];
77 int dtap_sms_message_type[0xff];
78 int dtap_sm_message_type[0xff];
79 int dtap_ss_message_type[0xff];
83 static gsm_a_stat_dlg_t dlg_bssmap;
84 static gsm_a_stat_dlg_t dlg_dtap_mm;
85 static gsm_a_stat_dlg_t dlg_dtap_rr;
86 static gsm_a_stat_dlg_t dlg_dtap_cc;
87 static gsm_a_stat_dlg_t dlg_dtap_gmm;
88 static gsm_a_stat_dlg_t dlg_dtap_sms;
89 static gsm_a_stat_dlg_t dlg_dtap_sm;
90 static gsm_a_stat_dlg_t dlg_dtap_ss;
91 static gsm_a_stat_t stat;
100 memset((void *) &stat, 0, sizeof(gsm_a_stat_t));
108 epan_dissect_t *edt _U_,
111 gsm_a_tap_rec_t *data_p = data;
117 switch (data_p->pdu_type)
119 case BSSAP_PDU_TYPE_BSSMAP:
120 stat.bssmap_message_type[data_p->message_type]++;
123 case BSSAP_PDU_TYPE_DTAP:
124 switch (data_p->protocol_disc)
127 stat.dtap_cc_message_type[data_p->message_type]++;
130 stat.dtap_mm_message_type[data_p->message_type]++;
133 stat.dtap_rr_message_type[data_p->message_type]++;
136 stat.dtap_gmm_message_type[data_p->message_type]++;
139 stat.dtap_sms_message_type[data_p->message_type]++;
142 stat.dtap_sm_message_type[data_p->message_type]++;
145 stat.dtap_ss_message_type[data_p->message_type]++;
157 * unknown PDU type !!!
168 gsm_a_stat_dlg_t *dlg_p,
170 const value_string *msg_strings)
176 if (dlg_p->win != NULL)
180 while (msg_strings[i].strptr)
182 j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_p->table), (gpointer) i);
184 strp = g_strdup_printf("%d", message_count[msg_strings[i].value]);
185 gtk_clist_set_text(GTK_CLIST(dlg_p->table), j, 2, strp);
191 gtk_clist_sort(GTK_CLIST(dlg_p->table));
202 if (dlg_bssmap.win != NULL)
204 gsm_a_stat_draw_aux(&dlg_bssmap,
205 stat.bssmap_message_type,
206 gsm_a_bssmap_msg_strings);
209 if (dlg_dtap_mm.win != NULL)
211 gsm_a_stat_draw_aux(&dlg_dtap_mm,
212 stat.dtap_mm_message_type,
213 gsm_a_dtap_msg_mm_strings);
216 if (dlg_dtap_rr.win != NULL)
218 gsm_a_stat_draw_aux(&dlg_dtap_rr,
219 stat.dtap_rr_message_type,
220 gsm_a_dtap_msg_rr_strings);
223 if (dlg_dtap_cc.win != NULL)
225 gsm_a_stat_draw_aux(&dlg_dtap_cc,
226 stat.dtap_cc_message_type,
227 gsm_a_dtap_msg_cc_strings);
230 if (dlg_dtap_gmm.win != NULL)
232 gsm_a_stat_draw_aux(&dlg_dtap_gmm,
233 stat.dtap_gmm_message_type,
234 gsm_a_dtap_msg_gmm_strings);
237 if (dlg_dtap_sms.win != NULL)
239 gsm_a_stat_draw_aux(&dlg_dtap_sms,
240 stat.dtap_sms_message_type,
241 gsm_a_dtap_msg_sms_strings);
244 if (dlg_dtap_sm.win != NULL)
246 gsm_a_stat_draw_aux(&dlg_dtap_sm,
247 stat.dtap_sm_message_type,
248 gsm_a_dtap_msg_sm_strings);
251 if (dlg_dtap_ss.win != NULL)
253 gsm_a_stat_draw_aux(&dlg_dtap_ss,
254 stat.dtap_ss_message_type,
255 gsm_a_dtap_msg_ss_strings);
261 gsm_a_stat_gtk_click_column_cb(
266 column_arrows *col_arrows = (column_arrows *) data;
270 gtk_clist_freeze(clist);
272 for (i=0; i < 3; i++)
274 gtk_widget_hide(col_arrows[i].ascend_pm);
275 gtk_widget_hide(col_arrows[i].descend_pm);
278 if (column == clist->sort_column)
280 if (clist->sort_type == GTK_SORT_ASCENDING)
282 clist->sort_type = GTK_SORT_DESCENDING;
283 gtk_widget_show(col_arrows[column].descend_pm);
287 clist->sort_type = GTK_SORT_ASCENDING;
288 gtk_widget_show(col_arrows[column].ascend_pm);
294 * Columns 0-1 sorted in descending order by default
295 * Columns 2 sorted in ascending order by default
299 clist->sort_type = GTK_SORT_ASCENDING;
300 gtk_widget_show(col_arrows[column].ascend_pm);
304 clist->sort_type = GTK_SORT_DESCENDING;
305 gtk_widget_show(col_arrows[column].descend_pm);
308 gtk_clist_set_sort_column(clist, column);
311 gtk_clist_thaw(clist);
312 gtk_clist_sort(clist);
317 gsm_a_stat_gtk_sort_column(
322 GtkCListRow *row1 = (GtkCListRow *) ptr1;
323 GtkCListRow *row2 = (GtkCListRow *) ptr2;
328 text1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text;
329 text2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text;
331 switch (clist->sort_column)
337 i1 = strtol(text1, NULL, 0);
338 i2 = strtol(text2, NULL, 0);
342 return(strcmp(text1, text2));
345 g_assert_not_reached();
352 gsm_a_stat_gtk_win_destroy_cb(
354 gpointer user_data _U_)
356 memset((void *) user_data, 0, sizeof(gsm_a_stat_dlg_t));
361 gsm_a_stat_gtk_win_create(
362 gsm_a_stat_dlg_t *dlg_p,
365 #define INIT_TABLE_NUM_COLUMNS 3
366 char *default_titles[] = { "IEI", "Message Name", "Count" };
368 column_arrows *col_arrows;
369 GtkWidget *column_lb;
375 dlg_p->win = window_new(GTK_WINDOW_TOPLEVEL, title);
376 gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 490, 500);
378 vbox = gtk_vbox_new(FALSE, 3);
379 gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
380 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
382 dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
383 gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
385 dlg_p->table = gtk_clist_new(INIT_TABLE_NUM_COLUMNS);
388 (column_arrows *) g_malloc(sizeof(column_arrows) * INIT_TABLE_NUM_COLUMNS);
390 for (i = 0; i < INIT_TABLE_NUM_COLUMNS; i++)
392 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
394 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
396 column_lb = gtk_label_new(default_titles[i]);
398 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb,
399 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
401 gtk_widget_show(column_lb);
403 col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
405 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm,
406 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
408 col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
410 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm,
411 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
415 /* default column sorting */
416 gtk_widget_show(col_arrows[i].ascend_pm);
419 gtk_clist_set_column_widget(GTK_CLIST(dlg_p->table), i, col_arrows[i].table);
420 gtk_widget_show(col_arrows[i].table);
422 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
424 gtk_clist_set_compare_func(GTK_CLIST(dlg_p->table), gsm_a_stat_gtk_sort_column);
425 gtk_clist_set_sort_column(GTK_CLIST(dlg_p->table), 0);
426 gtk_clist_set_sort_type(GTK_CLIST(dlg_p->table), GTK_SORT_ASCENDING);
428 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 0, 50);
429 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 1, 330);
430 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 2, 50);
432 gtk_clist_set_shadow_type(GTK_CLIST(dlg_p->table), GTK_SHADOW_IN);
433 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
434 gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
436 SIGNAL_CONNECT(dlg_p->table, "click-column", gsm_a_stat_gtk_click_column_cb, col_arrows);
439 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
440 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
442 bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
443 window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
445 SIGNAL_CONNECT(dlg_p->win, "delete_event", window_delete_event_cb, NULL);
446 SIGNAL_CONNECT(dlg_p->win, "destroy", gsm_a_stat_gtk_win_destroy_cb, dlg_p);
448 gtk_widget_show_all(dlg_p->win);
449 window_present(dlg_p->win);
454 * Never gets called ?
460 /* does not appear to be called */
467 gsm_a_stat_gtk_bssmap_cb(
476 * if the window is already open, bring it to front
480 gdk_window_raise(dlg_bssmap.win->window);
484 gsm_a_stat_gtk_win_create(&dlg_bssmap, "GSM A-I/F BSSMAP Statistics");
487 while (gsm_a_bssmap_msg_strings[i].strptr)
489 g_snprintf(str, 100, "0x%02x", gsm_a_bssmap_msg_strings[i].value);
490 dlg_bssmap.entries[0] = g_strdup(str);
492 dlg_bssmap.entries[1] = g_strdup(gsm_a_bssmap_msg_strings[i].strptr);
494 dlg_bssmap.entries[2] = g_strdup("0");
496 gtk_clist_insert(GTK_CLIST(dlg_bssmap.table), i, dlg_bssmap.entries);
497 gtk_clist_set_row_data(GTK_CLIST(dlg_bssmap.table), i, (gpointer) i);
502 gsm_a_stat_draw(NULL);
507 gsm_a_stat_gtk_dtap_cb(
510 gsm_a_stat_dlg_t *dlg_dtap_p,
512 const value_string *dtap_msg_strings)
519 * if the window is already open, bring it to front
523 gdk_window_raise(dlg_dtap_p->win->window);
527 gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
530 while (dtap_msg_strings[i].strptr)
532 g_snprintf(str, 100, "0x%02x", dtap_msg_strings[i].value);
533 dlg_dtap_p->entries[0] = g_strdup(str);
535 dlg_dtap_p->entries[1] = g_strdup(dtap_msg_strings[i].strptr);
537 dlg_dtap_p->entries[2] = g_strdup("0");
539 gtk_clist_insert(GTK_CLIST(dlg_dtap_p->table), i, dlg_dtap_p->entries);
540 gtk_clist_set_row_data(GTK_CLIST(dlg_dtap_p->table), i, (gpointer) i);
545 gsm_a_stat_draw(NULL);
549 gsm_a_stat_gtk_dtap_mm_cb(
553 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
554 "GSM A-I/F DTAP Mobility Management Statistics",
555 gsm_a_dtap_msg_mm_strings);
559 gsm_a_stat_gtk_dtap_rr_cb(
563 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
564 "GSM A-I/F DTAP Radio Resource Management Statistics",
565 gsm_a_dtap_msg_rr_strings);
569 gsm_a_stat_gtk_dtap_cc_cb(
573 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_cc,
574 "GSM A-I/F DTAP Call Control Statistics",
575 gsm_a_dtap_msg_cc_strings);
579 gsm_a_stat_gtk_dtap_gmm_cb(
583 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
584 "GSM A-I/F DTAP GPRS Mobility Management Statistics",
585 gsm_a_dtap_msg_gmm_strings);
589 gsm_a_stat_gtk_dtap_sms_cb(
593 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
594 "GSM A-I/F DTAP Short Message Service Statistics",
595 gsm_a_dtap_msg_sms_strings);
599 gsm_a_stat_gtk_dtap_sm_cb(
603 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
604 "GSM A-I/F DTAP GPRS Session Management Statistics",
605 gsm_a_dtap_msg_sm_strings);
609 gsm_a_stat_gtk_dtap_ss_cb(
613 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
614 "GSM A-I/F DTAP Supplementary Services Statistics",
615 gsm_a_dtap_msg_ss_strings);
620 register_tap_listener_gtkgsm_a_stat(void)
625 register_ethereal_tap("gsm_a,", gsm_a_stat_gtk_init);
627 memset((void *) &stat, 0, sizeof(gsm_a_stat_t));
630 register_tap_listener("gsm_a", NULL, NULL,
637 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_p->str);
638 g_string_free(err_p, TRUE);
643 register_tap_menu_item("GSM/A-Interface BSSMAP", REGISTER_TAP_GROUP_NONE,
644 gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
646 register_tap_menu_item("GSM/A-Interface DTAP/Mobility Management", REGISTER_TAP_GROUP_NONE,
647 gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
649 register_tap_menu_item("GSM/A-Interface DTAP/Radio Resource Management", REGISTER_TAP_GROUP_NONE,
650 gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
652 register_tap_menu_item("GSM/A-Interface DTAP/Call Control", REGISTER_TAP_GROUP_NONE,
653 gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
655 register_tap_menu_item("GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_TAP_GROUP_NONE,
656 gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
658 register_tap_menu_item("GSM/A-Interface DTAP/Short Message Service", REGISTER_TAP_GROUP_NONE,
659 gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
661 register_tap_menu_item("GSM/A-Interface DTAP/GPRS Session Management", REGISTER_TAP_GROUP_NONE,
662 gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
664 register_tap_menu_item("GSM/A-Interface DTAP/Supplementary Services", REGISTER_TAP_GROUP_NONE,
665 gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);