araditc/Arad.SnmpSharp

How to get incoming trap IP Address

BrettBurbidge opened this issue · 1 comments

This is not an issue but a question. Great library, by the way, very clean.

I am attempting to use this library to capture snmp v3 traps. In order to set the authentication for the SnmpV3Packet.UserSecurityModel I need to match the incoming trap ip address with an ip address in my system. Is there a way I can see the IPAddress of the device when receiving a trap?

'// Parse SNMP Version 3 TRAP packet
SnmpV3Packet pkt = new SnmpV3Packet();

// Get sending device IP
var ip = pkt.IPAddress; <= does not exist.

pkt.authPriv(ASCIIEncoding.UTF8.GetBytes("test"),
ASCIIEncoding.UTF8.GetBytes("test"),
Arad.SnmpSharp.Security.AuthenticationDigests.MD5,
ASCIIEncoding.UTF8.GetBytes("test"),
Arad.SnmpSharp.Security.PrivacyProtocols.AES256);
pkt.SetEngineId(GetEngineID());

pkt.decode(indata, inlen);
...
`

Oops, my bad! Found it in the connected endpoint.