(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.3

version 1.1.2.1, 2001/10/12 17:33:08 version 1.3, 2002/03/14 00:07:48
Line 27 
Line 27 
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <iostream>  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <iostream>
 #include <Pegasus/Handler/CIMHandler.h> #include <Pegasus/Handler/CIMHandler.h>
 #include <Pegasus/Repository/CIMRepository.h> #include <Pegasus/Repository/CIMRepository.h>
  
Line 55 
Line 55 
     DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)     DDD(cout << _SNMPINDICATIONHANDLER << "initialize()" << endl;)
 } }
  
 void snmpIndicationHandler::handleIndication(CIMInstance& handlerInstance,  void snmpIndicationHandler::handleIndication(CIMInstance& handler,
     CIMInstance& indicationInstance,      CIMInstance& indication, String nameSpace)
     String nameSpace)  
 { {
     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  
     propPos = indicationClass.findProperty("enterprise");  
     if (propPos != PEG_NOT_FOUND)  
     {  
         trapProp = indicationClass.getProperty(propPos);  
         qualifierPos = trapProp.findQualifier("OID");  
         trapQualifier = trapProp.getQualifier(qualifierPos);  
         enterprise = trapQualifier.getValue().toString();  
  
         int i;      for (Uint32 i=0; i<indication.getPropertyCount();i++)
         for (i=0; i<indicationInstance.getPropertyCount();i++)  
         {         {
             propValue = indicationInstance.getProperty(i).getValue();          prop = indication.getProperty(i);
  
             if (!propValue.isNull())          if (prop)
             {             {
                 propName = indicationInstance.getProperty(i).getName();              String propName = prop.getName();
                 propPos = indicationClass.findProperty(propName);              Uint32 propPos = indicationClass.findProperty(propName);
                 trapProp = indicationClass.getProperty(propPos);              CIMProperty trapProp = indicationClass.getProperty(propPos);
  
                 if (trapProp.existsQualifier("OID"))              if (trapProp.existsQualifier("MappingStrings"))
                 {                 {
                     if (propName == "trapOid")                  qualifierPos = trapProp.findQualifier("MappingStrings");
                   trapQualifier = trapProp.getQualifier(qualifierPos);
   
                   mapstr1.clear();
                   mapstr1 = trapQualifier.getValue().toString();
   
                   if ((mapstr1.find("OID.IETF") != PEG_NOT_FOUND) &&
                       (mapstr1.find("DataType.IETF") != PEG_NOT_FOUND))
                     {                     {
                         trapOid = propValue.toString();                      if (mapstr1.subString(0, 8) == "OID.IETF")
                     }  
                     else  
                     {                     {
                         qualifierPos = trapProp.findQualifier("OID");                          mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);
                         trapQualifier = trapProp.getQualifier(qualifierPos);                          if (mapstr1.find("|") != PEG_NOT_FOUND)
                         propOIDs.append(trapQualifier.getValue().toString());  
                         propVALUEs.append(propValue.toString());  
                         if (trapProp.existsQualifier("SNMPTYPE"))  
                         {                         {
                             typePos = trapProp.findQualifier("SNMPTYPE");                              mapstr2.clear();
                             trapQualifier = trapProp.getQualifier(typePos);                              mapstr2 = mapstr1.subString(0,
                             propTYPEs.append(trapQualifier.getValue().toString());                                  mapstr1.find("DataType.IETF")-1);
   
                               propOIDs.append(mapstr2);
   
                               propValue.clear();
                               propValue = prop.getValue().toString();
                               propVALUEs.append(propValue);
   
                               mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
   
                               // ATTN: There is a problem with mof compiler in
                               // loading mof with MappingString
   
                               // << 12-03-2002 : NU (HP) >>
   
                               // MappingString{}. It loads if one additional
                               // array is specified as follows:
   
                               // [MappingStrings {
                               // "OID.IETF | SNMP.1.3.6.1.4.1.11.2.3.1.6.3.1.1.4.1.1.2",
                               // "DataType.IETF | OctetString",
                               // "Junk"}]
   
                               // where "Junk" is not required in actual definition.
   
                               propTYPEs.append(mapstr2.subString(0, mapstr2.find("Junk")-1));
                           }
                         }                         }
                         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;      if ((handler.findProperty("TrapDestination") != PEG_NOT_FOUND) &&
           (handler.findProperty("SNMPVersion") != PEG_NOT_FOUND) &&
           (indication.findQualifier("TrapOid") != PEG_NOT_FOUND))
       {
           String community, trapType, destination;   // from handler instance
           String trapOid;     // from indication instance
   
           trapOid = indication.getQualifier(
               indication.findQualifier("TrapOid")).getValue().toString();
  
         emanateTrap.deliverTrap(trapOid,          community = handler.getProperty(
             enterprise,              handler.findProperty("SNMPCommunityName")).getValue().toString();
   
           destination = handler.getProperty(
               handler.findProperty("TrapDestination")).getValue().toString();
   
           trapType = handler.getProperty(
               handler.findProperty("SNMPVersion")).getValue().toString();
   
           emanateTrap.deliverTrap(
               trapOid,
               community,
             destination,             destination,
             trapType,             trapType,
             propOIDs,             propOIDs,
             propTYPEs,             propTYPEs,
             propVALUEs);             propVALUEs);
   
         cout << "Trap Delivered " << endl;  
     }     }
     else  
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
             "Indication is without enterprise OID");  
 } }
  
 // 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


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2