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
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