WinSNMP v1 陷阱

发布于 2024-07-07 15:10:23 字数 760 浏览 6 评论 0原文

我在 C++ 中使用 WinSNMP 来发送 snmp 陷阱。 为了向后兼容,我需要发送 v1 snmp 陷阱。 WinSNMP 使用 v2 陷阱,但在发送陷阱时能够将这些 v2 陷阱转换为 v1。 我使用 SnmpSetTranslateMode(SNMPAPI_UNTRANSLATED_V1) 来做到这一点。 我还在绑定列表的开头添加了 sysUpTime oid (1.3.6.1.2.1.1.3.0)、snmpTrapOID (1.3.6.1.6.3.1.1.4.1.0) 和 enterpriseOID (1.3.6.1.6.3)。 1.1.4.3.0) 位于绑定列表的末尾,以便可以发送 v1 陷阱。

除了两件事(可能相关)之外,一切都工作正常。

陷阱中的 agent-addr 字段始终为 0.0.0.0(我尝试将 snmpTrapAddress oid(1.3.6.1.6.3.18.1.3.0) 添加到绑定列表,但这不起作用) 。 我希望此字段包含源的 IP 地址。

第二个问题是,尽管我使用 SnmpStrToEntitySnmpSetPortHSNMP_ENTITY 中指定了 IP 地址和端口,但我使用了这个 SnmpSendMsg 函数中的 HSNMP_ENTITY 陷阱仍然从另一个端口(动态端口范围内的某个位置)发送。

这里有人知道如何解决这个问题,或者谁可以告诉我这是否可能?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪你到最终 2024-07-14 15:10:23

一些想法:

  • agent-addr 可以由较低层设置为网络适配器的 IP 地址。 是否有一个选项可以将一个特定的适配器与 SNMP 相关联?

  • 为什么需要设置trap的源端口? SNMP仅要求将trap发送到UDP端口162; 除非您的特定应用程序有其他要求,否则来源无关紧要。 (有关 SNMP 的详细信息,请参阅 RFC 1067。)

A couple of ideas:

  • The agent-addr may be set to the IP address of the network adapter by a lower layer. Is there an option to associate one particular adapter with SNMP?

  • Why do you need to set the source port for the trap? SNMP only requires that the trap be sent to UDP port 162; the source is irrelevant unless your specific application has additional requirements. (See RFC 1067 for SNMP details.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文