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;
98 gsm_a_stat_t *stat_p = tapdata;
100 memset(stat_p, 0, sizeof(gsm_a_stat_t));
107 packet_info *pinfo _U_,
108 epan_dissect_t *edt _U_,
111 gsm_a_stat_t *stat_p = tapdata;
112 const gsm_a_tap_rec_t *data_p = data;
114 switch (data_p->pdu_type)
116 case BSSAP_PDU_TYPE_BSSMAP:
117 stat_p->bssmap_message_type[data_p->message_type]++;
120 case BSSAP_PDU_TYPE_DTAP:
121 switch (data_p->protocol_disc)
124 stat_p->dtap_cc_message_type[data_p->message_type]++;
127 stat_p->dtap_mm_message_type[data_p->message_type]++;
130 stat_p->dtap_rr_message_type[data_p->message_type]++;
133 stat_p->dtap_gmm_message_type[data_p->message_type]++;
136 stat_p->dtap_sms_message_type[data_p->message_type]++;
139 stat_p->dtap_sm_message_type[data_p->message_type]++;
142 stat_p->dtap_ss_message_type[data_p->message_type]++;
154 * unknown PDU type !!!
165 gsm_a_stat_dlg_t *dlg_p,
167 const value_string *msg_strings)
173 if (dlg_p->win != NULL)
177 while (msg_strings[i].strptr)
179 j = gtk_clist_find_row_from_data(GTK_CLIST(dlg_p->table), (gpointer) i);
181 strp = g_strdup_printf("%d", message_count[msg_strings[i].value]);
182 gtk_clist_set_text(GTK_CLIST(dlg_p->table), j, 2, strp);
188 gtk_clist_sort(GTK_CLIST(dlg_p->table));
196 gsm_a_stat_t *stat_p = tapdata;
198 if (!tapdata) return;
200 if (dlg_bssmap.win != NULL)
202 gsm_a_stat_draw_aux(&dlg_bssmap,
203 stat_p->bssmap_message_type,
204 gsm_a_bssmap_msg_strings);
207 if (dlg_dtap_mm.win != NULL)
209 gsm_a_stat_draw_aux(&dlg_dtap_mm,
210 stat_p->dtap_mm_message_type,
211 gsm_a_dtap_msg_mm_strings);
214 if (dlg_dtap_rr.win != NULL)
216 gsm_a_stat_draw_aux(&dlg_dtap_rr,
217 stat_p->dtap_rr_message_type,
218 gsm_a_dtap_msg_rr_strings);
221 if (dlg_dtap_cc.win != NULL)
223 gsm_a_stat_draw_aux(&dlg_dtap_cc,
224 stat_p->dtap_cc_message_type,
225 gsm_a_dtap_msg_cc_strings);
228 if (dlg_dtap_gmm.win != NULL)
230 gsm_a_stat_draw_aux(&dlg_dtap_gmm,
231 stat_p->dtap_gmm_message_type,
232 gsm_a_dtap_msg_gmm_strings);
235 if (dlg_dtap_sms.win != NULL)
237 gsm_a_stat_draw_aux(&dlg_dtap_sms,
238 stat_p->dtap_sms_message_type,
239 gsm_a_dtap_msg_sms_strings);
242 if (dlg_dtap_sm.win != NULL)
244 gsm_a_stat_draw_aux(&dlg_dtap_sm,
245 stat_p->dtap_sm_message_type,
246 gsm_a_dtap_msg_sm_strings);
249 if (dlg_dtap_ss.win != NULL)
251 gsm_a_stat_draw_aux(&dlg_dtap_ss,
252 stat_p->dtap_ss_message_type,
253 gsm_a_dtap_msg_ss_strings);
259 gsm_a_stat_gtk_click_column_cb(
264 column_arrows *col_arrows = (column_arrows *) data;
268 gtk_clist_freeze(clist);
270 for (i=0; i < 3; i++)
272 gtk_widget_hide(col_arrows[i].ascend_pm);
273 gtk_widget_hide(col_arrows[i].descend_pm);
276 if (column == clist->sort_column)
278 if (clist->sort_type == GTK_SORT_ASCENDING)
280 clist->sort_type = GTK_SORT_DESCENDING;
281 gtk_widget_show(col_arrows[column].descend_pm);
285 clist->sort_type = GTK_SORT_ASCENDING;
286 gtk_widget_show(col_arrows[column].ascend_pm);
292 * Columns 0-1 sorted in descending order by default
293 * Columns 2 sorted in ascending order by default
297 clist->sort_type = GTK_SORT_ASCENDING;
298 gtk_widget_show(col_arrows[column].ascend_pm);
302 clist->sort_type = GTK_SORT_DESCENDING;
303 gtk_widget_show(col_arrows[column].descend_pm);
306 gtk_clist_set_sort_column(clist, column);
309 gtk_clist_thaw(clist);
310 gtk_clist_sort(clist);
315 gsm_a_stat_gtk_sort_column(
320 const GtkCListRow *row1 = ptr1;
321 const GtkCListRow *row2 = ptr2;
326 text1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text;
327 text2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text;
329 switch (clist->sort_column)
335 i1 = strtol(text1, NULL, 0);
336 i2 = strtol(text2, NULL, 0);
340 return(strcmp(text1, text2));
343 g_assert_not_reached();
350 gsm_a_stat_gtk_win_destroy_cb(
352 gpointer user_data _U_)
354 memset((void *) user_data, 0, sizeof(gsm_a_stat_dlg_t));
359 gsm_a_stat_gtk_win_create(
360 gsm_a_stat_dlg_t *dlg_p,
363 #define INIT_TABLE_NUM_COLUMNS 3
364 char *default_titles[] = { "IEI", "Message Name", "Count" };
366 column_arrows *col_arrows;
367 GtkWidget *column_lb;
373 dlg_p->win = window_new(GTK_WINDOW_TOPLEVEL, title);
374 gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 490, 500);
376 vbox = gtk_vbox_new(FALSE, 3);
377 gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
378 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
380 dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
381 gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
383 dlg_p->table = gtk_clist_new(INIT_TABLE_NUM_COLUMNS);
386 (column_arrows *) g_malloc(sizeof(column_arrows) * INIT_TABLE_NUM_COLUMNS);
388 for (i = 0; i < INIT_TABLE_NUM_COLUMNS; i++)
390 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
392 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
394 column_lb = gtk_label_new(default_titles[i]);
396 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb,
397 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
399 gtk_widget_show(column_lb);
401 col_arrows[i].ascend_pm = xpm_to_widget(clist_ascend_xpm);
403 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm,
404 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
406 col_arrows[i].descend_pm = xpm_to_widget(clist_descend_xpm);
408 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm,
409 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
413 /* default column sorting */
414 gtk_widget_show(col_arrows[i].ascend_pm);
417 gtk_clist_set_column_widget(GTK_CLIST(dlg_p->table), i, col_arrows[i].table);
418 gtk_widget_show(col_arrows[i].table);
420 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
422 gtk_clist_set_compare_func(GTK_CLIST(dlg_p->table), gsm_a_stat_gtk_sort_column);
423 gtk_clist_set_sort_column(GTK_CLIST(dlg_p->table), 0);
424 gtk_clist_set_sort_type(GTK_CLIST(dlg_p->table), GTK_SORT_ASCENDING);
426 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 0, 50);
427 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 1, 330);
428 gtk_clist_set_column_width(GTK_CLIST(dlg_p->table), 2, 50);
430 gtk_clist_set_shadow_type(GTK_CLIST(dlg_p->table), GTK_SHADOW_IN);
431 gtk_clist_column_titles_show(GTK_CLIST(dlg_p->table));
432 gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
434 SIGNAL_CONNECT(dlg_p->table, "click-column", gsm_a_stat_gtk_click_column_cb, col_arrows);
437 bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
438 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
440 bt_close = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
441 window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
443 SIGNAL_CONNECT(dlg_p->win, "delete_event", window_delete_event_cb, NULL);
444 SIGNAL_CONNECT(dlg_p->win, "destroy", gsm_a_stat_gtk_win_destroy_cb, dlg_p);
446 gtk_widget_show_all(dlg_p->win);
447 window_present(dlg_p->win);
452 * Never gets called ?
458 /* does not appear to be called */
465 gsm_a_stat_gtk_bssmap_cb(
474 * if the window is already open, bring it to front
478 gdk_window_raise(dlg_bssmap.win->window);
482 gsm_a_stat_gtk_win_create(&dlg_bssmap, "GSM A-I/F BSSMAP Statistics");
485 while (gsm_a_bssmap_msg_strings[i].strptr)
487 g_snprintf(str, 100, "0x%02x", gsm_a_bssmap_msg_strings[i].value);
488 dlg_bssmap.entries[0] = g_strdup(str);
490 dlg_bssmap.entries[1] = g_strdup(gsm_a_bssmap_msg_strings[i].strptr);
492 dlg_bssmap.entries[2] = g_strdup("0");
494 gtk_clist_insert(GTK_CLIST(dlg_bssmap.table), i, dlg_bssmap.entries);
495 gtk_clist_set_row_data(GTK_CLIST(dlg_bssmap.table), i, (gpointer) i);
500 gsm_a_stat_draw(NULL);
505 gsm_a_stat_gtk_dtap_cb(
508 gsm_a_stat_dlg_t *dlg_dtap_p,
510 const value_string *dtap_msg_strings)
517 * if the window is already open, bring it to front
521 gdk_window_raise(dlg_dtap_p->win->window);
525 gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
528 while (dtap_msg_strings[i].strptr)
530 g_snprintf(str, 100, "0x%02x", dtap_msg_strings[i].value);
531 dlg_dtap_p->entries[0] = g_strdup(str);
533 dlg_dtap_p->entries[1] = g_strdup(dtap_msg_strings[i].strptr);
535 dlg_dtap_p->entries[2] = g_strdup("0");
537 gtk_clist_insert(GTK_CLIST(dlg_dtap_p->table), i, dlg_dtap_p->entries);
538 gtk_clist_set_row_data(GTK_CLIST(dlg_dtap_p->table), i, (gpointer) i);
543 gsm_a_stat_draw(NULL);
547 gsm_a_stat_gtk_dtap_mm_cb(
551 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
552 "GSM A-I/F DTAP Mobility Management Statistics",
553 gsm_a_dtap_msg_mm_strings);
557 gsm_a_stat_gtk_dtap_rr_cb(
561 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
562 "GSM A-I/F DTAP Radio Resource Management Statistics",
563 gsm_a_dtap_msg_rr_strings);
567 gsm_a_stat_gtk_dtap_cc_cb(
571 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_cc,
572 "GSM A-I/F DTAP Call Control Statistics",
573 gsm_a_dtap_msg_cc_strings);
577 gsm_a_stat_gtk_dtap_gmm_cb(
581 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
582 "GSM A-I/F DTAP GPRS Mobility Management Statistics",
583 gsm_a_dtap_msg_gmm_strings);
587 gsm_a_stat_gtk_dtap_sms_cb(
591 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
592 "GSM A-I/F DTAP Short Message Service Statistics",
593 gsm_a_dtap_msg_sms_strings);
597 gsm_a_stat_gtk_dtap_sm_cb(
601 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
602 "GSM A-I/F DTAP GPRS Session Management Statistics",
603 gsm_a_dtap_msg_sm_strings);
607 gsm_a_stat_gtk_dtap_ss_cb(
611 gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
612 "GSM A-I/F DTAP Supplementary Services Statistics",
613 gsm_a_dtap_msg_ss_strings);
618 register_tap_listener_gtkgsm_a_stat(void)
623 register_ethereal_tap("gsm_a,", gsm_a_stat_gtk_init);
625 memset((void *) &stat, 0, sizeof(gsm_a_stat_t));
628 register_tap_listener("gsm_a", &stat, NULL,
635 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, err_p->str);
636 g_string_free(err_p, TRUE);
641 register_tap_menu_item("GSM/A-Interface BSSMAP", REGISTER_TAP_GROUP_NONE,
642 gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
644 register_tap_menu_item("GSM/A-Interface DTAP/Mobility Management", REGISTER_TAP_GROUP_NONE,
645 gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
647 register_tap_menu_item("GSM/A-Interface DTAP/Radio Resource Management", REGISTER_TAP_GROUP_NONE,
648 gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
650 register_tap_menu_item("GSM/A-Interface DTAP/Call Control", REGISTER_TAP_GROUP_NONE,
651 gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
653 register_tap_menu_item("GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_TAP_GROUP_NONE,
654 gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
656 register_tap_menu_item("GSM/A-Interface DTAP/Short Message Service", REGISTER_TAP_GROUP_NONE,
657 gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
659 register_tap_menu_item("GSM/A-Interface DTAP/GPRS Session Management", REGISTER_TAP_GROUP_NONE,
660 gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
662 register_tap_menu_item("GSM/A-Interface DTAP/Supplementary Services", REGISTER_TAP_GROUP_NONE,
663 gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);