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

Diff for /pegasus/src/Pegasus/Handler/snmpIndicationHandler/snmpDeliverTrap_emanate.cpp between version 1.22 and 1.31

version 1.22, 2006/01/30 16:17:54 version 1.31, 2010/12/22 12:19:06
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  //
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  // Permission is hereby granted, free of charge, to any person obtaining a
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  // copy of this software and associated documentation files (the "Software"),
 // EMC Corporation; Symantec Corporation; The Open Group.  // to deal in the Software without restriction, including without limitation
 //  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // and/or sell copies of the Software, and to permit persons to whom the
 // of this software and associated documentation files (the "Software"), to  // Software is furnished to do so, subject to the following conditions:
 // deal in the Software without restriction, including without limitation the  //
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // The above copyright notice and this permission notice shall be included
 // sell copies of the Software, and to permit persons to whom the Software is  // in all copies or substantial portions of the Software.
 // furnished to do so, subject to the following conditions:  //
 //  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  //////////////////////////////////////////////////////////////////////////
 //  
 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)  
 //  
 // Modified By: Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)  
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 40 
Line 34 
 #include <Pegasus/Common/InternalException.h> #include <Pegasus/Common/InternalException.h>
 #include "snmpDeliverTrap_emanate.h" #include "snmpDeliverTrap_emanate.h"
  
 // l10n  
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
  
 // EMANATE specific declarations and entry points - MUST be in begining // EMANATE specific declarations and entry points - MUST be in begining
Line 57 
Line 50 
  
 // This code would normally be generated by Emanate from defined MIB objects. // This code would normally be generated by Emanate from defined MIB objects.
 // Since we do not have MIB objects defined, just defined here to load // Since we do not have MIB objects defined, just defined here to load
 // subagent as library. OidList[] provides objects for entry point to master agent.  // subagent as library. OidList[] provides objects for entry point to master
   // agent.
  
 // The objects internal to the agent // The objects internal to the agent
 ObjectInfo OidList[] = ObjectInfo OidList[] =
 { {
 { { 0, NULL },      {
           { 0, NULL },
 #ifndef LIGHT #ifndef LIGHT
     NULL,     NULL,
 #endif /* LIGHT */ #endif /* LIGHT */
     0, 0, 0, 0,     0, 0, 0, 0,
     NULL, NULL }          NULL, NULL
       }
 }; };
  
 // This code would normally be generated by Emanate in k_* routine from defined MIB objects.  // This code would normally be generated by Emanate in k_* routine from
 // Since we do not have MIB objects defined, just define here to pass compile and  // defined MIB objects.  Since we do not have MIB objects defined, just
 // enable entry point for master agent to start communication with library.  // define here to pass compile and enable entry point for master agent to
   // start communication with library.
  
 // Called by the master agent during initialization */ // Called by the master agent during initialization */
 int k_initialize() int k_initialize()
Line 88 
Line 85 
  
 snmpDeliverTrap_emanate::snmpDeliverTrap_emanate() snmpDeliverTrap_emanate::snmpDeliverTrap_emanate()
 { {
     //  
     // Initialize Subagent and establish comunication with the Master Agent  
     //  
     initialize();  
 } }
  
 snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate() snmpDeliverTrap_emanate::~snmpDeliverTrap_emanate()
 { {
     //  
     // Close the connection to the Master Agent and shut down the  
     // Subagent  
     //  
     EndSubagent();  
 } }
  
  
Line 119 
Line 107 
  
     if(InitSubagent() == -1)     if(InitSubagent() == -1)
     {     {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
       // l10n              _MSG_INITSUBAGENT_FAILED_KEY,
   
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
       //   _MSG_INITSUBAGENT_FAILED);  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                     MessageLoaderParms(_MSG_INITSUBAGENT_FAILED_KEY,  
                                                        _MSG_INITSUBAGENT_FAILED));                                                        _MSG_INITSUBAGENT_FAILED));
  
     }     }
 } }
  
   void snmpDeliverTrap_emanate::terminate()
   {
       //
       // Close the connection to the Master Agent and shut down the
       // Subagent
       //
       EndSubagent();
   }
   
  
 void snmpDeliverTrap_emanate::deliverTrap( void snmpDeliverTrap_emanate::deliverTrap(
         const String& trapOid,         const String& trapOid,
Line 142 
Line 133 
         const Uint32& portNumber,         const Uint32& portNumber,
         const Uint16& snmpVersion,         const Uint16& snmpVersion,
         const String& engineID,         const String& engineID,
           const Uint8& snmpSecLevel,
           const Uint8& snmpSecAuthProto,
           const Array<Uint8>& snmpSecAuthKey,
           const Uint8& snmpSecPrivProto,
           const Array<Uint8>& snmpSecPrivKey,
         const Array<String>& vbOids,         const Array<String>& vbOids,
         const Array<String>& vbTypes,         const Array<String>& vbTypes,
         const Array<String>& vbValues)         const Array<String>& vbValues)
Line 157 
Line 153 
  
     if (sendtrapOid == NULL)     if (sendtrapOid == NULL)
     {     {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
       // l10n              _MSG_INVALID_KEY,
   
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
       // _MSG_INVALID_TRAPOID);  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                     MessageLoaderParms(_MSG_INVALID_KEY,  
                                                        _MSG_INVALID_TRAPOID));                                                        _MSG_INVALID_TRAPOID));
     }     }
  
Line 183 
Line 173 
  
             if (ipAddr == NULL)             if (ipAddr == NULL)
             {             {
   
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //   _MSG_DESTINATION_NOT_FOUND);  
   
               throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
                                              MessageLoaderParms(_MSG_DESTINATION_NOT_FOUND_KEY,                      MessageLoaderParms(
                          _MSG_DESTINATION_NOT_FOUND_KEY,
                                                                 _MSG_DESTINATION_NOT_FOUND));                                                                 _MSG_DESTINATION_NOT_FOUND));
  
             }             }
Line 204 
Line 189 
         }         }
         default:         default:
         {         {
   
           // l10n  
   
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,  
           // _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED);  
   
           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,           throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
                                          MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY,                  MessageLoaderParms(
                       _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY,
                                                             _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED));                                                             _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED));
   
             break;             break;
         }         }
     }     }
Line 237 
Line 216 
  
     if (community_name == NULL)     if (community_name == NULL)
     {     {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
       // l10n              _MSG_INVALID_SECURITY_NAME_KEY,
   
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
       //   _MSG_INVALID_SECURITY_NAME);  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                     MessageLoaderParms(_MSG_INVALID_SECURITY_NAME_KEY,  
                                                        _MSG_INVALID_SECURITY_NAME));                                                        _MSG_INVALID_SECURITY_NAME));
   
     }     }
  
     // getting IP address of the host     // getting IP address of the host
Line 270 
Line 242 
     if (!_isValidOctet(s1) || !_isValidOctet(s2) ||     if (!_isValidOctet(s1) || !_isValidOctet(s2) ||
         !_isValidOctet(s3) || !_isValidOctet(s4))         !_isValidOctet(s3) || !_isValidOctet(s4))
     {     {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
       // l10n              _MSG_INVALID_OCTET_VALUE_KEY,
   
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
       //   _MSG_INVALID_OCTET_VALUE);  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                   MessageLoaderParms(_MSG_INVALID_OCTET_VALUE_KEY,  
                                                      _MSG_INVALID_OCTET_VALUE));                                                      _MSG_INVALID_OCTET_VALUE));
     }     }
  
Line 287 
Line 253 
  
     if (agent_addr == NULL)     if (agent_addr == NULL)
     {     {
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
       // l10n              _MSG_CREATE_OCTET_FAILED_KEY,
   
       // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
       //   _MSG_CREATE_OCTET_FAILED);  
   
       throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                     MessageLoaderParms(_MSG_CREATE_OCTET_FAILED_KEY,  
                                                        _MSG_CREATE_OCTET_FAILED));                                                        _MSG_CREATE_OCTET_FAILED));
   
     }     }
  
     // fill in values for OctetString     // fill in values for OctetString
Line 385 
Line 344 
  
         if (enterpriseOid == NULL)         if (enterpriseOid == NULL)
         {         {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
           // l10n                  _MSG_INVALID_ENTERPRISEOID_KEY,
   
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
           //   _MSG_INVALID_ENTERPRISEOID);  
   
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                         MessageLoaderParms(_MSG_INVALID_ENTERPRISEOID_KEY,  
                                                            _MSG_INVALID_ENTERPRISEOID));                                                            _MSG_INVALID_ENTERPRISEOID));
         }         }
     }     }
Line 405 
Line 358 
  
         if ((object = MakeOIDFromDot(_vbOid)) == NULL)         if ((object = MakeOIDFromDot(_vbOid)) == NULL)
         {         {
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED, MessageLoaderParms(
           // l10n                  _MSG_INVALID_PROPERTYOID_KEY,
   
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
           //   _MSG_INVALID_PROPERTYOID);  
   
           throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,  
                                         MessageLoaderParms(_MSG_INVALID_PROPERTYOID_KEY,  
                                                            _MSG_INVALID_PROPERTYOID));                                                            _MSG_INVALID_PROPERTYOID));
         }         }
  
Line 423 
Line 370 
              value = CloneOctetString(MakeOctetStringFromText(_vbValue));              value = CloneOctetString(MakeOctetStringFromText(_vbValue));
              if (value == NULL)              if (value == NULL)
              {              {
   
                // l10n  
   
                // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
                //   _MSG_INVALID_PROPERTYVALUE);  
   
                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,                  throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                                MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,                      MessageLoaderParms(
                           _MSG_INVALID_PROPERTYVALUE_KEY,
                                                                   _MSG_INVALID_PROPERTYVALUE));                                                                   _MSG_INVALID_PROPERTYVALUE));
              }              }
  
              if ((vb = MakeVarBindWithValue(object,              if ((vb = MakeVarBindWithValue(
                        object,
                                         (OID *) NULL,                                         (OID *) NULL,
                                         OCTET_PRIM_TYPE,                                         OCTET_PRIM_TYPE,
                                         value)) == NULL)                                         value)) == NULL)
             {             {
   
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //    _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE);  
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                             MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY,                      MessageLoaderParms(
                           _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE_KEY,
                                                                _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE));                                                                _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE));
             }             }
         }         }
Line 455 
Line 393 
             void* value = MakeOIDFromDot(_vbValue);             void* value = MakeOIDFromDot(_vbValue);
             if (value == NULL)             if (value == NULL)
             {             {
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //    _MSG_INVALID_PROPERTYVALUE);  
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                             MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,                      MessageLoaderParms(
                           _MSG_INVALID_PROPERTYVALUE_KEY,
                                                                _MSG_INVALID_PROPERTYVALUE));                                                                _MSG_INVALID_PROPERTYVALUE));
   
             }             }
  
             if ((vb = MakeVarBindWithValue(object,              if ((vb = MakeVarBindWithValue(
                        object,
                                         (OID *) NULL,                                         (OID *) NULL,
                                         OBJECT_ID_TYPE,                                         OBJECT_ID_TYPE,
                                         value)) == NULL)                                         value)) == NULL)
             {             {
   
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //    _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE);  
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                             MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY,                      MessageLoaderParms(
                           _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE_KEY,
                                                                _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE));                                                                _MSG_MAKE_VARBIND_FAILED_FOR_OBJECT_ID_TYPE));
             }             }
         }         }
Line 489 
Line 418 
  
             if (value == NULL)             if (value == NULL)
             {             {
   
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //    _MSG_INVALID_PROPERTYVALUE);  
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                             MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,                      MessageLoaderParms(
                           _MSG_INVALID_PROPERTYVALUE_KEY,
                                                                _MSG_INVALID_PROPERTYVALUE));                                                                _MSG_INVALID_PROPERTYVALUE));
             }             }
  
             if ((vb = MakeVarBindWithValue(object,              if ((vb = MakeVarBindWithValue(
                        object,
                                         (OID *) NULL,                                         (OID *) NULL,
                                         INTEGER_TYPE,                                         INTEGER_TYPE,
                                         value)) == NULL)                                         value)) == NULL)
             {             {
   
               // l10n  
   
               // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,  
               //    _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE);  
   
               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,               throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                             MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY,                      MessageLoaderParms(
                           _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE_KEY,
                                                                _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE));                                                                _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE));
             }             }
         }         }
Line 573 
Line 493 
         }         }
         default:         default:
         {         {
           // l10n  
   
           // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,  
           // _MSG_VERSION_NOT_SUPPORTED);  
   
           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;           break;
         }         }
     }     }
Line 609 
Line 524 
     struct hostent *targetHostInfo;     struct hostent *targetHostInfo;
     struct in_addr in;     struct in_addr in;
  
 #if defined(PEGASUS_OS_LINUX)  
         char hostEntryBuffer[8192];         char hostEntryBuffer[8192];
         struct hostent hostEntryStruct;         struct hostent hostEntryStruct;
         int hostEntryErrno;      targetHostInfo = System::getHostByName(hostName,
           &hostEntryStruct, hostEntryBuffer, sizeof (hostEntryBuffer));
         gethostbyname_r(  
             hostName,  
             &hostEntryStruct,  
             hostEntryBuffer,  
             sizeof(hostEntryBuffer),  
             &targetHostInfo,  
             &hostEntryErrno);  
 #elif defined(PEGASUS_OS_SOLARIS)  
         char hostEntryBuffer[8192];  
         struct hostent hostEntryStruct;  
         int hostEntryErrno;  
   
         targetHostInfo = gethostbyname_r(  
             (char *)hostName,  
             &hostEntryStruct,  
             hostEntryBuffer,  
             sizeof(hostEntryBuffer),  
             &hostEntryErrno);  
 #else  
     targetHostInfo = gethostbyname(hostName);  
 #endif  
  
     if (targetHostInfo == NULL)     if (targetHostInfo == NULL)
     {     {
         return(NULL);          return NULL;
     }     }
  
     char ** networkAddr;     char ** networkAddr;


Legend:
Removed from v.1.22  
changed lines
  Added in v.1.31

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2