3 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
4 * In association with Telos Technology Inc.
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
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:
31 /* With MSVC and a libethereal.dll this file needs to import some variables
32 in a special way. Therefore _NEED_VAR_IMPORT_ is defined. */
33 #define _NEED_VAR_IMPORT_
41 #ifdef HAVE_SYS_TYPES_H
42 # include <sys/types.h>
46 #include "epan/packet_info.h"
47 #include "epan/value_string.h"
49 #include <epan/dissectors/packet-bssap.h>
50 #include <epan/dissectors/packet-gsm_a.h>
54 typedef struct _gsm_a_stat_t {
55 int bssmap_message_type[0xff];
56 int dtap_mm_message_type[0xff];
57 int dtap_rr_message_type[0xff];
58 int dtap_cc_message_type[0xff];
59 int dtap_gmm_message_type[0xff];
60 int dtap_sms_message_type[0xff];
61 int dtap_sm_message_type[0xff];
62 int dtap_ss_message_type[0xff];
70 epan_dissect_t *edt _U_,
73 gsm_a_stat_t *stat_p = tapdata;
74 gsm_a_tap_rec_t *tap_p = data;
79 switch (tap_p->pdu_type)
81 case BSSAP_PDU_TYPE_BSSMAP:
82 stat_p->bssmap_message_type[tap_p->message_type]++;
85 case BSSAP_PDU_TYPE_DTAP:
86 switch (tap_p->protocol_disc)
89 stat_p->dtap_cc_message_type[tap_p->message_type]++;
92 stat_p->dtap_mm_message_type[tap_p->message_type]++;
95 stat_p->dtap_rr_message_type[tap_p->message_type]++;
98 stat_p->dtap_gmm_message_type[tap_p->message_type]++;
101 stat_p->dtap_sms_message_type[tap_p->message_type]++;
104 stat_p->dtap_sm_message_type[tap_p->message_type]++;
107 stat_p->dtap_ss_message_type[tap_p->message_type]++;
119 * unknown PDU type !!!
132 gsm_a_stat_t *stat_p = tapdata;
137 printf("=========== GS=M A-i/f Statistics ============================\n");
139 printf("Message (ID)Type Number\n");
142 while (gsm_a_bssmap_msg_strings[i].strptr)
144 if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
146 printf("0x%02x %-50s%d\n",
147 gsm_a_bssmap_msg_strings[i].value,
148 gsm_a_bssmap_msg_strings[i].strptr,
149 stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
155 printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
156 printf("Message (ID)Type Number\n");
159 while (gsm_a_dtap_msg_mm_strings[i].strptr)
161 if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
163 printf("0x%02x %-50s%d\n",
164 gsm_a_dtap_msg_mm_strings[i].value,
165 gsm_a_dtap_msg_mm_strings[i].strptr,
166 stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
172 printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
173 printf("Message (ID)Type Number\n");
176 while (gsm_a_dtap_msg_rr_strings[i].strptr)
178 if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
180 printf("0x%02x %-50s%d\n",
181 gsm_a_dtap_msg_rr_strings[i].value,
182 gsm_a_dtap_msg_rr_strings[i].strptr,
183 stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
189 printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
190 printf("Message (ID)Type Number\n");
193 while (gsm_a_dtap_msg_cc_strings[i].strptr)
195 if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
197 printf("0x%02x %-50s%d\n",
198 gsm_a_dtap_msg_cc_strings[i].value,
199 gsm_a_dtap_msg_cc_strings[i].strptr,
200 stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
206 printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
207 printf("Message (ID)Type Number\n");
210 while (gsm_a_dtap_msg_gmm_strings[i].strptr)
212 if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
214 printf("0x%02x %-50s%d\n",
215 gsm_a_dtap_msg_gmm_strings[i].value,
216 gsm_a_dtap_msg_gmm_strings[i].strptr,
217 stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
223 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
224 printf("Message (ID)Type Number\n");
227 while (gsm_a_dtap_msg_sms_strings[i].strptr)
229 if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
231 printf("0x%02x %-50s%d\n",
232 gsm_a_dtap_msg_sms_strings[i].value,
233 gsm_a_dtap_msg_sms_strings[i].strptr,
234 stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
240 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
241 printf("Message (ID)Type Number\n");
244 while (gsm_a_dtap_msg_sm_strings[i].strptr)
246 if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
248 printf("0x%02x %-50s%d\n",
249 gsm_a_dtap_msg_sm_strings[i].value,
250 gsm_a_dtap_msg_sm_strings[i].strptr,
251 stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
257 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
258 printf("Message (ID)Type Number\n");
261 while (gsm_a_dtap_msg_ss_strings[i].strptr)
263 if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
265 printf("0x%02x %-50s%d\n",
266 gsm_a_dtap_msg_ss_strings[i].value,
267 gsm_a_dtap_msg_ss_strings[i].strptr,
268 stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
274 printf("==============================================================\n");
279 gsm_a_stat_init(char *optarg)
281 gsm_a_stat_t *stat_p;
287 stat_p = g_malloc(sizeof(gsm_a_stat_t));
289 memset(stat_p, 0, sizeof(gsm_a_stat_t));
292 register_tap_listener("gsm_a", stat_p, NULL,
300 g_string_free(err_p, TRUE);
308 register_tap_listener_gsm_astat(void)
310 register_ethereal_tap("gsm_a,", gsm_a_stat_init);