Ok... so it looks like I am successfully sending a V3 trap following your example code but I'm not receiving it on the other end which is essentially the same code as the snmptrapd sample.
I used RawCap to sniff the packets being sent and can see a trap message getting sent out and a get-response coming back from my manager. The get-response contains an error status of authorizationError (16).
Here is a snippet of my manager code:
Neil
I used RawCap to sniff the packets being sent and can see a trap message getting sent out and a get-response coming back from my manager. The get-response contains an error status of authorizationError (16).
Here is a snippet of my manager code:
Container = new UnityContainer().LoadConfiguration("snmptrapd");
var users = this.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;
Engine = Container.Resolve<SnmpEngine>();
Engine.Listener.AddBinding(new IPEndPoint(IPAddress.Any, snmpPort));
// The Engine is started later in the code as it is hosted in a service/console app
and here is my Trap sender code: var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 162);
//var privacy = DefaultPrivacyProvider.DefaultPair;
var privacy = new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication")));
//var privacy = new DESPrivacyProvider(new OctetString("privacyphrase"), new MD5AuthenticationProvider(new OctetString("authentication")));
var trap = new TrapV2Message(
VersionCode.V3,
528732060,
1905687779,
new OctetString("authen"),
new ObjectIdentifier("1.3.6"),
0,
new List<Variable>(),
privacy,
0x10000,
new OctetString(ByteTool.Convert("80001F8880E9630000D61FF449")),
0,
0
);
trap.Send(endpoint);
As you can see I've tried all three types of PrivacyProvider from the samples but they all return authorizationError (16). Not quite sure what could be going wrong since my usernames, community and privacy phrases all seem to match up?Neil