SNMP SET request

Namespace:  SnmpSharpNet
Assembly:  SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.5.0.0 (0.5.0.0)

Syntax

         
 C#  Visual Basic  Visual C++ 
public Dictionary<Oid, AsnType> Set(
	SnmpVersion version,
	Vb[] vbs
)
Public Function Set ( _
	version As SnmpVersion, _
	vbs As Vb() _
) As Dictionary(Of Oid, AsnType)
public:
Dictionary<Oid^, AsnType^>^ Set(
	SnmpVersion version, 
	array<Vb^>^ vbs
)

Parameters

version
SnmpVersion
SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
vbs
array< Vb >[]()[]
Vb array containing Oid/AsnValue pairs for the SET operation

Return Value

Result of the SNMP request in a dictionary format with Oid => AsnType values

Examples

Set operation in SNMP version 1:
CopyC#
String snmpAgent = "10.10.10.1";
String snmpCommunity = "private";
SimpleSnmp snmp = new SimpleSnmp(snmpAgent, snmpCommunity);
// Create a request Pdu
List<Vb> vbList = new List<Vb>();
Oid setOid = new Oid("1.3.6.1.2.1.1.1.0"); // sysDescr.0
OctetString setValue = new OctetString("My personal toy");
vbList.Add(new Vb(setOid, setValue));
Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1, list.ToArray());
if( result == null ) {
  Console.WriteLine("Request failed.");
} else {
  Console.WriteLine("Success!");
}
To use SNMP version 2, change snmp.Set() method call first parameter to SnmpVersion.Ver2.

See Also