[AGENT++] how to specify the source address for traps
Antoine Gatineau
antoine.gatineau at neotip.com
Wed Jan 26 17:43:31 CET 2005
Hello all,
I have a problem : I run an agent++ client in a chrooted environment
with user rights. The problem is that NotificationOriginator is not able
to give a valid address (address = 255.255.255.255).
I didn't find functions to generate traps with a specific source
address, Is there one? However, I came with a solution to force the
source address when creating the pdu. Here is what I did :
I overloaded all the function used to generate traps from :
virtual int Mib::notify(const NS_SNMP OctetStr&, const Oidx&, Vbx*,
int, unsigned int=0); (mib.h)
virtual int NotificationSender::notify(const NS_SNMP OctetStr&,const
Oidx&,Vbx*, int, unsigned int=0) = 0; (mib.h)
virtual int NotificationOriginator::notify(const NS_SNMP OctetStr&,
const Oidx&, Vbx*, int, unsigned int=0); (notification_originator.h)
int generate(Vbx*, int, const Oidx&, unsigned int, const Oidx&, const
NS_SNMP OctetStr&); (notification_originator.h:267)
int NotificationOriginator::send_notify(ListCursor<MibTableRow>& cur,
NotificationOriginatorParams& nop, int notify);
(notification_originator.h)
To :
virtual int Mib::notify(const NS_SNMP OctetStr&, const Oidx&, Vbx*,
int,UdpAddress, unsigned int=0);
virtual int NotificationSender::notify(const NS_SNMP OctetStr&, const
Oidx&,Vbx*, int,UdpAddress, unsigned int=0) = 0;
virtual int NotificationOriginator::notify(const NS_SNMP OctetStr&,
const Oidx&,Vbx*, int,UdpAddress , unsigned int=0);
int generate(Vbx*, int, const Oidx&, unsigned int, const Oidx&, const
NS_SNMP OctetStr&,UdpAddress srcAddr);
int NotificationOriginator::send_notify(ListCursor<MibTableRow>& cur,
NotificationOriginatorParams& nop, int notify,UdpAddress);
The UdpAddress parameter represents the source address a want the pdu to
use.
in send_notify, I added the line :
pdu.set_v1_trap_address(srcAddr); srcAddr = UdpAddress parameter
now, I just have to call :
UdpAddress source(SourceParameters);
mib->notify("context", oid, vbs, sz,source);
instead of :
mib->notify("context", oid, vbs, sz);
Could you tell me if there is a best solution?
Thank
Antoine Gatineau
--
More information about the AGENTPP
mailing list