我环顾四周,似乎找不到这个问题的答案。我在嵌入式项目中使用来自 net-snmp 的 snmpd。我在 snmpd 中写入了额外的代码以支持 GET 和 v2 陷阱,但现在我可能需要切换到 v3 陷阱/通知。
所以,这是我的问题:
假设我已经设置了我的 v3 密码、加密等,是否有与 send_v2trap()
函数类似的 v3?我无法想象它会像 send_v3trap()
一样简单,但必须有一个直接的方法。
此外,我严格限制使用 C。我认为使用其他语言的 net-snmp 绑定(bind)可能会更容易,但这不是我的选择。
最佳答案
来自 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().
希望这对您有所帮助。
关于linux - snmpv3 通知/陷阱 c 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30032339/