(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.12.12.2 and 1.31

version 1.12.12.2, 2003/08/13 19:39:51 version 1.31, 2006/07/25 18:27:26
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // 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 35 
Line 43 
 #include <iostream> #include <iostream>
 #include <Pegasus/Handler/CIMHandler.h> #include <Pegasus/Handler/CIMHandler.h>
 #include <Pegasus/Repository/CIMRepository.h> #include <Pegasus/Repository/CIMRepository.h>
   #include <Pegasus/Common/Tracer.h>
  
 #include "snmpIndicationHandler.h" #include "snmpIndicationHandler.h"
  
 #ifdef HPUX_EMANATE #ifdef HPUX_EMANATE
 #include "snmpDeliverTrap_emanate.h" #include "snmpDeliverTrap_emanate.h"
   #elif defined (PEGASUS_USE_NET_SNMP)
   #include "snmpDeliverTrap_netsnmp.h"
 #else #else
 #include "snmpDeliverTrap_stub.h" #include "snmpDeliverTrap_stub.h"
 #endif #endif
Line 51 
Line 62 
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
   #ifdef HPUX_EMANATE
           static snmpDeliverTrap_emanate snmpTrap;
   #elif defined (PEGASUS_USE_NET_SNMP)
           static snmpDeliverTrap_netsnmp snmpTrap;
   #else
           static snmpDeliverTrap_stub snmpTrap;
   #endif
   
   snmpIndicationHandler::snmpIndicationHandler()
   {
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::snmpIndicationHandler");
       PEG_METHOD_EXIT();
   }
   
 void snmpIndicationHandler::initialize(CIMRepository* repository) void snmpIndicationHandler::initialize(CIMRepository* repository)
 { {
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::initialize");
   
     _repository = repository;     _repository = repository;
   
   #ifdef PEGASUS_USE_NET_SNMP
       snmpTrap.initialize();
   #endif
   
       PEG_METHOD_EXIT();
   }
   
   void snmpIndicationHandler::terminate()
   {
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::terminate");
   
   #ifdef PEGASUS_USE_NET_SNMP
       snmpTrap.terminate();
   #endif
   
       PEG_METHOD_EXIT();
   }
   
   snmpIndicationHandler::~snmpIndicationHandler()
   {
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::~snmpIndicationHandler");
   
   
       PEG_METHOD_EXIT();
 } }
  
 // l10n - note: ignoring indication language // l10n - note: ignoring indication language
 void snmpIndicationHandler::handleIndication(CIMInstance& handler,  void snmpIndicationHandler::handleIndication(
     CIMInstance& indication, String nameSpace,      const OperationContext& context,
     ContentLanguages & contentLanguages)      const String nameSpace,
       CIMInstance& indication,
       CIMInstance& handler,
       CIMInstance& subscription,
       ContentLanguageList & contentLanguages)
 { {
     Array<String> propOIDs;     Array<String> propOIDs;
     Array<String> propTYPEs;     Array<String> propTYPEs;
Line 75 
Line 135 
     String mapstr1;     String mapstr1;
     String mapstr2;     String mapstr2;
  
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::handleIndication");
   
       try
       {
     CIMClass indicationClass = _repository->getClass(     CIMClass indicationClass = _repository->getClass(
         nameSpace, indication.getClassName(), false);              nameSpace, indication.getClassName(), false, true,
               false, CIMPropertyList());
  
     Uint32 propertyCount = indication.getPropertyCount();     Uint32 propertyCount = indication.getPropertyCount();
  
Line 132 
Line 198 
         // 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  
         snmpDeliverTrap_emanate emanateTrap;  
 #else  
         snmpDeliverTrap_stub emanateTrap;  
 #endif  
   
     Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));     Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
     Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));     Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));
     Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (     Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (
Line 149 
Line 209 
  
     if ((targetHostPos != PEG_NOT_FOUND) &&     if ((targetHostPos != PEG_NOT_FOUND) &&
         (targetHostFormatPos != PEG_NOT_FOUND) &&         (targetHostFormatPos != PEG_NOT_FOUND) &&
         (snmpVersionPos != PEG_NOT_FOUND) &&              (snmpVersionPos != PEG_NOT_FOUND))
         (indicationClass.findQualifier(CIMName ("MappingStrings")) !=  
             PEG_NOT_FOUND))  
     {     {
         // properties from the handler instance         // properties from the handler instance
         String targetHost, otherTargetHostFormat;              String targetHost;
         String securityName, engineID;              String otherTargetHostFormat = String();
         Uint16 targetHostFormat, snmpVersion;              String securityName = String();
               String engineID = String();
               Uint16 targetHostFormat = 0;
               Uint16 snmpVersion = 0;
         Uint32 portNumber;         Uint32 portNumber;
  
         // trapOid from indication Class              String trapOid;
               //
               //  Get snmpTrapOid from context
               //
               try
               {
                   SnmpTrapOidContainer trapContainer = context.get
                       (SnmpTrapOidContainer::NAME);
   
                   trapOid = trapContainer.getSnmpTrapOid();
               }
               catch (Exception& e)
               {
                   // get trapOid from indication Class
  
         String trapOid = indicationClass.getQualifier(                  Uint32 pos = indicationClass.findQualifier(CIMName ("MappingStrings"));
             indicationClass.findQualifier                  if (pos != PEG_NOT_FOUND)
                 (CIMName ("MappingStrings"))).getValue().toString();                  {
                       trapOid = indicationClass.getQualifier(pos).getValue().toString();
  
         Uint32 index = trapOid.find("SNMP.");                      trapOid = trapOid.subString(11, PEG_NOT_FOUND);
  
         if (index != PEG_NOT_FOUND)                      if ((String::compare(trapOid, "SNMP.", 5)) == 0)
         {         {
             trapOid = trapOid.subString(index+5);                          trapOid = trapOid.subString(5, (trapOid.size()-6));
             trapOid = trapOid.subString(0, (trapOid.size()-1));  
         }         }
         else         else
         {         {
                           PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                                            "Invalid MappingStrings Value " + trapOid);
                           PEG_METHOD_EXIT();
           // l10n           // l10n
   
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Invalid MappingStrings Value");
   
           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
                                          MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_VALUE",                                                     MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_MS_VALUE",
                                                             "Invalid $0 Value", "MappingStrings"));                                                                         "Invalid MappingStrings Value"));
                       }
                   }
                   else
                   {
                       PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                                    "Qualifier MappingStrings can not be found.");
                       PEG_METHOD_EXIT();
                       //L10N_ TODO DONE
                       //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Qualifier MappingStrings can not be found");
                       MessageLoaderParms parms("Handler.snmpIndicationHandler.snmpIndicationHandler.QUALIFIER_MAPPINGS_NOT_FOUND",
                                                                    "Qualifier MappingStrings can not be found");
                       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);
                   }
         }         }
  
         handler.getProperty(targetHostPos).getValue().get(targetHost);         handler.getProperty(targetHostPos).getValue().get(targetHost);
         handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);         handler.getProperty(targetHostFormatPos).getValue().get(targetHostFormat);
               if (otherTargetHostFormatPos != PEG_NOT_FOUND)
               {
         handler.getProperty(otherTargetHostFormatPos).getValue().get         handler.getProperty(otherTargetHostFormatPos).getValue().get
                 (otherTargetHostFormat);                 (otherTargetHostFormat);
               }
               if (portNumberPos != PEG_NOT_FOUND)
               {
         handler.getProperty(portNumberPos).getValue().get(portNumber);         handler.getProperty(portNumberPos).getValue().get(portNumber);
               }
               else
               {
                   // default port
                   portNumber = SNMP_TRAP_DEFAULT_PORT;
               }
   
         handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);         handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
               if (securityNamePos != PEG_NOT_FOUND)
               {
         handler.getProperty(securityNamePos).getValue().get(securityName);         handler.getProperty(securityNamePos).getValue().get(securityName);
               }
               if (engineIDPos != PEG_NOT_FOUND)
               {
         handler.getProperty(engineIDPos).getValue().get(engineID);         handler.getProperty(engineIDPos).getValue().get(engineID);
               }
  
         emanateTrap.deliverTrap(              snmpTrap.deliverTrap(
             trapOid,             trapOid,
             securityName,             securityName,
             targetHost,             targetHost,
Line 207 
Line 313 
     }     }
     else     else
     {     {
               PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                   "Invalid IndicationHandlerSNMPMapper instance.");
               PEG_METHOD_EXIT();
       // l10n       // l10n
  
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
       // "Invalid IndicationHandlerSNMPMapper instance");       // "Invalid IndicationHandlerSNMPMapper instance");
  
       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,       throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
                                      MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_INSTANCE",                                       MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_SNMP_INSTANCE",
                                                         "Invalid $0 instance", "IndicationHandlerSNMPMapper"));                                                          "Invalid IndicationHandlerSNMPMapper instance"));
           }
       }
       catch (CIMException & c)
       {
           PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, c.getMessage());
           PEG_METHOD_EXIT();
   
           throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, c.getMessage());
     }     }
       catch (Exception& e)
       {
           PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, e.getMessage());
           PEG_METHOD_EXIT();
   
           throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, e.getMessage());
       }
       catch (...)
       {
           PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                   "Failed to deliver trap.");
           PEG_METHOD_EXIT();
   
           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
                   MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP",
                                      "Failed to deliver trap."));
       }
   
       PEG_METHOD_EXIT();
 } }
  
 // 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.12.12.2  
changed lines
  Added in v.1.31

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2