http://bugs.ethereal.com/bugzilla/show_bug.cgi?id=377
[obnox/wireshark/wip.git] / tap-h225counter.c
index 20e34b5db987699dc3e28e6f53c4c80182330769..694cffae8a56799696aacc69e77ba2f067f6d35b 100644 (file)
@@ -2,7 +2,7 @@
  * h225 message counter for ethereal
  * 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>
 
 #include <string.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;
@@ -365,10 +131,10 @@ h225counter_reset(void *phs)
 }
 
 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) {
 
@@ -595,7 +361,7 @@ h225counter_draw(void *phs)
        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 */
@@ -622,17 +388,16 @@ h225counter_draw(void *phs)
 
 
 static void
-h225counter_init(char *optarg)
+h225counter_init(const char *optarg)
 {
        h225counter_t *hs;
-       char *filter=NULL;
+       const char *filter=NULL;
        GString *error_string;
 
        if(!strncmp(optarg,"h225,counter,",13)){
                filter=optarg+13;
        } else {
-               filter=g_malloc(1);
-               *filter='\0';
+               filter="";
        }
 
        hs = g_malloc(sizeof(h225counter_t));
@@ -658,5 +423,5 @@ h225counter_init(char *optarg)
 void
 register_tap_listener_h225counter(void)
 {
-       register_ethereal_tap("h225,counter", h225counter_init);
+       register_stat_cmd_arg("h225,counter", h225counter_init);
 }