Hi,
I've fixed the problem. The problem was in function
"usm_check_and_update_timeliness" (snmpusm.c)
myBoots = snmpv3_local_snmpEngineBoots();
myTime = snmpv3_local_snmpEngineTime();
if ((int) secEngineIDLen == myIDLength
&& memcmp(secEngineID, myID, myIDLength) == 0) {
u_int time_difference = myTime > time_uint ?
myTime - time_uint : time_uint - myTime;
if (boots_uint == ENGINEBOOT_MAX
|| boots_uint != myBoots
|| time_difference > USM_TIME_WINDOW) {
if (snmp_increment_statistic(STAT_USMSTATSNOTINTIMEWINDOWS)
==
0) {
DEBUGMSGTL(("usm", "%s\n",
"Failed to increment statistic."));
}
DEBUGMSGTL(("usm",
"boot_uint %u myBoots %u time_diff %u => not in
time window\n",
boots_uint, myBoots, time_difference));
*error = SNMPERR_USM_NOTINTIMEWINDOW;
return -1;
}
*error = SNMPERR_SUCCESS;
return 0;
}
Snmpv3_local_snmpEngineTime() gives a difference between start time and
now in seconds. It means when you change the year you have too big
difference. But actually one wants to know the time difference from
system start (snmpv3 engine start time).
So I defined following function in system.c (and added a prototype to
system.h):
long get_uptime_in_sec(void)
{
struct sysinfo *info = (struct sysinfo*)malloc(sizeof(struct
sysinfo));
if(sysinfo(info) < 0)
{
perror("Getting uptime");
return -1;
}
return info->uptime;
}
The I changed snmpv3.c as follows:
//static struct timeval snmpv3starttime;
static long snmpv3starttime;
void
init_snmpv3(const char *type)
{
//gettimeofday(&snmpv3starttime, NULL);
snmpv3starttime = get_uptime_in_sec();
...
}
u_long
snmpv3_local_snmpEngineTime(void)
{
//struct timeval now;
long now = get_uptime_in_sec();
// gettimeofday(&now, NULL);
// return calculate_time_diff(&now, &snmpv3starttime) / 100;
return now - snmpv3starttime;
}
lcd_time.c
int
get_enginetime(u_char * engineID,
u_int engineID_len,
u_int * engineboot,
u_int * engine_time, u_int authenticated)
{
...
//timediff = time(NULL) - e->lastReceivedEngineTime;
timediff = get_uptime_in_sec() - e->lastReceivedEngineTime;
...
}
int
get_enginetime_ex(u_char * engineID,
u_int engineID_len,
u_int * engineboot,
u_int * engine_time,
u_int * last_engine_time, u_int authenticated)
{
...
//timediff = time(NULL) - e->lastReceivedEngineTime;
timediff = get_uptime_in_sec() - e->lastReceivedEngineTime;
...
}
I worked with source code from version 5.0.9 but I looked at the 5.1.3.1
sources it's not a problem to make this changes there.
I tested the new version with the 5.2.1 binary and it works. Now one is
independent from from the time actually set on the system, cause one
works with the time the system is up.
With regards,
Yegor Yefremov
>Yegor Yefremov wrote:
>> I have changed to version 5.0.10(5.1.3.1 is not so easy to integrate
in
>> my system) but the bug is still there. Do you know in which file or
>> filegroup it was fixed?
>
>Too many to list, most of them in snmplib/. Check the CVS logs if
you're
>curious enough.
>
>Are you sure you removed 5.0.9 from your system *completely*?
>
>
>+Thomas
>--
>Thomas Anders (thomas.anders at blue-cable.de)
Best regards,
Yegor Yefremov
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders