0

我一直在环顾四周,似乎无法找到这个问题的答案。我正在使用来自 net-snmp 的 snmpd 进行嵌入式项目。我在 snmpd 中写入了额外的代码来支持 GET 和 v2 陷阱,但现在我可能需要切换到 v3 陷阱/通知。

所以,这是我的问题:

假设我已经设置了我的 v3 密码、加密等,是否有 v3 模拟该send_v2trap()功能?我无法想象它这么容易,send_v3trap()但必须有一个直截了当的方法。

此外,我严格限制使用 C。我想这可能会更容易在其他语言中使用 net-snmp 绑定,但这对我来说不是一个选择。

4

1 回答 1

1

来自netsnmp_trap_api(3)

   send_v2trap()  uses  the  supplied list of variable bindings to form an
   SNMPv2 trap, which is sent to SNMPv2-capable sinks  on  the  configured
   list.   An  equivalent INFORM is sent to the configuredq list of inform
   sinks.  Sinks that can only handle SNMPv1 traps are skipped.

这似乎表明相同的函数也应该能够发送 v3 陷阱(因为 v3 陷阱与 v2 陷阱相同)。

此外,查看代码(特别是agent/agent_trap.c),确实可以看到您最初的猜测是正确的并且该send_v3trap()函数存在。定义上方有一条评论,说:

Similar to send_v2trap(), with the added ability to specify a context.  If
the last parameter is NULL, then this call is equivalent to send_v2trap().

希望这可以帮助。

于 2015-05-04T20:32:57.560 回答