(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.4 and 1.14

version 1.4, 2002/03/21 23:00: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 <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/PegasusVersion.h>
   
 #include <iostream> #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;)  
 } }
  
   // l10n - note: ignoring indication language
 void snmpIndicationHandler::handleIndication(CIMInstance& handler, void snmpIndicationHandler::handleIndication(CIMInstance& handler,
     CIMInstance& indication, String nameSpace)      CIMInstance& indication, String nameSpace,
       ContentLanguages & contentLanguages)
 { {
     Array<String> propOIDs;     Array<String> propOIDs;
     Array<String> propTYPEs;     Array<String> propTYPEs;
Line 75 
Line 75 
     CIMClass indicationClass = _repository->getClass(     CIMClass indicationClass = _repository->getClass(
         nameSpace, indication.getClassName(), false);         nameSpace, indication.getClassName(), false);
  
     for (Uint32 i=0; i<indication.getPropertyCount();i++)      Uint32 propertyCount = indication.getPropertyCount();
   
       for (Uint32 i=0; i < propertyCount; i++)
     {     {
         prop = indication.getProperty(i);         prop = indication.getProperty(i);
  
         if (prop)          if (!prop.isUninitialized())
         {         {
             String propName = prop.getName();              CIMName propName = prop.getName();
             Uint32 propPos = indicationClass.findProperty(propName);             Uint32 propPos = indicationClass.findProperty(propName);
             if (propPos != PEG_NOT_FOUND)             if (propPos != PEG_NOT_FOUND)
             {             {
             CIMProperty trapProp = indicationClass.getProperty(propPos);             CIMProperty trapProp = indicationClass.getProperty(propPos);
  
             if (trapProp.existsQualifier("MappingStrings"))              qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));
               if (qualifierPos != PEG_NOT_FOUND)
             {             {
                 qualifierPos = trapProp.findQualifier("MappingStrings");  
                 trapQualifier = trapProp.getQualifier(qualifierPos);                 trapQualifier = trapProp.getQualifier(qualifierPos);
  
                 mapstr1.clear();                 mapstr1.clear();
Line 113 
Line 115 
                             propVALUEs.append(propValue);                             propVALUEs.append(propValue);
  
                             mapstr2 = mapstr1.subString(mapstr1.find("|")+2);                             mapstr2 = mapstr1.subString(mapstr1.find("|")+2);
                               mapstr2 = mapstr2.subString(0, mapstr2.size()-1);
                             propTYPEs.append(mapstr2);                             propTYPEs.append(mapstr2);
                         }                         }
                     }                     }
Line 132 
Line 135 
         snmpDeliverTrap_stub emanateTrap;         snmpDeliverTrap_stub emanateTrap;
 #endif #endif
  
     if ((handler.findProperty("TrapDestination") != PEG_NOT_FOUND) &&      Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
         (handler.findProperty("SNMPVersion") != PEG_NOT_FOUND) &&      Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
         (indication.findQualifier("TrapOid") != PEG_NOT_FOUND))      Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
     {                                        "OtherTargetHostFormat"));
         String community, trapType, destination;   // from handler instance      Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
         String trapOid;     // from indication instance      Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
       Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));
         trapOid = indication.getQualifier(      Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
             indication.findQualifier("TrapOid")).getValue().toString();  
       if ((targetHostPos != PEG_NOT_FOUND) &&
         community = handler.getProperty(          (targetHostFormatPos != PEG_NOT_FOUND) &&
             handler.findProperty("SNMPCommunityName")).getValue().toString();          (snmpVersionPos != PEG_NOT_FOUND) &&
           (indicationClass.findQualifier(CIMName ("MappingStrings")) !=
         destination = handler.getProperty(              PEG_NOT_FOUND))
             handler.findProperty("TrapDestination")).getValue().toString();      {
           // properties from the handler instance
         trapType = handler.getProperty(          String targetHost, otherTargetHostFormat;
             handler.findProperty("SNMPVersion")).getValue().toString();          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.");
   
           if (index != PEG_NOT_FOUND)
           {
               trapOid = trapOid.subString(index+5);
               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(         emanateTrap.deliverTrap(
             trapOid,             trapOid,
             community,              securityName,
             destination,              targetHost,
             trapType,              targetHostFormat,
               otherTargetHostFormat,
               portNumber,
               snmpVersion,
               engineID,
             propOIDs,             propOIDs,
             propTYPEs,             propTYPEs,
             propVALUEs);             propVALUEs);
     }     }
       else
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                   "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.4  
changed lines
  Added in v.1.14

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2