address comparison when receiving traps

Jochen Katz katz____agentpp.com
Mon May 12 16:37:59 CEST 2003


Hi Robert,

> So I have to determine the address of the trap generator to handle the
> different high level requests
> 
> The problem is the comparison of the trap originator address
> 
> There is a method to get the GenAddress of an SnmpTarget
> 
> Since the (local) target definition holds only the ip address I have
> problems because the trap originator has a UDP address
> 
> Is there a simple way (other than recoding the IPAddress and GenAddress
> class) to do this job?

to compare an IpAddress to an GenAddress that contains a UdpAddress you 
could compare ip[n] to gen[n] with n walking from 0 to ip.get_length().

You could also use the following:
   GenAddress addr;

   target.get_address(addr);
   IpAddress localhost("127.0.0.1");

   if (addr.get_type() == Address::type_udp)
     if ((IpAddress)addr.cast_udpaddress() == localhost)
       cout << "identical" << endl;

Regards,





More information about the AGENTPP mailing list