mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-23 06:35:57 +00:00
First getnext succes, values are returned insead of NULLs, empty tables are skipped. Limitation: a single varbind per request, so 'snmptable' will fail.
This commit is contained in:
parent
56c5fdbeaf
commit
41ff80e5d3
|
@ -4,8 +4,6 @@
|
||||||
*
|
*
|
||||||
* @note the object identifiers for this MIB-2 and private MIB tree
|
* @note the object identifiers for this MIB-2 and private MIB tree
|
||||||
* must be kept in sorted ascending order. This to ensure correct getnext operation.
|
* must be kept in sorted ascending order. This to ensure correct getnext operation.
|
||||||
*
|
|
||||||
* @todo optimize htonl, ntohl.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,17 +103,35 @@ static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
|
||||||
|
|
||||||
|
|
||||||
/* snmp .1.3.6.1.2.1.11 */
|
/* snmp .1.3.6.1.2.1.11 */
|
||||||
|
const mib_scalar_node snmp_scalar = {
|
||||||
|
&snmp_get_object_def,
|
||||||
|
&snmp_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
const s32_t snmp_ids[28] = {
|
const s32_t snmp_ids[28] = {
|
||||||
1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
||||||
17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
|
17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
|
||||||
};
|
};
|
||||||
struct mib_node* const snmp_nodes[28] = {
|
struct mib_node* const snmp_nodes[28] = {
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar,
|
||||||
|
(struct mib_node* const)&snmp_scalar, (struct mib_node* const)&snmp_scalar
|
||||||
};
|
};
|
||||||
const struct mib_array_node snmp = {
|
const struct mib_array_node snmp = {
|
||||||
&snmp_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&snmp_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
28,
|
28,
|
||||||
snmp_ids,
|
snmp_ids,
|
||||||
|
@ -150,24 +166,32 @@ const struct mib_array_node udpentry = {
|
||||||
udpentry_nodes
|
udpentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t udptable_id = 1;
|
s32_t udptable_id = 1;
|
||||||
struct mib_node* const udptable_node = (struct mib_node* const)&udpentry;
|
struct mib_node* udptable_node = (struct mib_node* const)&udpentry;
|
||||||
const struct mib_array_node udptable = {
|
struct mib_ram_array_node udptable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&udptable_id,
|
&udptable_id,
|
||||||
&udptable_node
|
&udptable_node
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
|
const mib_scalar_node udp_scalar = {
|
||||||
struct mib_node* const udp_nodes[5] = {
|
|
||||||
NULL, NULL, NULL, NULL, (struct mib_node* const)&udptable
|
|
||||||
};
|
|
||||||
const struct mib_array_node udp = {
|
|
||||||
&udp_get_object_def,
|
&udp_get_object_def,
|
||||||
&udp_get_value,
|
&udp_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
|
||||||
|
struct mib_node* const udp_nodes[5] = {
|
||||||
|
(struct mib_node* const)&udp_scalar, (struct mib_node* const)&udp_scalar,
|
||||||
|
(struct mib_node* const)&udp_scalar, (struct mib_node* const)&udp_scalar,
|
||||||
|
(struct mib_node* const)&udptable
|
||||||
|
};
|
||||||
|
const struct mib_array_node udp = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
5,
|
5,
|
||||||
udp_ids,
|
udp_ids,
|
||||||
|
@ -189,36 +213,52 @@ struct mib_list_rootnode tcpconntree_root = {
|
||||||
};
|
};
|
||||||
const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
|
const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
|
||||||
struct mib_node* const tcpconnentry_nodes[5] = {
|
struct mib_node* const tcpconnentry_nodes[5] = {
|
||||||
NULL, NULL, NULL, NULL, NULL
|
(struct mib_node* const)&tcpconntree_root, (struct mib_node* const)&tcpconntree_root,
|
||||||
|
(struct mib_node* const)&tcpconntree_root, (struct mib_node* const)&tcpconntree_root,
|
||||||
|
(struct mib_node* const)&tcpconntree_root
|
||||||
};
|
};
|
||||||
const struct mib_array_node tcpconnentry = {
|
const struct mib_array_node tcpconnentry = {
|
||||||
&tcpconnentry_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&tcpconnentry_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
5,
|
5,
|
||||||
tcpconnentry_ids,
|
tcpconnentry_ids,
|
||||||
tcpconnentry_nodes
|
tcpconnentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t tcpconntable_id = 1;
|
s32_t tcpconntable_id = 1;
|
||||||
struct mib_node* const tcpconntable_node = (struct mib_node* const)&tcpconnentry;
|
struct mib_node* tcpconntable_node = (struct mib_node* const)&tcpconnentry;
|
||||||
const struct mib_array_node tcpconntable = {
|
struct mib_ram_array_node tcpconntable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
/** @todo update maxlength when inserting / deleting from table
|
||||||
|
0 when table is empty, 1 when more than one entry */
|
||||||
|
0,
|
||||||
&tcpconntable_id,
|
&tcpconntable_id,
|
||||||
&tcpconntable_node
|
&tcpconntable_node
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
const mib_scalar_node tcp_scalar = {
|
||||||
struct mib_node* const tcp_nodes[15] = {
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
(struct mib_node* const)&tcpconntable, NULL, NULL
|
|
||||||
};
|
|
||||||
const struct mib_array_node tcp = {
|
|
||||||
&tcp_get_object_def,
|
&tcp_get_object_def,
|
||||||
&tcp_get_value,
|
&tcp_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||||
|
struct mib_node* const tcp_nodes[15] = {
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcpconntable, (struct mib_node* const)&tcp_scalar,
|
||||||
|
(struct mib_node* const)&tcp_scalar
|
||||||
|
};
|
||||||
|
const struct mib_array_node tcp = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
15,
|
15,
|
||||||
tcp_ids,
|
tcp_ids,
|
||||||
|
@ -227,14 +267,31 @@ const struct mib_array_node tcp = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* icmp .1.3.6.1.2.1.5 */
|
/* icmp .1.3.6.1.2.1.5 */
|
||||||
const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
|
const mib_scalar_node icmp_scalar = {
|
||||||
struct mib_node* const icmp_nodes[26] = {
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
|
|
||||||
};
|
|
||||||
const struct mib_array_node icmp = {
|
|
||||||
&icmp_get_object_def,
|
&icmp_get_object_def,
|
||||||
&icmp_get_value,
|
&icmp_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
|
||||||
|
struct mib_node* const icmp_nodes[26] = {
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar,
|
||||||
|
(struct mib_node* const)&icmp_scalar, (struct mib_node* const)&icmp_scalar
|
||||||
|
};
|
||||||
|
const struct mib_array_node icmp = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
26,
|
26,
|
||||||
icmp_ids,
|
icmp_ids,
|
||||||
|
@ -265,13 +322,13 @@ const struct mib_array_node ipntomentry = {
|
||||||
ipntomentry_nodes
|
ipntomentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t ipntomtable_id = 1;
|
s32_t ipntomtable_id = 1;
|
||||||
struct mib_node* const ipntomtable_node = (struct mib_node* const)&ipntomentry;
|
struct mib_node* ipntomtable_node = (struct mib_node* const)&ipntomentry;
|
||||||
const struct mib_array_node ipntomtable = {
|
struct mib_ram_array_node ipntomtable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&ipntomtable_id,
|
&ipntomtable_id,
|
||||||
&ipntomtable_node
|
&ipntomtable_node
|
||||||
};
|
};
|
||||||
|
@ -305,13 +362,13 @@ const struct mib_array_node iprteentry = {
|
||||||
iprteentry_nodes
|
iprteentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t iprtetable_id = 1;
|
s32_t iprtetable_id = 1;
|
||||||
struct mib_node* const iprtetable_node = (struct mib_node* const)&iprteentry;
|
struct mib_node* iprtetable_node = (struct mib_node* const)&iprteentry;
|
||||||
const struct mib_array_node iprtetable = {
|
struct mib_ram_array_node iprtetable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&iprtetable_id,
|
&iprtetable_id,
|
||||||
&iprtetable_node
|
&iprtetable_node
|
||||||
};
|
};
|
||||||
|
@ -343,27 +400,42 @@ const struct mib_array_node ipaddrentry = {
|
||||||
ipaddrentry_nodes
|
ipaddrentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t ipaddrtable_id = 1;
|
s32_t ipaddrtable_id = 1;
|
||||||
struct mib_node* const ipaddrtable_node = (struct mib_node* const)&ipaddrentry;
|
struct mib_node* ipaddrtable_node = (struct mib_node* const)&ipaddrentry;
|
||||||
const struct mib_array_node ipaddrtable = {
|
struct mib_ram_array_node ipaddrtable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&ipaddrtable_id,
|
&ipaddrtable_id,
|
||||||
&ipaddrtable_node
|
&ipaddrtable_node
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ip .1.3.6.1.2.1.4 */
|
/* ip .1.3.6.1.2.1.4 */
|
||||||
const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
|
const mib_scalar_node ip_scalar = {
|
||||||
struct mib_node* const ip_nodes[23] = {
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, (struct mib_node* const)&ipaddrtable,
|
|
||||||
(struct mib_node* const)&iprtetable, (struct mib_node* const)&ipntomtable, NULL
|
|
||||||
};
|
|
||||||
const struct mib_array_node ip = {
|
|
||||||
&ip_get_object_def,
|
&ip_get_object_def,
|
||||||
&ip_get_value,
|
&ip_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
|
||||||
|
struct mib_node* const ip_nodes[23] = {
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ip_scalar,
|
||||||
|
(struct mib_node* const)&ip_scalar, (struct mib_node* const)&ipaddrtable,
|
||||||
|
(struct mib_node* const)&iprtetable, (struct mib_node* const)&ipntomtable,
|
||||||
|
(struct mib_node* const)&ip_scalar
|
||||||
|
};
|
||||||
|
const struct mib_array_node ip = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
23,
|
23,
|
||||||
ip_ids,
|
ip_ids,
|
||||||
|
@ -407,13 +479,13 @@ const struct mib_array_node attable = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* at .1.3.6.1.2.1.3 */
|
/* at .1.3.6.1.2.1.3 */
|
||||||
const s32_t at_id = 1;
|
s32_t at_id = 1;
|
||||||
struct mib_node* const at_node = (struct mib_node* const)&attable;
|
struct mib_node* at_node = (struct mib_node* const)&attable;
|
||||||
const struct mib_array_node at = {
|
struct mib_ram_array_node at = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&at_id,
|
&at_id,
|
||||||
&at_node
|
&at_node
|
||||||
};
|
};
|
||||||
|
@ -451,37 +523,57 @@ const struct mib_array_node ifentry = {
|
||||||
ifentry_nodes
|
ifentry_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
const s32_t iftable_id = 1;
|
s32_t iftable_id = 1;
|
||||||
struct mib_node* const iftable_node = (struct mib_node* const)&ifentry;
|
struct mib_node* iftable_node = (struct mib_node* const)&ifentry;
|
||||||
const struct mib_array_node iftable = {
|
struct mib_ram_array_node iftable = {
|
||||||
&noleafs_get_object_def,
|
&noleafs_get_object_def,
|
||||||
&noleafs_get_value,
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_RA,
|
||||||
1,
|
0,
|
||||||
&iftable_id,
|
&iftable_id,
|
||||||
&iftable_node
|
&iftable_node
|
||||||
};
|
};
|
||||||
|
|
||||||
/* interfaces .1.3.6.1.2.1.2 */
|
/* interfaces .1.3.6.1.2.1.2 */
|
||||||
const s32_t interfaces_ids[2] = { 1, 2 };
|
const mib_scalar_node interfaces_scalar = {
|
||||||
struct mib_node* const interfaces_nodes[2] = { NULL, (struct mib_node* const)&iftable };
|
|
||||||
const struct mib_array_node interfaces = {
|
|
||||||
&interfaces_get_object_def,
|
&interfaces_get_object_def,
|
||||||
&interfaces_get_value,
|
&interfaces_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t interfaces_ids[2] = { 1, 2 };
|
||||||
|
struct mib_node* const interfaces_nodes[2] = {
|
||||||
|
(struct mib_node* const)&interfaces_scalar, (struct mib_node* const)&iftable
|
||||||
|
};
|
||||||
|
const struct mib_array_node interfaces = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
2,
|
2,
|
||||||
interfaces_ids,
|
interfaces_ids,
|
||||||
interfaces_nodes
|
interfaces_nodes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* 0 1 2 3 4 5 6 */
|
/* 0 1 2 3 4 5 6 */
|
||||||
/* system .1.3.6.1.2.1.1 */
|
/* system .1.3.6.1.2.1.1 */
|
||||||
const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
|
const mib_scalar_node sys_tem_scalar = {
|
||||||
struct mib_node* const sys_tem_nodes[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
|
||||||
/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
|
|
||||||
const struct mib_array_node sys_tem = {
|
|
||||||
&system_get_object_def,
|
&system_get_object_def,
|
||||||
&system_get_value,
|
&system_get_value,
|
||||||
|
MIB_NODE_SC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
|
||||||
|
struct mib_node* const sys_tem_nodes[7] = {
|
||||||
|
(struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
|
||||||
|
(struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
|
||||||
|
(struct mib_node* const)&sys_tem_scalar, (struct mib_node* const)&sys_tem_scalar,
|
||||||
|
(struct mib_node* const)&sys_tem_scalar
|
||||||
|
};
|
||||||
|
/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
|
||||||
|
const struct mib_array_node sys_tem = {
|
||||||
|
&noleafs_get_object_def,
|
||||||
|
&noleafs_get_value,
|
||||||
MIB_NODE_AR,
|
MIB_NODE_AR,
|
||||||
7,
|
7,
|
||||||
sys_tem_ids,
|
sys_tem_ids,
|
||||||
|
@ -869,11 +961,15 @@ void snmp_inc_iflist(void)
|
||||||
struct mib_list_node *if_node = NULL;
|
struct mib_list_node *if_node = NULL;
|
||||||
|
|
||||||
snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
|
snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
|
||||||
|
/* enable getnext traversal on filled table */
|
||||||
|
iftable.maxlength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void snmp_dec_iflist(void)
|
void snmp_dec_iflist(void)
|
||||||
{
|
{
|
||||||
snmp_mib_node_delete(&iflist_root, iflist_root.tail);
|
snmp_mib_node_delete(&iflist_root, iflist_root.tail);
|
||||||
|
/* disable getnext traversal on empty table */
|
||||||
|
if(iflist_root.count == 0) iftable.maxlength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -934,6 +1030,9 @@ void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* enable getnext traversal on filled tables */
|
||||||
|
at.maxlength = 1;
|
||||||
|
ipntomtable.maxlength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1005,6 +1104,9 @@ void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* disable getnext traversal on empty tables */
|
||||||
|
if(arptree_root.count == 0) at.maxlength = 0;
|
||||||
|
if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void snmp_inc_ipinreceives(void)
|
void snmp_inc_ipinreceives(void)
|
||||||
|
@ -1133,6 +1235,8 @@ void snmp_insert_ipaddridx_tree(struct netif *ni)
|
||||||
}
|
}
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
|
/* enable getnext traversal on filled table */
|
||||||
|
ipaddrtable.maxlength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1194,6 +1298,8 @@ void snmp_delete_ipaddridx_tree(struct netif *ni)
|
||||||
snmp_mib_lrn_free(next);
|
snmp_mib_lrn_free(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* disable getnext traversal on empty table */
|
||||||
|
if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1258,6 +1364,8 @@ void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
|
||||||
level++;
|
level++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* enable getnext traversal on filled table */
|
||||||
|
iprtetable.maxlength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1338,6 +1446,8 @@ void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* disable getnext traversal on empty table */
|
||||||
|
if (iprtetree_root.count == 0) iprtetable.maxlength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1576,6 +1686,7 @@ void snmp_insert_udpidx_tree(struct udp_pcb *pcb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
udptable.maxlength = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1588,13 +1699,29 @@ void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
|
||||||
struct mib_list_node *udp_n, *del_n[5];
|
struct mib_list_node *udp_n, *del_n[5];
|
||||||
struct ip_addr ip;
|
struct ip_addr ip;
|
||||||
s32_t udpidx[5];
|
s32_t udpidx[5];
|
||||||
u8_t fc, level, del_cnt;
|
u8_t bindings, fc, level, del_cnt;
|
||||||
|
|
||||||
LWIP_ASSERT("pcb != NULL", pcb != NULL);
|
LWIP_ASSERT("pcb != NULL", pcb != NULL);
|
||||||
ip.addr = ntohl(pcb->local_ip.addr);
|
ip.addr = ntohl(pcb->local_ip.addr);
|
||||||
snmp_iptooid(&ip, &udpidx[0]);
|
snmp_iptooid(&ip, &udpidx[0]);
|
||||||
udpidx[4] = pcb->local_port;
|
udpidx[4] = pcb->local_port;
|
||||||
|
|
||||||
|
/* count PCBs for a given binding
|
||||||
|
(e.g. when reusing ports or for temp output PCBs) */
|
||||||
|
bindings = 0;
|
||||||
|
pcb = udp_pcbs;
|
||||||
|
while ((pcb != NULL))
|
||||||
|
{
|
||||||
|
if ((pcb->local_ip.addr == ip.addr) &&
|
||||||
|
(pcb->local_port == udpidx[4]))
|
||||||
|
{
|
||||||
|
bindings++;
|
||||||
|
}
|
||||||
|
pcb = pcb->next;
|
||||||
|
}
|
||||||
|
if (bindings == 1)
|
||||||
|
{
|
||||||
|
/* selectively remove */
|
||||||
/* mark nodes for deletion */
|
/* mark nodes for deletion */
|
||||||
level = 0;
|
level = 0;
|
||||||
del_cnt = 0;
|
del_cnt = 0;
|
||||||
|
@ -1639,6 +1766,9 @@ void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* disable getnext traversal on empty table */
|
||||||
|
if (udp_root.count == 0) udptable.maxlength = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void snmp_inc_snmpinpkts(void)
|
void snmp_inc_snmpinpkts(void)
|
||||||
|
@ -1817,7 +1947,10 @@ system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
u8_t id;
|
u8_t id;
|
||||||
|
|
||||||
if ((ident_len == 2) && (ident[1] == 0))
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if (ident_len == 2)
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
od->id_inst_ptr = ident;
|
od->id_inst_ptr = ident;
|
||||||
|
@ -1938,7 +2071,10 @@ system_get_value(struct obj_def *od, u16_t len, void *value)
|
||||||
static void
|
static void
|
||||||
interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
if ((ident_len == 2) && (ident[0] == 1) && (ident[1] == 0))
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if (ident_len == 2)
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
od->id_inst_ptr = ident;
|
od->id_inst_ptr = ident;
|
||||||
|
@ -2329,7 +2465,10 @@ ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
u8_t id;
|
u8_t id;
|
||||||
|
|
||||||
if ((ident_len == 2) && (ident[1] == 0))
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if (ident_len == 2)
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
od->id_inst_ptr = ident;
|
od->id_inst_ptr = ident;
|
||||||
|
@ -2967,7 +3106,10 @@ ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||||
static void
|
static void
|
||||||
icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
if ((ident_len == 2) && (ident[1] == 0) &&
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if ((ident_len == 2) &&
|
||||||
(ident[0] > 0) && (ident[0] < 27))
|
(ident[0] > 0) && (ident[0] < 27))
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
|
@ -3083,7 +3225,10 @@ tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
u8_t id;
|
u8_t id;
|
||||||
|
|
||||||
if ((ident_len == 2) && (ident[1] == 0))
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if (ident_len == 2)
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
od->id_inst_ptr = ident;
|
od->id_inst_ptr = ident;
|
||||||
|
@ -3282,7 +3427,10 @@ tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||||
static void
|
static void
|
||||||
udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
if ((ident_len == 2) && (ident[1] == 0) &&
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if ((ident_len == 2) &&
|
||||||
(ident[0] > 0) && (ident[0] < 6))
|
(ident[0] > 0) && (ident[0] < 6))
|
||||||
{
|
{
|
||||||
od->id_inst_len = ident_len;
|
od->id_inst_len = ident_len;
|
||||||
|
@ -3409,7 +3557,10 @@ udpentry_get_value(struct obj_def *od, u16_t len, void *value)
|
||||||
static void
|
static void
|
||||||
snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
|
||||||
{
|
{
|
||||||
if ((ident_len == 2) && (ident[1] == 0))
|
/* return to object name, adding index depth (1) */
|
||||||
|
ident_len += 1;
|
||||||
|
ident -= 1;
|
||||||
|
if (ident_len == 2)
|
||||||
{
|
{
|
||||||
u8_t id;
|
u8_t id;
|
||||||
|
|
||||||
|
|
|
@ -437,6 +437,8 @@ snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n)
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches tree for the supplied (scalar?) object identifier.
|
* Searches tree for the supplied (scalar?) object identifier.
|
||||||
*
|
*
|
||||||
|
@ -544,7 +546,7 @@ snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* search failed, object id points to unknown object (nosuchname) */
|
/* search failed, object id points to unknown object (nosuchname) */
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed, object not in this MIB"));
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed, object not in this MIB\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,6 +617,23 @@ snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (node_type == MIB_NODE_SC)
|
||||||
|
{
|
||||||
|
mib_scalar_node *sn;
|
||||||
|
|
||||||
|
sn = (mib_scalar_node *)node;
|
||||||
|
if ((ident_len == 1) && (*ident == 0))
|
||||||
|
{
|
||||||
|
sn->get_object_def(ident_len, ident, object_def);
|
||||||
|
return (struct mib_node*)sn;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* search failed, short object identifier (nosuchname) */
|
||||||
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("search failed, short object identifier\n"));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* unknown node_type */
|
/* unknown node_type */
|
||||||
|
@ -627,11 +646,42 @@ snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test table for presence of at least one table entry.
|
||||||
|
*/
|
||||||
|
static u8_t
|
||||||
|
empty_table(struct mib_node *node)
|
||||||
|
{
|
||||||
|
u8_t node_type;
|
||||||
|
u8_t empty = 0;
|
||||||
|
|
||||||
|
if (node != NULL)
|
||||||
|
{
|
||||||
|
node_type = node->node_type;
|
||||||
|
if (node_type == MIB_NODE_LR)
|
||||||
|
{
|
||||||
|
struct mib_list_rootnode *lrn;
|
||||||
|
lrn = (struct mib_list_rootnode *)node;
|
||||||
|
if ((lrn->count == 0) || (lrn->head == NULL))
|
||||||
|
{
|
||||||
|
empty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((node_type == MIB_NODE_AR) || (node_type == MIB_NODE_RA))
|
||||||
|
{
|
||||||
|
struct mib_array_node *an;
|
||||||
|
an = (struct mib_array_node *)node;
|
||||||
|
if ((an->maxlength == 0) || (an->nptr == NULL))
|
||||||
|
{
|
||||||
|
empty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tree expansion.
|
* Tree expansion.
|
||||||
*
|
|
||||||
* @todo function ptrs for tabular items
|
|
||||||
* if not empty add first index, nextThing.0 otherwise
|
|
||||||
*/
|
*/
|
||||||
struct mib_node *
|
struct mib_node *
|
||||||
snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret)
|
snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret)
|
||||||
|
@ -669,49 +719,12 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
if (an->nptr[i] == NULL)
|
if (an->nptr[i] == NULL)
|
||||||
{
|
{
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n"));
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n"));
|
||||||
/* leaf node,
|
/* leaf node (e.g. in a fixed size table) */
|
||||||
if scalar: if ident_len == 1 add '.0', nextThing.0 otherwise */
|
if ((i + 1) < an->maxlength)
|
||||||
if (ident_len == 1)
|
|
||||||
{
|
|
||||||
oidret->id[oidret->len] = 0;
|
|
||||||
(oidret->len)++;
|
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("ident_len == 1, added .0\n"));
|
|
||||||
return (struct mib_node*)an;
|
|
||||||
}
|
|
||||||
else if ((i + 1) < an->maxlength)
|
|
||||||
{
|
{
|
||||||
(oidret->len)--;
|
(oidret->len)--;
|
||||||
oidret->id[oidret->len] = an->objid[i + 1];
|
oidret->id[oidret->len] = an->objid[i + 1];
|
||||||
(oidret->len)++;
|
(oidret->len)++;
|
||||||
if (an->nptr[i + 1] == NULL)
|
|
||||||
{
|
|
||||||
oidret->id[oidret->len] = 0;
|
|
||||||
(oidret->len)++;
|
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("(i + 1) < an->maxlength\n"));
|
|
||||||
return (struct mib_node*)an;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct nse cur_node;
|
|
||||||
|
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n"));
|
|
||||||
/* non-leaf, store right child ptr and id */
|
|
||||||
if ((i + 2) < an->maxlength)
|
|
||||||
{
|
|
||||||
cur_node.r_ptr = an->nptr[i + 2];
|
|
||||||
cur_node.r_id = an->objid[i + 2];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cur_node.r_ptr = NULL;
|
|
||||||
}
|
|
||||||
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 */
|
|
||||||
ident_len--;
|
|
||||||
ident++;
|
|
||||||
node = an->nptr[i+1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -721,14 +734,20 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
u8_t j;
|
||||||
struct nse cur_node;
|
struct nse cur_node;
|
||||||
|
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n"));
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("non-leaf node\n"));
|
||||||
/* non-leaf, store right child ptr and id */
|
/* non-leaf, store right child ptr and id */
|
||||||
if ((i + 1) < an->maxlength)
|
j = i + 1;
|
||||||
|
while ((j < an->maxlength) && (empty_table(an->nptr[j])))
|
||||||
{
|
{
|
||||||
cur_node.r_ptr = an->nptr[i + 1];
|
j++;
|
||||||
cur_node.r_id = an->objid[i + 1];
|
}
|
||||||
|
if (j < an->maxlength)
|
||||||
|
{
|
||||||
|
cur_node.r_ptr = an->nptr[j];
|
||||||
|
cur_node.r_id = an->objid[j];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -750,28 +769,38 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* ident_len == 0, complete object identifier */
|
u8_t j;
|
||||||
/* add leftmost '.thing' */
|
/* ident_len == 0, complete with leftmost '.thing' */
|
||||||
oidret->id[oidret->len] = an->objid[0];
|
j = 0;
|
||||||
(oidret->len)++;
|
while ((j < an->maxlength) && empty_table(an->nptr[j]))
|
||||||
if (an->nptr[0] == NULL)
|
|
||||||
{
|
{
|
||||||
/* leaf node
|
j++;
|
||||||
if scalar: add '.0' */
|
}
|
||||||
oidret->id[oidret->len] = 0;
|
if (j < an->maxlength)
|
||||||
|
{
|
||||||
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->objid[j]==%"S32_F"\n",an->objid[j]));
|
||||||
|
oidret->id[oidret->len] = an->objid[j];
|
||||||
(oidret->len)++;
|
(oidret->len)++;
|
||||||
|
if (an->nptr[j] == NULL)
|
||||||
|
{
|
||||||
|
/* leaf node */
|
||||||
return (struct mib_node*)an;
|
return (struct mib_node*)an;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no leaf, continue */
|
/* no leaf, continue */
|
||||||
node = an->nptr[0];
|
node = an->nptr[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* j == an->maxlength */
|
||||||
|
climb_tree = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(node_type == MIB_NODE_LR)
|
else if(node_type == MIB_NODE_LR)
|
||||||
{
|
{
|
||||||
/** @todo need this for indexing tables */
|
|
||||||
struct mib_list_rootnode *lrn;
|
struct mib_list_rootnode *lrn;
|
||||||
struct mib_list_node *ln;
|
struct mib_list_node *ln;
|
||||||
|
|
||||||
|
@ -793,7 +822,6 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
if (ln->nptr == NULL)
|
if (ln->nptr == NULL)
|
||||||
{
|
{
|
||||||
/* leaf node */
|
/* leaf node */
|
||||||
/** @todo if scalar: if ident_len == 1 add '.0', nextThing.0 otherwise */
|
|
||||||
if (ln->next != NULL)
|
if (ln->next != NULL)
|
||||||
{
|
{
|
||||||
(oidret->len)--;
|
(oidret->len)--;
|
||||||
|
@ -810,13 +838,19 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
struct mib_list_node *jn;
|
||||||
struct nse cur_node;
|
struct nse cur_node;
|
||||||
|
|
||||||
/* non-leaf, store right child ptr and id */
|
/* non-leaf, store right child ptr and id */
|
||||||
if (ln->next != NULL)
|
jn = ln->next;
|
||||||
|
while ((jn != NULL) && empty_table(jn->nptr))
|
||||||
{
|
{
|
||||||
cur_node.r_ptr = ln->next->nptr;
|
jn = jn->next;
|
||||||
cur_node.r_id = ln->next->objid;
|
}
|
||||||
|
if (jn != NULL)
|
||||||
|
{
|
||||||
|
cur_node.r_ptr = jn->nptr;
|
||||||
|
cur_node.r_id = jn->objid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -839,23 +873,57 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* ident_len == 0, complete object identifier */
|
struct mib_list_node *jn;
|
||||||
/* add leftmost '.thing' */
|
/* ident_len == 0, complete with leftmost '.thing' */
|
||||||
oidret->id[oidret->len] = lrn->head->objid;
|
jn = lrn->head;
|
||||||
|
while ((jn != NULL) && empty_table(jn->nptr))
|
||||||
|
{
|
||||||
|
jn = jn->next;
|
||||||
|
}
|
||||||
|
if (jn != NULL)
|
||||||
|
{
|
||||||
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("left jn->objid==%"S32_F"\n",jn->objid));
|
||||||
|
oidret->id[oidret->len] = jn->objid;
|
||||||
(oidret->len)++;
|
(oidret->len)++;
|
||||||
if (lrn->head->nptr == NULL)
|
if (jn->nptr == NULL)
|
||||||
{
|
{
|
||||||
/* leaf node */
|
/* leaf node */
|
||||||
/* @todo problem: if scalar add .0 */
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("jn->nptr == NULL\n"));
|
||||||
LWIP_DEBUGF(SNMP_MIB_DEBUG,("lrn->head->nptr == NULL\n"));
|
|
||||||
return (struct mib_node*)lrn;
|
return (struct mib_node*)lrn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* no leaf, continue */
|
/* no leaf, continue */
|
||||||
node = lrn->head->nptr;
|
node = jn->nptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* jn == NULL */
|
||||||
|
climb_tree = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(node_type == MIB_NODE_SC)
|
||||||
|
{
|
||||||
|
mib_scalar_node *sn;
|
||||||
|
|
||||||
|
/* scalar node */
|
||||||
|
sn = (mib_scalar_node *)node;
|
||||||
|
if (ident_len > 0)
|
||||||
|
{
|
||||||
|
/* at .0 */
|
||||||
|
climb_tree = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* ident_len == 0, complete object identifier */
|
||||||
|
oidret->id[oidret->len] = 0;
|
||||||
|
(oidret->len)++;
|
||||||
|
/* leaf node */
|
||||||
|
LWIP_DEBUGF(SNMP_MIB_DEBUG,("completed scalar leaf\n"));
|
||||||
|
return (struct mib_node*)sn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -318,8 +318,6 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
|
||||||
|
|
||||||
if (snmp_iso_prefix_expand(msg_ps->invb.head->ident_len, msg_ps->invb.head->ident, &oid))
|
if (snmp_iso_prefix_expand(msg_ps->invb.head->ident_len, msg_ps->invb.head->ident, &oid))
|
||||||
{
|
{
|
||||||
/** @todo expand tree and complete oid */
|
|
||||||
#if 1
|
|
||||||
if (msg_ps->invb.head->ident_len > 3)
|
if (msg_ps->invb.head->ident_len > 3)
|
||||||
{
|
{
|
||||||
/* can offset ident_len and ident */
|
/* can offset ident_len and ident */
|
||||||
|
@ -332,9 +330,6 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
|
||||||
/* can't offset ident_len -4, ident + 4 */
|
/* can't offset ident_len -4, ident + 4 */
|
||||||
mn = snmp_expand_tree((struct mib_node*)&internet, 0, NULL, &oid);
|
mn = snmp_expand_tree((struct mib_node*)&internet, 0, NULL, &oid);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
mn = (struct mib_node*)&internet;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -344,9 +339,12 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr,
|
||||||
{
|
{
|
||||||
struct snmp_varbind *vb;
|
struct snmp_varbind *vb;
|
||||||
|
|
||||||
vb = snmp_varbind_alloc(&oid, (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_NUL), 0);
|
mn->get_object_def(1, &oid.id[oid.len - 1], &object_def);
|
||||||
|
|
||||||
|
vb = snmp_varbind_alloc(&oid, object_def.asn_type, object_def.v_len);
|
||||||
if (vb != NULL)
|
if (vb != NULL)
|
||||||
{
|
{
|
||||||
|
mn->get_value(&object_def, object_def.v_len, vb->value);
|
||||||
snmp_varbind_tail_add(&msg_ps->outvb, vb);
|
snmp_varbind_tail_add(&msg_ps->outvb, vb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -75,14 +75,16 @@ struct obj_def
|
||||||
s32_t *id_inst_ptr;
|
s32_t *id_inst_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** MIB const scalar (.0) node */
|
||||||
|
#define MIB_NODE_SC 0x01
|
||||||
/** MIB const array node */
|
/** MIB const array node */
|
||||||
#define MIB_NODE_AR 0x01
|
#define MIB_NODE_AR 0x02
|
||||||
/** MIB array node (mem_malloced from RAM) */
|
/** MIB array node (mem_malloced from RAM) */
|
||||||
#define MIB_NODE_RA 0x02
|
#define MIB_NODE_RA 0x03
|
||||||
/** MIB list root node (mem_malloced from RAM) */
|
/** MIB list root node (mem_malloced from RAM) */
|
||||||
#define MIB_NODE_LR 0x03
|
#define MIB_NODE_LR 0x04
|
||||||
/** MIB node for external objects */
|
/** MIB node for external objects */
|
||||||
#define MIB_NODE_EX 0x04
|
#define MIB_NODE_EX 0x05
|
||||||
|
|
||||||
/** node "base class" layout, the mandatory fields for a node */
|
/** node "base class" layout, the mandatory fields for a node */
|
||||||
struct mib_node
|
struct mib_node
|
||||||
|
@ -99,6 +101,9 @@ struct mib_node
|
||||||
const u16_t maxlength;
|
const u16_t maxlength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** derived node for scalars .0 index */
|
||||||
|
typedef struct mib_node mib_scalar_node;
|
||||||
|
|
||||||
/** derived node, points to a fixed size const array
|
/** derived node, points to a fixed size const array
|
||||||
of sub-identifiers plus a 'child' pointer */
|
of sub-identifiers plus a 'child' pointer */
|
||||||
struct mib_array_node
|
struct mib_array_node
|
||||||
|
|
Loading…
Reference in New Issue
Block a user