(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.6 and 1.8

version 1.6, 2002/04/17 22:46:33 version 1.8, 2002/04/25 16:27:25
Line 29 
Line 29 
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
   #include <Pegasus/Common/Destroyer.h>
 #include <fcntl.h> #include <fcntl.h>
 #include <unistd.h> #include <unistd.h>
 #include <ctype.h> #include <ctype.h>
Line 115 
Line 116 
     initialize();     initialize();
  
     // TRAP OID: getting trapOid     // TRAP OID: getting trapOid
     char* _trapOid = trapOid.allocateCString();      ArrayDestroyer<char> _trapOid(trapOid.allocateCString());
     _trapOid[strlen(_trapOid)-1] = '\0';      _trapOid.getPointer()[strlen(_trapOid.getPointer())-1] = '\0';
     OID *sendtrapOid = MakeOIDFromDot(_trapOid);      OID *sendtrapOid = MakeOIDFromDot(_trapOid.getPointer());
  
     // Destination : converting destination into Transport     // Destination : converting destination into Transport
     char* trap_dest = destination.allocateCString();      ArrayDestroyer<char> trap_dest(destination.allocateCString());
     TransportInfo   global_ti;     TransportInfo   global_ti;
     global_ti.type = SR_IP_TRANSPORT;     global_ti.type = SR_IP_TRANSPORT;
     global_ti.t_ipAddr = inet_addr(trap_dest);      global_ti.t_ipAddr = inet_addr(trap_dest.getPointer());
     global_ti.t_ipPort = htons((unsigned short)GetSNMPTrapPort());     global_ti.t_ipPort = htons((unsigned short)GetSNMPTrapPort());
     delete [] trap_dest;  
  
     // Community Name     // Community Name
     char* _community = community.allocateCString();      ArrayDestroyer<char> _community(community.allocateCString());
     OctetString* community_name = MakeOctetStringFromText(_community);      OctetString* community_name = MakeOctetStringFromText(
     delete [] _community;                                        _community.getPointer());
  
     // getting IP address of the host     // getting IP address of the host
     char* hostname = System::getHostName().allocateCString();      ArrayDestroyer<char> hostname(System::getHostName().allocateCString());
     char **p;     char **p;
     struct hostent *hp;     struct hostent *hp;
     struct in_addr in;     struct in_addr in;
     hp=gethostbyname(hostname);      hp=gethostbyname(hostname.getPointer());
     p = hp->h_addr_list;     p = hp->h_addr_list;
     (void)memcpy(&in.s_addr, *p, sizeof(in.s_addr));     (void)memcpy(&in.s_addr, *p, sizeof(in.s_addr));
     char* IP_string = inet_ntoa(in);     char* IP_string = inet_ntoa(in);
     delete [] hostname;  
  
     // formatting agent(host) address into OctetString format     // formatting agent(host) address into OctetString format
     OctetString* agent_addr;     OctetString* agent_addr;
Line 165 
Line 164 
     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;
  
     // ATTN-NU-20020312 : Write code to get enterprise, genTrap and  
     // specTrap from trapOid.     // specTrap from trapOid.
   
     //NU_SNMP  
   
     SR_INT32 genTrap = 0;     SR_INT32 genTrap = 0;
     SR_INT32 specTrap = 0;     SR_INT32 specTrap = 0;
  
Line 208 
Line 203 
         for (Uint8 i = 1; i < oids.size()-1; i++)         for (Uint8 i = 1; i < oids.size()-1; i++)
             ent = ent + "." + oids[i];             ent = ent + "." + oids[i];
  
         char* gtrap = ent.allocateCString();          ArrayDestroyer<char> gtrap(ent.allocateCString());
         genTrap = atoi(gtrap) - 1;          genTrap = atoi(gtrap.getPointer()) - 1;
         enterpriseOid = sendtrapOid;         enterpriseOid = sendtrapOid;
         delete [] gtrap;  
     }     }
     else     else
     {     {
Line 220 
Line 214 
         ent = oids[0];         ent = oids[0];
         for (Uint8 i = 1; i < oids.size()-1; i++)         for (Uint8 i = 1; i < oids.size()-1; i++)
             ent = ent + "." + oids[i];             ent = ent + "." + oids[i];
         char* strap = oids[oids.size()-1].allocateCString();          ArrayDestroyer<char> strap(oids[oids.size()-1].allocateCString());
         specTrap = atoi(strap);          specTrap = atoi(strap.getPointer());
         delete [] strap;  
  
         if (oids[oids.size()-2] == "0")         if (oids[oids.size()-2] == "0")
         {         {
Line 230 
Line 223 
             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];
  
             char* _ent = ent.allocateCString();              ArrayDestroyer<char> _ent(ent.allocateCString());
             enterpriseOid = MakeOIDFromDot(_ent);              enterpriseOid = MakeOIDFromDot(_ent.getPointer());
             delete [] _ent;  
         }         }
         else         else
         {         {
Line 240 
Line 232 
             for (Uint8 i = 1; i < oids.size()-1; i++)             for (Uint8 i = 1; i < oids.size()-1; i++)
                 ent = ent + "." + oids[i];                 ent = ent + "." + oids[i];
  
             char* _ent = ent.allocateCString();              ArrayDestroyer<char> _ent(ent.allocateCString());
             enterpriseOid = MakeOIDFromDot(_ent);              enterpriseOid = MakeOIDFromDot(_ent.getPointer());
             delete [] _ent;  
         }         }
     }     }
  
     char* _vbOid;  
     char* _vbValue;  
   
     for(Uint32 i = 0; i < vbOids.size(); i++)     for(Uint32 i = 0; i < vbOids.size(); i++)
     {     {
         _vbOid = vbOids[i].allocateCString();          ArrayDestroyer<char> _vbOid(vbOids[i].allocateCString());
         _vbValue = vbValues[i].allocateCString();          ArrayDestroyer<char> _vbValue(vbValues[i].allocateCString());
  
         if ((object = MakeOIDFromDot(_vbOid)) == NULL)          if ((object = MakeOIDFromDot(_vbOid.getPointer())) == NULL)
         {         {
             cout << "Invalid OID received: " << vbOids[i] << endl;             cout << "Invalid OID received: " << vbOids[i] << endl;
             return;             return;
Line 262 
Line 250 
  
         if (vbTypes[i] == String("OctetString"))         if (vbTypes[i] == String("OctetString"))
         {         {
             newValue = CloneOctetString(MakeOctetStringFromText(_vbValue));              newValue = CloneOctetString(MakeOctetStringFromText(_vbValue.getPointer()));
             if (newValue == NULL)             if (newValue == NULL)
             {             {
                 cout << "Invalid Value provided : " << vbValues[i] << endl;                 cout << "Invalid Value provided : " << vbValues[i] << endl;
Line 279 
Line 267 
         }         }
         else         else
         {         {
             int vbvalue = atoi(_vbValue);              int vbvalue = atoi(_vbValue.getPointer());
             void* value = &vbvalue;             void* value = &vbvalue;
  
             if (newValue == NULL)             if (newValue == NULL)
Line 310 
Line 298 
         FreeOID(object);         FreeOID(object);
     }     }
  
     delete [] _vbValue;  
     delete [] _vbOid;  
   
     vb3->next_var = NULL;     vb3->next_var = NULL;
  
     // Now sending the trap     // Now sending the trap
Line 355 
Line 340 
     else     else
     {     {
         cout << "Trap type not supported : " << trapType << endl;         cout << "Trap type not supported : " << trapType << endl;
         delete [] _trapOid;  
         exit(2);         exit(2);
     }     }
  
     FreeVarBindList(vb);     FreeVarBindList(vb);
     FreeVarBindList(vb2);     FreeVarBindList(vb2);
     FreeVarBindList(vb3);     FreeVarBindList(vb3);
   
     delete [] _trapOid;  
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2