3 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
4 * In association with Telos Technology Inc.
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * This TAP provides statistics for the GSM A Interface:
37 #ifdef HAVE_SYS_TYPES_H
38 # include <sys/types.h>
42 #include "epan/packet_info.h"
43 #include "epan/value_string.h"
45 #include <epan/stat_cmd_args.h>
46 #include <epan/dissectors/packet-bssap.h>
47 #include <epan/dissectors/packet-gsm_a.h>
51 typedef struct _gsm_a_stat_t {
52 int bssmap_message_type[0xff];
53 int dtap_mm_message_type[0xff];
54 int dtap_rr_message_type[0xff];
55 int dtap_cc_message_type[0xff];
56 int dtap_gmm_message_type[0xff];
57 int dtap_sms_message_type[0xff];
58 int dtap_sm_message_type[0xff];
59 int dtap_ss_message_type[0xff];
66 packet_info *pinfo _U_,
67 epan_dissect_t *edt _U_,
70 gsm_a_stat_t *stat_p = tapdata;
71 const gsm_a_tap_rec_t *tap_p = data;
73 switch (tap_p->pdu_type)
75 case BSSAP_PDU_TYPE_BSSMAP:
76 stat_p->bssmap_message_type[tap_p->message_type]++;
79 case BSSAP_PDU_TYPE_DTAP:
80 switch (tap_p->protocol_disc)
83 stat_p->dtap_cc_message_type[tap_p->message_type]++;
86 stat_p->dtap_mm_message_type[tap_p->message_type]++;
89 stat_p->dtap_rr_message_type[tap_p->message_type]++;
92 stat_p->dtap_gmm_message_type[tap_p->message_type]++;
95 stat_p->dtap_sms_message_type[tap_p->message_type]++;
98 stat_p->dtap_sm_message_type[tap_p->message_type]++;
101 stat_p->dtap_ss_message_type[tap_p->message_type]++;
113 * unknown PDU type !!!
126 gsm_a_stat_t *stat_p = tapdata;
131 printf("=========== GS=M A-i/f Statistics ============================\n");
133 printf("Message (ID)Type Number\n");
136 while (gsm_a_bssmap_msg_strings[i].strptr)
138 if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
140 printf("0x%02x %-50s%d\n",
141 gsm_a_bssmap_msg_strings[i].value,
142 gsm_a_bssmap_msg_strings[i].strptr,
143 stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
149 printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
150 printf("Message (ID)Type Number\n");
153 while (gsm_a_dtap_msg_mm_strings[i].strptr)
155 if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
157 printf("0x%02x %-50s%d\n",
158 gsm_a_dtap_msg_mm_strings[i].value,
159 gsm_a_dtap_msg_mm_strings[i].strptr,
160 stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
166 printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
167 printf("Message (ID)Type Number\n");
170 while (gsm_a_dtap_msg_rr_strings[i].strptr)
172 if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
174 printf("0x%02x %-50s%d\n",
175 gsm_a_dtap_msg_rr_strings[i].value,
176 gsm_a_dtap_msg_rr_strings[i].strptr,
177 stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
183 printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
184 printf("Message (ID)Type Number\n");
187 while (gsm_a_dtap_msg_cc_strings[i].strptr)
189 if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
191 printf("0x%02x %-50s%d\n",
192 gsm_a_dtap_msg_cc_strings[i].value,
193 gsm_a_dtap_msg_cc_strings[i].strptr,
194 stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
200 printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
201 printf("Message (ID)Type Number\n");
204 while (gsm_a_dtap_msg_gmm_strings[i].strptr)
206 if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
208 printf("0x%02x %-50s%d\n",
209 gsm_a_dtap_msg_gmm_strings[i].value,
210 gsm_a_dtap_msg_gmm_strings[i].strptr,
211 stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
217 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
218 printf("Message (ID)Type Number\n");
221 while (gsm_a_dtap_msg_sms_strings[i].strptr)
223 if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
225 printf("0x%02x %-50s%d\n",
226 gsm_a_dtap_msg_sms_strings[i].value,
227 gsm_a_dtap_msg_sms_strings[i].strptr,
228 stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
234 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
235 printf("Message (ID)Type Number\n");
238 while (gsm_a_dtap_msg_sm_strings[i].strptr)
240 if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
242 printf("0x%02x %-50s%d\n",
243 gsm_a_dtap_msg_sm_strings[i].value,
244 gsm_a_dtap_msg_sm_strings[i].strptr,
245 stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
251 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
252 printf("Message (ID)Type Number\n");
255 while (gsm_a_dtap_msg_ss_strings[i].strptr)
257 if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
259 printf("0x%02x %-50s%d\n",
260 gsm_a_dtap_msg_ss_strings[i].value,
261 gsm_a_dtap_msg_ss_strings[i].strptr,
262 stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
268 printf("==============================================================\n");
273 gsm_a_stat_init(const char *optarg _U_,void* userdata _U_)
275 gsm_a_stat_t *stat_p;
278 stat_p = g_malloc(sizeof(gsm_a_stat_t));
280 memset(stat_p, 0, sizeof(gsm_a_stat_t));
283 register_tap_listener("gsm_a", stat_p, NULL,
291 g_string_free(err_p, TRUE);
299 register_tap_listener_gsm_astat(void)
301 register_stat_cmd_arg("gsm_a,", gsm_a_stat_init,NULL);