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

Diff for /pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_netsnmp.cpp between version 1.2 and 1.8

version 1.2, 2005/12/08 00:06:34 version 1.8, 2006/08/11 19:47:07
Line 1 
Line 1 
 //%2005////////////////////////////////////////////////////////////////////////  //%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.
Line 8 
Line 8 
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 // EMC Corporation; VERITAS Software Corporation; The Open Group. // 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 27 
Line 29 
 // //
 //============================================================================== //==============================================================================
 // //
 // Author: Yi Zhou, Hewlett-Packard Company (Yi.Zhou@hp.com)  
 //  
 // Modified By:  
 //  
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Packer.h> #include <Pegasus/Common/Packer.h>
Line 39 
Line 37 
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
   void snmpDeliverTrap_netsnmp::initialize()
   {
   
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpDeliverTrap_netsnmp::initialize");
   
       // Defined default MIB modules (in net-snmp-config.h) do not need to be
       // loaded and loading them can cause some stderr;
       // use environment variable MIBS to override the default MIB modules.
       // If there is no MIBS environment variable, add it in.
       char *envVar;
       envVar = getenv("MIBS");
   
       if (envVar == NULL)
       {
           putenv("MIBS=");
       }
   
       // Initialize the mib reader
       netsnmp_set_mib_directory("");
       init_mib();
   
       // Initializes the SNMP library
       init_snmp("snmpIndicationHandler");
   
       // windows32 specific initialization (is a NOOP on unix)
       SOCK_STARTUP;
   
       PEG_METHOD_EXIT ();
   
   }
   
   void snmpDeliverTrap_netsnmp::terminate()
   {
   
       PEG_METHOD_ENTER (TRC_IND_HANDLER,
           "snmpDeliverTrap_netsnmp::terminate");
   
       SOCK_CLEANUP;
   
       PEG_METHOD_EXIT ();
   }
   
 void snmpDeliverTrap_netsnmp::deliverTrap( void snmpDeliverTrap_netsnmp::deliverTrap(
         const String& trapOid,         const String& trapOid,
         const String& securityName,         const String& securityName,
Line 57 
Line 98 
         "snmpDeliverTrap_netsnmp::deliverTrap");         "snmpDeliverTrap_netsnmp::deliverTrap");
  
     void *sessionHandle;     void *sessionHandle;
     struct snmp_session snmpSession, *sessionPtr;      struct snmp_session *sessionPtr;
  
     struct snmp_pdu *snmpPdu;     struct snmp_pdu *snmpPdu;
  
     // Creates a SNMP session     // Creates a SNMP session
     _createSession(targetHost, portNumber, securityName, snmpSession,      _createSession(targetHost, portNumber, securityName,
                    sessionHandle, sessionPtr);                    sessionHandle, sessionPtr);
  
     try     try
Line 136 
Line 177 
     const String & targetHost,     const String & targetHost,
     Uint32 portNumber,     Uint32 portNumber,
     const String & securityName,     const String & securityName,
     snmp_session & snmpSession,  
     void *&sessionHandle,     void *&sessionHandle,
     snmp_session *&sessionPtr)     snmp_session *&sessionPtr)
 { {
Line 147 
Line 187 
     char *errStr;     char *errStr;
     String exceptionStr;     String exceptionStr;
  
     // Defined default MIB modules (in net-snmp-config.h) do not need to be      struct snmp_session snmpSession;
     // loaded and loading them can cause some stderr;  
     // use environment variable MIBS to override the default MIB modules.  
     // If there is no MIBS environment variable, add it in.  
  
     char *envVar;  
     envVar = getenv("MIBS");  
   
     if (envVar == NULL)  
     {     {
         putenv("MIBS=");      AutoMutex autoMut(_sessionInitMutex);
     }  
   
     // Initialize the mib reader  
     netsnmp_set_mib_directory("");  
     init_mib();  
   
     // Initializes the SNMP library  
     init_snmp("snmpIndicationHandler");  
   
     // Prepares a struct snmp_session that will be used for a set of  
     // SNMP transactions  
     snmp_sess_init(&snmpSession);     snmp_sess_init(&snmpSession);
  
     // windows32 specific initialization (is a NOOP on unix)  
     SOCK_STARTUP;  
   
     CString targetHostCStr = targetHost.getCString();     CString targetHostCStr = targetHost.getCString();
  
     // peername has format: targetHost:portNumber     // peername has format: targetHost:portNumber
Line 181 
Line 200 
                                           1+32));                                           1+32));
     sprintf(snmpSession.peername, "%s:%u", (const char*)targetHostCStr,     sprintf(snmpSession.peername, "%s:%u", (const char*)targetHostCStr,
             portNumber);             portNumber);
   
     sessionHandle = snmp_sess_open(&snmpSession);     sessionHandle = snmp_sess_open(&snmpSession);
       }
  
     if (sessionHandle == NULL)     if (sessionHandle == NULL)
     {     {
         exceptionStr = _MSG_SESSION_OPEN_FAILED;         exceptionStr = _MSG_SESSION_OPEN_FAILED;
  
         // Get library, system errno         // Get library, system errno
         snmp_sess_error(&snmpSession, &libErr, &sysErr, &errStr);          snmp_error(&snmpSession, &libErr, &sysErr, &errStr);
  
         exceptionStr.append(errStr);         exceptionStr.append(errStr);
  
         free(errStr);         free(errStr);
  
         SOCK_CLEANUP;  
   
         PEG_METHOD_EXIT ();         PEG_METHOD_EXIT ();
  
         throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,         throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
Line 235 
Line 254 
             communityName = securityName;             communityName = securityName;
         }         }
  
         if (snmpSession.peername)  
         {  
             free(snmpSession.peername);             free(snmpSession.peername);
         }  
  
         if (sessionPtr->community)  
         {  
             free(sessionPtr->community);             free(sessionPtr->community);
         }  
  
         CString communityNameCStr = communityName.getCString();         CString communityNameCStr = communityName.getCString();
         size_t communityNameLen = strlen(communityNameCStr);         size_t communityNameLen = strlen(communityNameCStr);
Line 274 
Line 287 
  
     snmp_sess_close(sessionHandle);     snmp_sess_close(sessionHandle);
  
     SOCK_CLEANUP;  
   
     PEG_METHOD_EXIT ();     PEG_METHOD_EXIT ();
 } }
  
Line 410 
Line 421 
             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                 MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY,                 MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY,
                                    _MSG_VERSION_NOT_SUPPORTED));                                    _MSG_VERSION_NOT_SUPPORTED));
             break;  
         }         }
     }     }
  
Line 517 
Line 527 
             strcat(numericEntOid, oidSubIdentifiers[i]);             strcat(numericEntOid, oidSubIdentifiers[i]);
         }         }
  
         if (oidSubIdentifiers[oidSubIdentifiers.size()-2] != "0")          if (strcmp(oidSubIdentifiers[oidSubIdentifiers.size()-2], "0") != 0)
         {         {
             strcat(numericEntOid, ".");             strcat(numericEntOid, ".");
             strcat(numericEntOid,             strcat(numericEntOid,


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2