(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.11 and 1.11.12.2

version 1.11, 2002/08/29 00:27:52 version 1.11.12.2, 2003/08/13 19:39:51
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: Yi Zhou, Hewlett-Packard Company (yi_zhou@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h>  
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
   #include <Pegasus/Common/ArrayInternal.h>
 #include <Pegasus/Common/Destroyer.h> #include <Pegasus/Common/Destroyer.h>
 #include <fcntl.h>  #include <Pegasus/Common/InternalException.h>
 #include <unistd.h>  
 #include <ctype.h>  
 #include <sys/stat.h>  
 #include "snmpDeliverTrap_emanate.h" #include "snmpDeliverTrap_emanate.h"
 #include "prnt_lib.h"  
   // l10n
   #include <Pegasus/Common/MessageLoader.h>
   
   // EMANATE specific declarations and entry points - MUST be in begining
   // and outside NAMESPACE.
   
   // master agent needs these two declarations for communication with sub-agent.
   // Following two declarations must be in the CODE.
   
   #include <prnt_lib.h>  // MUST be at the end in include list.
  
 static char *sr_filename = __FILE__; static char *sr_filename = __FILE__;
  
 IPCFunctionP IPCfp;  /* IPC functions pointer  */ IPCFunctionP IPCfp;  /* IPC functions pointer  */
  
 // This code should be generated by Emanate  // This code would normally be generated by Emanate from defined MIB objects.
 // Since we do not have MIB objects defined,  // Since we do not have MIB objects defined, just defined here to load
 // just defined here to load subagent as library  // 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[] =
Line 56 
Line 63 
     NULL, NULL }     NULL, NULL }
 }; };
  
 // This code should be generated by Emanate in k_* routine  // This code would normally be generated by Emanate in k_* routine from defined MIB objects.
 // Since we do not have MIB objects defined,  // Since we do not have MIB objects defined, just define here to pass compile and
 // just defined here to pass compile  // 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 66 
Line 73 
    return 1;    return 1;
 } }
  
   // END EMANATE specific declarations.
   
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 PEGASUS_USING_STD; PEGASUS_USING_STD;
Line 80 
Line 89 
  
 } }
  
   
   // initialize sub-agent
   
   // This also defines the communication protocol to be used between master
   // and sub-agent.
   
 void snmpDeliverTrap_emanate::initialize() void snmpDeliverTrap_emanate::initialize()
 { {
 #ifndef SR_UDS_IPC #ifndef SR_UDS_IPC
Line 90 
Line 105 
  
     if(InitSubagent() == -1)     if(InitSubagent() == -1)
     {     {
         cout << "InitSubagent Failed to initialize" << endl;  
         exit(1);        // l10n
   
         // 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));
   
     }     }
 } }
  
   
 void snmpDeliverTrap_emanate::deliverTrap( void snmpDeliverTrap_emanate::deliverTrap(
     const String& trapOid,     const String& trapOid,
     const String& community,          const String& securityName,
     const String& destination,          const String& targetHost,
     const String& trapType,          const Uint16& targetHostFormat,
           const String& otherTargetHostFormat,
           const Uint32& portNumber,
           const Uint16& snmpVersion,
           const String& engineID,
     Array<String>& vbOids,     Array<String>& vbOids,
     Array<String>& vbTypes,     Array<String>& vbTypes,
     Array<String>& vbValues)     Array<String>& vbValues)
 { {
     OctetString*    newValue;      VarBind *vbhead = NULL;
   
     VarBind *vb = NULL;     VarBind *vb = NULL;
     VarBind *vb2 = NULL;      VarBind *vblast = NULL;
     VarBind *vb3 = NULL;  
  
     OID     *object = NULL;     OID     *object = NULL;
  
     // Initializing with Master agent      // Initialize with Master agent
   
     initialize();     initialize();
  
     // TRAP OID: getting trapOid      // Translate a string into an OID
     CString _trapOid = trapOid.getCString();      OID *sendtrapOid = MakeOIDFromDot(trapOid.getCString());
     _trapOid[strlen(_trapOid)-1] = '\0';  
     OID *sendtrapOid = MakeOIDFromDot(_trapOid);      if (sendtrapOid == NULL)
       {
   
         // l10n
   
         // 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_TRAPOID));
       }
   
       // Destination : convert targetHost into Transport
   
       CString trap_dest = targetHost.getCString();
  
     // Destination : converting destination into Transport  
     TransportInfo   global_ti;     TransportInfo   global_ti;
     global_ti.type = SR_IP_TRANSPORT;     global_ti.type = SR_IP_TRANSPORT;
     global_ti.t_ipAddr = inet_addr(destination.getCString());  
     global_ti.t_ipPort = htons((unsigned short)GetSNMPTrapPort());  
  
     // Community Name  
     OctetString* community_name = MakeOctetStringFromText(  
                                       community.getCString());  
  
       switch (targetHostFormat)
       {
           case _HOST_NAME:
           {
               char * ipAddr = _getIPAddress(trap_dest);
   
               if (ipAddr == NULL)
               {
   
                 // l10n
   
                 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                 //   _MSG_DESTINATION_NOT_FOUND);
   
                 throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_FAILED,
                                                MessageLoaderParms(_MSG_DESTINATION_NOT_FOUND_KEY,
                                                                   _MSG_DESTINATION_NOT_FOUND));
   
               }
               global_ti.t_ipAddr = inet_addr(trap_dest);
               break;
           }
           case _IPV4_ADDRESS:
           {
               global_ti.t_ipAddr = inet_addr(trap_dest);
               break;
           }
           default:
           {
   
             // l10n
   
             // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
             // _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED);
   
             throw PEGASUS_CIM_EXCEPTION_L (CIM_ERR_NOT_SUPPORTED,
                                            MessageLoaderParms(_MSG_TARGETHOSTFORMAT_NOT_SUPPORTED_KEY,
                                                               _MSG_TARGETHOSTFORMAT_NOT_SUPPORTED,
                                                               _MSG_HOSTNAME,
                                                               _MSG_IPV4,
                                                               _MSG_TARGETHOSTFORMAT));
   
               break;
           }
       }
   
       global_ti.t_ipPort = htons((unsigned short)portNumber);
   
       // Community Name, default is public
       CString _community;
       if (securityName.size() == 0)
       {
           String community;
           community.assign("public");
           _community = community.getCString();
       }
       else
       {
           _community = securityName.getCString();
       }
   
       OctetString* community_name = MakeOctetStringFromText(_community);
   
       if (community_name == NULL)
       {
   
         // l10n
   
         // 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_SECURITY_NAME));
   
       }
     // getting IP address of the host     // getting IP address of the host
     char **p;  
     struct hostent *hp;      CString hostname = System::getHostName().getCString();
     struct in_addr in;      char* IP_string = _getIPAddress(hostname);
     hp=gethostbyname(System::getHostName().getCString());  
     p = hp->h_addr_list;  
     (void)memcpy(&in.s_addr, *p, sizeof(in.s_addr));  
     char* IP_string = inet_ntoa(in);  
  
     // formatting agent(host) address into OctetString format     // formatting agent(host) address into OctetString format
   
     OctetString* agent_addr;     OctetString* agent_addr;
  
     SR_INT32 s1, s2, s3, s4;     SR_INT32 s1, s2, s3, s4;
     SR_UINT32 ipaddr;     SR_UINT32 ipaddr;
  
     // pull out each of the 4 octet values from IP address     // pull out each of the 4 octet values from IP address
   
     sscanf(IP_string,"%d.%d.%d.%d", &s1, &s2, &s3, &s4);     sscanf(IP_string,"%d.%d.%d.%d", &s1, &s2, &s3, &s4);
  
     // Probably should perform some checks on values for      // validate the values for s1, s2, s3, and s4 to make sure values are
     // s1, s2, s3, and s4 here to make sure values are  
     // between 0 and 255     // between 0 and 255
       if (!_isValidOctet(s1) || !_isValidOctet(s2) ||
           !_isValidOctet(s3) || !_isValidOctet(s4))
       {
   
         // l10n
   
         // 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));
       }
  
     // create an empty 4 length OctetString     // create an empty 4 length OctetString
   
     agent_addr = MakeOctetString(NULL,4);     agent_addr = MakeOctetString(NULL,4);
  
       if (agent_addr == NULL)
       {
   
         // l10n
   
         // 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_OCTETSTRING));
   
       }
   
     // fill in values for OctetString     // fill in values for OctetString
   
     agent_addr->octet_ptr[0] = (unsigned char)s1;     agent_addr->octet_ptr[0] = (unsigned char)s1;
     agent_addr->octet_ptr[1] = (unsigned char)s2;     agent_addr->octet_ptr[1] = (unsigned char)s2;
     agent_addr->octet_ptr[2] = (unsigned char)s3;     agent_addr->octet_ptr[2] = (unsigned char)s3;
     agent_addr->octet_ptr[3] = (unsigned char)s4;     agent_addr->octet_ptr[3] = (unsigned char)s4;
  
     // specTrap from trapOid.     // specTrap from trapOid.
   
     SR_INT32 genTrap = 0;     SR_INT32 genTrap = 0;
     SR_INT32 specTrap = 0;     SR_INT32 specTrap = 0;
  
Line 184 
Line 327 
         oids.append(tmpoid.subString(0, tmpoid.find(".")));         oids.append(tmpoid.subString(0, tmpoid.find(".")));
         tmpoid = tmpoid.subString(tmpoid.find(".") + 1);         tmpoid = tmpoid.subString(tmpoid.find(".") + 1);
     }     }
   
     oids.append(tmpoid);     oids.append(tmpoid);
  
     String ent;     String ent;
     if (oids[oids.size()-2] == "0")  
     {  
         ent = oids[0];  
         for (Uint8 i = 1; i < oids.size()-2; i++)  
             ent = ent + "." + oids[i];  
     }  
   
     if (Contains(standard_traps, trapOid))     if (Contains(standard_traps, trapOid))
     {     {
         ent = oids[0];          //
         for (Uint8 i = 1; i < oids.size()-1; i++)          // if the trapOid is one of the standard traps,
             ent = ent + "." + oids[i];          // then the SNMPV1 enterprise parameter must be set
           // to the value of the trapOid, the generic-trap
           // parameter must be set to one of (0 - 5), and the
           // specific-trap parameter must be set to 0
           //
  
         genTrap = atoi(ent.getCString()) - 1;  
         enterpriseOid = sendtrapOid;         enterpriseOid = sendtrapOid;
   
           // the generic trap is last sub-identifier of the
           // trapOid minus 1
           genTrap = atoi(oids[oids.size() - 1].getCString()) - 1;
           specTrap = 0;
     }     }
     else     else
     {     {
           //
           // if the trapOid is not one of the standard traps:
           // then 1) the generic-trap parameter must be set to 6,
           // 2) if the next-to-last sub-identifier of the
           // trapOid is zero, then the SNMPV1 enterprise
           // parameter is the trapOid with the last 2
           // sub-identifiers removed, otherwise, the
           // SNMPV1 enterprise parameter is the trapOid
           // with the last sub-identifier removed;
           // 3) the SNMPv1 specific-trap parameter is the last
           // sub-identifier of the trapOid;
           //
   
         genTrap = 6;         genTrap = 6;
  
         ent = oids[0];  
         for (Uint8 i = 1; i < oids.size()-1; i++)  
             ent = ent + "." + oids[i];  
         specTrap = atoi(oids[oids.size()-1].getCString());         specTrap = atoi(oids[oids.size()-1].getCString());
  
         if (oids[oids.size()-2] == "0")  
         {  
             ent = oids[0];             ent = oids[0];
             for (Uint8 i = 1; i < oids.size()-2; i++)             for (Uint8 i = 1; i < oids.size()-2; i++)
           {
                 ent = ent + "." + oids[i];                 ent = ent + "." + oids[i];
   
             enterpriseOid = MakeOIDFromDot(ent.getCString());  
         }         }
         else  
           if (oids[oids.size()-2] != "0")
         {         {
             ent = oids[0];              ent = ent + "." + oids[oids.size()-2];
             for (Uint8 i = 1; i < oids.size()-1; i++)          }
                 ent = ent + "." + oids[i];  
  
             enterpriseOid = MakeOIDFromDot(ent.getCString());             enterpriseOid = MakeOIDFromDot(ent.getCString());
   
           if (enterpriseOid == NULL)
           {
   
             // l10n
   
             // 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_ENTERPRISEOID));
         }         }
     }     }
  
       // creates VarBind
     for(Uint32 i = 0; i < vbOids.size(); i++)     for(Uint32 i = 0; i < vbOids.size(); i++)
     {     {
         if ((object = MakeOIDFromDot(vbOids[i].getCString())) == NULL)          CString _vbOid = vbOids[i].getCString();
           CString _vbValue = vbValues[i].getCString();
   
           if ((object = MakeOIDFromDot(_vbOid)) == NULL)
         {         {
             cout << "Invalid OID received: " << vbOids[i] << endl;  
             return;            // l10n
   
             // 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_OID,
                                                              _MSG_CIM));
         }         }
  
         if (vbTypes[i] == String("OctetString"))          if (String::equalNoCase(vbTypes[i], "OctetString"))
         {         {
             newValue = CloneOctetString(MakeOctetStringFromText(vbValues[i].getCString()));               OctetString*    value;
             if (newValue == NULL)  
                value = CloneOctetString(MakeOctetStringFromText(_vbValue));
                if (value == NULL)
             {             {
                 cout << "Invalid Value provided : " << vbValues[i] << endl;  
                 return;                 // l10n
   
                  // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                  //   _MSG_INVALID_PROPERTYVALUE);
   
                    throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                                  MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
                                                                     _MSG_INVALID_PROPERTYVALUE,
                                                                     _MSG_CIM));
             }             }
             if ((vb2 = MakeVarBindWithValue(object,  
                if ((vb = MakeVarBindWithValue(object,
                 (OID *) NULL,                 (OID *) NULL,
                 OCTET_PRIM_TYPE,                 OCTET_PRIM_TYPE,
                 newValue)) == NULL)                                          value)) == NULL)
             {             {
                 cout << "Invalid OctetString value: " << vbValues[i] << endl;  
                 return;                // l10n
   
                 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                 //    _MSG_MAKE_VARBIND_FAILED_FOR_OCTET_PRIM_TYPE);
   
                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                               MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY,
                                                                  _MSG_MAKE_VARBIND_FAILED,
                                                                  _MSG_VARBIND,
                                                                  _MSG_OCTET_PRIM_TYPE));
               }
           }
           else if (String::equalNoCase(vbTypes[i], "OID"))
           {
               void* value = MakeOIDFromDot(_vbValue);
               if (value == NULL)
               {
                 // l10n
   
                 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                 //    _MSG_INVALID_PROPERTYVALUE);
   
                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                               MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
                                                                  _MSG_INVALID_PROPERTYVALUE,
                                                                  _MSG_CIM));
   
               }
   
               if ((vb = MakeVarBindWithValue(object,
                                           (OID *) NULL,
                                           OBJECT_ID_TYPE,
                                           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,
                                               MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY,
                                                                  _MSG_MAKE_VARBIND_FAILED,
                                                                  _MSG_VARBIND,
                                                                  _MSG_OBJECT_ID_TYPE));
             }             }
         }         }
         else         else
         {         {
             int vbvalue = atoi(_vbValue.getPointer());              int vbvalue = atoi(_vbValue);
             void* value = &vbvalue;             void* value = &vbvalue;
  
             if (newValue == NULL)              if (value == NULL)
             {             {
                 cout << "Invalid Value provided : " << vbValues[i] << endl;                // l10n
                 return;  
                 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                 //    _MSG_INVALID_PROPERTYVALUE);
   
                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                               MessageLoaderParms(_MSG_INVALID_PROPERTYVALUE_KEY,
                                                                  _MSG_INVALID_PROPERTYVALUE,
                                                                  _MSG_CIM));
             }             }
             if ((vb2 = MakeVarBindWithValue(object,  
               if ((vb = MakeVarBindWithValue(object,
                 (OID *) NULL,                 (OID *) NULL,
                 INTEGER_TYPE,                 INTEGER_TYPE,
                 value)) == NULL)                 value)) == NULL)
             {             {
                 cout << "Invalid Integer Value: " << vbValues[i] << endl;                // l10n
                 return;  
                 // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED,
                 //    _MSG_MAKE_VARBIND_FAILED_FOR_INTEGER_TYPE);
   
                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,
                                               MessageLoaderParms(_MSG_MAKE_VARBIND_FAILED_KEY,
                                                                  _MSG_MAKE_VARBIND_FAILED,
                                                                  _MSG_VARBIND,
                                                                  _MSG_INTEGER_TYPE));
             }             }
         }         }
   
         if (i == 0)         if (i == 0)
         {         {
             vb = vb2;              vbhead = vb;
             vb3 = vb2;              vblast = vb;
         }         }
         else         else
         {         {
             vb3->next_var = vb2;              vblast->next_var = vb;
             vb3 = vb3->next_var;              vblast = vblast->next_var;
         }         }
  
         FreeOID(object);  
     }     }
  
     vb3->next_var = NULL;      vblast->next_var = NULL;
  
     // Now sending the trap      // Now send the trap
     if (trapType == String("SNMPv1"))      switch (snmpVersion)
       {
           case _SNMPv1_TRAP:
     {     {
         SendNotificationToDestSMIv1Params(         SendNotificationToDestSMIv1Params(
             1,                                  // notifyType - TRAP             1,                                  // notifyType - TRAP
Line 299 
Line 550 
             specTrap,                           // specTrap             specTrap,                           // specTrap
             enterpriseOid,                      // enterprise             enterpriseOid,                      // enterprise
             agent_addr,                         // agent_addr             agent_addr,                         // agent_addr
             vb,                                 // vb              vbhead,                             // vb
             NULL,                               // contextName             NULL,                               // contextName
             1,                                  // retryCount             1,                                  // retryCount
             1,                                  // timeout             1,                                  // timeout
Line 308 
Line 559 
             SR_SECURITY_MODEL_V1,               // securityModel             SR_SECURITY_MODEL_V1,               // securityModel
             &global_ti,                         // Transport Info             &global_ti,                         // Transport Info
             0);                                 // cfg_chk             0);                                 // cfg_chk
               break;
     }     }
     else if (trapType == String("SNMPv2"))          case _SNMPv2C_TRAP:
     {     {
         SendNotificationToDestSMIv2Params(         SendNotificationToDestSMIv2Params(
             1,                                  // notifyType - NOTIFICATION              (SR_INT32)SNMPv2_TRAP_TYPE,         // notifyType - NOTIFICATION
             sendtrapOid,                        // snmpTrapOID             sendtrapOid,                        // snmpTrapOID
             agent_addr,                         // agent_addr             agent_addr,                         // agent_addr
             vb,                                 // vb              vbhead,                             // vb
             NULL,                               // contextName             NULL,                               // contextName
             1,                                  // retryCount             1,                                  // retryCount
             100,                                // timeout             100,                                // timeout
             community_name,                     // securityName or community             community_name,                     // securityName or community
             SR_SECURITY_LEVEL_NOAUTH,           // securityLevel             SR_SECURITY_LEVEL_NOAUTH,           // securityLevel
             SR_SECURITY_MODEL_V1,               // securityModel              SR_SECURITY_MODEL_V2C,              // securityModel
             &global_ti,                         // TransportInfo             &global_ti,                         // TransportInfo
             0);                                 // cfg_chk             0);                                 // cfg_chk
         FreeVarBindList(vb);  
         FreeVarBindList(vb2);              break;
     }     }
     else          default:
     {     {
         cout << "Trap type not supported : " << trapType << endl;            // l10n
         exit(2);  
             // throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED,
             // _MSG_VERSION_NOT_SUPPORTED);
   
             throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED,
                                           MessageLoaderParms(_MSG_VERSION_NOT_SUPPORTED_KEY,
                                                              _MSG_VERSION_NOT_SUPPORTED,
                                                              _MSG_SNMPv1,
                                                              _MSG_SNMPv2C,
                                                              _MSG_SNMPVersion));
   
             break;
     }     }
       }
   
       // Free OID built by calls MakeOIDFromDot()
       FreeOID(sendtrapOid);
       FreeOID(enterpriseOid);
       FreeOID(object);
  
       // Free the data structures allocated and built by calls
       // MakeOctetString() and MakeOctetStringFrom Text()
       FreeOctetString(community_name);
       FreeOctetString(agent_addr);
   
       // Free the VarBind data structures allocated and built
       // by calls MakeVarBindWithValue()
       FreeVarBindList(vbhead);
     FreeVarBindList(vb);     FreeVarBindList(vb);
     FreeVarBindList(vb2);      FreeVarBindList(vblast);
     FreeVarBindList(vb3);  }
   
   // get the IP address of a host
   char * snmpDeliverTrap_emanate::_getIPAddress(const CString& hostName)
   {
       struct hostent *targetHostInfo;
       struct in_addr in;
   
   #ifdef PEGASUS_OS_SOLARIS
   #define HOSTENT_BUFF_SIZE       8192
       char                        buf[HOSTENT_BUFF_SIZE];
       struct hostent              h_result;
       int                         h_errorp;
       targetHostInfo=gethostbyname_r(hostName, &h_result, buff,
                                           HOSTENT_BUFF_SIZE, &h_errorp);
   #else
       targetHostInfo = gethostbyname(hostName);
   #endif
   
       if (targetHostInfo == NULL)
       {
           return(NULL);
       }
   
       char ** networkAddr;
       networkAddr = targetHostInfo->h_addr_list;
       (void)memcpy(&in.s_addr, *networkAddr, sizeof(in.s_addr));
       char * ipAddr = inet_ntoa(in);
       return(ipAddr);
   }
   
   // check the value of each part of an IP address which should be
   // between 0 and 255
   Boolean snmpDeliverTrap_emanate::_isValidOctet(const Uint32& octetValue)
   {
       if (octetValue > 0 && octetValue < 255)
       {
           return true;
       }
       else
       {
           return false;
       }
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.11  
changed lines
  Added in v.1.11.12.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2