Incorrect Time Stamp in V1/V2 Traps

Jochen Katz katz____agentpp.com
Wed Feb 28 00:12:03 CET 2001


Hi,

> While testing SNMP traps, I noticed that when I send a V1 or V2 trap using
> the NotificationOriginator::generate function, the time stamp that is sent
> in the trap is incorrect. The generate function eventually calls the
> Snmp::trap function. Instead of using sysUpTime, this function retrieves the
> current time, subtracts 946080000 seconds (30 years), and uses the result as
> the time stamp.

the problem here is, that the Snmp class does not know, how long the
agent is running (the object could have been created only temporarily).
So if the timestamp wasn't set by the application it uses the above
method which should be ok for a timestamp.

> I noticed that the NotificationOriginator::generate function does retrieve
> the value of sysUpTime and insert it into a PDU object, but that object is
> only used if _SNMPv3 is defined. I commented out this #define from both
> config.h and agent++.h because I only want SNMPv2 support. Therefore, the
> generate function is calling SnmpRequest::process_trap, which is building a
> new PDU instead of using the one that it had already constructed.

The creation of the Pdu object should only occur if _SNMPv3 is defined. 

Does something speak against a

        pdu.set_notify_timestamp(sysUpTime::get());

before the line 

        pdu.set_notify_enterprise(enterprise);

in SnmpRequest::process_trap()?

Best regards,
  Jochen



More information about the AGENTPP mailing list