mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-16 08:43:17 +00:00
Redesign of snmp_msg_event() fsm, added SNMP SET to fsm.
This commit is contained in:
parent
f576755b13
commit
64dab92c6b
@ -38,6 +38,8 @@
|
||||
#include "lwip/snmp_structs.h"
|
||||
#include "lwip/mem.h"
|
||||
|
||||
#define TODO_GETNEXT_MIB_NODE_EX 0
|
||||
|
||||
/** .iso.org.dod.internet address prefix, @see snmp_iso_*() */
|
||||
const s32_t prefix[4] = {1, 3, 6, 1};
|
||||
|
||||
@ -675,11 +677,11 @@ empty_table(struct mib_node *node)
|
||||
struct mib_node *
|
||||
snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret)
|
||||
{
|
||||
u8_t node_type, climb_tree;
|
||||
u8_t node_type, ext_level, climb_tree;
|
||||
|
||||
/* reset stack */
|
||||
ext_level = 0;
|
||||
/* reset node stack */
|
||||
node_stack_cnt = 0;
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
climb_tree = 0;
|
||||
@ -744,9 +746,17 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||
}
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand, push_node() node=%p id=%"S32_F"\n",(void*)cur_node.r_ptr,cur_node.r_id));
|
||||
push_node(&cur_node);
|
||||
/* follow next child pointer */
|
||||
if (an->objid[i] == *ident)
|
||||
{
|
||||
ident_len--;
|
||||
ident++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* an->objid[i] < *ident */
|
||||
ident_len = 0;
|
||||
}
|
||||
/* follow next child pointer */
|
||||
node = an->nptr[i];
|
||||
}
|
||||
}
|
||||
@ -847,9 +857,17 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||
}
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("expand, push_node() node=%p id=%"S32_F"\n",(void*)cur_node.r_ptr,cur_node.r_id));
|
||||
push_node(&cur_node);
|
||||
/* follow next child pointer */
|
||||
if (ln->objid == *ident)
|
||||
{
|
||||
ident_len--;
|
||||
ident++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ln->objid < *ident */
|
||||
ident_len = 0;
|
||||
}
|
||||
/* follow next child pointer */
|
||||
node = ln->nptr;
|
||||
}
|
||||
|
||||
@ -893,6 +911,36 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||
}
|
||||
}
|
||||
}
|
||||
#if TODO_GETNEXT_MIB_NODE_EX
|
||||
else if(node_type == MIB_NODE_EX)
|
||||
{
|
||||
struct mib_external_node *en;
|
||||
|
||||
/* external node (addressing and access via functions) */
|
||||
en = (struct mib_external_node *)node;
|
||||
if (ident_len > 0)
|
||||
{
|
||||
u16_t i, len;
|
||||
|
||||
i = 0;
|
||||
len = en->level_length(en->addr_inf,ext_level);
|
||||
while ((i < len) && (en->ident_cmp(en->addr_inf,ext_level,i,*ident) < 0))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (i < len)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ident_len == 0, complete with leftmost '.thing' */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if(node_type == MIB_NODE_SC)
|
||||
{
|
||||
mib_scalar_node *sn;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -180,17 +180,25 @@ struct snmp_trap_header_lengths
|
||||
u16_t seqlen;
|
||||
};
|
||||
|
||||
/* can accept new SNMP message */
|
||||
/* Accepting new SNMP messages. */
|
||||
#define SNMP_MSG_EMPTY 0
|
||||
/* decode SNMP variable binding */
|
||||
#define SNMP_MSG_DEMUX 1
|
||||
/* perform SNMP operation on varbind for in-memory case */
|
||||
#define SNMP_MSG_INTERNAL 2
|
||||
/* perform SNMP operation on private varbind external case */
|
||||
#define SNMP_MSG_EXTERNAL_GET_OBJDEF 3
|
||||
#define SNMP_MSG_EXTERNAL_GET_VALUE 4
|
||||
#define SNMP_MSG_EXTERNAL_SET_TEST 5
|
||||
#define SNMP_MSG_EXTERNAL_SET_VALUE 6
|
||||
/* Search for matching object for variable binding. */
|
||||
#define SNMP_MSG_SEARCH_OBJ 1
|
||||
/* Perform SNMP operation on in-memory object.
|
||||
Pass-through states, for symmetry only. */
|
||||
#define SNMP_MSG_INTERNAL_GET_OBJDEF 2
|
||||
#define SNMP_MSG_INTERNAL_GET_VALUE 3
|
||||
#define SNMP_MSG_INTERNAL_SET_TEST 4
|
||||
#define SNMP_MSG_INTERNAL_GET_OBJDEF_S 5
|
||||
#define SNMP_MSG_INTERNAL_SET_VALUE 6
|
||||
/* Perform SNMP operation on object located externally.
|
||||
In theory this could be used for building a proxy agent.
|
||||
Practical use is for an enterprise spc. app. gateway. */
|
||||
#define SNMP_MSG_EXTERNAL_GET_OBJDEF 7
|
||||
#define SNMP_MSG_EXTERNAL_GET_VALUE 8
|
||||
#define SNMP_MSG_EXTERNAL_SET_TEST 9
|
||||
#define SNMP_MSG_EXTERNAL_GET_OBJDEF_S 10
|
||||
#define SNMP_MSG_EXTERNAL_SET_VALUE 11
|
||||
|
||||
#define SNMP_COMMUNITY_STR_LEN 64
|
||||
struct snmp_msg_pstat
|
||||
@ -222,6 +230,7 @@ struct snmp_msg_pstat
|
||||
struct mib_external_node *ext_mib_node;
|
||||
struct snmp_name_ptr ext_name_ptr;
|
||||
struct obj_def ext_object_def;
|
||||
struct snmp_obj_id ext_oid;
|
||||
/* index into input variable binding list */
|
||||
u8_t vb_idx;
|
||||
/* ptr into input variable binding list */
|
||||
@ -283,10 +292,8 @@ void snmp_varbind_list_free(struct snmp_varbind_root *root);
|
||||
void snmp_varbind_tail_add(struct snmp_varbind_root *root, struct snmp_varbind *vb);
|
||||
struct snmp_varbind* snmp_varbind_tail_remove(struct snmp_varbind_root *root);
|
||||
|
||||
/** Handle a single internal or external event. */
|
||||
/** Handle an internal (recv) or external (private response) event. */
|
||||
void snmp_msg_event(u8_t request_id);
|
||||
/** Handle as many events as possible in one go. */
|
||||
void snmp_msg_event_loop(u8_t request_id);
|
||||
err_t snmp_send_response(struct snmp_msg_pstat *m_stat);
|
||||
err_t snmp_send_trap(s8_t generic_trap, s32_t specific_trap);
|
||||
void snmp_coldstart_trap(void);
|
||||
|
@ -207,7 +207,7 @@ struct mib_external_node
|
||||
void (*get_object_def_q)(void* addr_inf, u8_t rid, u8_t ident_len, s32_t *ident);
|
||||
void (*get_value_q)(u8_t rid, struct obj_def *od);
|
||||
void (*set_test_q)(u8_t rid, struct obj_def *od);
|
||||
void (*set_value_q)(u8_t rid, struct obj_def *od);
|
||||
void (*set_value_q)(u8_t rid, struct obj_def *od, u16_t len, void *value);
|
||||
/** async Answers */
|
||||
void (*get_object_def_a)(u8_t rid, u8_t ident_len, s32_t *ident, struct obj_def *od);
|
||||
void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user