enable to remove SNMP timer (which consumne several cycles even when it's not necessary). snmp_agent.txt tell to call snmp_inc_sysuptime() each 10ms (but, it's intrusive if you use sys_timeout feature). Now, you can decide to call snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to a lower frequency). Or, you can decide to not call snmp_inc_sysuptime() or snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro. This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only when it's queried (any direct call to "sysuptime" is changed by a call to snmp_get_sysuptime).

This commit is contained in:
fbernon
2007-09-10 18:50:44 +00:00
parent 54e1b79ac5
commit 47ae677652
3 changed files with 29 additions and 2 deletions

View File

@@ -70,6 +70,10 @@
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
#endif
#ifndef SNMP_GET_SYSUPTIME
#define SNMP_GET_SYSUPTIME(sysuptime)
#endif
static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
static void system_get_value(struct obj_def *od, u16_t len, void *value);
static u8_t system_set_test(struct obj_def *od, u16_t len, void *value);
@@ -949,8 +953,14 @@ void snmp_inc_sysuptime(void)
sysuptime++;
}
void snmp_add_sysuptime(u32_t value)
{
sysuptime+=value;
}
void snmp_get_sysuptime(u32_t *value)
{
SNMP_GET_SYSUPTIME(sysuptime);
*value = sysuptime;
}
@@ -2193,8 +2203,7 @@ system_get_value(struct obj_def *od, u16_t len, void *value)
break;
case 3: /* sysUpTime */
{
u32_t *uint_ptr = value;
*uint_ptr = sysuptime;
snmp_get_sysuptime(value);
}
break;
case 4: /* sysContact */