2015-05-04 114 views
0

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

所以,这里是我的问题:

假设我已经设置了我的V3密码,加密等,是有V3的模拟到send_v2trap()功能?我无法想象它像send_v3trap()一样容易,但是这需要一个简单的方法。

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

回答

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(). 

希望这会有所帮助。