SNMP SET request
Namespace: SnmpSharpNetAssembly: SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.9.1.0 (0.9.1)
Syntax
| C# |
|---|
public Dictionary<Oid, AsnType> Set( SnmpVersion version, Pdu pdu ) |
| Visual Basic |
|---|
Public Function Set ( _ version As SnmpVersion, _ pdu As Pdu _ ) As Dictionary(Of Oid, AsnType) |
| Visual C++ |
|---|
public: Dictionary<Oid^, AsnType^>^ Set( SnmpVersion version, Pdu^ pdu ) |
Parameters
- version
- Type: SnmpSharpNet..::..SnmpVersion
SNMP protocol version number. Acceptable values are SnmpVersion.Ver1 and SnmpVersion.Ver2
- pdu
- Type: SnmpSharpNet..::..Pdu
Request Protocol Data Unit
Return Value
Result of the SNMP request in a dictionary format with Oid => AsnType values
Examples
Set operation in SNMP version 1:
CopyC#
To use SNMP version 2, change snmp.Set() method call first parameter to SnmpVersion.Ver2.
String snmpAgent = "10.10.10.1"; String snmpCommunity = "private"; SimpleSnmp snmp = new SimpleSnmp(snmpAgent, snmpCommunity); // Create a request Pdu Pdu pdu = new Pdu(); pdu.Type = SnmpConstants.SET; // type SET Oid setOid = new Oid("1.3.6.1.2.1.1.1.0"); // sysDescr.0 OctetString setValue = new OctetString("My personal toy"); pdu.VbList.Add(setOid, setValue); Dictionary<Oid, AsnType> result = snmp.Set(SnmpVersion.Ver1, pdu); if( result == null ) { Console.WriteLine("Request failed."); } else { Console.WriteLine("Success!"); }