(file) Return to snmpIndicationHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Handler / snmpIndicationHandler

Diff for /pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpIndicationHandler.cpp between version 1.1.2.1 and 1.14

version 1.1.2.1, 2001/10/12 17:33:08 version 1.14, 2003/07/25 17:54:37
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 BMC Software, Hewlett Packard, IBM, The Open Group,  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
 // Tivoli Systems  // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 23 
Line 23 
 // //
 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 // //
 // Modified By:  // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
   //                (carolann_graves@hp.com)
   //            : Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <iostream>  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/PegasusVersion.h>
   
   #include <iostream>
 #include <Pegasus/Handler/CIMHandler.h> #include <Pegasus/Handler/CIMHandler.h>
 #include <Pegasus/Repository/CIMRepository.h> #include <Pegasus/Repository/CIMRepository.h>
  
Line 44 
Line 48 
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 //#define DDD(X) X  
 #define DDD(X) // X  
   
 DDD(static const char* _SNMPINDICATIONHANDLER = "snmpIndicationHandler::";)  
   
 void snmpIndicationHandler::initialize(CIMRepository* repository) void snmpIndicationHandler::initialize(CIMRepository* repository)
 { {
     _repository = repository;     _repository = repository;
     DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)  
 } }
  
 void snmpIndicationHandler::handleIndication(CIMInstance& handlerInstance,  // l10n - note: ignoring indication language
     CIMInstance& indicationInstance,  void snmpIndicationHandler::handleIndication(CIMInstance& handler,
     String nameSpace)      CIMInstance& indication, String nameSpace,
       ContentLanguages & contentLanguages)
 { {
     String enterprise, trapOid, destination, trapType;  
   
     Array<String> propOIDs;     Array<String> propOIDs;
     Array<String> propTYPEs;     Array<String> propTYPEs;
     Array<String> propVALUEs;     Array<String> propVALUEs;
  
     String propName;      CIMProperty prop;
       CIMQualifier trapQualifier;
  
     Uint32 propPos;  
     Uint32 qualifierPos;     Uint32 qualifierPos;
     Uint32 typePos;  
     CIMValue propValue;      String propValue;
     CIMProperty trapProp;  
     CIMQualifier trapQualifier;      String mapstr1;
       String mapstr2;
  
     CIMClass indicationClass = _repository->getClass(     CIMClass indicationClass = _repository->getClass(
         nameSpace,          nameSpace, indication.getClassName(), false);
         indicationInstance.getClassName(),  
         false);  
  
     //filling the array with enterprise first      Uint32 propertyCount = indication.getPropertyCount();
     propPos = indicationClass.findProperty("enterprise");  
     if (propPos != PEG_NOT_FOUND)      for (Uint32 i=0; i < propertyCount; i++)
     {     {
         trapProp = indicationClass.getProperty(propPos);          prop = indication.getProperty(i);
         qualifierPos = trapProp.findQualifier("OID");  
         trapQualifier = trapProp.getQualifier(qualifierPos);  
         enterprise = trapQualifier.getValue().toString();  
  
         int i;          if (!prop.isUninitialized())
         for (i=0; i<indicationInstance.getPropertyCount();i++)          {
               CIMName propName = prop.getName();
               Uint32 propPos = indicationClass.findProperty(propName);
               if (propPos != PEG_NOT_FOUND)
         {         {
             propValue = indicationInstance.getProperty(i).getValue();              CIMProperty trapProp = indicationClass.getProperty(propPos);
  
             if (!propValue.isNull())              qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
               if (qualifierPos != PEG_NOT_FOUND)
             {             {
                 propName = indicationInstance.getProperty(i).getName();                  trapQualifier = trapProp.getQualifier(qualifierPos);
                 propPos = indicationClass.findProperty(propName);  
                 trapProp = indicationClass.getProperty(propPos);                  mapstr1.clear();
                   mapstr1 = trapQualifier.getValue().toString();
  
                 if (trapProp.existsQualifier("OID"))                  if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
                       (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
                 {                 {
                     if (propName == "trapOid")                      if (mapstr1.subString(0, 8) == "OID.IETF")
                     {                     {
                         trapOid = propValue.toString();                          mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
                     }                          if (mapstr1.find("|") != PEG_NOT_FOUND)
                     else  
                     {                     {
                         qualifierPos = trapProp.findQualifier("OID");                              mapstr2.clear();
                         trapQualifier = trapProp.getQualifier(qualifierPos);                              mapstr2 = mapstr1.subString(0,
                         propOIDs.append(trapQualifier.getValue().toString());                                  mapstr1.find("DataType.IETF")-1);
                         propVALUEs.append(propValue.toString());                              propOIDs.append(mapstr2);
                         if (trapProp.existsQualifier("SNMPTYPE"))  
                         {                              propValue.clear();
                             typePos = trapProp.findQualifier("SNMPTYPE");                              propValue = prop.getValue().toString();
                             trapQualifier = trapProp.getQualifier(typePos);                              propVALUEs.append(propValue);
                             propTYPEs.append(trapQualifier.getValue().toString());  
                               mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
                               mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
                               propTYPEs.append(mapstr2);
                           }
                       }
                         }                         }
                         else  
                             propTYPEs.append(TypeToString(trapProp.getType()));  
                     }                     }
                 }                 }
             }             }
         }         }
   
         destination = handlerInstance.getProperty(  
             handlerInstance.findProperty("destination")).getValue().toString();  
   
         trapType = handlerInstance.getProperty(  
             handlerInstance.findProperty("trapType")).getValue().toString();  
  
         // Collected complete data in arrays and ready to send the trap.         // Collected complete data in arrays and ready to send the trap.
         // trap destination and SNMP type are defined in handlerInstance         // trap destination and SNMP type are defined in handlerInstance
         // and passing this instance as it is to deliverTrap() call         // and passing this instance as it is to deliverTrap() call
   
 #ifdef HPUX_EMANATE #ifdef HPUX_EMANATE
         snmpDeliverTrap_emanate emanateTrap;         snmpDeliverTrap_emanate emanateTrap;
 #else #else
         snmpDeliverTrap_stub emanateTrap;         snmpDeliverTrap_stub emanateTrap;
 #endif #endif
  
         cout << "Trap to deliver " << endl;      Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
       Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
       Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
                                         "OtherTargetHostFormat"));
       Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
       Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
       Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
       Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
   
       if ((targetHostPos != PEG_NOT_FOUND) &&
           (targetHostFormatPos != PEG_NOT_FOUND) &&
           (snmpVersionPos != PEG_NOT_FOUND) &&
           (indicationClass.findQualifier(CIMName ("MappingStrings")) !=
               PEG_NOT_FOUND))
       {
           // properties from the handler instance
           String targetHost, otherTargetHostFormat;
           String securityName, engineID;
           Uint16 targetHostFormat, snmpVersion;
           Uint32 portNumber;
   
           // trapOid from indication Class
   
           String trapOid = indicationClass.getQualifier(
               indicationClass.findQualifier
                   (CIMName ("MappingStrings"))).getValue().toString();
   
           Uint32 index = trapOid.find("SNMP.");
  
         emanateTrap.deliverTrap(trapOid,          if (index != PEG_NOT_FOUND)
             enterprise,          {
             destination,              trapOid = trapOid.subString(index+5);
             trapType,              trapOid = trapOid.subString(0, (trapOid.size()-1));
           }
           else
           {
               throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");
           }
   
           handler.getProperty(targetHostPos).getValue().get(targetHost);
           handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);
           handler.getProperty(otherTargetHostFormatPos).getValue().get
                   (otherTargetHostFormat);
           handler.getProperty(portNumberPos).getValue().get(portNumber);
           handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
           handler.getProperty(securityNamePos).getValue().get(securityName);
           handler.getProperty(engineIDPos).getValue().get(engineID);
   
           emanateTrap.deliverTrap(
               trapOid,
               securityName,
               targetHost,
               targetHostFormat,
               otherTargetHostFormat,
               portNumber,
               snmpVersion,
               engineID,
             propOIDs,             propOIDs,
             propTYPEs,             propTYPEs,
             propVALUEs);             propVALUEs);
   
         cout << "Trap Delivered " << endl;  
     }     }
     else     else
       {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
             "Indication is without enterprise OID");                  "Invalid IndicationHandlerSNMPMapper instance");
       }
 } }
  
 // This is the dynamic entry point into this dynamic module. The name of // This is the dynamic entry point into this dynamic module. The name of
 // this handler is "snmpIndicationHandler" which is appened to "PegasusCreateHandler_"  // this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_"
 // to form a symbol name. This function is called by the HandlerTable // to form a symbol name. This function is called by the HandlerTable
 // to load this handler. // to load this handler.
  
 extern "C" PEGASUS_EXPORT CIMHandler* extern "C" PEGASUS_EXPORT CIMHandler*
     PegasusCreateHandler_snmpIndicationHandler() {     PegasusCreateHandler_snmpIndicationHandler() {
     DDD(cout << "Called PegasusCreateHandler_snmpIndicationHandler" << endl;)  
     return new snmpIndicationHandler;     return new snmpIndicationHandler;
 } }
  


Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.14

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2