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];
69 packet_info *pinfo _U_,
70 epan_dissect_t *edt _U_,
73 gsm_a_stat_t *stat_p = tapdata;
74 const gsm_a_tap_rec_t *tap_p = data;
76 switch (tap_p->pdu_type)
78 case BSSAP_PDU_TYPE_BSSMAP:
79 stat_p->bssmap_message_type[tap_p->message_type]++;
82 case BSSAP_PDU_TYPE_DTAP:
83 switch (tap_p->protocol_disc)
86 stat_p->dtap_cc_message_type[tap_p->message_type]++;
89 stat_p->dtap_mm_message_type[tap_p->message_type]++;
92 stat_p->dtap_rr_message_type[tap_p->message_type]++;
95 stat_p->dtap_gmm_message_type[tap_p->message_type]++;
98 stat_p->dtap_sms_message_type[tap_p->message_type]++;
101 stat_p->dtap_sm_message_type[tap_p->message_type]++;
104 stat_p->dtap_ss_message_type[tap_p->message_type]++;
116 * unknown PDU type !!!
129 gsm_a_stat_t *stat_p = tapdata;
134 printf("=========== GS=M A-i/f Statistics ============================\n");
136 printf("Message (ID)Type Number\n");
139 while (gsm_a_bssmap_msg_strings[i].strptr)
141 if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
143 printf("0x%02x %-50s%d\n",
144 gsm_a_bssmap_msg_strings[i].value,
145 gsm_a_bssmap_msg_strings[i].strptr,
146 stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
152 printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
153 printf("Message (ID)Type Number\n");
156 while (gsm_a_dtap_msg_mm_strings[i].strptr)
158 if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
160 printf("0x%02x %-50s%d\n",
161 gsm_a_dtap_msg_mm_strings[i].value,
162 gsm_a_dtap_msg_mm_strings[i].strptr,
163 stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
169 printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
170 printf("Message (ID)Type Number\n");
173 while (gsm_a_dtap_msg_rr_strings[i].strptr)
175 if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
177 printf("0x%02x %-50s%d\n",
178 gsm_a_dtap_msg_rr_strings[i].value,
179 gsm_a_dtap_msg_rr_strings[i].strptr,
180 stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
186 printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
187 printf("Message (ID)Type Number\n");
190 while (gsm_a_dtap_msg_cc_strings[i].strptr)
192 if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
194 printf("0x%02x %-50s%d\n",
195 gsm_a_dtap_msg_cc_strings[i].value,
196 gsm_a_dtap_msg_cc_strings[i].strptr,
197 stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
203 printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
204 printf("Message (ID)Type Number\n");
207 while (gsm_a_dtap_msg_gmm_strings[i].strptr)
209 if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
211 printf("0x%02x %-50s%d\n",
212 gsm_a_dtap_msg_gmm_strings[i].value,
213 gsm_a_dtap_msg_gmm_strings[i].strptr,
214 stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
220 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
221 printf("Message (ID)Type Number\n");
224 while (gsm_a_dtap_msg_sms_strings[i].strptr)
226 if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
228 printf("0x%02x %-50s%d\n",
229 gsm_a_dtap_msg_sms_strings[i].value,
230 gsm_a_dtap_msg_sms_strings[i].strptr,
231 stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
237 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
238 printf("Message (ID)Type Number\n");
241 while (gsm_a_dtap_msg_sm_strings[i].strptr)
243 if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
245 printf("0x%02x %-50s%d\n",
246 gsm_a_dtap_msg_sm_strings[i].value,
247 gsm_a_dtap_msg_sm_strings[i].strptr,
248 stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
254 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
255 printf("Message (ID)Type Number\n");
258 while (gsm_a_dtap_msg_ss_strings[i].strptr)
260 if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
262 printf("0x%02x %-50s%d\n",
263 gsm_a_dtap_msg_ss_strings[i].value,
264 gsm_a_dtap_msg_ss_strings[i].strptr,
265 stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
271 printf("==============================================================\n");
276 gsm_a_stat_init(char *optarg)
278 gsm_a_stat_t *stat_p;
284 stat_p = g_malloc(sizeof(gsm_a_stat_t));
286 memset(stat_p, 0, sizeof(gsm_a_stat_t));
289 register_tap_listener("gsm_a", stat_p, NULL,
297 g_string_free(err_p, TRUE);
305 register_tap_listener_gsm_astat(void)
307 register_ethereal_tap("gsm_a,", gsm_a_stat_init);