我正在测试SharpSNMP lib并使用这些示例,该库很棒,但缺少一些文档。
我的问题是如何改变社区,我正在听陷阱,因为示例中没有任何内容让我有意义。
if (args.Length != 0)
{
return;
}
Container = new UnityContainer().LoadConfiguration("snmptrapd");
var users = Container.Resolve<UserRegistry>();
users.Add(new OctetString("neither"), DefaultPrivacyProvider.DefaultPair);
users.Add(new OctetString("authen"), new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication"))));
users.Add(new OctetString("privacy"), new DESPrivacyProvider(new OctetString("privacyphrase"),
new MD5AuthenticationProvider(new OctetString("authentication"))));
var trapv1 = Container.Resolve<TrapV1MessageHandler>("TrapV1Handler");
trapv1.MessageReceived += WatcherTrapV1Received;
var trapv2 = Container.Resolve<TrapV2MessageHandler>("TrapV2Handler");
trapv2.MessageReceived += WatcherTrapV2Received;
var inform = Container.Resolve<InformRequestMessageHandler>("InformHandler");
inform.MessageReceived += WatcherInformRequestReceived;
using(var engine = Container.Resolve<SnmpEngine>())
{
engine.Listener.AddBinding(new IPEndPoint(IPAddress.Any, 162));
engine.Start();
Console.WriteLine("#SNMP is available at http://sharpsnmplib.codeplex.com");
Console.WriteLine("Press any key to stop . . . ");
Console.Read();
engine.Stop();
}
答案 0 :(得分:0)
用户被添加到用户注册表中,因此如果SNMP v3消息(TRAP v2或INFORM),则陷阱代理可以正确处理它。
如果在您的方案中您需要使用其他用户,您可以手动创建它们,然后插入注册表。