LATER... ei_kerberos_kdc_session_key ...
[wireshark-sm.git] / ui / cli / tap-gsm_astat.c
blob8ecf93847aeb2fa3f47ee02a54fc2d3422c8ef27
1 /* tap-gsm_astat.c
3 * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
4 * In association with Telos Technology Inc.
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
14 * This TAP provides statistics for the GSM A Interface:
17 #include "config.h"
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
23 #include <glib.h>
25 #include <epan/packet_info.h>
26 #include <epan/value_string.h>
27 #include <epan/tap.h>
28 #include <epan/stat_tap_ui.h>
29 #include <epan/dissectors/packet-bssap.h>
30 #include <epan/dissectors/packet-gsm_a_common.h>
32 void register_tap_listener_gsm_astat(void);
34 typedef struct _gsm_a_stat_t {
35 int bssmap_message_type[0x100];
36 int dtap_mm_message_type[0x100];
37 int dtap_rr_message_type[0x100];
38 int dtap_cc_message_type[0x100];
39 int dtap_gmm_message_type[0x100];
40 int dtap_sms_message_type[0x100];
41 int dtap_sm_message_type[0x100];
42 int dtap_ss_message_type[0x100];
43 int dtap_tp_message_type[0x100];
44 int sacch_rr_message_type[0x100];
45 } gsm_a_stat_t;
48 static tap_packet_status
49 gsm_a_stat_packet(
50 void *tapdata,
51 packet_info *pinfo _U_,
52 epan_dissect_t *edt _U_,
53 const void *data,
54 tap_flags_t flags _U_)
56 gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
57 const gsm_a_tap_rec_t *tap_p = (const gsm_a_tap_rec_t *)data;
59 switch (tap_p->pdu_type)
61 case BSSAP_PDU_TYPE_BSSMAP:
62 stat_p->bssmap_message_type[tap_p->message_type]++;
63 break;
65 case BSSAP_PDU_TYPE_DTAP:
66 switch (tap_p->protocol_disc)
68 case PD_CC:
69 stat_p->dtap_cc_message_type[tap_p->message_type]++;
70 break;
71 case PD_MM:
72 stat_p->dtap_mm_message_type[tap_p->message_type]++;
73 break;
74 case PD_RR:
75 stat_p->dtap_rr_message_type[tap_p->message_type]++;
76 break;
77 case PD_GMM:
78 stat_p->dtap_gmm_message_type[tap_p->message_type]++;
79 break;
80 case PD_SMS:
81 stat_p->dtap_sms_message_type[tap_p->message_type]++;
82 break;
83 case PD_SM:
84 stat_p->dtap_sm_message_type[tap_p->message_type]++;
85 break;
86 case PD_SS:
87 stat_p->dtap_ss_message_type[tap_p->message_type]++;
88 break;
89 case PD_TP:
90 stat_p->dtap_tp_message_type[tap_p->message_type]++;
91 break;
92 default:
94 * unsupported PD
96 return(TAP_PACKET_DONT_REDRAW);
98 break;
100 case GSM_A_PDU_TYPE_SACCH:
101 switch (tap_p->protocol_disc)
103 case 0:
104 stat_p->sacch_rr_message_type[tap_p->message_type]++;
105 break;
106 default:
107 /* unknown Short PD */
108 break;
110 break;
112 default:
114 * unknown PDU type !!!
116 return(TAP_PACKET_DONT_REDRAW);
119 return(TAP_PACKET_REDRAW);
123 static void
124 gsm_a_stat_draw(
125 void *tapdata)
127 gsm_a_stat_t *stat_p = (gsm_a_stat_t *)tapdata;
128 uint8_t i;
131 printf("\n");
132 printf("=========== GS=M A-i/f Statistics ============================\n");
133 printf("BSSMAP\n");
134 printf("Message (ID)Type Number\n");
136 i = 0;
137 while (gsm_a_bssmap_msg_strings[i].strptr)
139 if (stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value] > 0)
141 printf("0x%02x %-50s%d\n",
142 gsm_a_bssmap_msg_strings[i].value,
143 gsm_a_bssmap_msg_strings[i].strptr,
144 stat_p->bssmap_message_type[gsm_a_bssmap_msg_strings[i].value]);
147 i++;
150 printf("\nDTAP %s\n", gsm_a_pd_str[PD_MM]);
151 printf("Message (ID)Type Number\n");
153 i = 0;
154 while (gsm_a_dtap_msg_mm_strings[i].strptr)
156 if (stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value] > 0)
158 printf("0x%02x %-50s%d\n",
159 gsm_a_dtap_msg_mm_strings[i].value,
160 gsm_a_dtap_msg_mm_strings[i].strptr,
161 stat_p->dtap_mm_message_type[gsm_a_dtap_msg_mm_strings[i].value]);
164 i++;
167 printf("\nDTAP %s\n", gsm_a_pd_str[PD_RR]);
168 printf("Message (ID)Type Number\n");
170 i = 0;
171 while (gsm_a_dtap_msg_rr_strings[i].strptr)
173 if (stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value] > 0)
175 printf("0x%02x %-50s%d\n",
176 gsm_a_dtap_msg_rr_strings[i].value,
177 gsm_a_dtap_msg_rr_strings[i].strptr,
178 stat_p->dtap_rr_message_type[gsm_a_dtap_msg_rr_strings[i].value]);
181 i++;
184 printf("\nDTAP %s\n", gsm_a_pd_str[PD_CC]);
185 printf("Message (ID)Type Number\n");
187 i = 0;
188 while (gsm_a_dtap_msg_cc_strings[i].strptr)
190 if (stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value] > 0)
192 printf("0x%02x %-50s%d\n",
193 gsm_a_dtap_msg_cc_strings[i].value,
194 gsm_a_dtap_msg_cc_strings[i].strptr,
195 stat_p->dtap_cc_message_type[gsm_a_dtap_msg_cc_strings[i].value]);
198 i++;
201 printf("\nDTAP %s\n", gsm_a_pd_str[PD_GMM]);
202 printf("Message (ID)Type Number\n");
204 i = 0;
205 while (gsm_a_dtap_msg_gmm_strings[i].strptr)
207 if (stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value] > 0)
209 printf("0x%02x %-50s%d\n",
210 gsm_a_dtap_msg_gmm_strings[i].value,
211 gsm_a_dtap_msg_gmm_strings[i].strptr,
212 stat_p->dtap_gmm_message_type[gsm_a_dtap_msg_gmm_strings[i].value]);
215 i++;
218 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SMS]);
219 printf("Message (ID)Type Number\n");
221 i = 0;
222 while (gsm_a_dtap_msg_sms_strings[i].strptr)
224 if (stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value] > 0)
226 printf("0x%02x %-50s%d\n",
227 gsm_a_dtap_msg_sms_strings[i].value,
228 gsm_a_dtap_msg_sms_strings[i].strptr,
229 stat_p->dtap_sms_message_type[gsm_a_dtap_msg_sms_strings[i].value]);
232 i++;
235 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SM]);
236 printf("Message (ID)Type Number\n");
238 i = 0;
239 while (gsm_a_dtap_msg_sm_strings[i].strptr)
241 if (stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value] > 0)
243 printf("0x%02x %-50s%d\n",
244 gsm_a_dtap_msg_sm_strings[i].value,
245 gsm_a_dtap_msg_sm_strings[i].strptr,
246 stat_p->dtap_sm_message_type[gsm_a_dtap_msg_sm_strings[i].value]);
249 i++;
252 printf("\nDTAP %s\n", gsm_a_pd_str[PD_SS]);
253 printf("Message (ID)Type Number\n");
255 i = 0;
256 while (gsm_a_dtap_msg_ss_strings[i].strptr)
258 if (stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value] > 0)
260 printf("0x%02x %-50s%d\n",
261 gsm_a_dtap_msg_ss_strings[i].value,
262 gsm_a_dtap_msg_ss_strings[i].strptr,
263 stat_p->dtap_ss_message_type[gsm_a_dtap_msg_ss_strings[i].value]);
266 i++;
269 printf("\nDTAP %s\n", gsm_a_pd_str[PD_TP]);
270 printf("Message (ID)Type Number\n");
272 i = 0;
273 while (gsm_a_dtap_msg_tp_strings[i].strptr)
275 if (stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value] > 0)
277 printf("0x%02x %-50s%d\n",
278 gsm_a_dtap_msg_tp_strings[i].value,
279 gsm_a_dtap_msg_tp_strings[i].strptr,
280 stat_p->dtap_tp_message_type[gsm_a_dtap_msg_tp_strings[i].value]);
283 i++;
286 printf("\nSACCH Radio Resources Management messages\n");
287 printf("Message (ID)Type Number\n");
289 i = 0;
290 while (gsm_a_rr_short_pd_msg_strings[i].strptr)
292 if (stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value] > 0)
294 printf("0x%02x %-50s%d\n",
295 gsm_a_rr_short_pd_msg_strings[i].value,
296 gsm_a_rr_short_pd_msg_strings[i].strptr,
297 stat_p->sacch_rr_message_type[gsm_a_rr_short_pd_msg_strings[i].value]);
300 i++;
303 printf("==============================================================\n");
307 static void
308 gsm_a_stat_init(const char *opt_arg _U_, void *userdata _U_)
310 gsm_a_stat_t *stat_p;
311 GString *err_p;
313 stat_p = g_new(gsm_a_stat_t, 1);
315 memset(stat_p, 0, sizeof(gsm_a_stat_t));
317 err_p =
318 register_tap_listener("gsm_a", stat_p, NULL, 0,
319 NULL,
320 gsm_a_stat_packet,
321 gsm_a_stat_draw,
322 NULL);
324 if (err_p != NULL)
326 g_free(stat_p);
327 g_string_free(err_p, TRUE);
329 exit(1);
333 static stat_tap_ui gsm_a_stat_ui = {
334 REGISTER_STAT_GROUP_GENERIC,
335 NULL,
336 "gsm_a",
337 gsm_a_stat_init,
339 NULL
342 void
343 register_tap_listener_gsm_astat(void)
345 register_stat_tap_ui(&gsm_a_stat_ui, NULL);