2 * h225 message counter for ethereal
3 * Copyright 2003 Lars Roland
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #ifdef HAVE_SYS_TYPES_H
33 # include <sys/types.h>
37 #include "epan/packet_info.h"
39 #include "epan/value_string.h"
41 #include <epan/dissectors/packet-h225.h>
43 /* following values represent the size of their valuestring arrays */
45 #define RAS_MSG_TYPES 33
46 #define CS_MSG_TYPES 13
49 #define RRJ_REASONS 18
52 #define ARJ_REASONS 22
56 #define LRJ_REASONS 16
57 #define IRQNAK_REASONS 4
58 #define REL_CMP_REASONS 26
59 #define FACILITY_REASONS 11
62 /* used to keep track of the statistics for an entire program interface */
63 typedef struct _h225counter_t {
65 guint32 ras_msg[RAS_MSG_TYPES + 1];
66 guint32 cs_msg[CS_MSG_TYPES + 1];
67 guint32 grj_reason[GRJ_REASONS + 1];
68 guint32 rrj_reason[RRJ_REASONS + 1];
69 guint32 urq_reason[URQ_REASONS + 1];
70 guint32 urj_reason[URJ_REASONS + 1];
71 guint32 arj_reason[ARJ_REASONS + 1];
72 guint32 brj_reason[BRJ_REASONS + 1];
73 guint32 drq_reason[DRQ_REASONS + 1];
74 guint32 drj_reason[DRJ_REASONS + 1];
75 guint32 lrj_reason[LRJ_REASONS + 1];
76 guint32 irqnak_reason[IRQNAK_REASONS + 1];
77 guint32 rel_cmp_reason[REL_CMP_REASONS + 1];
78 guint32 facility_reason[FACILITY_REASONS + 1];
83 h225counter_reset(void *phs)
85 h225counter_t *hs=(h225counter_t *)phs;
88 for(i=0;i<=RAS_MSG_TYPES;i++) {
91 for(i=0;i<=CS_MSG_TYPES;i++) {
94 for(i=0;i<=GRJ_REASONS;i++) {
95 hs->grj_reason[i] = 0;
97 for(i=0;i<=RRJ_REASONS;i++) {
98 hs->rrj_reason[i] = 0;
100 for(i=0;i<=URQ_REASONS;i++) {
101 hs->urq_reason[i] = 0;
103 for(i=0;i<=URJ_REASONS;i++) {
104 hs->urj_reason[i] = 0;
106 for(i=0;i<=ARJ_REASONS;i++) {
107 hs->arj_reason[i] = 0;
109 for(i=0;i<=BRJ_REASONS;i++) {
110 hs->brj_reason[i] = 0;
112 for(i=0;i<=DRQ_REASONS;i++) {
113 hs->drq_reason[i] = 0;
115 for(i=0;i<=DRJ_REASONS;i++) {
116 hs->drj_reason[i] = 0;
118 for(i=0;i<=LRJ_REASONS;i++) {
119 hs->lrj_reason[i] = 0;
121 for(i=0;i<=IRQNAK_REASONS;i++) {
122 hs->irqnak_reason[i] = 0;
124 for(i=0;i<=REL_CMP_REASONS;i++) {
125 hs->rel_cmp_reason[i] = 0;
127 for(i=0;i<=FACILITY_REASONS;i++) {
128 hs->facility_reason[i] = 0;
133 h225counter_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *phi)
135 h225counter_t *hs=(h225counter_t *)phs;
136 const h225_packet_info *pi=phi;
138 switch (pi->msg_type) {
141 if(pi->msg_tag==-1) { /* uninitialized */
144 else if (pi->msg_tag >= RAS_MSG_TYPES) { /* unknown */
145 hs->ras_msg[RAS_MSG_TYPES]++;
148 hs->ras_msg[pi->msg_tag]++;
151 /* Look for reason tag */
152 if(pi->reason==-1) { /* uninitialized */
156 switch(pi->msg_tag) {
159 if(pi->reason < GRJ_REASONS)
160 hs->grj_reason[pi->reason]++;
162 hs->grj_reason[GRJ_REASONS]++;
165 if(pi->reason < RRJ_REASONS)
166 hs->rrj_reason[pi->reason]++;
168 hs->rrj_reason[RRJ_REASONS]++;
171 if(pi->reason < URQ_REASONS)
172 hs->urq_reason[pi->reason]++;
174 hs->urq_reason[URQ_REASONS]++;
177 if(pi->reason < URJ_REASONS)
178 hs->urj_reason[pi->reason]++;
180 hs->urj_reason[URJ_REASONS]++;
183 if(pi->reason < ARJ_REASONS)
184 hs->arj_reason[pi->reason]++;
186 hs->arj_reason[ARJ_REASONS]++;
189 if(pi->reason < BRJ_REASONS)
190 hs->brj_reason[pi->reason]++;
192 hs->brj_reason[BRJ_REASONS]++;
195 if(pi->reason < DRQ_REASONS)
196 hs->drq_reason[pi->reason]++;
198 hs->drq_reason[DRQ_REASONS]++;
201 if(pi->reason < DRJ_REASONS)
202 hs->drj_reason[pi->reason]++;
204 hs->drj_reason[DRJ_REASONS]++;
207 if(pi->reason < LRJ_REASONS)
208 hs->lrj_reason[pi->reason]++;
210 hs->lrj_reason[LRJ_REASONS]++;
212 case 29: /* IRQ Nak */
213 if(pi->reason < IRQNAK_REASONS)
214 hs->irqnak_reason[pi->reason]++;
216 hs->irqnak_reason[IRQNAK_REASONS]++;
227 if(pi->msg_tag==-1) { /* uninitialized */
230 else if (pi->msg_tag >= CS_MSG_TYPES) { /* unknown */
231 hs->cs_msg[CS_MSG_TYPES]++;
234 hs->cs_msg[pi->msg_tag]++;
237 /* Look for reason tag */
238 if(pi->reason==-1) { /* uninitialized */
242 switch(pi->msg_tag) {
244 case 5: /* ReleaseComplete */
245 if(pi->reason < REL_CMP_REASONS)
246 hs->rel_cmp_reason[pi->reason]++;
248 hs->rel_cmp_reason[REL_CMP_REASONS]++;
250 case 6: /* Facility */
251 if(pi->reason < FACILITY_REASONS)
252 hs->facility_reason[pi->reason]++;
254 hs->facility_reason[FACILITY_REASONS]++;
273 h225counter_draw(void *phs)
275 h225counter_t *hs=(h225counter_t *)phs;
278 printf("================== H225 Message and Reason Counter ==================\n");
279 printf("RAS-Messages:\n");
280 for(i=0;i<=RAS_MSG_TYPES;i++) {
281 if(hs->ras_msg[i]!=0) {
282 printf(" %s : %u\n", val_to_str(i,RasMessage_vals,"unknown ras-messages "), hs->ras_msg[i]);
286 for(j=0;j<=GRJ_REASONS;j++) {
287 if(hs->grj_reason[j]!=0) {
288 printf(" %s : %u\n", val_to_str(j,GatekeeperRejectReason_vals,"unknown reason "), hs->grj_reason[j]);
293 for(j=0;j<=RRJ_REASONS;j++) {
294 if(hs->rrj_reason[j]!=0) {
295 printf(" %s : %u\n", val_to_str(j,RegistrationRejectReason_vals,"unknown reason "), hs->rrj_reason[j]);
300 for(j=0;j<=URQ_REASONS;j++) {
301 if(hs->urq_reason[j]!=0) {
302 printf(" %s : %u\n", val_to_str(j,UnregRequestReason_vals,"unknown reason "), hs->urq_reason[j]);
307 for(j=0;j<=URJ_REASONS;j++) {
308 if(hs->urj_reason[j]!=0) {
309 printf(" %s : %u\n", val_to_str(j,UnregRejectReason_vals,"unknown reason "), hs->urj_reason[j]);
314 for(j=0;j<=ARJ_REASONS;j++) {
315 if(hs->arj_reason[j]!=0) {
316 printf(" %s : %u\n", val_to_str(j,AdmissionRejectReason_vals,"unknown reason "), hs->arj_reason[j]);
321 for(j=0;j<=BRJ_REASONS;j++) {
322 if(hs->brj_reason[j]!=0) {
323 printf(" %s : %u\n", val_to_str(j,BandRejectReason_vals,"unknown reason "), hs->brj_reason[j]);
328 for(j=0;j<=DRQ_REASONS;j++) {
329 if(hs->drq_reason[j]!=0) {
330 printf(" %s : %u\n", val_to_str(j,DisengageReason_vals,"unknown reason "), hs->drq_reason[j]);
335 for(j=0;j<=DRJ_REASONS;j++) {
336 if(hs->drj_reason[j]!=0) {
337 printf(" %s : %u\n", val_to_str(j,DisengageRejectReason_vals,"unknown reason "), hs->drj_reason[j]);
342 for(j=0;j<=LRJ_REASONS;j++) {
343 if(hs->lrj_reason[j]!=0) {
344 printf(" %s : %u\n", val_to_str(j,LocationRejectReason_vals,"unknown reason "), hs->lrj_reason[j]);
347 case 29: /* IRQNak */
348 for(j=0;j<=IRQNAK_REASONS;j++) {
349 if(hs->irqnak_reason[j]!=0) {
350 printf(" %s : %u\n", val_to_str(j,InfoRequestNakReason_vals,"unknown reason "), hs->irqnak_reason[j]);
357 /* end of reason counter*/
360 printf("Call Signalling:\n");
361 for(i=0;i<=CS_MSG_TYPES;i++) {
362 if(hs->cs_msg[i]!=0) {
363 printf(" %s : %u\n", val_to_str(i,T_h323_message_body_vals,"unknown cs-messages "), hs->cs_msg[i]);
366 case 5: /* ReleaseComplete */
367 for(j=0;j<=REL_CMP_REASONS;j++) {
368 if(hs->rel_cmp_reason[j]!=0) {
369 printf(" %s : %u\n", val_to_str(j,ReleaseCompleteReason_vals,"unknown reason "), hs->rel_cmp_reason[j]);
373 case 6: /* Facility */
374 for(j=0;j<=FACILITY_REASONS;j++) {
375 if(hs->facility_reason[j]!=0) {
376 printf(" %s : %u\n", val_to_str(j,FacilityReason_vals,"unknown reason "), hs->facility_reason[j]);
385 printf("=====================================================================\n");
390 h225counter_init(const char *optarg)
393 const char *filter=NULL;
394 GString *error_string;
396 if(!strncmp(optarg,"h225,counter,",13)){
402 hs = g_malloc(sizeof(h225counter_t));
403 hs->filter=g_malloc(strlen(filter)+1);
404 strcpy(hs->filter, filter);
406 h225counter_reset(hs);
408 error_string=register_tap_listener("h225", hs, filter, NULL, h225counter_packet, h225counter_draw);
410 /* error, we failed to attach to the tap. clean up */
414 fprintf(stderr, "tethereal: Couldn't register h225,counter tap: %s\n",
416 g_string_free(error_string, TRUE);
423 register_tap_listener_h225counter(void)
425 register_tap_listener_cmd_arg("h225,counter", h225counter_init);