I'm using WinSNMP in c++ to send snmp traps. For backwards compatibility I’m required to send v1 snmp traps. WinSNMP works with v2 traps but is capable of converting those v2 traps to v1 when sending the trap. I use SnmpSetTranslateMode(SNMPAPI_UNTRANSLATED_V1)
in order to do that. I also added the sysUpTime oid (1.3.6.1.2.1.1.3.0), the snmpTrapOID (1.3.6.1.6.3.1.1.4.1.0) in the beginning of the bindings list and the enterpriseOID (1.3.6.1.6.3.1.1.4.3.0) at the end of the bindings list to make it possible to send v1 traps.
Everything is working fine except two (possibly related) things.
The agent-addr
field in the trap is always to 0.0.0.0 (I tried adding a snmpTrapAddress oid(1.3.6.1.6.3.18.1.3.0) to the bindings list but that didn’t work). I would like this field to contain the Ip-address of the source.
The second problem is that although I specify an IP-address and a port in a HSNMP_ENTITY
with SnmpStrToEntity
and SnmpSetPort
and I use this HSNMP_ENTITY
in the SnmpSendMsg
function the trap still gets send from another port (somewhere in the dynamic ports range).
Is there anybody here who has an idea of how to fix this or who can tell me if this is at all possible?