Hi there.
First off, apologies for mailing here but I was having little luck from the
users mailing list.
I am writing a trap listener which listens on upd 162. When each trap comes
in I want to grab the source IP address of the device which sent the trap.
My code basically takes snmptrapd.c and stripped it down to essentials -
http://pastebin.com/fbCSQhpc
Now, the trap callback function is where I want to get the client ip
address. I thought 'pdu->agent_addr' would have the ip but I got null form
that.
I also tried:
netsnmp_transport *t = (netsnmp_transport *)(session->callback_magic);
//callback_magic was given the transport variable in the add_session()
function
netsnmp_udp_addr_pair *pp = (netsnmp_udp_addr_pair *)(t->data);
where netsnmp_udp_addr_pair is a struct:
typedef struct netsnmp_udp_addr_pair_s {
struct sockaddr_in remote_addr;
struct in_addr local_addr;
} netsnmp_udp_addr_pair;
But I got nothing from that with t->data_length returning 0.
The somebody suggested getting the sockaddr_in by casting
pdu->transport_data but I got nothing worthwhile after I gave the
sockaddr_in to inet_pton().
I was hoping somebody could point me in the right direction? Can I just
grab the client ip from somewhere?
Thanks,
Tom
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders