Corrected endif.
[obnox/wireshark/wip.git] / gtk / gsm_a_stat.c
1 /* gsm_a_stat.c
2  *
3  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
4  * In association with Telos Technology Inc.
5  *
6  * MUCH code modified from service_response_time_table.c.
7  *
8  * $Id$
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
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.
18  *
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.
23  *
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.
27  */
28
29 /*
30  * This TAP provides statistics for the GSM A-Interface:
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36 #include <string.h>
37
38 #include <gtk/gtk.h>
39
40 #include "epan/packet_info.h"
41 #include "epan/epan.h"
42 #include "epan/value_string.h"
43 #include <epan/stat_cmd_args.h>
44 #include <epan/tap.h>
45 #include <epan/dissectors/packet-bssap.h>
46 #include <epan/dissectors/packet-gsm_a_common.h>
47
48 #include "../stat_menu.h"
49 #include "../simple_dialog.h"
50
51 #include "gtk/gui_stat_menu.h"
52 #include "gtk/dlg_utils.h"
53 #include "gtk/filter_dlg.h"
54 #include "gtk/gui_utils.h"
55
56 enum
57 {
58     IEI_COLUMN,
59     MSG_NAME_COLUMN,
60     COUNT_COLUMN,
61     N_COLUMN /* The number of columns */
62 };
63
64 typedef struct _gsm_a_stat_dlg_t {
65     GtkWidget       *win;
66     GtkWidget       *scrolled_win;
67     GtkWidget       *table;
68 } gsm_a_stat_dlg_t;
69
70 typedef struct _gsm_a_stat_t {
71     int     bssmap_message_type[0xff];
72     int     dtap_mm_message_type[0xff];
73     int     dtap_rr_message_type[0xff];
74     int     dtap_cc_message_type[0xff];
75     int     dtap_gmm_message_type[0xff];
76     int     dtap_sms_message_type[0xff];
77     int     dtap_sm_message_type[0xff];
78     int     dtap_ss_message_type[0xff];
79     int     dtap_tp_message_type[0xff];
80     int     sacch_rr_message_type[0xff];
81 } gsm_a_stat_t;
82
83
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_dlg_t     dlg_dtap_tp;
93 static gsm_a_stat_dlg_t     dlg_sacch_rr;
94 static gsm_a_stat_t         gsm_a_stat;
95
96 /* Create list */
97 static
98 GtkWidget* create_list(void)
99 {
100
101     GtkListStore *list_store;
102     GtkWidget *list;
103     GtkTreeViewColumn *column;
104     GtkCellRenderer *renderer;
105     GtkTreeSortable *sortable;
106     GtkTreeView     *list_view;
107     GtkTreeSelection  *selection;
108
109     /* Create the store */
110     list_store = gtk_list_store_new(N_COLUMN,   /* Total number of columns XXX*/
111                                G_TYPE_UINT,     /* IEI              */
112                                G_TYPE_STRING,   /* Message Name     */
113                                G_TYPE_UINT);    /* Count            */
114
115     /* Create a view */
116     list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
117
118     list_view = GTK_TREE_VIEW(list);
119     sortable = GTK_TREE_SORTABLE(list_store);
120
121 #if GTK_CHECK_VERSION(2,6,0)
122     /* Speed up the list display */
123     gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
124 #endif
125
126     /* Setup the sortable columns */
127     gtk_tree_sortable_set_sort_column_id(sortable, IEI_COLUMN, GTK_SORT_ASCENDING);
128     gtk_tree_view_set_headers_clickable(list_view, FALSE);
129
130     /* The view now holds a reference.  We can get rid of our own reference */
131     g_object_unref (G_OBJECT (list_store));
132
133     /*
134      * Create the first column packet, associating the "text" attribute of the
135      * cell_renderer to the first column of the model
136      */
137     renderer = gtk_cell_renderer_text_new ();
138     column = gtk_tree_view_column_new_with_attributes ("IEI", renderer,
139         "text", IEI_COLUMN,
140         NULL);
141
142     /* gtk_tree_view_column_set_cell_data_func(column, renderer, present_as_hex_func,
143         GINT_TO_POINTER(IEI_COLUMN), NULL);
144         */
145
146     gtk_tree_view_column_set_sort_column_id(column, IEI_COLUMN);
147     gtk_tree_view_column_set_resizable(column, TRUE);
148     gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
149     gtk_tree_view_column_set_min_width(column, 50);
150
151     /* Add the column to the view. */
152     gtk_tree_view_append_column (list_view, column);
153
154     /* Second column.. Message Name. */
155     renderer = gtk_cell_renderer_text_new ();
156     column = gtk_tree_view_column_new_with_attributes ("Message Name", renderer,
157         "text", MSG_NAME_COLUMN,
158         NULL);
159     gtk_tree_view_column_set_sort_column_id(column, MSG_NAME_COLUMN);
160     gtk_tree_view_column_set_resizable(column, TRUE);
161     gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
162     gtk_tree_view_column_set_min_width(column, 280);
163     gtk_tree_view_append_column (list_view, column);
164
165     /* Third column.. Count. */
166     renderer = gtk_cell_renderer_text_new ();
167     column = gtk_tree_view_column_new_with_attributes ("Count", renderer,
168         "text", COUNT_COLUMN,
169         NULL);
170
171
172     gtk_tree_view_column_set_sort_column_id(column, COUNT_COLUMN);
173     gtk_tree_view_column_set_resizable(column, TRUE);
174     gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
175     gtk_tree_view_column_set_min_width(column, 50);
176     gtk_tree_view_append_column (list_view, column);
177
178     /* Now enable the sorting of each column */
179     gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view), TRUE);
180     gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(list_view), TRUE);
181
182     /* Setup the selection handler */
183     selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
184     gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
185
186     return list;
187
188 }
189 static void
190 gsm_a_stat_reset(
191     void        *tapdata)
192 {
193     gsm_a_stat_t    *stat_p = tapdata;
194
195     memset(stat_p, 0, sizeof(gsm_a_stat_t));
196 }
197
198
199 static gboolean
200 gsm_a_stat_packet(
201     void        *tapdata,
202     packet_info     *pinfo _U_,
203     epan_dissect_t  *edt _U_,
204     const void      *data)
205 {
206     gsm_a_stat_t    *stat_p = tapdata;
207     const gsm_a_tap_rec_t   *data_p = data;
208
209     switch (data_p->pdu_type)
210     {
211     case BSSAP_PDU_TYPE_BSSMAP:
212         stat_p->bssmap_message_type[data_p->message_type]++;
213         break;
214
215     case BSSAP_PDU_TYPE_DTAP:
216         switch (data_p->protocol_disc)
217         {
218         case PD_CC:
219             stat_p->dtap_cc_message_type[data_p->message_type]++;
220             break;
221         case PD_MM:
222             stat_p->dtap_mm_message_type[data_p->message_type]++;
223             break;
224         case PD_RR:
225             stat_p->dtap_rr_message_type[data_p->message_type]++;
226             break;
227         case PD_GMM:
228             stat_p->dtap_gmm_message_type[data_p->message_type]++;
229             break;
230         case PD_SMS:
231             stat_p->dtap_sms_message_type[data_p->message_type]++;
232             break;
233         case PD_SM:
234             stat_p->dtap_sm_message_type[data_p->message_type]++;
235             break;
236         case PD_SS:
237             stat_p->dtap_ss_message_type[data_p->message_type]++;
238             break;
239         case PD_TP:
240             stat_p->dtap_tp_message_type[data_p->message_type]++;
241             break;
242         default:
243             /*
244              * unsupported PD
245              */
246             return(FALSE);
247     }
248     break;
249
250     case GSM_A_PDU_TYPE_SACCH:
251         switch (data_p->protocol_disc)
252         {
253         case 0:
254             stat_p->sacch_rr_message_type[data_p->message_type]++;
255             break;
256         default:
257             /* unknown Short PD */
258             break;
259         }
260         break;
261
262     default:
263     /*
264      * unknown PDU type !!!
265      */
266     return(FALSE);
267     }
268
269     return(TRUE);
270 }
271
272
273 static void
274 gsm_a_stat_draw_aux(
275     gsm_a_stat_dlg_t    *dlg_p,
276     int                 *message_count,
277     const value_string  *msg_strings)
278 {
279     GtkListStore *list_store;
280     GtkTreeIter  iter;
281     int          i;
282
283
284     if (dlg_p->win != NULL){
285         i = 0;
286         list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW (dlg_p->table))); /* Get store */
287
288         while (msg_strings[i].strptr){
289             /* Creates a new row at position. iter will be changed to point to this new row.
290              * If position is larger than the number of rows on the list, then the new row will be appended to the list.
291              * The row will be filled with the values given to this function.
292              * :
293              * should generally be preferred when inserting rows in a sorted list store.
294              */
295 #if GTK_CHECK_VERSION(2,6,0)
296             gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
297 #else
298             gtk_list_store_append  (list_store, &iter);
299             gtk_list_store_set  (list_store, &iter,
300 #endif
301                     IEI_COLUMN, msg_strings[i].value,
302                     MSG_NAME_COLUMN, (char *)msg_strings[i].strptr,
303                     COUNT_COLUMN, message_count[msg_strings[i].value],
304                     -1);
305             i++;
306         }
307     }
308 }
309
310 static void
311 gsm_a_stat_draw(
312     void        *tapdata)
313 {
314     gsm_a_stat_t    *stat_p = tapdata;
315
316     if (!tapdata) return;
317
318     if (dlg_bssmap.win != NULL)
319     {
320         gsm_a_stat_draw_aux(&dlg_bssmap,
321             stat_p->bssmap_message_type,
322             gsm_a_bssmap_msg_strings);
323     }
324
325     if (dlg_dtap_mm.win != NULL)
326     {
327         gsm_a_stat_draw_aux(&dlg_dtap_mm,
328             stat_p->dtap_mm_message_type,
329             gsm_a_dtap_msg_mm_strings);
330     }
331
332     if (dlg_dtap_rr.win != NULL)
333     {
334         gsm_a_stat_draw_aux(&dlg_dtap_rr,
335             stat_p->dtap_rr_message_type,
336             gsm_a_dtap_msg_rr_strings);
337     }
338
339     if (dlg_dtap_cc.win != NULL)
340     {
341         gsm_a_stat_draw_aux(&dlg_dtap_cc,
342             stat_p->dtap_cc_message_type,
343             gsm_a_dtap_msg_cc_strings);
344     }
345
346     if (dlg_dtap_gmm.win != NULL)
347     {
348         gsm_a_stat_draw_aux(&dlg_dtap_gmm,
349             stat_p->dtap_gmm_message_type,
350             gsm_a_dtap_msg_gmm_strings);
351     }
352
353     if (dlg_dtap_sms.win != NULL)
354     {
355         gsm_a_stat_draw_aux(&dlg_dtap_sms,
356             stat_p->dtap_sms_message_type,
357             gsm_a_dtap_msg_sms_strings);
358     }
359
360     if (dlg_dtap_sm.win != NULL)
361     {
362         gsm_a_stat_draw_aux(&dlg_dtap_sm,
363             stat_p->dtap_sm_message_type,
364             gsm_a_dtap_msg_sm_strings);
365     }
366
367     if (dlg_dtap_ss.win != NULL)
368     {
369         gsm_a_stat_draw_aux(&dlg_dtap_ss,
370             stat_p->dtap_ss_message_type,
371             gsm_a_dtap_msg_ss_strings);
372     }
373
374     if (dlg_dtap_tp.win != NULL)
375     {
376         gsm_a_stat_draw_aux(&dlg_dtap_tp,
377             stat_p->dtap_tp_message_type,
378             gsm_a_dtap_msg_tp_strings);
379     }
380
381     if (dlg_sacch_rr.win != NULL)
382     {
383         gsm_a_stat_draw_aux(&dlg_sacch_rr,
384             stat_p->sacch_rr_message_type,
385             gsm_a_sacch_msg_rr_strings);
386     }
387 }
388
389
390
391 static void
392 gsm_a_stat_gtk_win_destroy_cb(
393     GtkWindow       *win _U_,
394     gpointer        user_data)
395 {
396     memset((void *) user_data, 0, sizeof(gsm_a_stat_dlg_t));
397 }
398
399
400 static void
401 gsm_a_stat_gtk_win_create(
402     gsm_a_stat_dlg_t    *dlg_p,
403     const char      *title)
404 {
405     GtkWidget       *vbox;
406     GtkWidget       *bt_close;
407     GtkWidget       *bbox;
408
409
410     dlg_p->win = dlg_window_new(title);  /* transient_for top_level */
411     gtk_window_set_destroy_with_parent (GTK_WINDOW(dlg_p->win), TRUE);
412     gtk_window_set_default_size(GTK_WINDOW(dlg_p->win), 490, 500);
413
414     vbox = gtk_vbox_new(FALSE, 3);
415     gtk_container_add(GTK_CONTAINER(dlg_p->win), vbox);
416     gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
417
418     dlg_p->scrolled_win = scrolled_window_new(NULL, NULL);
419     gtk_box_pack_start(GTK_BOX(vbox), dlg_p->scrolled_win, TRUE, TRUE, 0);
420
421     dlg_p->table = create_list();
422     gtk_container_add(GTK_CONTAINER(dlg_p->scrolled_win), dlg_p->table);
423
424     /* Button row. */
425     bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
426     gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
427
428     bt_close = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
429     window_set_cancel_button(dlg_p->win, bt_close, window_cancel_button_cb);
430
431     g_signal_connect(dlg_p->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
432     g_signal_connect(dlg_p->win, "destroy", G_CALLBACK(gsm_a_stat_gtk_win_destroy_cb), dlg_p);
433
434     gtk_widget_show_all(dlg_p->win);
435     window_present(dlg_p->win);
436 }
437
438 #ifdef MAIN_MENU_USE_UIMANAGER
439 void gsm_a_stat_gtk_bssmap_cb(GtkAction *action _U_, gpointer user_data _U_)
440 #else
441 static void
442 gsm_a_stat_gtk_bssmap_cb(
443     GtkWidget      *w _U_,
444     gpointer        d _U_)
445 #endif
446 {
447  /*   int           i;*/
448
449
450     /*
451      * if the window is already open, bring it to front
452      */
453     if (dlg_bssmap.win)
454     {
455     gdk_window_raise(dlg_bssmap.win->window);
456     return;
457     }
458
459     gsm_a_stat_gtk_win_create(&dlg_bssmap, "GSM A-I/F BSSMAP Statistics");
460     gsm_a_stat_draw(&gsm_a_stat);
461 }
462
463
464 static void
465 gsm_a_stat_gtk_bssmap_init(
466     const char      *optarg _U_,
467     void* userdata _U_)
468 {
469     gsm_a_stat_gtk_bssmap_cb(NULL, NULL);
470 }
471
472
473 static void
474 gsm_a_stat_gtk_dtap_cb(
475     GtkWidget       *w _U_,
476     gpointer        d _U_,
477     gsm_a_stat_dlg_t    *dlg_dtap_p,
478     const char      *title,
479     const value_string  *dtap_msg_strings _U_)
480 {
481
482     /*
483      * if the window is already open, bring it to front
484      */
485     if (dlg_dtap_p->win)
486     {
487     gdk_window_raise(dlg_dtap_p->win->window);
488     return;
489     }
490
491     gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
492
493     gsm_a_stat_draw(&gsm_a_stat);
494 }
495
496 #ifdef MAIN_MENU_USE_UIMANAGER
497 void 
498 gsm_a_stat_gtk_dtap_mm_cb(GtkAction *action _U_, gpointer user_data _U_)
499 #else
500 static void
501 gsm_a_stat_gtk_dtap_mm_cb(
502     GtkWidget       *w _U_,
503     gpointer        d _U_)
504 #endif
505 {
506     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
507     "GSM A-I/F DTAP Mobility Management Statistics",
508     gsm_a_dtap_msg_mm_strings);
509 }
510
511 static void
512 gsm_a_stat_gtk_dtap_mm_init(const char      *optarg _U_,
513                             void* userdata _U_)
514 {
515     gsm_a_stat_gtk_dtap_mm_cb(NULL, NULL);
516 }
517
518 #ifdef MAIN_MENU_USE_UIMANAGER
519 void
520 gsm_a_stat_gtk_dtap_rr_cb(GtkAction *action _U_, gpointer user_data _U_)
521 #else
522 static void
523 gsm_a_stat_gtk_dtap_rr_cb(
524     GtkWidget       *w _U_,
525     gpointer        d _U_)
526 #endif
527 {
528     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
529     "GSM A-I/F DTAP Radio Resource Management Statistics",
530     gsm_a_dtap_msg_rr_strings);
531 }
532
533 static void
534 gsm_a_stat_gtk_dtap_rr_init(const char      *optarg _U_,
535                             void* userdata _U_)
536 {
537     gsm_a_stat_gtk_dtap_rr_cb(NULL, NULL);
538 }
539
540 #ifdef MAIN_MENU_USE_UIMANAGER
541 void
542 gsm_a_stat_gtk_dtap_cc_cb(GtkAction *action _U_, gpointer user_data _U_)
543 #else
544 static void
545 gsm_a_stat_gtk_dtap_cc_cb(
546     GtkWidget       *w _U_,
547     gpointer        d _U_)
548 #endif
549 {
550     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_cc,
551     "GSM A-I/F DTAP Call Control Statistics",
552     gsm_a_dtap_msg_cc_strings);
553 }
554
555 static void
556 gsm_a_stat_gtk_dtap_cc_init(const char      *optarg _U_,
557                             void* userdata _U_)
558 {
559     gsm_a_stat_gtk_dtap_cc_cb(NULL, NULL);
560 }
561
562 #ifdef MAIN_MENU_USE_UIMANAGER
563 void
564 gsm_a_stat_gtk_dtap_gmm_cb(GtkAction *action _U_, gpointer user_data _U_)
565 #else
566 static void
567 gsm_a_stat_gtk_dtap_gmm_cb(
568     GtkWidget       *w _U_,
569     gpointer        d _U_)
570 #endif
571 {
572     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
573     "GSM A-I/F DTAP GPRS Mobility Management Statistics",
574     gsm_a_dtap_msg_gmm_strings);
575 }
576
577 static void
578 gsm_a_stat_gtk_dtap_gmm_init(const char     *optarg _U_,
579                              void* userdata _U_)
580 {
581     gsm_a_stat_gtk_dtap_gmm_cb(NULL, NULL);
582 }
583
584 static void
585 gsm_a_stat_gtk_dtap_sms_cb(
586     GtkWidget       *w _U_,
587     gpointer        d _U_)
588 {
589     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
590     "GSM A-I/F DTAP Short Message Service Statistics",
591     gsm_a_dtap_msg_sms_strings);
592 }
593
594 static void
595 gsm_a_stat_gtk_dtap_sms_init(const char     *optarg _U_,
596                              void* userdata _U_)
597 {
598     gsm_a_stat_gtk_dtap_sms_cb(NULL, NULL);
599 }
600
601 static void
602 gsm_a_stat_gtk_dtap_sm_cb(
603     GtkWidget       *w _U_,
604     gpointer        d _U_)
605 {
606     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
607     "GSM A-I/F DTAP GPRS Session Management Statistics",
608     gsm_a_dtap_msg_sm_strings);
609 }
610
611 static void
612 gsm_a_stat_gtk_dtap_sm_init(const char      *optarg _U_,
613                             void* userdata _U_)
614 {
615     gsm_a_stat_gtk_dtap_sm_cb(NULL, NULL);
616 }
617
618 static void
619 gsm_a_stat_gtk_dtap_ss_cb(
620     GtkWidget       *w _U_,
621     gpointer        d _U_)
622 {
623     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
624     "GSM A-I/F DTAP Supplementary Services Statistics",
625     gsm_a_dtap_msg_ss_strings);
626 }
627
628 static void
629 gsm_a_stat_gtk_dtap_ss_init(
630     const char      *optarg _U_,
631     void        *userdata _U_)
632 {
633     gsm_a_stat_gtk_dtap_ss_cb(NULL, NULL);
634 }
635
636 static void
637 gsm_a_stat_gtk_dtap_tp_cb(
638     GtkWidget       *w _U_,
639     gpointer        d _U_)
640 {
641     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_tp,
642     "GSM A-I/F DTAP Special Conformance Testing Functions Statistics",
643     gsm_a_dtap_msg_tp_strings);
644 }
645
646 static void
647 gsm_a_stat_gtk_dtap_tp_init(
648     const char      *optarg _U_,
649     void        *userdata _U_)
650 {
651     gsm_a_stat_gtk_dtap_tp_cb(NULL, NULL);
652 }
653
654 static void
655 gsm_a_stat_gtk_sacch_rr_cb(
656     GtkWidget       *w _U_,
657     gpointer        d _U_)
658 {
659
660     /*
661      * if the window is already open, bring it to front
662      */
663     if (dlg_sacch_rr.win)
664     {
665     gdk_window_raise(dlg_sacch_rr.win->window);
666     return;
667     }
668
669     gsm_a_stat_gtk_win_create(&dlg_sacch_rr, "GSM A-I/F SACCH Statistics");
670     gsm_a_stat_draw(&gsm_a_stat);
671 }
672
673
674 static void
675 gsm_a_stat_gtk_sacch_rr_init(
676     const char      *optarg _U_,
677     void* userdata _U_)
678 {
679     gsm_a_stat_gtk_sacch_rr_cb(NULL, NULL);
680 }
681
682 void
683 register_tap_listener_gtkgsm_a_stat(void)
684 {
685     GString     *err_p;
686
687
688     memset((void *) &gsm_a_stat, 0, sizeof(gsm_a_stat_t));
689
690     err_p =
691     register_tap_listener("gsm_a", &gsm_a_stat, NULL, 0,
692         gsm_a_stat_reset,
693         gsm_a_stat_packet,
694         gsm_a_stat_draw);
695
696     if (err_p != NULL)
697     {
698         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_p->str);
699         g_string_free(err_p, TRUE);
700
701         exit(1);
702     }
703
704 #ifdef MAIN_MENU_USE_UIMANAGER
705 #else
706     register_stat_menu_item("_GSM/A-Interface BSSMAP", REGISTER_STAT_GROUP_TELEPHONY,
707     gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
708     register_stat_menu_item("_GSM/A-Interface DTAP/Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
709     gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
710     register_stat_menu_item("_GSM/A-Interface DTAP/Radio Resource Management", REGISTER_STAT_GROUP_TELEPHONY,
711     gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
712     register_stat_menu_item("_GSM/A-Interface DTAP/Call Control", REGISTER_STAT_GROUP_TELEPHONY,
713     gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
714     register_stat_menu_item("_GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
715     gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
716     register_stat_menu_item("_GSM/A-Interface DTAP/Short Message Service", REGISTER_STAT_GROUP_TELEPHONY,
717     gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
718     register_stat_menu_item("_GSM/A-Interface DTAP/GPRS Session Management", REGISTER_STAT_GROUP_TELEPHONY,
719     gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
720     register_stat_menu_item("_GSM/A-Interface DTAP/Supplementary Services", REGISTER_STAT_GROUP_TELEPHONY,
721     gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);
722     register_stat_menu_item("_GSM/A-Interface DTAP/Special Conformance Testing Functions", REGISTER_STAT_GROUP_TELEPHONY,
723     gsm_a_stat_gtk_dtap_tp_cb, NULL, NULL, NULL);
724     register_stat_menu_item("_GSM/A-Interface SACCH", REGISTER_STAT_GROUP_TELEPHONY,
725     gsm_a_stat_gtk_sacch_rr_cb, NULL, NULL, NULL);
726 #endif
727
728     register_stat_cmd_arg("gsm_a,bssmap", gsm_a_stat_gtk_bssmap_init,NULL);
729
730     register_stat_cmd_arg("gsm_a,dtap_mm", gsm_a_stat_gtk_dtap_mm_init,NULL);
731
732     register_stat_cmd_arg("gsm_a,dtap_rr", gsm_a_stat_gtk_dtap_rr_init,NULL);
733
734     register_stat_cmd_arg("gsm_a,dtap_cc", gsm_a_stat_gtk_dtap_cc_init,NULL);
735
736     register_stat_cmd_arg("gsm_a,dtap_gmm", gsm_a_stat_gtk_dtap_gmm_init,NULL);
737
738     register_stat_cmd_arg("gsm_a,dtap_sms", gsm_a_stat_gtk_dtap_sms_init,NULL);
739
740     register_stat_cmd_arg("gsm_a,dtap_sm", gsm_a_stat_gtk_dtap_sm_init,NULL);
741
742     register_stat_cmd_arg("gsm_a,dtap_ss", gsm_a_stat_gtk_dtap_ss_init,NULL);
743
744     register_stat_cmd_arg("gsm_a,dtap_tp", gsm_a_stat_gtk_dtap_tp_init,NULL);
745
746     register_stat_cmd_arg("gsm_a,sacch", gsm_a_stat_gtk_sacch_rr_init,NULL);
747 }