1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
/* tap-gsm_astat.c
*
* Copyright 2003, Michael Lum <mlum [AT] telostech.com>
* In association with Telos Technology Inc.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/*
* This TAP provides statistics for the GSM A Interface:
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/stat_tap_ui.h>
#include <epan/dissectors/packet-bssap.h>
#include <epan/dissectors/packet-gsm_a_common.h>
void register_tap_listener_gsm_astat(void);
typedef struct _gsm_a_stat_t {
int bssmap_message_type[0x100];
int dtap_mm_message_type[0x100];
int dtap_rr_message_type[0x100];
int dtap_cc_message_type[0x100];
int dtap_gmm_message_type[0x100];
int dtap_sms_message_type[0x100];
int dtap_sm_message_type[0x100];
int dtap_ss_message_type[0x100];
int dtap_tp_message_type[0x100];
int sacch_rr_message_type[0x100];
} gsm_a_stat_t;
static tap_packet_status
gsm_a_stat_packet(
void *tapdata,
packet_info *pinfo _U_,
epan_dissect_t *edt _U_,
const void *data,
tap_flags_t flags _U_)
{
gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
const gsm_a_tap_rec_t *tap_p = (const gsm_a_tap_rec_t *)data;
switch (tap_p->pdu_type)
{
case BSSAP_PDU_TYPE_BSSMAP:
stat_p->bssmap_message_type[tap_p->message_type]++;
break;
case BSSAP_PDU_TYPE_DTAP:
switch (tap_p->protocol_disc)
{
case PD_CC:
stat_p->dtap_cc_message_type[tap_p->message_type]++;
break;
case PD_MM:
stat_p->dtap_mm_message_type[tap_p->message_type]++;
break;
case PD_RR:
stat_p->dtap_rr_message_type[tap_p->message_type]++;
break;
case PD_GMM:
stat_p->dtap_gmm_message_type[tap_p->message_type]++;
break;
case PD_SMS:
stat_p->dtap_sms_message_type[tap_p->message_type]++;
break;
case PD_SM:
stat_p->dtap_sm_message_type[tap_p->message_type]++;
break;
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
*/
return(TAP_PACKET_DONT_REDRAW);
}
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 !!!
*/
return(TAP_PACKET_DONT_REDRAW);
}
return(TAP_PACKET_REDRAW);
}
static void
gsm_a_stat_draw(
void *tapdata)
{
gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
guint8 i;
printf("\n");
printf("=========== GS=M A-i/f Statistics ============================\n");
printf("BSSMAP\n");
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_bssmap_msg_strings[i].strptr)
{
if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_bssmap_msg_strings[i].value,
gsm_a_bssmap_msg_strings[i].strptr,
stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_mm_strings[i].strptr)
{
if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_mm_strings[i].value,
gsm_a_dtap_msg_mm_strings[i].strptr,
stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_rr_strings[i].strptr)
{
if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_rr_strings[i].value,
gsm_a_dtap_msg_rr_strings[i].strptr,
stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_cc_strings[i].strptr)
{
if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_cc_strings[i].value,
gsm_a_dtap_msg_cc_strings[i].strptr,
stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_gmm_strings[i].strptr)
{
if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_gmm_strings[i].value,
gsm_a_dtap_msg_gmm_strings[i].strptr,
stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_sms_strings[i].strptr)
{
if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_sms_strings[i].value,
gsm_a_dtap_msg_sms_strings[i].strptr,
stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_sm_strings[i].strptr)
{
if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_sm_strings[i].value,
gsm_a_dtap_msg_sm_strings[i].strptr,
stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
}
i++;
}
printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
printf("Message (ID)Type Number\n");
i = 0;
while (gsm_a_dtap_msg_ss_strings[i].strptr)
{
if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
{
printf("0x%02x %-50s%d\n",
gsm_a_dtap_msg_ss_strings[i].value,
gsm_a_dtap_msg_ss_strings[i].strptr,
stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
}
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(const char *opt_arg _U_, void *userdata _U_)
{
gsm_a_stat_t *stat_p;
GString *err_p;
stat_p = g_new(gsm_a_stat_t, 1);
memset(stat_p, 0, sizeof(gsm_a_stat_t));
err_p =
register_tap_listener("gsm_a", stat_p, NULL, 0,
NULL,
gsm_a_stat_packet,
gsm_a_stat_draw,
NULL);
if (err_p != NULL)
{
g_free(stat_p);
g_string_free(err_p, TRUE);
exit(1);
}
}
static stat_tap_ui gsm_a_stat_ui = {
REGISTER_STAT_GROUP_GENERIC,
NULL,
"gsm_a",
gsm_a_stat_init,
0,
NULL
};
void
register_tap_listener_gsm_astat(void)
{
register_stat_tap_ui(&gsm_a_stat_ui, NULL);
}
|