Quantcast
Channel: C# Based Open Source SNMP Library for .NET and Mono
Viewing all articles
Browse latest Browse all 576

Created Unassigned: Small Bug with Cisco SNMP Trap Messages [7264]

$
0
0
I've noticed a small bug with the SNMP Trap Message received from Cisco devices
This is within the TrapV2 Receiver

The timeticks value returned from a cisco device will be formated as an unsigned integer
But within the snmp packet it's identified as an Integer32 snmp type which defaults to signed
so the library tries to parse the value as a signed instead of unsigned value

Quick Fix:

TrapV2Pdu.cs
TrapV2Pdu(Tuple<int, byte[]> length, Stream stream) function

Variables = Variable.Transform(_varbindSection); // v[0] is timestamp. v[1] oid, v[2] value.
//For Cisco Devices if the TimeTicks is too high it can cause problems
//As the value is parsed as a Integer32 SNMP Type which defaults to signed
//But the value is actually Unsigned

//_time = (TimeTicks)Variables[0].Data;

string tmpstr = Variables[0].Data.ToString();
Int32 tmpint = Int32.Parse(tmpstr);
var tmparr = BitConverter.GetBytes(tmpint);
UInt32 unsigned_ticks = BitConverter.ToUInt32(tmparr, 0);
_time = new TimeTicks(unsigned_ticks);

Variables.RemoveAt(0);
Enterprise = (ObjectIdentifier)Variables[0].Data;
Variables.RemoveAt(0);
_length = length.Item2;
}

Also it'd be nicer if Nlog was used instead of log4net (I've patched my own version to use NLog)
just because NLog seems to be updated more than log4net these days

Viewing all articles
Browse latest Browse all 576

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>