0

I like to understand if there are any APIs available in lextm sharpsnmp library to encode SNMPv1/v2c/V3 PDU to byte array and also API to construct a SnmpPdu (SNMP v1/v2c/v3) based on a byte array. Thank you in Advance

Ayan
  • 31
  • 5

1 Answers1

1

To get the raw bytes of a PDU, use ISnmpMessage.ToBytes:

GetRequestMessage getRequest = new(requestID, VersionCode.V1, new OctetString("public"), new Variable[] { variable });

byte[] getRequestBytes = getRequest.ToBytes();

To build a PDU from raw bytes, use MessageFactory.ParseMessages:

byte[] rawBytes = { 0x30, byte2, byte3, ... };

IList<ISnmpMessage> message = MessageFactory.ParseMessages(rawBytes, new UserRegistry());