C# Class SnmpSharpNet.ScopedPdu

SNMP Version 3 Scoped Protocol Data Unit.
ScopedPdu extends the Pdu class by adding SNMP version 3 specific Context Engine Id and Context Name variables to the beginning of the packet. Context engine id is retrieved from the agent using the SNMP version 3 standard defined discovery process. Context name is used to define which subsection of the agents MIB user is allowed (or wants) to access. When creating a new ScopedPdu, for a valid request, ContextEngineId value has to be set for a valid reply to be received. Context value is implementation specific (depends on the configuration of the agent) and might not be required for a successful request.
Inheritance: Pdu
Datei anzeigen Open project: griffina/SnmpSharpNet Class Usage Examples

Protected Properties

Property Type Description
_contextEngineId OctetString
_contextName OctetString

Public Methods

Method Description
ScopedPdu ( ) : System

Standard constructor.

Intializes the ScopedPdu type to SNMP-GET. For details see base class Pdu standard constructor definition. Context engine id and name variables are initialized to 0 length values.

ScopedPdu ( Pdu pdu ) : System

Constructor.

ScopedPdu ( PduType pduType ) : System

Constructor.

ScopedPdu ( PduType pduType, int requestId ) : System

Constructor.

Standard constructor that sets ScopedPdu request type and request id. For valid types see PduType. By default, requestId value is set to a random value. Second argument allows caller to specify request id for this packet

decode ( byte buffer, int offset ) : int

Decode BER encoded ScopedPdu values. This method does not perform SNMP v3 privacy operations and is not aware of privacy requirements. To decode a privacy protected SNMP v3 packet, you will need to a) extract OctetString value holding encrypted ScopedPdu data, b) decrypt the encrypted ScopedPdu data into an unecrypted byte array, c) pass unencrypted ScopedPdu and BER encoded byte array to this method for final data conversion from BER into individual sequences and variables.

encode ( MutableByte buffer ) : void

Convert ScopedPdu into a BER encoded byte array. Resulting byte array is appended to the argument specified MutableByte class. Privacy operations are not performed by this method. Value encoded and returned by this method is suitable for sending in NoAuthNoPriv or AuthNoPriv security configurations. If privacy is required, caller will have to perform encryption and decryption operations after BER encoding is performed. In privacy protected SNMP version 3 packets, ScopedPdu is 1) encrypted using configured encryption method, 2) added to a OctetString field, and 3) appended to the data buffer. Because privacy operation is intrusive, it is recommended that BER encoding of the ScopedPdu packet is stored in a temporary MutableByte class, where it can be privacy protected and added to the OctetString class for final encoding into the target SNMP v3 packet.

Method Details

ScopedPdu() public method

Standard constructor.
Intializes the ScopedPdu type to SNMP-GET. For details see base class Pdu standard constructor definition. Context engine id and name variables are initialized to 0 length values.
public ScopedPdu ( ) : System
return System

ScopedPdu() public method

Constructor.
public ScopedPdu ( Pdu pdu ) : System
pdu Pdu Initialize class from this class
return System

ScopedPdu() public method

Constructor.
public ScopedPdu ( PduType pduType ) : System
pduType PduType Pdu type value. For available types see .
return System

ScopedPdu() public method

Constructor.
Standard constructor that sets ScopedPdu request type and request id. For valid types see PduType. By default, requestId value is set to a random value. Second argument allows caller to specify request id for this packet
public ScopedPdu ( PduType pduType, int requestId ) : System
pduType PduType Pdu type value.
requestId int Request id for the ScopedPdu instance.
return System

decode() public method

Decode BER encoded ScopedPdu values. This method does not perform SNMP v3 privacy operations and is not aware of privacy requirements. To decode a privacy protected SNMP v3 packet, you will need to a) extract OctetString value holding encrypted ScopedPdu data, b) decrypt the encrypted ScopedPdu data into an unecrypted byte array, c) pass unencrypted ScopedPdu and BER encoded byte array to this method for final data conversion from BER into individual sequences and variables.
Error was encountered when decoding the PDU Thrown when buffer is too short to contain the PDU
public decode ( byte buffer, int offset ) : int
buffer byte Buffer holding BER encoded data
offset int Offset within the buffer BER encoded data begins.
return int

encode() public method

Convert ScopedPdu into a BER encoded byte array. Resulting byte array is appended to the argument specified MutableByte class. Privacy operations are not performed by this method. Value encoded and returned by this method is suitable for sending in NoAuthNoPriv or AuthNoPriv security configurations. If privacy is required, caller will have to perform encryption and decryption operations after BER encoding is performed. In privacy protected SNMP version 3 packets, ScopedPdu is 1) encrypted using configured encryption method, 2) added to a OctetString field, and 3) appended to the data buffer. Because privacy operation is intrusive, it is recommended that BER encoding of the ScopedPdu packet is stored in a temporary MutableByte class, where it can be privacy protected and added to the OctetString class for final encoding into the target SNMP v3 packet.
public encode ( MutableByte buffer ) : void
buffer MutableByte class passed by reference that encoded ScopedPdu /// value is appended to.
return void

Property Details

_contextEngineId protected_oe property

Context Engine Id variable.
protected OctetString _contextEngineId
return OctetString

_contextName protected_oe property

Context name variable
protected OctetString _contextName
return OctetString