【问题标题】:snmpv3 inform/trap c codesnmpv3通知/陷阱c代码
【发布时间】:2024-05-21 01:05:01
【问题描述】:
我环顾四周,似乎找不到这个问题的答案。我正在使用来自 net-snmp 的 snmpd 进行嵌入式项目。我有额外的代码写入 snmpd 以支持 GET 和 v2 陷阱,但现在我可能需要切换到 v3 陷阱/通知。
所以,这是我的问题:
假设我已经设置了 v3 密码、加密等,是否有 v3 模拟 send_v2trap() 功能?我无法想象它像send_v3trap() 那样简单,但必须有一个直截了当的方法。
另外,我严格限制使用 C。我想在其他语言中使用 net-snmp 绑定可能会更容易,但这不是我的选择。
【问题讨论】:
标签:
linux
embedded
snmp
net-snmp
snmp-trap
【解决方案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().
希望这会有所帮助。