Use correct signature for event callback functions;
[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, gpointer user_data )
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 #ifdef MAIN_MENU_USE_UIMANAGER
473 static void
474 gsm_a_stat_gtk_dtap_cb(
475     GtkAction *action _U_,
476     gpointer user_data _U_,
477     gsm_a_stat_dlg_t    *dlg_dtap_p,
478     const char      *title,
479     const value_string  *dtap_msg_strings _U_)
480 #else
481 static void
482 gsm_a_stat_gtk_dtap_cb(
483     GtkWidget       *w _U_,
484     gpointer        d _U_,
485     gsm_a_stat_dlg_t    *dlg_dtap_p,
486     const char      *title,
487     const value_string  *dtap_msg_strings _U_)
488 #endif
489 {
490
491     /*
492      * if the window is already open, bring it to front
493      */
494     if (dlg_dtap_p->win)
495     {
496     gdk_window_raise(dlg_dtap_p->win->window);
497     return;
498     }
499
500     gsm_a_stat_gtk_win_create(dlg_dtap_p, title);
501
502     gsm_a_stat_draw(&gsm_a_stat);
503 }
504
505 #ifdef MAIN_MENU_USE_UIMANAGER
506 void 
507 gsm_a_stat_gtk_dtap_mm_cb(GtkAction *action, gpointer user_data )
508 {
509     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_mm,
510     "GSM A-I/F DTAP Mobility Management Statistics",
511     gsm_a_dtap_msg_mm_strings);
512 }
513 #else
514 static void
515 gsm_a_stat_gtk_dtap_mm_cb(
516     GtkWidget       *w _U_,
517     gpointer        d _U_)
518 {
519     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_mm,
520     "GSM A-I/F DTAP Mobility Management Statistics",
521     gsm_a_dtap_msg_mm_strings);
522 }
523 #endif
524 static void
525 gsm_a_stat_gtk_dtap_mm_init(const char      *optarg _U_,
526                             void* userdata _U_)
527 {
528     gsm_a_stat_gtk_dtap_mm_cb(NULL, NULL);
529 }
530
531 #ifdef MAIN_MENU_USE_UIMANAGER
532 void
533 gsm_a_stat_gtk_dtap_rr_cb(GtkAction *action, gpointer user_data )
534 {
535     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_rr,
536     "GSM A-I/F DTAP Radio Resource Management Statistics",
537     gsm_a_dtap_msg_rr_strings);
538 }
539 #else
540 static void
541 gsm_a_stat_gtk_dtap_rr_cb(
542     GtkWidget       *w _U_,
543     gpointer        d _U_)
544 {
545     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_rr,
546     "GSM A-I/F DTAP Radio Resource Management Statistics",
547     gsm_a_dtap_msg_rr_strings);
548 }
549 #endif
550
551
552 static void
553 gsm_a_stat_gtk_dtap_rr_init(const char      *optarg _U_,
554                             void* userdata _U_)
555 {
556     gsm_a_stat_gtk_dtap_rr_cb(NULL, NULL);
557 }
558
559 #ifdef MAIN_MENU_USE_UIMANAGER
560 void
561 gsm_a_stat_gtk_dtap_cc_cb(GtkAction *action, gpointer user_data )
562 {
563     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_cc,
564     "GSM A-I/F DTAP Call Control Statistics",
565     gsm_a_dtap_msg_cc_strings);
566 }
567 #else
568 static void
569 gsm_a_stat_gtk_dtap_cc_cb(
570     GtkWidget       *w _U_,
571     gpointer        d _U_)
572 {
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);
576 }
577 #endif
578
579 static void
580 gsm_a_stat_gtk_dtap_cc_init(const char      *optarg _U_,
581                             void* userdata _U_)
582 {
583     gsm_a_stat_gtk_dtap_cc_cb(NULL, NULL);
584 }
585
586 #ifdef MAIN_MENU_USE_UIMANAGER
587 void
588 gsm_a_stat_gtk_dtap_gmm_cb(GtkAction *action, gpointer user_data )
589 {
590     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_gmm,
591     "GSM A-I/F DTAP GPRS Mobility Management Statistics",
592     gsm_a_dtap_msg_gmm_strings);
593 }
594
595 #else
596 static void
597 gsm_a_stat_gtk_dtap_gmm_cb(
598     GtkWidget       *w _U_,
599     gpointer        d _U_)
600 {
601     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_gmm,
602     "GSM A-I/F DTAP GPRS Mobility Management Statistics",
603     gsm_a_dtap_msg_gmm_strings);
604 }
605 #endif
606
607 static void
608 gsm_a_stat_gtk_dtap_gmm_init(const char     *optarg _U_,
609                              void* userdata _U_)
610 {
611     gsm_a_stat_gtk_dtap_gmm_cb(NULL, NULL);
612 }
613
614 #ifdef MAIN_MENU_USE_UIMANAGER
615 void
616 gsm_a_stat_gtk_dtap_sms_cb(GtkAction *action, gpointer user_data )
617 {
618     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_sms,
619     "GSM A-I/F DTAP Short Message Service Statistics",
620     gsm_a_dtap_msg_sms_strings);
621 }
622 #else
623 static void
624 gsm_a_stat_gtk_dtap_sms_cb(
625     GtkWidget       *w _U_,
626     gpointer        d _U_)
627 {
628     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sms,
629     "GSM A-I/F DTAP Short Message Service Statistics",
630     gsm_a_dtap_msg_sms_strings);
631 }
632 #endif
633
634 static void
635 gsm_a_stat_gtk_dtap_sms_init(const char     *optarg _U_,
636                              void* userdata _U_)
637 {
638     gsm_a_stat_gtk_dtap_sms_cb(NULL, NULL);
639 }
640
641 #ifdef MAIN_MENU_USE_UIMANAGER
642 void
643 gsm_a_stat_gtk_dtap_sm_cb(GtkAction *action, gpointer user_data )
644 {
645     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_sm,
646     "GSM A-I/F DTAP GPRS Session Management Statistics",
647     gsm_a_dtap_msg_sm_strings);
648 }
649 #else
650 static void
651 gsm_a_stat_gtk_dtap_sm_cb(
652     GtkWidget       *w _U_,
653     gpointer        d _U_)
654 {
655     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_sm,
656     "GSM A-I/F DTAP GPRS Session Management Statistics",
657     gsm_a_dtap_msg_sm_strings);
658 }
659 #endif
660
661 static void
662 gsm_a_stat_gtk_dtap_sm_init(const char      *optarg _U_,
663                             void* userdata _U_)
664 {
665     gsm_a_stat_gtk_dtap_sm_cb(NULL, NULL);
666 }
667
668 #ifdef MAIN_MENU_USE_UIMANAGER
669 void
670 gsm_a_stat_gtk_dtap_ss_cb(GtkAction *action, gpointer user_data )
671 {
672     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_ss,
673     "GSM A-I/F DTAP Supplementary Services Statistics",
674     gsm_a_dtap_msg_ss_strings);
675 }
676 #else
677 static void
678 gsm_a_stat_gtk_dtap_ss_cb(
679     GtkWidget       *w _U_,
680     gpointer        d _U_)
681 {
682     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_ss,
683     "GSM A-I/F DTAP Supplementary Services Statistics",
684     gsm_a_dtap_msg_ss_strings);
685 }
686 #endif
687
688 static void
689 gsm_a_stat_gtk_dtap_ss_init(
690     const char      *optarg _U_,
691     void        *userdata _U_)
692 {
693     gsm_a_stat_gtk_dtap_ss_cb(NULL, NULL);
694 }
695
696 #ifdef MAIN_MENU_USE_UIMANAGER
697 void
698 gsm_a_stat_gtk_dtap_tp_cb(GtkAction *action, gpointer user_data )
699 {
700     gsm_a_stat_gtk_dtap_cb(action, user_data, &dlg_dtap_tp,
701     "GSM A-I/F DTAP Special Conformance Testing Functions Statistics",
702     gsm_a_dtap_msg_tp_strings);
703 }
704 #else
705 static void
706 gsm_a_stat_gtk_dtap_tp_cb(
707     GtkWidget       *w _U_,
708     gpointer        d _U_)
709 {
710     gsm_a_stat_gtk_dtap_cb(w, d, &dlg_dtap_tp,
711     "GSM A-I/F DTAP Special Conformance Testing Functions Statistics",
712     gsm_a_dtap_msg_tp_strings);
713 }
714 #endif
715
716 static void
717 gsm_a_stat_gtk_dtap_tp_init(
718     const char      *optarg _U_,
719     void        *userdata _U_)
720 {
721     gsm_a_stat_gtk_dtap_tp_cb(NULL, NULL);
722 }
723
724 #ifdef MAIN_MENU_USE_UIMANAGER
725 void
726 gsm_a_stat_gtk_sacch_rr_cb(GtkAction *action _U_, gpointer user_data _U_ )
727 {
728
729     /*
730      * if the window is already open, bring it to front
731      */
732     if (dlg_sacch_rr.win)
733     {
734     gdk_window_raise(dlg_sacch_rr.win->window);
735     return;
736     }
737
738     gsm_a_stat_gtk_win_create(&dlg_sacch_rr, "GSM A-I/F SACCH Statistics");
739     gsm_a_stat_draw(&gsm_a_stat);
740 }
741 #else
742 static void
743 gsm_a_stat_gtk_sacch_rr_cb(
744     GtkWidget       *w _U_,
745     gpointer        d _U_)
746 {
747
748     /*
749      * if the window is already open, bring it to front
750      */
751     if (dlg_sacch_rr.win)
752     {
753     gdk_window_raise(dlg_sacch_rr.win->window);
754     return;
755     }
756
757     gsm_a_stat_gtk_win_create(&dlg_sacch_rr, "GSM A-I/F SACCH Statistics");
758     gsm_a_stat_draw(&gsm_a_stat);
759 }
760 #endif
761
762 static void
763 gsm_a_stat_gtk_sacch_rr_init(
764     const char      *optarg _U_,
765     void* userdata _U_)
766 {
767     gsm_a_stat_gtk_sacch_rr_cb(NULL, NULL);
768 }
769
770 void
771 register_tap_listener_gtkgsm_a_stat(void)
772 {
773     GString     *err_p;
774
775
776     memset((void *) &gsm_a_stat, 0, sizeof(gsm_a_stat_t));
777
778     err_p =
779     register_tap_listener("gsm_a", &gsm_a_stat, NULL, 0,
780         gsm_a_stat_reset,
781         gsm_a_stat_packet,
782         gsm_a_stat_draw);
783
784     if (err_p != NULL)
785     {
786         simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_p->str);
787         g_string_free(err_p, TRUE);
788
789         exit(1);
790     }
791
792 #ifdef MAIN_MENU_USE_UIMANAGER
793 #else
794     register_stat_menu_item("_GSM/A-Interface BSSMAP", REGISTER_STAT_GROUP_TELEPHONY,
795     gsm_a_stat_gtk_bssmap_cb, NULL, NULL, NULL);
796     register_stat_menu_item("_GSM/A-Interface DTAP/Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
797     gsm_a_stat_gtk_dtap_mm_cb, NULL, NULL, NULL);
798     register_stat_menu_item("_GSM/A-Interface DTAP/Radio Resource Management", REGISTER_STAT_GROUP_TELEPHONY,
799     gsm_a_stat_gtk_dtap_rr_cb, NULL, NULL, NULL);
800     register_stat_menu_item("_GSM/A-Interface DTAP/Call Control", REGISTER_STAT_GROUP_TELEPHONY,
801     gsm_a_stat_gtk_dtap_cc_cb, NULL, NULL, NULL);
802     register_stat_menu_item("_GSM/A-Interface DTAP/GPRS Mobility Management", REGISTER_STAT_GROUP_TELEPHONY,
803     gsm_a_stat_gtk_dtap_gmm_cb, NULL, NULL, NULL);
804     register_stat_menu_item("_GSM/A-Interface DTAP/Short Message Service", REGISTER_STAT_GROUP_TELEPHONY,
805     gsm_a_stat_gtk_dtap_sms_cb, NULL, NULL, NULL);
806     register_stat_menu_item("_GSM/A-Interface DTAP/GPRS Session Management", REGISTER_STAT_GROUP_TELEPHONY,
807     gsm_a_stat_gtk_dtap_sm_cb, NULL, NULL, NULL);
808     register_stat_menu_item("_GSM/A-Interface DTAP/Supplementary Services", REGISTER_STAT_GROUP_TELEPHONY,
809     gsm_a_stat_gtk_dtap_ss_cb, NULL, NULL, NULL);
810     register_stat_menu_item("_GSM/A-Interface DTAP/Special Conformance Testing Functions", REGISTER_STAT_GROUP_TELEPHONY,
811     gsm_a_stat_gtk_dtap_tp_cb, NULL, NULL, NULL);
812     register_stat_menu_item("_GSM/A-Interface SACCH", REGISTER_STAT_GROUP_TELEPHONY,
813     gsm_a_stat_gtk_sacch_rr_cb, NULL, NULL, NULL);
814 #endif
815
816     register_stat_cmd_arg("gsm_a,bssmap", gsm_a_stat_gtk_bssmap_init,NULL);
817
818     register_stat_cmd_arg("gsm_a,dtap_mm", gsm_a_stat_gtk_dtap_mm_init,NULL);
819
820     register_stat_cmd_arg("gsm_a,dtap_rr", gsm_a_stat_gtk_dtap_rr_init,NULL);
821
822     register_stat_cmd_arg("gsm_a,dtap_cc", gsm_a_stat_gtk_dtap_cc_init,NULL);
823
824     register_stat_cmd_arg("gsm_a,dtap_gmm", gsm_a_stat_gtk_dtap_gmm_init,NULL);
825
826     register_stat_cmd_arg("gsm_a,dtap_sms", gsm_a_stat_gtk_dtap_sms_init,NULL);
827
828     register_stat_cmd_arg("gsm_a,dtap_sm", gsm_a_stat_gtk_dtap_sm_init,NULL);
829
830     register_stat_cmd_arg("gsm_a,dtap_ss", gsm_a_stat_gtk_dtap_ss_init,NULL);
831
832     register_stat_cmd_arg("gsm_a,dtap_tp", gsm_a_stat_gtk_dtap_tp_init,NULL);
833
834     register_stat_cmd_arg("gsm_a,sacch", gsm_a_stat_gtk_sacch_rr_init,NULL);
835 }