Closed lextudio-support closed 5 hours ago
Copied from CodePlex without authors:
I don't know what you want to get, but can you spend some time on snmpget?
It supports all SNMP versions.
Lex
Original Posted Date: 2011-02-11T18:24:10.117-08:00
Copied from CodePlex without authors:
Thank you for asnwering Lex,
My actual question was useage of Messanger.Get() methods. I discovered that this method is not supporting v3.
By the way, I guess I have to deal with snmpget.
Thanks.
Original Posted Date: 2011-02-11T23:27:42.277-08:00
Copied from CodePlex without authors:
Messenger.Get does not support v3. This is by design.
Like what you can find from the samples, for SNMP v3 queries, you need to use the ISnmpMessage derived classes directly.
Regards,
Lex
Original Posted Date: 2011-02-12T06:11:17.027-08:00
Copied from CodePlex without authors:
Hi,
Any help topics or sample code of using "the ISnmpMessage derived classes directly" for SMNP v3 are avalibale?
Thanks!
Original Posted Date: 2011-09-23T00:42:34.223-07:00
Copied from CodePlex without authors:
All samples (snmpget/getnext/set and so on) show how to do v1/v2 operations using Messenger class, while v3 operations using ISnmpMessage derived class.
Regards,
Lex
Original Posted Date: 2011-09-23T04:37:55.93-07:00
Copied from CodePlex without authors:
Is that means that there is no way at this moment to look at the code that works with the V3?
Original Posted Date: 2011-09-23T04:44:12.583-07:00
Copied from CodePlex without authors:
More information is provided below,
SNMP v3 is fully supported by #SNMP.
Messenger class does not have the API to perform v3 operations, so you need to use ISnmpMessage derived classes directly.
In the samples, for example, snmpget, you can see how GetRequestMessage is used to perform v3 GET operation. http://sharpsnmplib.codeplex.com/SourceControl/changeset/view/5497af31d15e#Samples%2fC%23%2fsnmpget%2fProgram.cs
if (string.IsNullOrEmpty(user))
{
Console.WriteLine("User name need to be specified for v3.");
return;
}
IAuthenticationProvider auth = (level & Levels.Authentication) == Levels.Authentication
? GetAuthenticationProviderByName(authentication, authPhrase)
: DefaultAuthenticationProvider.Instance;
IPrivacyProvider priv;
if ((level & Levels.Privacy) == Levels.Privacy)
{
priv = new DESPrivacyProvider(new OctetString(privPhrase), auth);
}
else
{
priv = new DefaultPrivacyProvider(auth);
}
Discovery discovery = Messenger.NextDiscovery;
ReportMessage report = discovery.GetResponse(timeout, receiver);
GetRequestMessage request = new GetRequestMessage(VersionCode.V3, Messenger.NextMessageId, Messenger.NextRequestId, new OctetString(user), vList, priv, Messenger.MaxMessageSize, report);
ISnmpMessage response = request.GetResponse(timeout, receiver);
if (dump)
{
Console.WriteLine(ByteTool.Convert(request.ToBytes()));
}
if (response.Pdu.ErrorStatus.ToInt32() != 0) // != ErrorCode.NoError
{
throw ErrorException.Create(
"error in response",
receiver.Address,
response);
}
foreach (Variable v in response.Pdu.Variables)
{
Console.WriteLine(v);
}
Regards,
Lex
Original Posted Date: 2011-09-23T20:39:18.9-07:00
Copied from CodePlex without authors:
Thank you very much!
Original Posted Date: 2011-09-24T05:45:28.363-07:00
Marked as Answer Date: 2013-10-06T04:23:23.547-07:00
Hi,
Can you give a sample get string for v3 please?
Thank you..
Original Reported Date: 2011-02-11T06:40:37.223-08:00 Original CodePlex Discussion Thread ID: 245623