C# Класс SnmpSharpNet.SnmpV1Packet

SNMP version 1 packet class.
Supported request types are SNMP-GET, SNMP-GETNEXT, SNMP-SET and SNMP-RESPONSE. Available packet classes are:
  • SnmpV1Packet
  • SnmpV1TrapPacket
  • SnmpV2Packet
  • SnmpV3Packet
This class is provided to simplify encoding and decoding of packets and to provide consistent interface for users who wish to handle transport part of protocol on their own without using the UdpTarget class. SnmpPacket and derived classes have been developed to implement SNMP version 1, 2 and 3 packet support. For SNMP version 1 and 2 packet, SnmpV1Packet and SnmpV2Packet classes provides sufficient support for encoding and decoding data to/from BER buffers to satisfy requirements of most applications. SNMP version 3 on the other hand requires a lot more information to be passed to the encoder method and returned by the decode method. While using SnmpV3Packet class for full packet handling is possible, transport specific class UdpTarget uses SecureAgentParameters class to store protocol version 3 specific information that carries over from request to request when used on the same SNMP agent and therefore simplifies both initial definition of agents configuration (mostly security) as well as removes the need for repeated initialization of the packet class for subsequent requests. If you decide not to use transport helper class(es) like UdpTarget, BER encoding and decoding and packets is easily done with SnmpPacket derived classes. Example, SNMP version 1 packet encoding: SnmpV1Packet packetv1 = new SnmpV1Packet(); packetv1.Community.Set("public"); packetv1.Pdu.Set(mypdu); byte[] berpacket = packetv1.encode(); Example, SNMP version 1 packet decoding: SnmpV1Packet packetv1 = new SnmpV1Packet(); packetv1.decode(inbuffer,inlen);
Наследование: SnmpPacket
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
_pdu Pdu

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

Свойство Тип Описание
_snmpCommunity OctetString

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

Метод Описание
SnmpV1Packet ( ) : System

Standard constructor.

SnmpV1Packet ( string snmpCommunity ) : System

Standard constructor.

ToString ( ) : string

String representation of the SNMP v1 Packet contents.

decode ( byte buffer, int length ) : int

Decode received SNMP packet.

encode ( ) : byte[]

Encode SNMP packet for sending.

Приватные методы

Метод Описание
encode ( MutableByte buffer ) : void

Replacement for the base class encode method.

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

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

Standard constructor.
public SnmpV1Packet ( ) : System
Результат System

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

Standard constructor.
public SnmpV1Packet ( string snmpCommunity ) : System
snmpCommunity string SNMP community name for the packet
Результат System

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

String representation of the SNMP v1 Packet contents.
public ToString ( ) : string
Результат string

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

Decode received SNMP packet.
Thrown when invalid encoding has been found in the packet Thrown when parsed header points to more data then is available in the packet Thrown when parsed packet is not SNMP version 1 Thrown when received PDU is of a type not supported by SNMP version 1
public decode ( byte buffer, int length ) : int
buffer byte BER encoded packet buffer
length int BER encoded packet buffer length
Результат int

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

Encode SNMP packet for sending.
Thrown when PDU being encoded is not a valid SNMP version 1 PDU. Acceptable /// protocol version 1 operations are GET, GET-NEXT, SET and RESPONSE.
public encode ( ) : byte[]
Результат byte[]

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

_pdu публичное свойство

SNMP Protocol Data Unit
public Pdu _pdu
Результат Pdu

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

SNMP community name
protected OctetString _snmpCommunity
Результат OctetString