(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.23 and 1.34

version 1.23, 2004/01/08 19:13:39 version 1.34, 2006/11/14 18:34:53
Line 1 
Line 1 
 //%2003////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // Company, L. P., IBM Corp., 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.; // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
 // IBM Corp.; EMC Corporation, The Open Group. // 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 23 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)  
 //  
 // 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>
Line 43 
Line 43 
  
 #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
  
 // l10n  
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
  
   PEGASUS_USING_STD;
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 PEGASUS_USING_STD;  snmpIndicationHandler::snmpIndicationHandler()
   {
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpIndicationHandler::snmpIndicationHandler");
   
   #ifdef HPUX_EMANATE
       _snmpTrapSender = new snmpDeliverTrap_emanate();
   #elif defined (PEGASUS_USE_NET_SNMP)
       _snmpTrapSender = new snmpDeliverTrap_netsnmp();
   #else
       _snmpTrapSender = new snmpDeliverTrap_stub();
   #endif
   
       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;
   
       _snmpTrapSender->initialize();
   
       PEG_METHOD_EXIT();
   }
   
   void snmpIndicationHandler::terminate()
   {
       PEG_METHOD_ENTER(TRC_IND_HANDLER,
           "snmpIndicationHandler::terminate");
   
       _snmpTrapSender->terminate();
   
       PEG_METHOD_EXIT();
   }
   
   snmpIndicationHandler::~snmpIndicationHandler()
   {
       PEG_METHOD_ENTER(TRC_IND_HANDLER,
           "snmpIndicationHandler::~snmpIndicationHandler");
   
       delete _snmpTrapSender;
   
       PEG_METHOD_EXIT();
 } }
  
 // l10n - note: ignoring indication language // l10n - note: ignoring indication language
 void snmpIndicationHandler::handleIndication( void snmpIndicationHandler::handleIndication(
     const OperationContext& context,     const OperationContext& context,
       const String nameSpace,
       CIMInstance& indication,
     CIMInstance& handler,     CIMInstance& handler,
     CIMInstance& indication, String nameSpace,      CIMInstance& subscription,
     ContentLanguages & contentLanguages)      ContentLanguageList & contentLanguages)
 { {
     Array<String> propOIDs;     Array<String> propOIDs;
     Array<String> propTYPEs;     Array<String> propTYPEs;
Line 103 
Line 149 
                 {                 {
                     CIMProperty trapProp = indicationClass.getProperty(propPos);                     CIMProperty trapProp = indicationClass.getProperty(propPos);
  
                     qualifierPos = trapProp.findQualifier(CIMName ("MappingStrings"));                      qualifierPos =
                           trapProp.findQualifier(CIMName("MappingStrings"));
                     if (qualifierPos != PEG_NOT_FOUND)                     if (qualifierPos != PEG_NOT_FOUND)
                     {                     {
                         trapQualifier = trapProp.getQualifier(qualifierPos);                         trapQualifier = trapProp.getQualifier(qualifierPos);
Line 116 
Line 163 
                         {                         {
                             if (mapstr1.subString(0, 8) == "OID.IETF")                             if (mapstr1.subString(0, 8) == "OID.IETF")
                             {                             {
                                 mapstr1 = mapstr1.subString(mapstr1.find("SNMP.")+5);                                  mapstr1 = mapstr1.subString(
                                       mapstr1.find("SNMP.") + 5);
                                 if (mapstr1.find("|") != PEG_NOT_FOUND)                                 if (mapstr1.find("|") != PEG_NOT_FOUND)
                                 {                                 {
                                     mapstr2.clear();                                     mapstr2.clear();
Line 128 
Line 176 
                                     propValue = prop.getValue().toString();                                     propValue = prop.getValue().toString();
                                     propVALUEs.append(propValue);                                     propVALUEs.append(propValue);
  
                                     mapstr2 = mapstr1.subString(mapstr1.find("|")+2);                                      mapstr2 = mapstr1.subString(
                                     mapstr2 = mapstr2.subString(0, mapstr2.size()-1);                                          mapstr1.find("|") + 2);
                                       mapstr2 = mapstr2.subString(
                                           0, mapstr2.size() - 1);
                                     propTYPEs.append(mapstr2);                                     propTYPEs.append(mapstr2);
                                 }                                 }
                             }                             }
Line 143 
Line 193 
         // 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  
         static snmpDeliverTrap_emanate emanateTrap;  
 #else  
         static snmpDeliverTrap_stub emanateTrap;  
 #endif  
   
         Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));         Uint32 targetHostPos = handler.findProperty(CIMName ("TargetHost"));
         Uint32 targetHostFormatPos = handler.findProperty(CIMName ("TargetHostFormat"));          Uint32 targetHostFormatPos =
         Uint32 otherTargetHostFormatPos = handler.findProperty(CIMName (              handler.findProperty(CIMName("TargetHostFormat"));
                                       "OtherTargetHostFormat"));          Uint32 otherTargetHostFormatPos =
               handler.findProperty(CIMName("OtherTargetHostFormat"));
         Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));         Uint32 portNumberPos = handler.findProperty(CIMName ("PortNumber"));
         Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));         Uint32 snmpVersionPos = handler.findProperty(CIMName ("SNMPVersion"));
         Uint32 securityNamePos =  handler.findProperty(CIMName ("SNMPSecurityName"));          Uint32 securityNamePos =
               handler.findProperty(CIMName("SNMPSecurityName"));
         Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));         Uint32 engineIDPos =  handler.findProperty(CIMName ("SNMPEngineID"));
  
         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;             String targetHost;
Line 177 
Line 221 
             //             //
             //  Get snmpTrapOid from context             //  Get snmpTrapOid from context
             //             //
             try              if (context.contains(SnmpTrapOidContainer::NAME))
             {             {
                 SnmpTrapOidContainer trapContainer = context.get                  SnmpTrapOidContainer trapContainer =
                     (SnmpTrapOidContainer::NAME);                      context.get(SnmpTrapOidContainer::NAME);
  
                 trapOid = trapContainer.getSnmpTrapOid();                 trapOid = trapContainer.getSnmpTrapOid();
             }             }
             catch (Exception& e)              else
             {             {
                 // get trapOid from indication Class                 // get trapOid from indication Class
  
                 Uint32 pos = indicationClass.findQualifier(CIMName ("MappingStrings"));                  Uint32 pos =
                       indicationClass.findQualifier(CIMName("MappingStrings"));
                 if (pos != PEG_NOT_FOUND)                 if (pos != PEG_NOT_FOUND)
                 {                 {
                     trapOid = indicationClass.getQualifier(pos).getValue().toString();                      trapOid =
                           indicationClass.getQualifier(pos).getValue().toString();
  
                     trapOid = trapOid.subString(11, PEG_NOT_FOUND);                     trapOid = trapOid.subString(11, PEG_NOT_FOUND);
  
Line 204 
Line 250 
                         PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,                         PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                                          "Invalid MappingStrings Value " + trapOid);                                          "Invalid MappingStrings Value " + trapOid);
                         PEG_METHOD_EXIT();                         PEG_METHOD_EXIT();
                         // l10n  
                         // 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_MS_VALUE",                              MessageLoaderParms(
                                   "Handler.snmpIndicationHandler."
                                       "snmpIndicationHandler.INVALID_MS_VALUE",
                                                                        "Invalid MappingStrings Value"));                                                                        "Invalid MappingStrings Value"));
                     }                     }
                 }                 }
Line 216 
Line 262 
                     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,                     PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                                  "Qualifier MappingStrings can not be found.");                                  "Qualifier MappingStrings can not be found.");
                     PEG_METHOD_EXIT();                     PEG_METHOD_EXIT();
                     //L10N_ TODO DONE                      MessageLoaderParms parms(
                     //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, "Qualifier MappingStrings can not be found");                          "Handler.snmpIndicationHandler.snmpIndicationHandler."
                     MessageLoaderParms parms("Handler.snmpIndicationHandler.snmpIndicationHandler.QUALIFIER_MAPPINGS_NOT_FOUND",                              "QUALIFIER_MAPPINGS_NOT_FOUND",
                                                                  "Qualifier MappingStrings can not be found");                                                                  "Qualifier MappingStrings can not be found");
                     throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, parms);                     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)             if (otherTargetHostFormatPos != PEG_NOT_FOUND)
             {             {
                 handler.getProperty(otherTargetHostFormatPos).getValue().get                  handler.getProperty(otherTargetHostFormatPos).getValue().get(
                     (otherTargetHostFormat);                      otherTargetHostFormat);
             }             }
             if (portNumberPos != PEG_NOT_FOUND)             if (portNumberPos != PEG_NOT_FOUND)
             {             {
Line 244 
Line 291 
             handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);             handler.getProperty(snmpVersionPos).getValue().get(snmpVersion);
             if (securityNamePos != PEG_NOT_FOUND)             if (securityNamePos != PEG_NOT_FOUND)
             {             {
                 handler.getProperty(securityNamePos).getValue().get(securityName);                  handler.getProperty(securityNamePos).getValue().get(
                       securityName);
             }             }
             if (engineIDPos != PEG_NOT_FOUND)             if (engineIDPos != PEG_NOT_FOUND)
             {             {
                 handler.getProperty(engineIDPos).getValue().get(engineID);                 handler.getProperty(engineIDPos).getValue().get(engineID);
             }             }
  
             emanateTrap.deliverTrap(              _snmpTrapSender->deliverTrap(
                 trapOid,                 trapOid,
                 securityName,                 securityName,
                 targetHost,                 targetHost,
Line 269 
Line 317 
             PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,             PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4,
                 "Invalid IndicationHandlerSNMPMapper instance.");                 "Invalid IndicationHandlerSNMPMapper instance.");
             PEG_METHOD_EXIT();             PEG_METHOD_EXIT();
           // l10n              throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                   "Handler.snmpIndicationHandler.snmpIndicationHandler."
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,                      "INVALID_SNMP_INSTANCE",
           // "Invalid IndicationHandlerSNMPMapper instance");  
   
           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,  
                                      MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.INVALID_SNMP_INSTANCE",  
                                                         "Invalid IndicationHandlerSNMPMapper instance"));                                                         "Invalid IndicationHandlerSNMPMapper instance"));
         }         }
     }     }
Line 283 
Line 327 
     {     {
         PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, c.getMessage());         PEG_TRACE_STRING(TRC_IND_HANDLER, Tracer::LEVEL4, c.getMessage());
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
   
         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, c.getMessage());         throw PEGASUS_CIM_EXCEPTION (CIM_ERR_FAILED, c.getMessage());
     }     }
     catch (Exception& e)     catch (Exception& e)
Line 299 
Line 342 
                 "Failed to deliver trap.");                 "Failed to deliver trap.");
         PEG_METHOD_EXIT();         PEG_METHOD_EXIT();
  
         throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
                 MessageLoaderParms("Handler.snmpIndicationHandler.snmpIndicationHandler.FAILED_TO_DELIVER_TRAP",              "Handler.snmpIndicationHandler.snmpIndicationHandler."
                   "FAILED_TO_DELIVER_TRAP",
                                    "Failed to deliver trap."));                                    "Failed to deliver trap."));
     }     }
   
       PEG_METHOD_EXIT();
 } }
  
 // This is the dynamic entry point into this dynamic module. The name of  PEGASUS_NAMESPACE_END
 // this handler is "snmpIndicationHandler" which is appended to "PegasusCreateHandler_"  
 // to form a symbol name. This function is called by the HandlerTable  
 // to load this handler.  
  
 extern "C" PEGASUS_EXPORT CIMHandler*  PEGASUS_USING_PEGASUS;
     PegasusCreateHandler_snmpIndicationHandler() {  
   // This is the entry point into this dynamic module.
   
   extern "C" PEGASUS_EXPORT CIMHandler* PegasusCreateHandler(
       const String& handlerName)
   {
       if (handlerName == "snmpIndicationHandler")
       {
     return new snmpIndicationHandler;     return new snmpIndicationHandler;
 } }
  
 PEGASUS_NAMESPACE_END      return 0;
   }


Legend:
Removed from v.1.23  
changed lines
  Added in v.1.34

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2