mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 03:35:38 +00:00
snmp: cleaned up mib_* structs: "base" class 'struct mib_node' only needs the type, get/set functions are not used on array/external nodes (only on scalar/listroot nodes)
This commit is contained in:
parent
bf75ace695
commit
fe33fd6d86
@ -279,9 +279,9 @@ HISTORY
|
||||
|
||||
++ Bugfixes:
|
||||
|
||||
2015-10-01: Dirk Ziegelmeier:
|
||||
* snmp: fixed bug #46089: snmp: race condition on length change between
|
||||
get_object_def() and get_value()
|
||||
2015-10-02: Dirk Ziegelmeier/Simon Goldschmidt
|
||||
* snmp: cleaned up snmp structs API (fixed race conditions from bug #46089,
|
||||
reduce ram/rom usage of tables): incompatible change for private MIBs
|
||||
|
||||
2015-09-30: Simon Goldschmidt
|
||||
* ip4_addr.c: fixed bug #46072: ip4addr_aton() does not check the number range
|
||||
|
@ -132,14 +132,11 @@ static void snmp_set_value(struct obj_def *od, u16_t len, void *value);
|
||||
|
||||
/* snmp .1.3.6.1.2.1.11 */
|
||||
static const struct mib_scalar_node snmp_scalar = {
|
||||
{
|
||||
&snmp_get_object_def,
|
||||
&snmp_get_value,
|
||||
&snmp_set_test,
|
||||
&snmp_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&snmp_get_object_def,
|
||||
&snmp_get_value,
|
||||
&snmp_set_test,
|
||||
&snmp_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry snmp_nodes[] = {
|
||||
{1, &snmp_scalar.node}, {2, &snmp_scalar.node},
|
||||
@ -158,14 +155,8 @@ static const struct mib_array_node_entry snmp_nodes[] = {
|
||||
{29, &snmp_scalar.node}, {30, &snmp_scalar.node}
|
||||
};
|
||||
static const struct mib_array_node snmp = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(snmp_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(snmp_nodes),
|
||||
snmp_nodes
|
||||
};
|
||||
|
||||
@ -177,54 +168,38 @@ static const struct mib_array_node snmp = {
|
||||
/** index root node for udpTable */
|
||||
static struct mib_list_rootnode udp_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry udpentry_nodes[] = {
|
||||
{1, &udp_root.node}, {2, &udp_root.node}
|
||||
{1, &udp_root.scalar.node}, {2, &udp_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node udpentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(udpentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(udpentry_nodes),
|
||||
udpentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry udptable_node = {1, &udpentry.node};
|
||||
static struct mib_ram_array_node udptable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&udptable_node
|
||||
};
|
||||
|
||||
static const struct mib_scalar_node udp_scalar = {
|
||||
{
|
||||
&udp_get_object_def,
|
||||
&udp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&udp_get_object_def,
|
||||
&udp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry udp_nodes[] = {
|
||||
{1, &udp_scalar.node}, {2, &udp_scalar.node},
|
||||
@ -232,14 +207,8 @@ static const struct mib_array_node_entry udp_nodes[] = {
|
||||
{5, &udptable.node}
|
||||
};
|
||||
static const struct mib_array_node udp = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(udp_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(udp_nodes),
|
||||
udp_nodes
|
||||
};
|
||||
|
||||
@ -249,58 +218,42 @@ static const struct mib_array_node udp = {
|
||||
/** index root node for tcpConnTable */
|
||||
static struct mib_list_rootnode tcpconntree_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry tcpconnentry_nodes[] = {
|
||||
{1, &tcpconntree_root.node}, {2, &tcpconntree_root.node},
|
||||
{3, &tcpconntree_root.node}, {4, &tcpconntree_root.node},
|
||||
{5, &tcpconntree_root.node}
|
||||
{1, &tcpconntree_root.scalar.node}, {2, &tcpconntree_root.scalar.node},
|
||||
{3, &tcpconntree_root.scalar.node}, {4, &tcpconntree_root.scalar.node},
|
||||
{5, &tcpconntree_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node tcpconnentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(tcpconnentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(tcpconnentry_nodes),
|
||||
tcpconnentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry tcpconntable_node = {1, &tcpconnentry.node};
|
||||
static struct mib_ram_array_node tcpconntable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
{ MIB_NODE_RA },
|
||||
/** @todo update maxlength when inserting / deleting from table
|
||||
0 when table is empty, 1 when more than one entry */
|
||||
0
|
||||
},
|
||||
0,
|
||||
&tcpconntable_node
|
||||
};
|
||||
|
||||
static const struct mib_scalar_node tcp_scalar = {
|
||||
{
|
||||
&tcp_get_object_def,
|
||||
&tcp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&tcp_get_object_def,
|
||||
&tcp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry tcp_nodes[] = {
|
||||
{1, &tcp_scalar.node}, {2, &tcp_scalar.node},
|
||||
@ -313,28 +266,19 @@ static const struct mib_array_node_entry tcp_nodes[] = {
|
||||
{15, &tcp_scalar.node}
|
||||
};
|
||||
static const struct mib_array_node tcp = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(tcp_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(tcp_nodes),
|
||||
tcp_nodes
|
||||
};
|
||||
#endif
|
||||
|
||||
/* icmp .1.3.6.1.2.1.5 */
|
||||
static const struct mib_scalar_node icmp_scalar = {
|
||||
{
|
||||
&icmp_get_object_def,
|
||||
&icmp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&icmp_get_object_def,
|
||||
&icmp_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry icmp_nodes[] = {
|
||||
{1, &icmp_scalar.node}, {2, &icmp_scalar.node},
|
||||
@ -352,164 +296,116 @@ static const struct mib_array_node_entry icmp_nodes[] = {
|
||||
{25, &icmp_scalar.node}, {26, &icmp_scalar.node}
|
||||
};
|
||||
static const struct mib_array_node icmp = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(icmp_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(icmp_nodes),
|
||||
icmp_nodes
|
||||
};
|
||||
|
||||
/** index root node for ipNetToMediaTable */
|
||||
static struct mib_list_rootnode ipntomtree_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry ipntomentry_nodes[] = {
|
||||
{1, &ipntomtree_root.node}, {2, &ipntomtree_root.node},
|
||||
{3, &ipntomtree_root.node}, {4, &ipntomtree_root.node}
|
||||
{1, &ipntomtree_root.scalar.node}, {2, &ipntomtree_root.scalar.node},
|
||||
{3, &ipntomtree_root.scalar.node}, {4, &ipntomtree_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node ipntomentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(ipntomentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(ipntomentry_nodes),
|
||||
ipntomentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry ipntomtable_node = {1, &ipntomentry.node};
|
||||
static struct mib_ram_array_node ipntomtable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&ipntomtable_node
|
||||
};
|
||||
|
||||
/** index root node for ipRouteTable */
|
||||
static struct mib_list_rootnode iprtetree_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry iprteentry_nodes[] = {
|
||||
{1, &iprtetree_root.node}, {2, &iprtetree_root.node},
|
||||
{3, &iprtetree_root.node}, {4, &iprtetree_root.node},
|
||||
{5, &iprtetree_root.node}, {6, &iprtetree_root.node},
|
||||
{7, &iprtetree_root.node}, {8, &iprtetree_root.node},
|
||||
{9, &iprtetree_root.node}, {10, &iprtetree_root.node},
|
||||
{11, &iprtetree_root.node}, {12, &iprtetree_root.node},
|
||||
{13, &iprtetree_root.node}
|
||||
{1, &iprtetree_root.scalar.node}, {2, &iprtetree_root.scalar.node},
|
||||
{3, &iprtetree_root.scalar.node}, {4, &iprtetree_root.scalar.node},
|
||||
{5, &iprtetree_root.scalar.node}, {6, &iprtetree_root.scalar.node},
|
||||
{7, &iprtetree_root.scalar.node}, {8, &iprtetree_root.scalar.node},
|
||||
{9, &iprtetree_root.scalar.node}, {10, &iprtetree_root.scalar.node},
|
||||
{11, &iprtetree_root.scalar.node}, {12, &iprtetree_root.scalar.node},
|
||||
{13, &iprtetree_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node iprteentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(iprteentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(iprteentry_nodes),
|
||||
iprteentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry iprtetable_node = {1, &iprteentry.node};
|
||||
static struct mib_ram_array_node iprtetable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&iprtetable_node
|
||||
};
|
||||
|
||||
/** index root node for ipAddrTable */
|
||||
static struct mib_list_rootnode ipaddrtree_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry ipaddrentry_nodes[] = {
|
||||
{1, &ipaddrtree_root.node},
|
||||
{2, &ipaddrtree_root.node},
|
||||
{3, &ipaddrtree_root.node},
|
||||
{4, &ipaddrtree_root.node},
|
||||
{5, &ipaddrtree_root.node}
|
||||
{1, &ipaddrtree_root.scalar.node},
|
||||
{2, &ipaddrtree_root.scalar.node},
|
||||
{3, &ipaddrtree_root.scalar.node},
|
||||
{4, &ipaddrtree_root.scalar.node},
|
||||
{5, &ipaddrtree_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node ipaddrentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(ipaddrentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(ipaddrentry_nodes),
|
||||
ipaddrentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry ipaddrtable_node = {1, &ipaddrentry.node};
|
||||
static struct mib_ram_array_node ipaddrtable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&ipaddrtable_node
|
||||
};
|
||||
|
||||
/* ip .1.3.6.1.2.1.4 */
|
||||
static const struct mib_scalar_node ip_scalar = {
|
||||
{
|
||||
&ip_get_object_def,
|
||||
&ip_get_value,
|
||||
&ip_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC, },
|
||||
&ip_get_object_def,
|
||||
&ip_get_value,
|
||||
&ip_set_test,
|
||||
&noleafs_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry ip_nodes[] = {
|
||||
{1, &ip_scalar.node}, {2, &ip_scalar.node},
|
||||
@ -526,78 +422,54 @@ static const struct mib_array_node_entry ip_nodes[] = {
|
||||
{23, &ip_scalar.node}
|
||||
};
|
||||
static const struct mib_array_node mib2_ip = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(ip_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(ip_nodes),
|
||||
ip_nodes
|
||||
};
|
||||
|
||||
/** index root node for atTable */
|
||||
static struct mib_list_rootnode arptree_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry atentry_nodes[] = {
|
||||
{1, &arptree_root.node},
|
||||
{2, &arptree_root.node},
|
||||
{3, &arptree_root.node}
|
||||
{1, &arptree_root.scalar.node},
|
||||
{2, &arptree_root.scalar.node},
|
||||
{3, &arptree_root.scalar.node}
|
||||
};
|
||||
static const struct mib_array_node atentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(atentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(atentry_nodes),
|
||||
atentry_nodes
|
||||
};
|
||||
|
||||
static const struct mib_array_node_entry attable_node = {1, &atentry.node};
|
||||
static struct mib_array_node attable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
1
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
1,
|
||||
&attable_node
|
||||
};
|
||||
|
||||
/* at .1.3.6.1.2.1.3 */
|
||||
static struct mib_array_node_entry mib2_at_node = {1, &attable.node};
|
||||
static struct mib_ram_array_node at = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&mib2_at_node
|
||||
};
|
||||
|
||||
/** index root node for ifTable */
|
||||
static struct mib_list_rootnode iflist_root = {
|
||||
{
|
||||
{ MIB_NODE_LR },
|
||||
&ifentry_get_object_def,
|
||||
&ifentry_get_value,
|
||||
#if SNMP_SAFE_REQUESTS
|
||||
@ -607,74 +479,51 @@ static struct mib_list_rootnode iflist_root = {
|
||||
&ifentry_set_test,
|
||||
&ifentry_set_value,
|
||||
#endif /* SNMP_SAFE_REQUESTS */
|
||||
MIB_NODE_LR,
|
||||
0
|
||||
},
|
||||
NULL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
static const struct mib_array_node_entry ifentry_nodes[] = {
|
||||
{1, &iflist_root.node}, {2, &iflist_root.node},
|
||||
{3, &iflist_root.node}, {4, &iflist_root.node},
|
||||
{5, &iflist_root.node}, {6, &iflist_root.node},
|
||||
{7, &iflist_root.node}, {8, &iflist_root.node},
|
||||
{9, &iflist_root.node}, {10, &iflist_root.node},
|
||||
{11, &iflist_root.node}, {12, &iflist_root.node},
|
||||
{13, &iflist_root.node}, {14, &iflist_root.node},
|
||||
{15, &iflist_root.node}, {16, &iflist_root.node},
|
||||
{17, &iflist_root.node}, {18, &iflist_root.node},
|
||||
{19, &iflist_root.node}, {20, &iflist_root.node},
|
||||
{21, &iflist_root.node}, {22, &iflist_root.node}
|
||||
{1, &iflist_root.scalar.node}, {2, &iflist_root.scalar.node},
|
||||
{3, &iflist_root.scalar.node}, {4, &iflist_root.scalar.node},
|
||||
{5, &iflist_root.scalar.node}, {6, &iflist_root.scalar.node},
|
||||
{7, &iflist_root.scalar.node}, {8, &iflist_root.scalar.node},
|
||||
{9, &iflist_root.scalar.node}, {10, &iflist_root.scalar.node},
|
||||
{11, &iflist_root.scalar.node}, {12, &iflist_root.scalar.node},
|
||||
{13, &iflist_root.scalar.node}, {14, &iflist_root.scalar.node},
|
||||
{15, &iflist_root.scalar.node}, {16, &iflist_root.scalar.node},
|
||||
{17, &iflist_root.scalar.node}, {18, &iflist_root.scalar.node},
|
||||
{19, &iflist_root.scalar.node}, {20, &iflist_root.scalar.node},
|
||||
{21, &iflist_root.scalar.node}, {22, &iflist_root.scalar.node}
|
||||
};
|
||||
static struct mib_array_node ifentry = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(ifentry_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(ifentry_nodes),
|
||||
ifentry_nodes
|
||||
};
|
||||
|
||||
static struct mib_array_node_entry iftable_node = {1, &ifentry.node};
|
||||
static struct mib_ram_array_node iftable = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_RA,
|
||||
0
|
||||
},
|
||||
{ MIB_NODE_RA },
|
||||
0,
|
||||
&iftable_node
|
||||
};
|
||||
|
||||
/* interfaces .1.3.6.1.2.1.2 */
|
||||
static const struct mib_scalar_node interfaces_scalar = {
|
||||
{
|
||||
&interfaces_get_object_def,
|
||||
&interfaces_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&interfaces_get_object_def,
|
||||
&interfaces_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry interfaces_nodes[] = {
|
||||
{1, &interfaces_scalar.node}, {2, &iftable.node}
|
||||
};
|
||||
static const struct mib_array_node interfaces = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(interfaces_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(interfaces_nodes),
|
||||
interfaces_nodes
|
||||
};
|
||||
|
||||
@ -682,14 +531,11 @@ static const struct mib_array_node interfaces = {
|
||||
/* 0 1 2 3 4 5 6 */
|
||||
/* system .1.3.6.1.2.1.1 */
|
||||
static const struct mib_scalar_node system_scalar = {
|
||||
{
|
||||
&system_get_object_def,
|
||||
&system_get_value,
|
||||
&system_set_test,
|
||||
&system_set_value,
|
||||
MIB_NODE_SC,
|
||||
0
|
||||
}
|
||||
{ MIB_NODE_SC },
|
||||
&system_get_object_def,
|
||||
&system_get_value,
|
||||
&system_set_test,
|
||||
&system_set_value,
|
||||
};
|
||||
static const struct mib_array_node_entry system_nodes[] = {
|
||||
{1, &system_scalar.node}, {2, &system_scalar.node},
|
||||
@ -699,14 +545,8 @@ static const struct mib_array_node_entry system_nodes[] = {
|
||||
};
|
||||
/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
|
||||
static const struct mib_array_node sys_tem = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(system_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(system_nodes),
|
||||
system_nodes
|
||||
};
|
||||
|
||||
@ -725,28 +565,16 @@ static const struct mib_array_node_entry mib2_nodes[] = {
|
||||
};
|
||||
|
||||
static const struct mib_array_node mib2 = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(mib2_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(mib2_nodes),
|
||||
mib2_nodes
|
||||
};
|
||||
|
||||
/* mgmt .1.3.6.1.2 */
|
||||
const struct mib_array_node_entry mgmt_nodes[] = { {1, &mib2.node} };
|
||||
const struct mib_array_node mgmt = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(mgmt_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(mgmt_nodes),
|
||||
mgmt_nodes
|
||||
};
|
||||
|
||||
@ -760,14 +588,8 @@ const struct mib_array_node_entry internet_nodes[] = {
|
||||
#endif /* SNMP_PRIVATE_MIB */
|
||||
};
|
||||
const struct mib_array_node internet = {
|
||||
{
|
||||
&noleafs_get_object_def,
|
||||
&noleafs_get_value,
|
||||
&noleafs_set_test,
|
||||
&noleafs_set_value,
|
||||
MIB_NODE_AR,
|
||||
LWIP_ARRAYSIZE(internet_nodes)
|
||||
},
|
||||
{ MIB_NODE_AR },
|
||||
LWIP_ARRAYSIZE(internet_nodes),
|
||||
internet_nodes
|
||||
};
|
||||
|
||||
@ -937,7 +759,7 @@ void mib2_netif_added(struct netif *ni)
|
||||
|
||||
snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
|
||||
/* enable getnext traversal on filled table */
|
||||
iftable.node.maxlength = 1;
|
||||
iftable.maxlength = 1;
|
||||
}
|
||||
|
||||
void mib2_netif_removed(struct netif *ni)
|
||||
@ -946,7 +768,7 @@ void mib2_netif_removed(struct netif *ni)
|
||||
|
||||
snmp_mib_node_delete(&iflist_root, iflist_root.tail);
|
||||
/* disable getnext traversal on empty table */
|
||||
if(iflist_root.count == 0) iftable.node.maxlength = 0;
|
||||
if(iflist_root.count == 0) iftable.maxlength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -983,23 +805,23 @@ void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip)
|
||||
if (at_node->nptr == NULL)
|
||||
{
|
||||
at_rn = snmp_mib_lrn_alloc();
|
||||
at_node->nptr = &at_rn->node;
|
||||
at_node->nptr = &at_rn->scalar.node;
|
||||
if (at_rn != NULL)
|
||||
{
|
||||
if (level == 3)
|
||||
{
|
||||
if (tree == 0)
|
||||
{
|
||||
at_rn->node.get_object_def = atentry_get_object_def;
|
||||
at_rn->node.get_value = atentry_get_value;
|
||||
at_rn->scalar.get_object_def = atentry_get_object_def;
|
||||
at_rn->scalar.get_value = atentry_get_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
at_rn->node.get_object_def = ip_ntomentry_get_object_def;
|
||||
at_rn->node.get_value = ip_ntomentry_get_value;
|
||||
at_rn->scalar.get_object_def = ip_ntomentry_get_object_def;
|
||||
at_rn->scalar.get_value = ip_ntomentry_get_value;
|
||||
}
|
||||
at_rn->node.set_test = noleafs_set_test;
|
||||
at_rn->node.set_value = noleafs_set_value;
|
||||
at_rn->scalar.set_test = noleafs_set_test;
|
||||
at_rn->scalar.set_value = noleafs_set_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1017,8 +839,8 @@ void mib2_add_arp_entry(struct netif *ni, ip4_addr_t *ip)
|
||||
}
|
||||
}
|
||||
/* enable getnext traversal on filled tables */
|
||||
at.node.maxlength = 1;
|
||||
ipntomtable.node.maxlength = 1;
|
||||
at.maxlength = 1;
|
||||
ipntomtable.maxlength = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1089,8 +911,8 @@ void mib2_remove_arp_entry(struct netif *ni, ip4_addr_t *ip)
|
||||
}
|
||||
}
|
||||
/* disable getnext traversal on empty tables */
|
||||
if(arptree_root.count == 0) at.node.maxlength = 0;
|
||||
if(ipntomtree_root.count == 0) ipntomtable.node.maxlength = 0;
|
||||
if(arptree_root.count == 0) at.maxlength = 0;
|
||||
if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1118,15 +940,15 @@ void mib2_add_ip4(struct netif *ni)
|
||||
if (ipa_node->nptr == NULL)
|
||||
{
|
||||
ipa_rn = snmp_mib_lrn_alloc();
|
||||
ipa_node->nptr = &ipa_rn->node;
|
||||
ipa_node->nptr = &ipa_rn->scalar.node;
|
||||
if (ipa_rn != NULL)
|
||||
{
|
||||
if (level == 2)
|
||||
{
|
||||
ipa_rn->node.get_object_def = ip_addrentry_get_object_def;
|
||||
ipa_rn->node.get_value = ip_addrentry_get_value;
|
||||
ipa_rn->node.set_test = noleafs_set_test;
|
||||
ipa_rn->node.set_value = noleafs_set_value;
|
||||
ipa_rn->scalar.get_object_def = ip_addrentry_get_object_def;
|
||||
ipa_rn->scalar.get_value = ip_addrentry_get_value;
|
||||
ipa_rn->scalar.set_test = noleafs_set_test;
|
||||
ipa_rn->scalar.set_value = noleafs_set_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1144,7 +966,7 @@ void mib2_add_ip4(struct netif *ni)
|
||||
level++;
|
||||
}
|
||||
/* enable getnext traversal on filled table */
|
||||
ipaddrtable.node.maxlength = 1;
|
||||
ipaddrtable.maxlength = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1205,7 +1027,7 @@ void mib2_remove_ip4(struct netif *ni)
|
||||
}
|
||||
}
|
||||
/* disable getnext traversal on empty table */
|
||||
if (ipaddrtree_root.count == 0) ipaddrtable.node.maxlength = 0;
|
||||
if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1257,15 +1079,15 @@ void mib2_add_route_ip4(u8_t dflt, struct netif *ni)
|
||||
if (iprte_node->nptr == NULL)
|
||||
{
|
||||
iprte_rn = snmp_mib_lrn_alloc();
|
||||
iprte_node->nptr = &iprte_rn->node;
|
||||
iprte_node->nptr = &iprte_rn->scalar.node;
|
||||
if (iprte_rn != NULL)
|
||||
{
|
||||
if (level == 2)
|
||||
{
|
||||
iprte_rn->node.get_object_def = ip_rteentry_get_object_def;
|
||||
iprte_rn->node.get_value = ip_rteentry_get_value;
|
||||
iprte_rn->node.set_test = noleafs_set_test;
|
||||
iprte_rn->node.set_value = noleafs_set_value;
|
||||
iprte_rn->scalar.get_object_def = ip_rteentry_get_object_def;
|
||||
iprte_rn->scalar.get_value = ip_rteentry_get_value;
|
||||
iprte_rn->scalar.set_test = noleafs_set_test;
|
||||
iprte_rn->scalar.set_value = noleafs_set_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1284,7 +1106,7 @@ void mib2_add_route_ip4(u8_t dflt, struct netif *ni)
|
||||
}
|
||||
}
|
||||
/* enable getnext traversal on filled table */
|
||||
iprtetable.node.maxlength = 1;
|
||||
iprtetable.maxlength = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1368,7 +1190,7 @@ void mib2_remove_route_ip4(u8_t dflt, struct netif *ni)
|
||||
}
|
||||
}
|
||||
/* disable getnext traversal on empty table */
|
||||
if (iprtetree_root.count == 0) iprtetable.node.maxlength = 0;
|
||||
if (iprtetree_root.count == 0) iprtetable.maxlength = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1401,15 +1223,15 @@ void mib2_udp_bind(struct udp_pcb *pcb)
|
||||
if (udp_node->nptr == NULL)
|
||||
{
|
||||
udp_rn = snmp_mib_lrn_alloc();
|
||||
udp_node->nptr = &udp_rn->node;
|
||||
udp_node->nptr = &udp_rn->scalar.node;
|
||||
if (udp_rn != NULL)
|
||||
{
|
||||
if (level == 3)
|
||||
{
|
||||
udp_rn->node.get_object_def = udpentry_get_object_def;
|
||||
udp_rn->node.get_value = udpentry_get_value;
|
||||
udp_rn->node.set_test = noleafs_set_test;
|
||||
udp_rn->node.set_value = noleafs_set_value;
|
||||
udp_rn->scalar.get_object_def = udpentry_get_object_def;
|
||||
udp_rn->scalar.get_value = udpentry_get_value;
|
||||
udp_rn->scalar.set_test = noleafs_set_test;
|
||||
udp_rn->scalar.set_value = noleafs_set_value;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1425,7 +1247,7 @@ void mib2_udp_bind(struct udp_pcb *pcb)
|
||||
}
|
||||
}
|
||||
}
|
||||
udptable.node.maxlength = 1;
|
||||
udptable.maxlength = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1509,7 +1331,7 @@ void mib2_udp_unbind(struct udp_pcb *pcb)
|
||||
}
|
||||
}
|
||||
/* disable getnext traversal on empty table */
|
||||
if (udp_root.count == 0) udptable.node.maxlength = 0;
|
||||
if (udp_root.count == 0) udptable.maxlength = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,12 +183,11 @@ snmp_mib_lrn_alloc(void)
|
||||
lrn = (struct mib_list_rootnode*)memp_malloc(MEMP_SNMP_ROOTNODE);
|
||||
if (lrn != NULL)
|
||||
{
|
||||
lrn->node.get_object_def = noleafs_get_object_def;
|
||||
lrn->node.get_value = noleafs_get_value;
|
||||
lrn->node.set_test = noleafs_set_test;
|
||||
lrn->node.set_value = noleafs_set_value;
|
||||
lrn->node.node_type = MIB_NODE_LR;
|
||||
lrn->node.maxlength = 0;
|
||||
lrn->scalar.get_object_def = noleafs_get_object_def;
|
||||
lrn->scalar.get_value = noleafs_get_value;
|
||||
lrn->scalar.set_test = noleafs_set_test;
|
||||
lrn->scalar.set_value = noleafs_set_value;
|
||||
lrn->scalar.node.node_type = MIB_NODE_LR;
|
||||
lrn->head = NULL;
|
||||
lrn->tail = NULL;
|
||||
lrn->count = 0;
|
||||
@ -469,11 +468,11 @@ snmp_search_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
/* array node (internal ROM or RAM, fixed length) */
|
||||
an = (const struct mib_array_node *)node;
|
||||
i = 0;
|
||||
while ((i < an->node.maxlength) && (an->entries[i].objid != *ident))
|
||||
while ((i < an->maxlength) && (an->entries[i].objid != *ident))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (i < an->node.maxlength)
|
||||
if (i < an->maxlength)
|
||||
{
|
||||
/* found it, if available proceed to child, otherwise inspect leaf */
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->entries[i].objid,*ident));
|
||||
@ -530,7 +529,7 @@ snmp_search_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
{
|
||||
np->ident_len = ident_len;
|
||||
np->ident = ident;
|
||||
return &lrn->node;
|
||||
return &lrn->scalar.node;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -657,7 +656,7 @@ empty_table(const struct mib_node *node)
|
||||
{
|
||||
const struct mib_array_node *an;
|
||||
an = (const struct mib_array_node *)node;
|
||||
if ((an->node.maxlength == 0) || (an->entries == NULL))
|
||||
if ((an->maxlength == 0) || (an->entries == NULL))
|
||||
{
|
||||
empty = 1;
|
||||
}
|
||||
@ -700,11 +699,11 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
if (ident_len > 0)
|
||||
{
|
||||
i = 0;
|
||||
while ((i < an->node.maxlength) && (an->entries[i].objid < *ident))
|
||||
while ((i < an->maxlength) && (an->entries[i].objid < *ident))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
if (i < an->node.maxlength)
|
||||
if (i < an->maxlength)
|
||||
{
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->entries[i].objid,*ident));
|
||||
/* add identifier to oidret */
|
||||
@ -719,7 +718,7 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
{
|
||||
return &an->node;
|
||||
}
|
||||
else if ((i + 1) < an->node.maxlength)
|
||||
else if ((i + 1) < an->maxlength)
|
||||
{
|
||||
/* an->entries[i].objid == *ident */
|
||||
(oidret->len)--;
|
||||
@ -742,11 +741,11 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
/* non-leaf, store right child ptr and id */
|
||||
LWIP_ASSERT("i < 0xff", i < 0xff);
|
||||
j = i + 1;
|
||||
while ((j < an->node.maxlength) && (empty_table(an->entries[j].nptr)))
|
||||
while ((j < an->maxlength) && (empty_table(an->entries[j].nptr)))
|
||||
{
|
||||
j++;
|
||||
}
|
||||
if (j < an->node.maxlength)
|
||||
if (j < an->maxlength)
|
||||
{
|
||||
struct nse cur_node;
|
||||
cur_node.r_ptr = an->entries[j].nptr;
|
||||
@ -783,11 +782,11 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
u16_t j;
|
||||
/* ident_len == 0, complete with leftmost '.thing' */
|
||||
j = 0;
|
||||
while ((j < an->node.maxlength) && empty_table(an->entries[j].nptr))
|
||||
while ((j < an->maxlength) && empty_table(an->entries[j].nptr))
|
||||
{
|
||||
j++;
|
||||
}
|
||||
if (j < an->node.maxlength)
|
||||
if (j < an->maxlength)
|
||||
{
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->entries[j].objid==%"S32_F"\n",an->entries[j].objid));
|
||||
oidret->id[oidret->len] = an->entries[j].objid;
|
||||
@ -835,7 +834,7 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
/* leaf node */
|
||||
if (ln->objid > *ident)
|
||||
{
|
||||
return &lrn->node;
|
||||
return &lrn->scalar.node;
|
||||
}
|
||||
else if (ln->next != NULL)
|
||||
{
|
||||
@ -843,7 +842,7 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
(oidret->len)--;
|
||||
oidret->id[oidret->len] = ln->next->objid;
|
||||
(oidret->len)++;
|
||||
return &lrn->node;
|
||||
return &lrn->scalar.node;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -913,7 +912,7 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
|
||||
{
|
||||
/* leaf node */
|
||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("jn->nptr == NULL\n"));
|
||||
return &lrn->node;
|
||||
return &lrn->scalar.node;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -344,7 +344,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
/** test object identifier for .iso.org.dod.internet prefix */
|
||||
if (snmp_iso_prefix_tst(msg_ps->vb_ptr->ident_len, msg_ps->vb_ptr->ident))
|
||||
{
|
||||
mn = snmp_search_tree((const struct mib_node*)&internet, msg_ps->vb_ptr->ident_len - 4,
|
||||
mn = snmp_search_tree(&internet.node, msg_ps->vb_ptr->ident_len - 4,
|
||||
msg_ps->vb_ptr->ident + 4, &np);
|
||||
if (mn != NULL)
|
||||
{
|
||||
@ -360,23 +360,20 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident);
|
||||
}
|
||||
else
|
||||
else if((mn->node_type == MIB_NODE_SC) || (mn->node_type == MIB_NODE_LR))
|
||||
{
|
||||
/* internal object */
|
||||
struct obj_def object_def;
|
||||
const struct mib_scalar_node *msn = (const struct mib_scalar_node*)mn;
|
||||
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF;
|
||||
mn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
if (object_def.instance != MIB_OBJECT_NONE)
|
||||
{
|
||||
mn = mn;
|
||||
}
|
||||
else
|
||||
msn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
if (object_def.instance == MIB_OBJECT_NONE)
|
||||
{
|
||||
/* search failed, object id points to unknown object (nosuchname) */
|
||||
mn = NULL;
|
||||
}
|
||||
if (mn != NULL)
|
||||
else
|
||||
{
|
||||
struct snmp_varbind *vb;
|
||||
|
||||
@ -400,7 +397,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
vb->value = memp_malloc(MEMP_SNMP_VALUE);
|
||||
if (vb->value != NULL)
|
||||
{
|
||||
vb->value_len = mn->get_value(&object_def, vb->value);
|
||||
vb->value_len = msn->get_value(&object_def, vb->value);
|
||||
LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE);
|
||||
if(vb->value_len == 0)
|
||||
{
|
||||
@ -553,20 +550,21 @@ snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
en->get_object_def_q(en->addr_inf, request_id, 1, &oid.id[oid.len - 1]);
|
||||
}
|
||||
else
|
||||
else if((mn->node_type == MIB_NODE_SC) || (mn->node_type == MIB_NODE_LR))
|
||||
{
|
||||
/* internal object */
|
||||
struct obj_def object_def;
|
||||
struct snmp_varbind *vb;
|
||||
const struct mib_scalar_node *msn = (const struct mib_scalar_node*)mn;
|
||||
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF;
|
||||
mn->get_object_def(1, &oid.id[oid.len - 1], &object_def);
|
||||
msn->get_object_def(1, &oid.id[oid.len - 1], &object_def);
|
||||
|
||||
vb = snmp_varbind_alloc(&oid, object_def.asn_type, SNMP_MAX_VALUE_SIZE);
|
||||
if (vb != NULL)
|
||||
{
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE;
|
||||
vb->value_len = mn->get_value(&object_def, vb->value);
|
||||
vb->value_len = msn->get_value(&object_def, vb->value);
|
||||
snmp_varbind_tail_add(&msg_ps->outvb, vb);
|
||||
msg_ps->state = SNMP_MSG_SEARCH_OBJ;
|
||||
msg_ps->vb_idx += 1;
|
||||
@ -577,6 +575,10 @@ snmp_msg_getnext_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
snmp_error_response(msg_ps,SNMP_ES_TOOBIG);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mn = NULL;
|
||||
}
|
||||
}
|
||||
if (mn == NULL)
|
||||
{
|
||||
@ -727,30 +729,27 @@ snmp_msg_set_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident);
|
||||
}
|
||||
else
|
||||
else if((mn->node_type == MIB_NODE_SC) || (mn->node_type == MIB_NODE_LR))
|
||||
{
|
||||
/* internal object */
|
||||
struct obj_def object_def;
|
||||
const struct mib_scalar_node *msn = (const struct mib_scalar_node*)mn;
|
||||
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF;
|
||||
mn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
if (object_def.instance != MIB_OBJECT_NONE)
|
||||
{
|
||||
mn = mn;
|
||||
}
|
||||
else
|
||||
msn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
if (object_def.instance == MIB_OBJECT_NONE)
|
||||
{
|
||||
/* search failed, object id points to unknown object (nosuchname) */
|
||||
mn = NULL;
|
||||
}
|
||||
if (mn != NULL)
|
||||
else
|
||||
{
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_SET_TEST;
|
||||
|
||||
if (object_def.access & MIB_ACCESS_WRITE)
|
||||
{
|
||||
if ((object_def.asn_type == msg_ps->vb_ptr->value_type) &&
|
||||
(mn->set_test(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0))
|
||||
(msn->set_test(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value) != 0))
|
||||
{
|
||||
msg_ps->state = SNMP_MSG_SEARCH_OBJ;
|
||||
msg_ps->vb_idx += 1;
|
||||
@ -768,6 +767,10 @@ snmp_msg_set_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mn = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -822,15 +825,16 @@ snmp_msg_set_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
en->get_object_def_q(en->addr_inf, request_id, np.ident_len, np.ident);
|
||||
}
|
||||
else
|
||||
else if((mn->node_type == MIB_NODE_SC) || (mn->node_type == MIB_NODE_LR))
|
||||
{
|
||||
/* internal object */
|
||||
struct obj_def object_def;
|
||||
const struct mib_scalar_node *msn = (const struct mib_scalar_node*)mn;
|
||||
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_OBJDEF_S;
|
||||
mn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
msn->get_object_def(np.ident_len, np.ident, &object_def);
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_SET_VALUE;
|
||||
mn->set_value(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value);
|
||||
msn->set_value(&object_def,msg_ps->vb_ptr->value_len,msg_ps->vb_ptr->value);
|
||||
msg_ps->vb_idx += 1;
|
||||
}
|
||||
}
|
||||
|
@ -103,6 +103,15 @@ struct snmp_name_ptr
|
||||
/** node "base class" layout, the mandatory fields for a node */
|
||||
struct mib_node
|
||||
{
|
||||
/** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
|
||||
u8_t node_type;
|
||||
};
|
||||
|
||||
/** derived node for scalars .0 index */
|
||||
struct mib_scalar_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct mib_node node;
|
||||
/** returns struct obj_def for the given object identifier */
|
||||
void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
|
||||
/** returns object value for the given object identifier */
|
||||
@ -111,17 +120,6 @@ struct mib_node
|
||||
u8_t (*set_test)(struct obj_def *od, u16_t len, void *value);
|
||||
/** sets object value, only to be called when set_test() */
|
||||
void (*set_value)(struct obj_def *od, u16_t len, void *value);
|
||||
/** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */
|
||||
u8_t node_type;
|
||||
/* array or max list length */
|
||||
u16_t maxlength;
|
||||
};
|
||||
|
||||
/** derived node for scalars .0 index */
|
||||
struct mib_scalar_node
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct mib_node node;
|
||||
};
|
||||
|
||||
/** describes an array entry (objid/node pair) */
|
||||
@ -139,7 +137,8 @@ struct mib_array_node
|
||||
struct mib_node node;
|
||||
|
||||
/* additional struct members */
|
||||
const struct mib_array_node_entry * const entries;
|
||||
u16_t maxlength;
|
||||
const struct mib_array_node_entry *entries;
|
||||
};
|
||||
|
||||
/** derived node, points to a fixed size mem_malloced array
|
||||
@ -149,7 +148,8 @@ struct mib_ram_array_node
|
||||
/* inherited "base class" members */
|
||||
struct mib_node node;
|
||||
|
||||
/* aditional struct members */
|
||||
/* additional struct members */
|
||||
u16_t maxlength;
|
||||
struct mib_array_node_entry *entries;
|
||||
};
|
||||
|
||||
@ -166,7 +166,7 @@ struct mib_list_node
|
||||
struct mib_list_rootnode
|
||||
{
|
||||
/* inherited "base class" members */
|
||||
struct mib_node node;
|
||||
struct mib_scalar_node scalar;
|
||||
|
||||
/* additional struct members */
|
||||
struct mib_list_node *head;
|
||||
|
Loading…
x
Reference in New Issue
Block a user