Try to fix some of the build problems, it still bumms out on:
[obnox/wireshark/wip.git] / tap-gsm_astat.c
index 33b6f91120016348bc79bc178148bff23b4217d0..b84e377dfb06572a1c49dc0abf19109f79a81893 100644 (file)
@@ -3,10 +3,10 @@
  * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
  * In association with Telos Technology Inc.
  *
- * $Id: tap-gsm_astat.c,v 1.2 2004/05/09 10:03:38 guy Exp $
+ * $Id$
  *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
  *
  * This program is free software; you can redistribute it and/or
  * This TAP provides statistics for the GSM A Interface:
  */
 
-/* With MSVC and a libethereal.dll this file needs to import some variables 
-   in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */ 
-#define _NEED_VAR_IMPORT_
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 #include <string.h>
 #include "epan/packet_info.h"
 #include "epan/value_string.h"
-#include "tap.h"
-#include "packet-bssap.h"
-#include "packet-gsm_a.h"
-#include "register.h"
+#include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
+#include <epan/dissectors/packet-bssap.h>
+#include <epan/dissectors/packet-gsm_a_common.h>
 
 
 typedef struct _gsm_a_stat_t {
@@ -60,21 +56,20 @@ typedef struct _gsm_a_stat_t {
     int                dtap_sms_message_type[0xff];
     int                dtap_sm_message_type[0xff];
     int                dtap_ss_message_type[0xff];
+    int                dtap_tp_message_type[0xff];
+    int                sacch_rr_message_type[0xff];
 } gsm_a_stat_t;
 
 
 static int
 gsm_a_stat_packet(
     void                       *tapdata,
-    packet_info                        *pinfo,
+    packet_info                        *pinfo _U_,
     epan_dissect_t             *edt _U_,
-    void                       *data)
+    const void                 *data)
 {
     gsm_a_stat_t               *stat_p = tapdata;
-    gsm_a_tap_rec_t            *tap_p = data;
-
-
-    pinfo = pinfo;
+    const gsm_a_tap_rec_t      *tap_p = data;
 
     switch (tap_p->pdu_type)
     {
@@ -106,6 +101,9 @@ gsm_a_stat_packet(
        case PD_SS:
            stat_p->dtap_ss_message_type[tap_p->message_type]++;
            break;
+       case PD_TP:
+           stat_p->dtap_tp_message_type[tap_p->message_type]++;
+           break;
        default:
            /*
             * unsupported PD
@@ -114,6 +112,19 @@ gsm_a_stat_packet(
        }
        break;
 
+   case GSM_A_PDU_TYPE_SACCH:
+   switch (tap_p->protocol_disc)
+   {
+   case 0:
+      stat_p->sacch_rr_message_type[tap_p->message_type]++;
+      break;
+   default:
+      /* unknown Short PD */
+      break;
+   }
+   break;
+
+
     default:
        /*
         * unknown PDU type !!!
@@ -271,25 +282,56 @@ gsm_a_stat_draw(
        i++;
     }
 
+    printf("\nDTAP %s\n", gsm_a_pd_str[PD_TP]);
+    printf("Message (ID)Type                                        Number\n");
+
+    i = 0;
+    while (gsm_a_dtap_msg_tp_strings[i].strptr)
+    {
+       if (stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value] > 0)
+       {
+           printf("0x%02x  %-50s%d\n",
+               gsm_a_dtap_msg_tp_strings[i].value,
+               gsm_a_dtap_msg_tp_strings[i].strptr,
+               stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value]);
+       }
+
+       i++;
+    }
+
+    printf("\nSACCH Radio Resources Management messages\n");
+    printf("Message (ID)Type                                        Number\n");
+
+    i = 0;
+    while (gsm_a_rr_short_pd_msg_strings[i].strptr)
+    {
+       if (stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value] > 0)
+       {
+           printf("0x%02x  %-50s%d\n",
+               gsm_a_rr_short_pd_msg_strings[i].value,
+               gsm_a_rr_short_pd_msg_strings[i].strptr,
+               stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value]);
+       }
+
+       i++;
+    }
+
     printf("==============================================================\n");
 }
 
 
 static void
-gsm_a_stat_init(char *optarg)
+gsm_a_stat_init(const char *optarg _U_,void* userdata _U_)
 {
     gsm_a_stat_t       *stat_p;
     GString            *err_p;
 
-
-    optarg = optarg;
-
     stat_p = g_malloc(sizeof(gsm_a_stat_t));
 
     memset(stat_p, 0, sizeof(gsm_a_stat_t));
 
     err_p =
-       register_tap_listener("gsm_a", stat_p, NULL,
+       register_tap_listener("gsm_a", stat_p, NULL, 0,
            NULL,
            gsm_a_stat_packet,
            gsm_a_stat_draw);
@@ -307,5 +349,5 @@ gsm_a_stat_init(char *optarg)
 void
 register_tap_listener_gsm_astat(void)
 {
-    register_ethereal_tap("gsm_a,", gsm_a_stat_init);
+    register_stat_cmd_arg("gsm_a,", gsm_a_stat_init,NULL);
 }