C# Класс 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.
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_protocolVersion Integer32

Открытые методы

Метод Описание
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.

Описание методов

GetProtocolVersion() публичный статический Метод

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
Результат int

SnmpPacket() публичный Метод

Constructor. Sets SNMP version to SNMPV1.
public SnmpPacket ( ) : System
Результат System

SnmpPacket() публичный Метод

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
Результат System

decode() публичный Метод

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
Результат int

encode() публичный абстрактный Метод

Place holder for derived class implementations.
public abstract encode ( ) : byte[]
Результат byte[]

encode() публичный Метод

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
Результат void

Описание свойств

_protocolVersion защищенное свойство

SNMP protocol version
protected Integer32 _protocolVersion
Результат Integer32