"Look-ahead" decode of SNMP packet header including USM information

Namespace: SnmpSharpNet
Assembly: SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.9.1.0 (0.9.1)

Syntax

C#
public UserSecurityModel GetUSM(
	byte[] berBuffer,
	int length
)
Visual Basic
Public Function GetUSM ( _
	berBuffer As Byte(), _
	length As Integer _
) As UserSecurityModel
Visual C++
public:
UserSecurityModel^ GetUSM(
	array<unsigned char>^ berBuffer, 
	int length
)

Parameters

berBuffer
Type: array<System..::..Byte>[]()[][]
Raw SNMP version 3 packet
length
Type: System..::..Int32
SNMP version 3 packet length

Return Value

UserSecurityModel class parsed from the parameter SNMP version 3 packet

Remarks

Decode first component of the SNMP version 3 packet allowing the caller to retrieve USM SecureName needed to retrieve client security parameters that will allow authentication and privacy decryption to take place. This method is used to support Agent like behavior or to handle unsolicited packets like TRAP and INFORMs. In all of these cases, sender of packets will forward a packet without a request being sent by you. In turn, you will need to parse enough of the packet to retrieve SecureName which you can use to retrieve security parameters associated with that user and attempt to authorize and privacy decrypt the received packet. Only use this method when your application is acting as an Agent or if you need to process TRAP and INFORM packets.

Exceptions

ExceptionCondition
SnmpSharpNet..::..SnmpInvalidVersionExceptionThrown when attempting to parse an SNMP packet that is not version 3
System..::..OverflowExceptionThrown when header specifies packet length that is longer then the amount of data received.
SnmpSharpNet..::..SnmpDecodingExceptionThrown when invalid sequence is enountered while decoding global message data sequence
SnmpSharpNet..::..SnmpExceptionThrown with SnmpException.UnsupportedNoAuthPriv when packet is using privacy without authentication (not allowed)
SnmpSharpNet..::..SnmpExceptionThrown with SnmpException.UnsupportedSecurityModel when packet is sent with security model other then USM (only USM is defined in SNMPv3 standard)

See Also