2 * h225 message counter for ethereal
3 * Copyright 2003 Lars Roland
5 * $Id: tap-h225counter.c,v 1.1 2003/10/28 00:31:16 guy Exp $
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 "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
63 static const value_string RasMessage_vals[] = {
64 { 0, "gatekeeperRequest" },
65 { 1, "gatekeeperConfirm" },
66 { 2, "gatekeeperReject" },
67 { 3, "registrationRequest" },
68 { 4, "registrationConfirm" },
69 { 5, "registrationReject" },
70 { 6, "unregistrationRequest" },
71 { 7, "unregistrationConfirm" },
72 { 8, "unregistrationReject" },
73 { 9, "admissionRequest" },
74 {10, "admissionConfirm" },
75 {11, "admissionReject" },
76 {12, "bandwidthRequest" },
77 {13, "bandwidthConfirm" },
78 {14, "bandwidthReject" },
79 {15, "disengageRequest" },
80 {16, "disengageConfirm" },
81 {17, "disengageReject" },
82 {18, "locationRequest" },
83 {19, "locationConfirm" },
84 {20, "locationReject" },
86 {22, "infoRequestResponse" },
87 {23, "nonStandardMessage" },
88 {24, "unknownMessageResponse" },
89 {25, "requestInProgress" },
90 {26, "resourcesAvailableIndicate" },
91 {27, "resourcesAvailableConfirm" },
92 {28, "infoRequestAck" },
93 {29, "infoRequestNak" },
94 {30, "serviceControlIndication" },
95 {31, "serviceControlResponse" },
96 {32, "admissionConfirmSequence" },
100 static const value_string h323_message_body_vals[] = {
102 { 1, "callProceeding" },
105 { 4, "information" },
106 { 5, "releaseComplete" },
111 { 10, "statusInquiry" },
112 { 11, "setupAcknowledge" },
117 static const value_string FacilityReason_vals[] = {
118 { 0, "routeCallToGatekeeper" },
119 { 1, "callForwarded" },
120 { 2, "routeCallToMC" },
121 { 3, "undefinedReason" },
122 { 4, "conferenceListChoice" },
126 { 8, "featureSetUpdate" },
127 { 9, "forwardedElements" },
128 { 10, "transportedInformation" },
132 static const value_string GatekeeperRejectReason_vals[] = {
133 { 0, "resourceUnavailable" },
134 { 1, "terminalExcluded" },
135 { 2, "invalidRevision" },
136 { 3, "undefinedReason" },
137 { 4, "securityDenial" },
138 { 5, "genericDataReason" },
139 { 6, "neededFeatureNotSupported" },
140 { 7, "securityError" },
144 static const value_string UnregRequestReason_vals[] = {
145 { 0, "reregistrationRequired" },
147 { 2, "securityDenial" },
148 { 3, "undefinedReason" },
149 { 4, "maintenance" },
150 { 5, "securityError" },
154 static const value_string UnregRejectReason_vals[] = {
155 { 0, "notCurrentlyRegistered" },
156 { 1, "callInProgress" },
157 { 2, "undefinedReason" },
158 { 3, "permissionDenied" },
159 { 4, "securityDenial" },
160 { 5, "securityError" },
164 static const value_string BandRejectReason_vals[] = {
166 { 1, "invalidConferenceID" },
167 { 2, "invalidPermission" },
168 { 3, "insufficientResources" },
169 { 4, "invalidRevision" },
170 { 5, "undefinedReason" },
171 { 6, "securityDenial" },
172 { 7, "securityError" },
176 static const value_string DisengageReason_vals[] = {
179 { 2, "undefinedReason" },
183 static const value_string DisengageRejectReason_vals[] = {
184 { 0, "notRegistered" },
185 { 1, "requestToDropOther" },
186 { 2, "securityDenial" },
187 { 3, "securityError" },
191 static const value_string InfoRequestNakReason_vals[] = {
192 { 0, "notRegistered" },
193 { 1, "securityDenial" },
194 { 2, "undefinedReason" },
195 { 3, "securityError" },
199 static const value_string ReleaseCompleteReason_vals[] = {
200 { 0, "noBandwidth" },
201 { 1, "gatekeeperResources" },
202 { 2, "unreachableDestination" },
203 { 3, "destinationRejection" },
204 { 4, "invalidRevision" },
205 { 5, "noPermission" },
206 { 6, "unreachableGatekeeper" },
207 { 7, "gatewayResources" },
208 { 8, "badFormatAddress" },
209 { 9, "adaptiveBusy" },
211 { 11, "undefinedReason" },
212 { 12, "facilityCallDeflection" },
213 { 13, "securityDenied" },
214 { 14, "calledPartyNotRegistered" },
215 { 15, "callerNotRegistered" },
216 { 16, "newConnectionNeeded" },
217 { 17, "nonStandardReason" },
218 { 18, "replaceWithConferenceInvite" },
219 { 19, "genericDataReason" },
220 { 20, "neededFeatureNotSupported" },
221 { 21, "tunnelledSignallingRejected" },
222 { 22, "invalidCID" },
223 { 23, "invalidCID" },
224 { 24, "securityError" },
225 { 25, "hopCountExceeded" },
229 static const value_string AdmissionRejectReason_vals[] = {
230 { 0, "calledPartyNotRegistered" },
231 { 1, "invalidPermission" },
232 { 2, "requestDenied" },
233 { 3, "undefinedReason" },
234 { 4, "callerNotRegistered" },
235 { 5, "routeCallToGatekeeper" },
236 { 6, "invalidEndpointIdentifier" },
237 { 7, "resourceUnavailable" },
238 { 8, "securityDenial" },
239 { 9, "qosControlNotSupported" },
240 { 10, "incompleteAddress" },
241 { 11, "aliasesInconsistent" },
242 { 12, "routeCallToSCN" },
243 { 13, "exceedsCallCapacity" },
244 { 14, "collectDestination" },
245 { 15, "collectPIN" },
246 { 16, "genericDataReason" },
247 { 17, "neededFeatureNotSupported" },
248 { 18, "securityErrors" },
249 { 19, "securityDHmismatch" },
250 { 20, "noRouteToDestination" },
251 { 21, "unallocatedNumber" },
255 static const value_string LocationRejectReason_vals[] = {
256 { 0, "notRegistered" },
257 { 1, "invalidPermission" },
258 { 2, "requestDenied" },
259 { 3, "undefinedReason" },
260 { 4, "securityDenial" },
261 { 5, "aliasesInconsistent" },
262 { 6, "routeCalltoSCN" },
263 { 7, "resourceUnavailable" },
264 { 8, "genericDataReason" },
265 { 9, "neededFeatureNotSupported" },
266 {10, "hopCountExceeded" },
267 {11, "incompleteAddress" },
268 {12, "securityError" },
269 {13, "securityDHmismatch" },
270 {14, "noRouteToDestination" },
271 {15, "unallocatedNumber" },
275 static const value_string RegistrationRejectReason_vals[] = {
276 { 0, "discoveryRequired" },
277 { 1, "invalidRevision" },
278 { 2, "invalidCallSignalAddress" },
279 { 3, "invalidRASAddress" },
280 { 4, "duplicateAlias" },
281 { 5, "invalidTerminalType" },
282 { 6, "undefinedReason" },
283 { 7, "transportNotSupported" },
284 { 8, "transportQOSNotSupported" },
285 { 9, "resourceUnavailable" },
286 { 10, "invalidAlias" },
287 { 11, "securityDenial" },
288 { 12, "fullRegistrationRequired" },
289 { 13, "additiveRegistrationNotSupported" },
290 { 14, "invalidTerminalAliases" },
291 { 15, "genericDataReason" },
292 { 16, "neededFeatureNotSupported" },
293 { 17, "securityError" },
297 /* used to keep track of the statistics for an entire program interface */
298 typedef struct _h225counter_t {
300 guint32 ras_msg[RAS_MSG_TYPES + 1];
301 guint32 cs_msg[CS_MSG_TYPES + 1];
302 guint32 grj_reason[GRJ_REASONS + 1];
303 guint32 rrj_reason[RRJ_REASONS + 1];
304 guint32 urq_reason[URQ_REASONS + 1];
305 guint32 urj_reason[URJ_REASONS + 1];
306 guint32 arj_reason[ARJ_REASONS + 1];
307 guint32 brj_reason[BRJ_REASONS + 1];
308 guint32 drq_reason[DRQ_REASONS + 1];
309 guint32 drj_reason[DRJ_REASONS + 1];
310 guint32 lrj_reason[LRJ_REASONS + 1];
311 guint32 irqnak_reason[IRQNAK_REASONS + 1];
312 guint32 rel_cmp_reason[REL_CMP_REASONS + 1];
313 guint32 facility_reason[FACILITY_REASONS + 1];
318 h225counter_reset(void *phs)
320 h225counter_t *hs=(h225counter_t *)phs;
323 for(i=0;i<=RAS_MSG_TYPES;i++) {
326 for(i=0;i<=CS_MSG_TYPES;i++) {
329 for(i=0;i<=GRJ_REASONS;i++) {
330 hs->grj_reason[i] = 0;
332 for(i=0;i<=RRJ_REASONS;i++) {
333 hs->rrj_reason[i] = 0;
335 for(i=0;i<=URQ_REASONS;i++) {
336 hs->urq_reason[i] = 0;
338 for(i=0;i<=URJ_REASONS;i++) {
339 hs->urj_reason[i] = 0;
341 for(i=0;i<=ARJ_REASONS;i++) {
342 hs->arj_reason[i] = 0;
344 for(i=0;i<=BRJ_REASONS;i++) {
345 hs->brj_reason[i] = 0;
347 for(i=0;i<=DRQ_REASONS;i++) {
348 hs->drq_reason[i] = 0;
350 for(i=0;i<=DRJ_REASONS;i++) {
351 hs->drj_reason[i] = 0;
353 for(i=0;i<=LRJ_REASONS;i++) {
354 hs->lrj_reason[i] = 0;
356 for(i=0;i<=IRQNAK_REASONS;i++) {
357 hs->irqnak_reason[i] = 0;
359 for(i=0;i<=REL_CMP_REASONS;i++) {
360 hs->rel_cmp_reason[i] = 0;
362 for(i=0;i<=FACILITY_REASONS;i++) {
363 hs->facility_reason[i] = 0;
368 h225counter_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void *phi)
370 h225counter_t *hs=(h225counter_t *)phs;
371 h225_packet_info *pi=phi;
373 switch (pi->msg_type) {
376 if(pi->msg_tag==-1) { /* uninitialized */
379 else if (pi->msg_tag >= RAS_MSG_TYPES) { /* unknown */
380 hs->ras_msg[RAS_MSG_TYPES]++;
383 hs->ras_msg[pi->msg_tag]++;
386 /* Look for reason tag */
387 if(pi->reason==-1) { /* uninitialized */
391 switch(pi->msg_tag) {
394 if(pi->reason < GRJ_REASONS)
395 hs->grj_reason[pi->reason]++;
397 hs->grj_reason[GRJ_REASONS]++;
400 if(pi->reason < RRJ_REASONS)
401 hs->rrj_reason[pi->reason]++;
403 hs->rrj_reason[RRJ_REASONS]++;
406 if(pi->reason < URQ_REASONS)
407 hs->urq_reason[pi->reason]++;
409 hs->urq_reason[URQ_REASONS]++;
412 if(pi->reason < URJ_REASONS)
413 hs->urj_reason[pi->reason]++;
415 hs->urj_reason[URJ_REASONS]++;
418 if(pi->reason < ARJ_REASONS)
419 hs->arj_reason[pi->reason]++;
421 hs->arj_reason[ARJ_REASONS]++;
424 if(pi->reason < BRJ_REASONS)
425 hs->brj_reason[pi->reason]++;
427 hs->brj_reason[BRJ_REASONS]++;
430 if(pi->reason < DRQ_REASONS)
431 hs->drq_reason[pi->reason]++;
433 hs->drq_reason[DRQ_REASONS]++;
436 if(pi->reason < DRJ_REASONS)
437 hs->drj_reason[pi->reason]++;
439 hs->drj_reason[DRJ_REASONS]++;
442 if(pi->reason < LRJ_REASONS)
443 hs->lrj_reason[pi->reason]++;
445 hs->lrj_reason[LRJ_REASONS]++;
447 case 29: /* IRQ Nak */
448 if(pi->reason < IRQNAK_REASONS)
449 hs->irqnak_reason[pi->reason]++;
451 hs->irqnak_reason[IRQNAK_REASONS]++;
462 if(pi->msg_tag==-1) { /* uninitialized */
465 else if (pi->msg_tag >= CS_MSG_TYPES) { /* unknown */
466 hs->cs_msg[CS_MSG_TYPES]++;
469 hs->cs_msg[pi->msg_tag]++;
472 /* Look for reason tag */
473 if(pi->reason==-1) { /* uninitialized */
477 switch(pi->msg_tag) {
479 case 5: /* ReleaseComplete */
480 if(pi->reason < REL_CMP_REASONS)
481 hs->rel_cmp_reason[pi->reason]++;
483 hs->rel_cmp_reason[REL_CMP_REASONS]++;
485 case 6: /* Facility */
486 if(pi->reason < FACILITY_REASONS)
487 hs->facility_reason[pi->reason]++;
489 hs->facility_reason[FACILITY_REASONS]++;
508 h225counter_draw(void *phs)
510 h225counter_t *hs=(h225counter_t *)phs;
513 printf("================== H225 Message and Reason Counter ==================\n");
514 printf("RAS-Messages:\n");
515 for(i=0;i<=RAS_MSG_TYPES;i++) {
516 if(hs->ras_msg[i]!=0) {
517 printf(" %s : %u\n", val_to_str(i,RasMessage_vals,"unknown ras-messages "), hs->ras_msg[i]);
521 for(j=0;j<=GRJ_REASONS;j++) {
522 if(hs->grj_reason[j]!=0) {
523 printf(" %s : %u\n", val_to_str(j,GatekeeperRejectReason_vals,"unknown reason "), hs->grj_reason[j]);
528 for(j=0;j<=RRJ_REASONS;j++) {
529 if(hs->rrj_reason[j]!=0) {
530 printf(" %s : %u\n", val_to_str(j,RegistrationRejectReason_vals,"unknown reason "), hs->rrj_reason[j]);
535 for(j=0;j<=URQ_REASONS;j++) {
536 if(hs->urq_reason[j]!=0) {
537 printf(" %s : %u\n", val_to_str(j,UnregRequestReason_vals,"unknown reason "), hs->urq_reason[j]);
542 for(j=0;j<=URJ_REASONS;j++) {
543 if(hs->urj_reason[j]!=0) {
544 printf(" %s : %u\n", val_to_str(j,UnregRejectReason_vals,"unknown reason "), hs->urj_reason[j]);
549 for(j=0;j<=ARJ_REASONS;j++) {
550 if(hs->arj_reason[j]!=0) {
551 printf(" %s : %u\n", val_to_str(j,AdmissionRejectReason_vals,"unknown reason "), hs->arj_reason[j]);
556 for(j=0;j<=BRJ_REASONS;j++) {
557 if(hs->brj_reason[j]!=0) {
558 printf(" %s : %u\n", val_to_str(j,BandRejectReason_vals,"unknown reason "), hs->brj_reason[j]);
563 for(j=0;j<=DRQ_REASONS;j++) {
564 if(hs->drq_reason[j]!=0) {
565 printf(" %s : %u\n", val_to_str(j,DisengageReason_vals,"unknown reason "), hs->drq_reason[j]);
570 for(j=0;j<=DRJ_REASONS;j++) {
571 if(hs->drj_reason[j]!=0) {
572 printf(" %s : %u\n", val_to_str(j,DisengageRejectReason_vals,"unknown reason "), hs->drj_reason[j]);
577 for(j=0;j<=LRJ_REASONS;j++) {
578 if(hs->lrj_reason[j]!=0) {
579 printf(" %s : %u\n", val_to_str(j,LocationRejectReason_vals,"unknown reason "), hs->lrj_reason[j]);
582 case 29: /* IRQNak */
583 for(j=0;j<=IRQNAK_REASONS;j++) {
584 if(hs->irqnak_reason[j]!=0) {
585 printf(" %s : %u\n", val_to_str(j,InfoRequestNakReason_vals,"unknown reason "), hs->irqnak_reason[j]);
592 /* end of reason counter*/
595 printf("Call Signalling:\n");
596 for(i=0;i<=CS_MSG_TYPES;i++) {
597 if(hs->cs_msg[i]!=0) {
598 printf(" %s : %u\n", val_to_str(i,h323_message_body_vals,"unknown cs-messages "), hs->cs_msg[i]);
601 case 5: /* ReleaseComplete */
602 for(j=0;j<=REL_CMP_REASONS;j++) {
603 if(hs->rel_cmp_reason[j]!=0) {
604 printf(" %s : %u\n", val_to_str(j,ReleaseCompleteReason_vals,"unknown reason "), hs->rel_cmp_reason[j]);
608 case 6: /* Facility */
609 for(j=0;j<=FACILITY_REASONS;j++) {
610 if(hs->facility_reason[j]!=0) {
611 printf(" %s : %u\n", val_to_str(j,FacilityReason_vals,"unknown reason "), hs->facility_reason[j]);
620 printf("=====================================================================\n");
625 h225counter_init(char *optarg)
629 GString *error_string;
631 if(!strncmp(optarg,"h225,counter,",13)){
638 hs = g_malloc(sizeof(h225counter_t));
639 hs->filter=g_malloc(strlen(filter)+1);
640 strcpy(hs->filter, filter);
642 h225counter_reset(hs);
644 error_string=register_tap_listener("h225", hs, filter, NULL, h225counter_packet, h225counter_draw);
646 /* error, we failed to attach to the tap. clean up */
650 fprintf(stderr, "tethereal: Couldn't register h225,counter tap: %s\n",
652 g_string_free(error_string, TRUE);
659 register_tap_listener_h225counter(void)
661 register_ethereal_tap("h225,counter", h225counter_init);