diff --git a/CHANGELOG b/CHANGELOG index c8d025c6..3979fde0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,18 @@ HISTORY ++ New features: + 2007-09-10 Frédéric Bernon + * snmp.h, mib2.c: 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). + 2007-09-09 Frédéric Bernon, Bill Florac * igmp.h, igmp.c, netif.h, netif.c, ip.c: To enable to have interfaces with IGMP, and others without it, there is a new NETIF_FLAG_IGMP flag to set in netif->flags diff --git a/src/core/snmp/mib2.c b/src/core/snmp/mib2.c index 8c379343..a968375b 100644 --- a/src/core/snmp/mib2.c +++ b/src/core/snmp/mib2.c @@ -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 */ diff --git a/src/include/lwip/snmp.h b/src/include/lwip/snmp.h index 36a087b4..dd03d5d7 100644 --- a/src/include/lwip/snmp.h +++ b/src/include/lwip/snmp.h @@ -81,8 +81,12 @@ enum snmp_ifType { #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ +/** SNMP "sysuptime" Interval */ +#define SNMP_SYSUPTIME_INTERVAL 10 + /** fixed maximum length for object identifier type */ #define LWIP_SNMP_OBJ_ID_LEN 32 + /** internal object identifier representation */ struct snmp_obj_id { @@ -95,6 +99,7 @@ void snmp_set_sysdesr(u8_t* str, u8_t* len); void snmp_set_sysobjid(struct snmp_obj_id *oid); void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); void snmp_inc_sysuptime(void); +void snmp_add_sysuptime(u32_t value); void snmp_get_sysuptime(u32_t *value); void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen); void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen); @@ -227,6 +232,7 @@ void snmp_get_snmpenableauthentraps(u8_t *value); #define snmp_set_sysobjid(oid); #define snmp_get_sysobjid_ptr(oid) #define snmp_inc_sysuptime() +#define snmp_add_sysuptime(value) #define snmp_get_sysuptime(value) #define snmp_set_syscontact(ocstr, ocstrlen); #define snmp_set_sysname(ocstr, ocstrlen);