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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * This TAP provides statistics for the GSM A Interface:
37 #include "epan/packet_info.h"
38 #include "epan/value_string.h"
40 #include <epan/stat_cmd_args.h>
41 #include <epan/dissectors/packet-bssap.h>
42 #include <epan/dissectors/packet-gsm_a_common.h>
44 void register_tap_listener_gsm_astat(void);
46 typedef struct _gsm_a_stat_t
{
47 int bssmap_message_type
[0xff];
48 int dtap_mm_message_type
[0xff];
49 int dtap_rr_message_type
[0xff];
50 int dtap_cc_message_type
[0xff];
51 int dtap_gmm_message_type
[0xff];
52 int dtap_sms_message_type
[0xff];
53 int dtap_sm_message_type
[0xff];
54 int dtap_ss_message_type
[0xff];
55 int dtap_tp_message_type
[0xff];
56 int sacch_rr_message_type
[0xff];
63 packet_info
*pinfo _U_
,
64 epan_dissect_t
*edt _U_
,
67 gsm_a_stat_t
*stat_p
= (gsm_a_stat_t
*)tapdata
;
68 const gsm_a_tap_rec_t
*tap_p
= (const gsm_a_tap_rec_t
*)data
;
70 switch (tap_p
->pdu_type
)
72 case BSSAP_PDU_TYPE_BSSMAP
:
73 stat_p
->bssmap_message_type
[tap_p
->message_type
]++;
76 case BSSAP_PDU_TYPE_DTAP
:
77 switch (tap_p
->protocol_disc
)
80 stat_p
->dtap_cc_message_type
[tap_p
->message_type
]++;
83 stat_p
->dtap_mm_message_type
[tap_p
->message_type
]++;
86 stat_p
->dtap_rr_message_type
[tap_p
->message_type
]++;
89 stat_p
->dtap_gmm_message_type
[tap_p
->message_type
]++;
92 stat_p
->dtap_sms_message_type
[tap_p
->message_type
]++;
95 stat_p
->dtap_sm_message_type
[tap_p
->message_type
]++;
98 stat_p
->dtap_ss_message_type
[tap_p
->message_type
]++;
101 stat_p
->dtap_tp_message_type
[tap_p
->message_type
]++;
111 case GSM_A_PDU_TYPE_SACCH
:
112 switch (tap_p
->protocol_disc
)
115 stat_p
->sacch_rr_message_type
[tap_p
->message_type
]++;
118 /* unknown Short PD */
126 * unknown PDU type !!!
139 gsm_a_stat_t
*stat_p
= (gsm_a_stat_t
*)tapdata
;
144 printf("=========== GS=M A-i/f Statistics ============================\n");
146 printf("Message (ID)Type Number\n");
149 while (gsm_a_bssmap_msg_strings
[i
].strptr
)
151 if (stat_p
->bssmap_message_type
[gsm_a_bssmap_msg_strings
[i
].value
] > 0)
153 printf("0x%02x %-50s%d\n",
154 gsm_a_bssmap_msg_strings
[i
].value
,
155 gsm_a_bssmap_msg_strings
[i
].strptr
,
156 stat_p
->bssmap_message_type
[gsm_a_bssmap_msg_strings
[i
].value
]);
162 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_MM
]);
163 printf("Message (ID)Type Number\n");
166 while (gsm_a_dtap_msg_mm_strings
[i
].strptr
)
168 if (stat_p
->dtap_mm_message_type
[gsm_a_dtap_msg_mm_strings
[i
].value
] > 0)
170 printf("0x%02x %-50s%d\n",
171 gsm_a_dtap_msg_mm_strings
[i
].value
,
172 gsm_a_dtap_msg_mm_strings
[i
].strptr
,
173 stat_p
->dtap_mm_message_type
[gsm_a_dtap_msg_mm_strings
[i
].value
]);
179 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_RR
]);
180 printf("Message (ID)Type Number\n");
183 while (gsm_a_dtap_msg_rr_strings
[i
].strptr
)
185 if (stat_p
->dtap_rr_message_type
[gsm_a_dtap_msg_rr_strings
[i
].value
] > 0)
187 printf("0x%02x %-50s%d\n",
188 gsm_a_dtap_msg_rr_strings
[i
].value
,
189 gsm_a_dtap_msg_rr_strings
[i
].strptr
,
190 stat_p
->dtap_rr_message_type
[gsm_a_dtap_msg_rr_strings
[i
].value
]);
196 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_CC
]);
197 printf("Message (ID)Type Number\n");
200 while (gsm_a_dtap_msg_cc_strings
[i
].strptr
)
202 if (stat_p
->dtap_cc_message_type
[gsm_a_dtap_msg_cc_strings
[i
].value
] > 0)
204 printf("0x%02x %-50s%d\n",
205 gsm_a_dtap_msg_cc_strings
[i
].value
,
206 gsm_a_dtap_msg_cc_strings
[i
].strptr
,
207 stat_p
->dtap_cc_message_type
[gsm_a_dtap_msg_cc_strings
[i
].value
]);
213 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_GMM
]);
214 printf("Message (ID)Type Number\n");
217 while (gsm_a_dtap_msg_gmm_strings
[i
].strptr
)
219 if (stat_p
->dtap_gmm_message_type
[gsm_a_dtap_msg_gmm_strings
[i
].value
] > 0)
221 printf("0x%02x %-50s%d\n",
222 gsm_a_dtap_msg_gmm_strings
[i
].value
,
223 gsm_a_dtap_msg_gmm_strings
[i
].strptr
,
224 stat_p
->dtap_gmm_message_type
[gsm_a_dtap_msg_gmm_strings
[i
].value
]);
230 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_SMS
]);
231 printf("Message (ID)Type Number\n");
234 while (gsm_a_dtap_msg_sms_strings
[i
].strptr
)
236 if (stat_p
->dtap_sms_message_type
[gsm_a_dtap_msg_sms_strings
[i
].value
] > 0)
238 printf("0x%02x %-50s%d\n",
239 gsm_a_dtap_msg_sms_strings
[i
].value
,
240 gsm_a_dtap_msg_sms_strings
[i
].strptr
,
241 stat_p
->dtap_sms_message_type
[gsm_a_dtap_msg_sms_strings
[i
].value
]);
247 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_SM
]);
248 printf("Message (ID)Type Number\n");
251 while (gsm_a_dtap_msg_sm_strings
[i
].strptr
)
253 if (stat_p
->dtap_sm_message_type
[gsm_a_dtap_msg_sm_strings
[i
].value
] > 0)
255 printf("0x%02x %-50s%d\n",
256 gsm_a_dtap_msg_sm_strings
[i
].value
,
257 gsm_a_dtap_msg_sm_strings
[i
].strptr
,
258 stat_p
->dtap_sm_message_type
[gsm_a_dtap_msg_sm_strings
[i
].value
]);
264 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_SS
]);
265 printf("Message (ID)Type Number\n");
268 while (gsm_a_dtap_msg_ss_strings
[i
].strptr
)
270 if (stat_p
->dtap_ss_message_type
[gsm_a_dtap_msg_ss_strings
[i
].value
] > 0)
272 printf("0x%02x %-50s%d\n",
273 gsm_a_dtap_msg_ss_strings
[i
].value
,
274 gsm_a_dtap_msg_ss_strings
[i
].strptr
,
275 stat_p
->dtap_ss_message_type
[gsm_a_dtap_msg_ss_strings
[i
].value
]);
281 printf("\nDTAP %s\n", gsm_a_pd_str
[PD_TP
]);
282 printf("Message (ID)Type Number\n");
285 while (gsm_a_dtap_msg_tp_strings
[i
].strptr
)
287 if (stat_p
->dtap_tp_message_type
[gsm_a_dtap_msg_tp_strings
[i
].value
] > 0)
289 printf("0x%02x %-50s%d\n",
290 gsm_a_dtap_msg_tp_strings
[i
].value
,
291 gsm_a_dtap_msg_tp_strings
[i
].strptr
,
292 stat_p
->dtap_tp_message_type
[gsm_a_dtap_msg_tp_strings
[i
].value
]);
298 printf("\nSACCH Radio Resources Management messages\n");
299 printf("Message (ID)Type Number\n");
302 while (gsm_a_rr_short_pd_msg_strings
[i
].strptr
)
304 if (stat_p
->sacch_rr_message_type
[gsm_a_rr_short_pd_msg_strings
[i
].value
] > 0)
306 printf("0x%02x %-50s%d\n",
307 gsm_a_rr_short_pd_msg_strings
[i
].value
,
308 gsm_a_rr_short_pd_msg_strings
[i
].strptr
,
309 stat_p
->sacch_rr_message_type
[gsm_a_rr_short_pd_msg_strings
[i
].value
]);
315 printf("==============================================================\n");
320 gsm_a_stat_init(const char *opt_arg _U_
,void* userdata _U_
)
322 gsm_a_stat_t
*stat_p
;
325 stat_p
= g_new(gsm_a_stat_t
,1);
327 memset(stat_p
, 0, sizeof(gsm_a_stat_t
));
330 register_tap_listener("gsm_a", stat_p
, NULL
, 0,
338 g_string_free(err_p
, TRUE
);
346 register_tap_listener_gsm_astat(void)
348 register_stat_cmd_arg("gsm_a,", gsm_a_stat_init
,NULL
);