C# Class SnmpSharpNet.SnmpPacket

Base SNMP packet class.
All SNMP packets begin with the SMI_SEQUENCE header and SNMP protocol version number. This class parses and encodes these values. Derived classes parse further information from SNMP packets.
Afficher le fichier Open project: griffina/SnmpSharpNet Class Usage Examples

Protected Properties

Свойство Type Description
_protocolVersion Integer32

Méthodes publiques

Méthode Description
GetProtocolVersion ( byte buffer, int bufferLength ) : int

Get SNMP protocol version from the packet. This routine does not verify if version number is valid. Caller should verify that returned value represents a valid SNMP protocol version number. int protocolVersion = Packet.GetProtocolVersion(inPacket, inLength); if( protocolVersion != -1 ) { if( protocolVersion == SnmpConstants.SNMPV1 || protocolVersion == SnmpConstants.SNMPV2 || protocolVersion == SnmpConstants.SNMPV3 ) { // do something } else { Console.WriteLine("Invalid SNMP protocol version."); } } else { Console.WriteLine("Invalid SNMP packet."); }

SnmpPacket ( ) : System

Constructor. Sets SNMP version to SNMPV1.

SnmpPacket ( SnmpVersion protocolVersion ) : System

Constructor. Initialize SNMP version as supplied.

decode ( byte buffer, int length ) : int

Decode SNMP packet header. This class decodes the initial sequence and SNMP protocol version number.

encode ( ) : byte[]

Place holder for derived class implementations.

encode ( MutableByte buffer ) : void

Wrap BER encoded SNMP information contained in the parameter MutableByte class. Information in the parameter is prepended by the SNMP version field and wrapped in a sequence header. Derived classes call this method to finalize SNMP packet encoding.

Method Details

GetProtocolVersion() public static méthode

Get SNMP protocol version from the packet. This routine does not verify if version number is valid. Caller should verify that returned value represents a valid SNMP protocol version number. int protocolVersion = Packet.GetProtocolVersion(inPacket, inLength); if( protocolVersion != -1 ) { if( protocolVersion == SnmpConstants.SNMPV1 || protocolVersion == SnmpConstants.SNMPV2 || protocolVersion == SnmpConstants.SNMPV3 ) { // do something } else { Console.WriteLine("Invalid SNMP protocol version."); } } else { Console.WriteLine("Invalid SNMP packet."); }
Thrown when invalid sequence type is found at the start of the SNMP packet being decoded
public static GetProtocolVersion ( byte buffer, int bufferLength ) : int
buffer byte BER encoded SNMP packet
bufferLength int Length of the BER encoded packet
Résultat int

SnmpPacket() public méthode

Constructor. Sets SNMP version to SNMPV1.
public SnmpPacket ( ) : System
Résultat System

SnmpPacket() public méthode

Constructor. Initialize SNMP version as supplied.
public SnmpPacket ( SnmpVersion protocolVersion ) : System
protocolVersion SnmpVersion Protocol version. Acceptable values are SnmpConstants.SNMPV1, /// SnmpConstants.SNMPV2 and SnmpConstants.SNMPV3
Résultat System

decode() public méthode

Decode SNMP packet header. This class decodes the initial sequence and SNMP protocol version number.
Thrown when invalid sequence type is found at the start of the SNMP packet being decoded
public decode ( byte buffer, int length ) : int
buffer byte BER encoded SNMP packet
length int Packet length
Résultat int

encode() public abstract méthode

Place holder for derived class implementations.
public abstract encode ( ) : byte[]
Résultat byte[]

encode() public méthode

Wrap BER encoded SNMP information contained in the parameter MutableByte class. Information in the parameter is prepended by the SNMP version field and wrapped in a sequence header. Derived classes call this method to finalize SNMP packet encoding.
public encode ( MutableByte buffer ) : void
buffer MutableByte Buffer containing BER encoded SNMP information
Résultat void

Property Details

_protocolVersion protected_oe property

SNMP protocol version
protected Integer32 _protocolVersion
Résultat Integer32