/* tap_h225counter.c
- * h225 message counter for ethereal
+ * h225 message counter for wireshark
* Copyright 2003 Lars Roland
*
- * $Id: tap-h225counter.c,v 1.1 2003/10/28 00:31:16 guy Exp $
+ * $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
#endif
#include <string.h>
+#include "epan/packet.h"
#include "epan/packet_info.h"
-#include "tap.h"
+#include <epan/tap.h>
+#include <epan/stat_cmd_args.h>
#include "epan/value_string.h"
-#include "register.h"
-#include "packet-h225.h"
+#include <epan/dissectors/packet-h225.h>
/* following values represent the size of their valuestring arrays */
#define FACILITY_REASONS 11
-
-static const value_string RasMessage_vals[] = {
- { 0, "gatekeeperRequest" },
- { 1, "gatekeeperConfirm" },
- { 2, "gatekeeperReject" },
- { 3, "registrationRequest" },
- { 4, "registrationConfirm" },
- { 5, "registrationReject" },
- { 6, "unregistrationRequest" },
- { 7, "unregistrationConfirm" },
- { 8, "unregistrationReject" },
- { 9, "admissionRequest" },
- {10, "admissionConfirm" },
- {11, "admissionReject" },
- {12, "bandwidthRequest" },
- {13, "bandwidthConfirm" },
- {14, "bandwidthReject" },
- {15, "disengageRequest" },
- {16, "disengageConfirm" },
- {17, "disengageReject" },
- {18, "locationRequest" },
- {19, "locationConfirm" },
- {20, "locationReject" },
- {21, "infoRequest" },
- {22, "infoRequestResponse" },
- {23, "nonStandardMessage" },
- {24, "unknownMessageResponse" },
- {25, "requestInProgress" },
- {26, "resourcesAvailableIndicate" },
- {27, "resourcesAvailableConfirm" },
- {28, "infoRequestAck" },
- {29, "infoRequestNak" },
- {30, "serviceControlIndication" },
- {31, "serviceControlResponse" },
- {32, "admissionConfirmSequence" },
- { 0, NULL}
-};
-
-static const value_string h323_message_body_vals[] = {
- { 0, "setup" },
- { 1, "callProceeding" },
- { 2, "connect" },
- { 3, "alerting" },
- { 4, "information" },
- { 5, "releaseComplete" },
- { 6, "facility" },
- { 7, "progress" },
- { 8, "empty" },
- { 9, "status" },
- { 10, "statusInquiry" },
- { 11, "setupAcknowledge" },
- { 12, "notify" },
- { 0, NULL}
-};
-
-static const value_string FacilityReason_vals[] = {
- { 0, "routeCallToGatekeeper" },
- { 1, "callForwarded" },
- { 2, "routeCallToMC" },
- { 3, "undefinedReason" },
- { 4, "conferenceListChoice" },
- { 5, "startH245" },
- { 6, "noH245" },
- { 7, "newTokens" },
- { 8, "featureSetUpdate" },
- { 9, "forwardedElements" },
- { 10, "transportedInformation" },
- { 0, NULL}
-};
-
-static const value_string GatekeeperRejectReason_vals[] = {
- { 0, "resourceUnavailable" },
- { 1, "terminalExcluded" },
- { 2, "invalidRevision" },
- { 3, "undefinedReason" },
- { 4, "securityDenial" },
- { 5, "genericDataReason" },
- { 6, "neededFeatureNotSupported" },
- { 7, "securityError" },
- { 0, NULL}
-};
-
-static const value_string UnregRequestReason_vals[] = {
- { 0, "reregistrationRequired" },
- { 1, "ttlExpired" },
- { 2, "securityDenial" },
- { 3, "undefinedReason" },
- { 4, "maintenance" },
- { 5, "securityError" },
- { 0, NULL}
-};
-
-static const value_string UnregRejectReason_vals[] = {
- { 0, "notCurrentlyRegistered" },
- { 1, "callInProgress" },
- { 2, "undefinedReason" },
- { 3, "permissionDenied" },
- { 4, "securityDenial" },
- { 5, "securityError" },
- { 0, NULL}
-};
-
-static const value_string BandRejectReason_vals[] = {
- { 0, "notBound" },
- { 1, "invalidConferenceID" },
- { 2, "invalidPermission" },
- { 3, "insufficientResources" },
- { 4, "invalidRevision" },
- { 5, "undefinedReason" },
- { 6, "securityDenial" },
- { 7, "securityError" },
- { 0, NULL}
-};
-
-static const value_string DisengageReason_vals[] = {
- { 0, "forcedDrop" },
- { 1, "normalDrop" },
- { 2, "undefinedReason" },
- { 0, NULL}
-};
-
-static const value_string DisengageRejectReason_vals[] = {
- { 0, "notRegistered" },
- { 1, "requestToDropOther" },
- { 2, "securityDenial" },
- { 3, "securityError" },
- { 0, NULL}
-};
-
-static const value_string InfoRequestNakReason_vals[] = {
- { 0, "notRegistered" },
- { 1, "securityDenial" },
- { 2, "undefinedReason" },
- { 3, "securityError" },
- { 0, NULL}
-};
-
-static const value_string ReleaseCompleteReason_vals[] = {
- { 0, "noBandwidth" },
- { 1, "gatekeeperResources" },
- { 2, "unreachableDestination" },
- { 3, "destinationRejection" },
- { 4, "invalidRevision" },
- { 5, "noPermission" },
- { 6, "unreachableGatekeeper" },
- { 7, "gatewayResources" },
- { 8, "badFormatAddress" },
- { 9, "adaptiveBusy" },
- { 10, "inConf" },
- { 11, "undefinedReason" },
- { 12, "facilityCallDeflection" },
- { 13, "securityDenied" },
- { 14, "calledPartyNotRegistered" },
- { 15, "callerNotRegistered" },
- { 16, "newConnectionNeeded" },
- { 17, "nonStandardReason" },
- { 18, "replaceWithConferenceInvite" },
- { 19, "genericDataReason" },
- { 20, "neededFeatureNotSupported" },
- { 21, "tunnelledSignallingRejected" },
- { 22, "invalidCID" },
- { 23, "invalidCID" },
- { 24, "securityError" },
- { 25, "hopCountExceeded" },
- { 0, NULL}
-};
-
-static const value_string AdmissionRejectReason_vals[] = {
- { 0, "calledPartyNotRegistered" },
- { 1, "invalidPermission" },
- { 2, "requestDenied" },
- { 3, "undefinedReason" },
- { 4, "callerNotRegistered" },
- { 5, "routeCallToGatekeeper" },
- { 6, "invalidEndpointIdentifier" },
- { 7, "resourceUnavailable" },
- { 8, "securityDenial" },
- { 9, "qosControlNotSupported" },
- { 10, "incompleteAddress" },
- { 11, "aliasesInconsistent" },
- { 12, "routeCallToSCN" },
- { 13, "exceedsCallCapacity" },
- { 14, "collectDestination" },
- { 15, "collectPIN" },
- { 16, "genericDataReason" },
- { 17, "neededFeatureNotSupported" },
- { 18, "securityErrors" },
- { 19, "securityDHmismatch" },
- { 20, "noRouteToDestination" },
- { 21, "unallocatedNumber" },
- { 0, NULL}
-};
-
-static const value_string LocationRejectReason_vals[] = {
- { 0, "notRegistered" },
- { 1, "invalidPermission" },
- { 2, "requestDenied" },
- { 3, "undefinedReason" },
- { 4, "securityDenial" },
- { 5, "aliasesInconsistent" },
- { 6, "routeCalltoSCN" },
- { 7, "resourceUnavailable" },
- { 8, "genericDataReason" },
- { 9, "neededFeatureNotSupported" },
- {10, "hopCountExceeded" },
- {11, "incompleteAddress" },
- {12, "securityError" },
- {13, "securityDHmismatch" },
- {14, "noRouteToDestination" },
- {15, "unallocatedNumber" },
- { 0, NULL}
-};
-
-static const value_string RegistrationRejectReason_vals[] = {
- { 0, "discoveryRequired" },
- { 1, "invalidRevision" },
- { 2, "invalidCallSignalAddress" },
- { 3, "invalidRASAddress" },
- { 4, "duplicateAlias" },
- { 5, "invalidTerminalType" },
- { 6, "undefinedReason" },
- { 7, "transportNotSupported" },
- { 8, "transportQOSNotSupported" },
- { 9, "resourceUnavailable" },
- { 10, "invalidAlias" },
- { 11, "securityDenial" },
- { 12, "fullRegistrationRequired" },
- { 13, "additiveRegistrationNotSupported" },
- { 14, "invalidTerminalAliases" },
- { 15, "genericDataReason" },
- { 16, "neededFeatureNotSupported" },
- { 17, "securityError" },
- { 0, NULL}
-};
-
/* used to keep track of the statistics for an entire program interface */
typedef struct _h225counter_t {
char *filter;
h225counter_reset(void *phs)
{
h225counter_t *hs=(h225counter_t *)phs;
- int i;
+ char *save_filter = hs->filter;
- for(i=0;i<=RAS_MSG_TYPES;i++) {
- hs->ras_msg[i] = 0;
- }
- for(i=0;i<=CS_MSG_TYPES;i++) {
- hs->cs_msg[i] = 0;
- }
- for(i=0;i<=GRJ_REASONS;i++) {
- hs->grj_reason[i] = 0;
- }
- for(i=0;i<=RRJ_REASONS;i++) {
- hs->rrj_reason[i] = 0;
- }
- for(i=0;i<=URQ_REASONS;i++) {
- hs->urq_reason[i] = 0;
- }
- for(i=0;i<=URJ_REASONS;i++) {
- hs->urj_reason[i] = 0;
- }
- for(i=0;i<=ARJ_REASONS;i++) {
- hs->arj_reason[i] = 0;
- }
- for(i=0;i<=BRJ_REASONS;i++) {
- hs->brj_reason[i] = 0;
- }
- for(i=0;i<=DRQ_REASONS;i++) {
- hs->drq_reason[i] = 0;
- }
- for(i=0;i<=DRJ_REASONS;i++) {
- hs->drj_reason[i] = 0;
- }
- for(i=0;i<=LRJ_REASONS;i++) {
- hs->lrj_reason[i] = 0;
- }
- for(i=0;i<=IRQNAK_REASONS;i++) {
- hs->irqnak_reason[i] = 0;
- }
- for(i=0;i<=REL_CMP_REASONS;i++) {
- hs->rel_cmp_reason[i] = 0;
- }
- for(i=0;i<=FACILITY_REASONS;i++) {
- hs->facility_reason[i] = 0;
- }
+ memset(hs, 0, sizeof(h225counter_t));
+
+ hs->filter = save_filter;
}
static int
-h225counter_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, void *phi)
+h225counter_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *phi)
{
h225counter_t *hs=(h225counter_t *)phs;
- h225_packet_info *pi=phi;
+ const h225_packet_info *pi=phi;
switch (pi->msg_type) {
default:
return 0;
- break;
}
return 1;
printf("RAS-Messages:\n");
for(i=0;i<=RAS_MSG_TYPES;i++) {
if(hs->ras_msg[i]!=0) {
- printf(" %s : %u\n", val_to_str(i,RasMessage_vals,"unknown ras-messages "), hs->ras_msg[i]);
+ printf(" %s : %u\n", val_to_str(i,h225_RasMessage_vals,"unknown ras-messages "), hs->ras_msg[i]);
/* reason counter */
switch(i) {
case 2: /* GRJ */
printf(" %s : %u\n", val_to_str(j,LocationRejectReason_vals,"unknown reason "), hs->lrj_reason[j]);
}
}
+ break;
case 29: /* IRQNak */
for(j=0;j<=IRQNAK_REASONS;j++) {
if(hs->irqnak_reason[j]!=0) {
printf("Call Signalling:\n");
for(i=0;i<=CS_MSG_TYPES;i++) {
if(hs->cs_msg[i]!=0) {
- printf(" %s : %u\n", val_to_str(i,h323_message_body_vals,"unknown cs-messages "), hs->cs_msg[i]);
+ printf(" %s : %u\n", val_to_str(i,T_h323_message_body_vals,"unknown cs-messages "), hs->cs_msg[i]);
/* reason counter */
switch(i) {
case 5: /* ReleaseComplete */
for(j=0;j<=REL_CMP_REASONS;j++) {
if(hs->rel_cmp_reason[j]!=0) {
- printf(" %s : %u\n", val_to_str(j,ReleaseCompleteReason_vals,"unknown reason "), hs->rel_cmp_reason[j]);
+ printf(" %s : %u\n", val_to_str(j,h225_ReleaseCompleteReason_vals,"unknown reason "), hs->rel_cmp_reason[j]);
}
}
break;
static void
-h225counter_init(char *optarg)
+h225counter_init(const char *optarg, void* userdata _U_)
{
h225counter_t *hs;
- char *filter=NULL;
GString *error_string;
+ hs = g_malloc(sizeof(h225counter_t));
if(!strncmp(optarg,"h225,counter,",13)){
- filter=optarg+13;
+ hs->filter=g_strdup(optarg+13);
} else {
- filter=g_malloc(1);
- *filter='\0';
+ hs->filter=NULL;
}
- hs = g_malloc(sizeof(h225counter_t));
- hs->filter=g_malloc(strlen(filter)+1);
- strcpy(hs->filter, filter);
-
h225counter_reset(hs);
- error_string=register_tap_listener("h225", hs, filter, NULL, h225counter_packet, h225counter_draw);
+ error_string=register_tap_listener("h225", hs, hs->filter, 0, NULL, h225counter_packet, h225counter_draw);
if(error_string){
/* error, we failed to attach to the tap. clean up */
g_free(hs->filter);
g_free(hs);
- fprintf(stderr, "tethereal: Couldn't register h225,counter tap: %s\n",
+ fprintf(stderr, "tshark: Couldn't register h225,counter tap: %s\n",
error_string->str);
g_string_free(error_string, TRUE);
exit(1);
void
register_tap_listener_h225counter(void)
{
- register_ethereal_tap("h225,counter", h225counter_init);
+ register_stat_cmd_arg("h225,counter", h225counter_init,NULL);
}