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

@ -19,6 +19,18 @@ HISTORY
++ New features: ++ 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 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, * 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 and others without it, there is a new NETIF_FLAG_IGMP flag to set in netif->flags

View File

@ -70,6 +70,10 @@
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2)) #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
#endif #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_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 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); 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++; sysuptime++;
} }
void snmp_add_sysuptime(u32_t value)
{
sysuptime+=value;
}
void snmp_get_sysuptime(u32_t *value) void snmp_get_sysuptime(u32_t *value)
{ {
SNMP_GET_SYSUPTIME(sysuptime);
*value = sysuptime; *value = sysuptime;
} }
@ -2193,8 +2203,7 @@ system_get_value(struct obj_def *od, u16_t len, void *value)
break; break;
case 3: /* sysUpTime */ case 3: /* sysUpTime */
{ {
u32_t *uint_ptr = value; snmp_get_sysuptime(value);
*uint_ptr = sysuptime;
} }
break; break;
case 4: /* sysContact */ case 4: /* sysContact */

View File

@ -81,8 +81,12 @@ enum snmp_ifType {
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */ #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 */ /** fixed maximum length for object identifier type */
#define LWIP_SNMP_OBJ_ID_LEN 32 #define LWIP_SNMP_OBJ_ID_LEN 32
/** internal object identifier representation */ /** internal object identifier representation */
struct snmp_obj_id 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_set_sysobjid(struct snmp_obj_id *oid);
void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid); void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid);
void snmp_inc_sysuptime(void); void snmp_inc_sysuptime(void);
void snmp_add_sysuptime(u32_t value);
void snmp_get_sysuptime(u32_t *value); void snmp_get_sysuptime(u32_t *value);
void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen); void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen);
void snmp_set_sysname(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_set_sysobjid(oid);
#define snmp_get_sysobjid_ptr(oid) #define snmp_get_sysobjid_ptr(oid)
#define snmp_inc_sysuptime() #define snmp_inc_sysuptime()
#define snmp_add_sysuptime(value)
#define snmp_get_sysuptime(value) #define snmp_get_sysuptime(value)
#define snmp_set_syscontact(ocstr, ocstrlen); #define snmp_set_syscontact(ocstr, ocstrlen);
#define snmp_set_sysname(ocstr, ocstrlen); #define snmp_set_sysname(ocstr, ocstrlen);