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.
CopyC#
int protocolVersion = Packet.GetProtocolVersion(inPacket, inLength);
if( protocolVersion != -1 )
{
if( protocolVersion == SnmpConstants.SNMPV1 || protocolVersion == SnmpConstants.SNMPV2 || protocolVersion == SnmpConstants.SNMPV3 )
{
}
else
{
Console.WriteLine("Invalid SNMP protocol version.");
}
}
else
{
Console.WriteLine("Invalid SNMP packet.");
}
Namespace:
SnmpSharpNet
Assembly:
SnmpSharpNet (in SnmpSharpNet.dll) Version: 0.5.2.0 (0.5.2.0)
Syntax
| C# |
|---|
public static int GetProtocolVersion(
byte[] buffer,
int bufferLength
) |
| Visual Basic (Declaration) |
|---|
Public Shared Function GetProtocolVersion ( _
buffer As Byte(), _
bufferLength As Integer _
) As Integer |
| Visual C++ |
|---|
public:
static int GetProtocolVersion(
array<unsigned char>^ buffer,
int bufferLength
) |
Return Value
Returns SNMP protocol version, if packet is not valid returned value is -1.
See Also