snmp: combine oid and node pointers in array entries

This commit is contained in:
goldsimon 2015-10-02 10:53:17 +02:00
parent 5b1b430403
commit bf75ace695
3 changed files with 174 additions and 251 deletions

View File

@ -141,25 +141,21 @@ static const struct mib_scalar_node snmp_scalar = {
0 0
} }
}; };
static const s32_t snmp_ids[28] = { static const struct mib_array_node_entry snmp_nodes[] = {
1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, {1, &snmp_scalar.node}, {2, &snmp_scalar.node},
17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30 {3, &snmp_scalar.node}, {4, &snmp_scalar.node},
}; {5, &snmp_scalar.node}, {6, &snmp_scalar.node},
static const struct mib_node* const snmp_nodes[28] = { {8, &snmp_scalar.node}, {9, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {10, &snmp_scalar.node}, {11, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {12, &snmp_scalar.node}, {13, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {14, &snmp_scalar.node}, {15, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {16, &snmp_scalar.node}, {17, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {18, &snmp_scalar.node}, {19, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {20, &snmp_scalar.node}, {21, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {22, &snmp_scalar.node}, {24, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {25, &snmp_scalar.node}, {26, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {27, &snmp_scalar.node}, {28, &snmp_scalar.node},
&snmp_scalar.node, &snmp_scalar.node, {29, &snmp_scalar.node}, {30, &snmp_scalar.node}
&snmp_scalar.node, &snmp_scalar.node,
&snmp_scalar.node, &snmp_scalar.node,
&snmp_scalar.node, &snmp_scalar.node,
&snmp_scalar.node, &snmp_scalar.node
}; };
static const struct mib_array_node snmp = { static const struct mib_array_node snmp = {
{ {
@ -168,9 +164,8 @@ static const struct mib_array_node snmp = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
28 LWIP_ARRAYSIZE(snmp_nodes)
}, },
snmp_ids,
snmp_nodes snmp_nodes
}; };
@ -193,9 +188,8 @@ static struct mib_list_rootnode udp_root = {
NULL, NULL,
0 0
}; };
static const s32_t udpentry_ids[2] = { 1, 2 }; static const struct mib_array_node_entry udpentry_nodes[] = {
static const struct mib_node* const udpentry_nodes[2] = { {1, &udp_root.node}, {2, &udp_root.node}
&udp_root.node, &udp_root.node
}; };
static struct mib_array_node udpentry = { static struct mib_array_node udpentry = {
{ {
@ -204,14 +198,12 @@ static struct mib_array_node udpentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
2 LWIP_ARRAYSIZE(udpentry_nodes)
}, },
udpentry_ids,
udpentry_nodes udpentry_nodes
}; };
static s32_t udptable_id = 1; static struct mib_array_node_entry udptable_node = {1, &udpentry.node};
static struct mib_node* udptable_node = &udpentry.node;
static struct mib_ram_array_node udptable = { static struct mib_ram_array_node udptable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -221,7 +213,6 @@ static struct mib_ram_array_node udptable = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&udptable_id,
&udptable_node &udptable_node
}; };
@ -235,11 +226,10 @@ static const struct mib_scalar_node udp_scalar = {
0 0
} }
}; };
static const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 }; static const struct mib_array_node_entry udp_nodes[] = {
static const struct mib_node* const udp_nodes[5] = { {1, &udp_scalar.node}, {2, &udp_scalar.node},
&udp_scalar.node, &udp_scalar.node, {3, &udp_scalar.node}, {4, &udp_scalar.node},
&udp_scalar.node, &udp_scalar.node, {5, &udptable.node}
&udptable.node
}; };
static const struct mib_array_node udp = { static const struct mib_array_node udp = {
{ {
@ -248,9 +238,8 @@ static const struct mib_array_node udp = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
5 LWIP_ARRAYSIZE(udp_nodes)
}, },
udp_ids,
udp_nodes udp_nodes
}; };
@ -271,11 +260,10 @@ static struct mib_list_rootnode tcpconntree_root = {
NULL, NULL,
0 0
}; };
static const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 }; static const struct mib_array_node_entry tcpconnentry_nodes[] = {
static const struct mib_node* const tcpconnentry_nodes[5] = { {1, &tcpconntree_root.node}, {2, &tcpconntree_root.node},
&tcpconntree_root.node, &tcpconntree_root.node, {3, &tcpconntree_root.node}, {4, &tcpconntree_root.node},
&tcpconntree_root.node, &tcpconntree_root.node, {5, &tcpconntree_root.node}
&tcpconntree_root.node
}; };
static struct mib_array_node tcpconnentry = { static struct mib_array_node tcpconnentry = {
{ {
@ -284,14 +272,12 @@ static struct mib_array_node tcpconnentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
5 LWIP_ARRAYSIZE(tcpconnentry_nodes)
}, },
tcpconnentry_ids,
tcpconnentry_nodes tcpconnentry_nodes
}; };
static s32_t tcpconntable_id = 1; static struct mib_array_node_entry tcpconntable_node = {1, &tcpconnentry.node};
static struct mib_node* tcpconntable_node = &tcpconnentry.node;
static struct mib_ram_array_node tcpconntable = { static struct mib_ram_array_node tcpconntable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -303,7 +289,6 @@ static struct mib_ram_array_node tcpconntable = {
0 when table is empty, 1 when more than one entry */ 0 when table is empty, 1 when more than one entry */
0 0
}, },
&tcpconntable_id,
&tcpconntable_node &tcpconntable_node
}; };
@ -317,16 +302,15 @@ static const struct mib_scalar_node tcp_scalar = {
0 0
} }
}; };
static const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; static const struct mib_array_node_entry tcp_nodes[] = {
static const struct mib_node* const tcp_nodes[15] = { {1, &tcp_scalar.node}, {2, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {3, &tcp_scalar.node}, {4, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {5, &tcp_scalar.node}, {6, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {7, &tcp_scalar.node}, {8, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {9, &tcp_scalar.node}, {10, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {11, &tcp_scalar.node}, {12, &tcp_scalar.node},
&tcp_scalar.node, &tcp_scalar.node, {13, &tcpconntable.node}, {14, &tcp_scalar.node},
&tcpconntable.node, &tcp_scalar.node, {15, &tcp_scalar.node}
&tcp_scalar.node
}; };
static const struct mib_array_node tcp = { static const struct mib_array_node tcp = {
{ {
@ -335,9 +319,8 @@ static const struct mib_array_node tcp = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
15 LWIP_ARRAYSIZE(tcp_nodes)
}, },
tcp_ids,
tcp_nodes tcp_nodes
}; };
#endif #endif
@ -353,21 +336,20 @@ static const struct mib_scalar_node icmp_scalar = {
0 0
} }
}; };
static 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 }; static const struct mib_array_node_entry icmp_nodes[] = {
static const struct mib_node* const icmp_nodes[26] = { {1, &icmp_scalar.node}, {2, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {3, &icmp_scalar.node}, {4, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {5, &icmp_scalar.node}, {6, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {7, &icmp_scalar.node}, {8, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {9, &icmp_scalar.node}, {10, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {11, &icmp_scalar.node}, {12, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {13, &icmp_scalar.node}, {14, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {15, &icmp_scalar.node}, {16, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {17, &icmp_scalar.node}, {18, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {19, &icmp_scalar.node}, {20, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {21, &icmp_scalar.node}, {22, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {23, &icmp_scalar.node}, {24, &icmp_scalar.node},
&icmp_scalar.node, &icmp_scalar.node, {25, &icmp_scalar.node}, {26, &icmp_scalar.node}
&icmp_scalar.node, &icmp_scalar.node
}; };
static const struct mib_array_node icmp = { static const struct mib_array_node icmp = {
{ {
@ -376,9 +358,8 @@ static const struct mib_array_node icmp = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
26 LWIP_ARRAYSIZE(icmp_nodes)
}, },
icmp_ids,
icmp_nodes icmp_nodes
}; };
@ -396,10 +377,9 @@ static struct mib_list_rootnode ipntomtree_root = {
NULL, NULL,
0 0
}; };
static const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 }; static const struct mib_array_node_entry ipntomentry_nodes[] = {
static const struct mib_node* const ipntomentry_nodes[4] = { {1, &ipntomtree_root.node}, {2, &ipntomtree_root.node},
&ipntomtree_root.node, &ipntomtree_root.node, {3, &ipntomtree_root.node}, {4, &ipntomtree_root.node}
&ipntomtree_root.node, &ipntomtree_root.node
}; };
static struct mib_array_node ipntomentry = { static struct mib_array_node ipntomentry = {
{ {
@ -408,14 +388,12 @@ static struct mib_array_node ipntomentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
4 LWIP_ARRAYSIZE(ipntomentry_nodes)
}, },
ipntomentry_ids,
ipntomentry_nodes ipntomentry_nodes
}; };
static s32_t ipntomtable_id = 1; static struct mib_array_node_entry ipntomtable_node = {1, &ipntomentry.node};
static struct mib_node* ipntomtable_node = &ipntomentry.node;
static struct mib_ram_array_node ipntomtable = { static struct mib_ram_array_node ipntomtable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -425,7 +403,6 @@ static struct mib_ram_array_node ipntomtable = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&ipntomtable_id,
&ipntomtable_node &ipntomtable_node
}; };
@ -443,15 +420,14 @@ static struct mib_list_rootnode iprtetree_root = {
NULL, NULL,
0 0
}; };
static const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; static const struct mib_array_node_entry iprteentry_nodes[] = {
static const struct mib_node* const iprteentry_nodes[13] = { {1, &iprtetree_root.node}, {2, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {3, &iprtetree_root.node}, {4, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {5, &iprtetree_root.node}, {6, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {7, &iprtetree_root.node}, {8, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {9, &iprtetree_root.node}, {10, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {11, &iprtetree_root.node}, {12, &iprtetree_root.node},
&iprtetree_root.node, &iprtetree_root.node, {13, &iprtetree_root.node}
&iprtetree_root.node
}; };
static struct mib_array_node iprteentry = { static struct mib_array_node iprteentry = {
{ {
@ -460,14 +436,12 @@ static struct mib_array_node iprteentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
13 LWIP_ARRAYSIZE(iprteentry_nodes)
}, },
iprteentry_ids,
iprteentry_nodes iprteentry_nodes
}; };
static s32_t iprtetable_id = 1; static struct mib_array_node_entry iprtetable_node = {1, &iprteentry.node};
static struct mib_node* iprtetable_node = &iprteentry.node;
static struct mib_ram_array_node iprtetable = { static struct mib_ram_array_node iprtetable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -477,7 +451,6 @@ static struct mib_ram_array_node iprtetable = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&iprtetable_id,
&iprtetable_node &iprtetable_node
}; };
@ -495,13 +468,12 @@ static struct mib_list_rootnode ipaddrtree_root = {
NULL, NULL,
0 0
}; };
static const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 }; static const struct mib_array_node_entry ipaddrentry_nodes[] = {
static const struct mib_node* const ipaddrentry_nodes[5] = { {1, &ipaddrtree_root.node},
&ipaddrtree_root.node, {2, &ipaddrtree_root.node},
&ipaddrtree_root.node, {3, &ipaddrtree_root.node},
&ipaddrtree_root.node, {4, &ipaddrtree_root.node},
&ipaddrtree_root.node, {5, &ipaddrtree_root.node}
&ipaddrtree_root.node
}; };
static struct mib_array_node ipaddrentry = { static struct mib_array_node ipaddrentry = {
{ {
@ -510,14 +482,12 @@ static struct mib_array_node ipaddrentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
5 LWIP_ARRAYSIZE(ipaddrentry_nodes)
}, },
ipaddrentry_ids,
ipaddrentry_nodes ipaddrentry_nodes
}; };
static s32_t ipaddrtable_id = 1; static struct mib_array_node_entry ipaddrtable_node = {1, &ipaddrentry.node};
static struct mib_node* ipaddrtable_node = &ipaddrentry.node;
static struct mib_ram_array_node ipaddrtable = { static struct mib_ram_array_node ipaddrtable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -527,7 +497,6 @@ static struct mib_ram_array_node ipaddrtable = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&ipaddrtable_id,
&ipaddrtable_node &ipaddrtable_node
}; };
@ -542,20 +511,19 @@ static const struct mib_scalar_node ip_scalar = {
0 0
} }
}; };
static 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 }; static const struct mib_array_node_entry ip_nodes[] = {
static const struct mib_node* const ip_nodes[23] = { {1, &ip_scalar.node}, {2, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {3, &ip_scalar.node}, {4, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {5, &ip_scalar.node}, {6, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {7, &ip_scalar.node}, {8, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {9, &ip_scalar.node}, {10, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {11, &ip_scalar.node}, {12, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {13, &ip_scalar.node}, {14, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {15, &ip_scalar.node}, {16, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {17, &ip_scalar.node}, {18, &ip_scalar.node},
&ip_scalar.node, &ip_scalar.node, {19, &ip_scalar.node}, {20, &ipaddrtable.node},
&ip_scalar.node, &ipaddrtable.node, {21, &iprtetable.node}, {22, &ipntomtable.node},
&iprtetable.node, &ipntomtable.node, {23, &ip_scalar.node}
&ip_scalar.node
}; };
static const struct mib_array_node mib2_ip = { static const struct mib_array_node mib2_ip = {
{ {
@ -564,9 +532,8 @@ static const struct mib_array_node mib2_ip = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
23 LWIP_ARRAYSIZE(ip_nodes)
}, },
ip_ids,
ip_nodes ip_nodes
}; };
@ -584,11 +551,10 @@ static struct mib_list_rootnode arptree_root = {
NULL, NULL,
0 0
}; };
static const s32_t atentry_ids[3] = { 1, 2, 3 }; static const struct mib_array_node_entry atentry_nodes[] = {
static const struct mib_node* const atentry_nodes[3] = { {1, &arptree_root.node},
&arptree_root.node, {2, &arptree_root.node},
&arptree_root.node, {3, &arptree_root.node}
&arptree_root.node
}; };
static const struct mib_array_node atentry = { static const struct mib_array_node atentry = {
{ {
@ -597,14 +563,12 @@ static const struct mib_array_node atentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
3 LWIP_ARRAYSIZE(atentry_nodes)
}, },
atentry_ids,
atentry_nodes atentry_nodes
}; };
static const s32_t attable_id = 1; static const struct mib_array_node_entry attable_node = {1, &atentry.node};
static const struct mib_node* const attable_node = &atentry.node;
static struct mib_array_node attable = { static struct mib_array_node attable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -614,13 +578,11 @@ static struct mib_array_node attable = {
MIB_NODE_AR, MIB_NODE_AR,
1 1
}, },
&attable_id,
&attable_node &attable_node
}; };
/* at .1.3.6.1.2.1.3 */ /* at .1.3.6.1.2.1.3 */
static s32_t at_id = 1; static struct mib_array_node_entry mib2_at_node = {1, &attable.node};
static struct mib_node* mib2_at_node = &attable.node;
static struct mib_ram_array_node at = { static struct mib_ram_array_node at = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -630,7 +592,6 @@ static struct mib_ram_array_node at = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&at_id,
&mib2_at_node &mib2_at_node
}; };
@ -653,19 +614,18 @@ static struct mib_list_rootnode iflist_root = {
NULL, NULL,
0 0
}; };
static const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; static const struct mib_array_node_entry ifentry_nodes[] = {
static const struct mib_node* const ifentry_nodes[22] = { {1, &iflist_root.node}, {2, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {3, &iflist_root.node}, {4, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {5, &iflist_root.node}, {6, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {7, &iflist_root.node}, {8, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {9, &iflist_root.node}, {10, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {11, &iflist_root.node}, {12, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {13, &iflist_root.node}, {14, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {15, &iflist_root.node}, {16, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {17, &iflist_root.node}, {18, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {19, &iflist_root.node}, {20, &iflist_root.node},
&iflist_root.node, &iflist_root.node, {21, &iflist_root.node}, {22, &iflist_root.node}
&iflist_root.node, &iflist_root.node
}; };
static struct mib_array_node ifentry = { static struct mib_array_node ifentry = {
{ {
@ -674,14 +634,12 @@ static struct mib_array_node ifentry = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
22 LWIP_ARRAYSIZE(ifentry_nodes)
}, },
ifentry_ids,
ifentry_nodes ifentry_nodes
}; };
static s32_t iftable_id = 1; static struct mib_array_node_entry iftable_node = {1, &ifentry.node};
static struct mib_node* iftable_node = &ifentry.node;
static struct mib_ram_array_node iftable = { static struct mib_ram_array_node iftable = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -691,7 +649,6 @@ static struct mib_ram_array_node iftable = {
MIB_NODE_RA, MIB_NODE_RA,
0 0
}, },
&iftable_id,
&iftable_node &iftable_node
}; };
@ -706,9 +663,8 @@ static const struct mib_scalar_node interfaces_scalar = {
0 0
} }
}; };
static const s32_t interfaces_ids[2] = { 1, 2 }; static const struct mib_array_node_entry interfaces_nodes[] = {
static const struct mib_node* const interfaces_nodes[2] = { {1, &interfaces_scalar.node}, {2, &iftable.node}
&interfaces_scalar.node, &iftable.node
}; };
static const struct mib_array_node interfaces = { static const struct mib_array_node interfaces = {
{ {
@ -717,9 +673,8 @@ static const struct mib_array_node interfaces = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
2 LWIP_ARRAYSIZE(interfaces_nodes)
}, },
interfaces_ids,
interfaces_nodes interfaces_nodes
}; };
@ -736,12 +691,11 @@ static const struct mib_scalar_node system_scalar = {
0 0
} }
}; };
static const s32_t system_ids[7] = { 1, 2, 3, 4, 5, 6, 7 }; static const struct mib_array_node_entry system_nodes[] = {
static const struct mib_node* const system_nodes[7] = { {1, &system_scalar.node}, {2, &system_scalar.node},
&system_scalar.node, &system_scalar.node, {3, &system_scalar.node}, {4, &system_scalar.node},
&system_scalar.node, &system_scalar.node, {5, &system_scalar.node}, {6, &system_scalar.node},
&system_scalar.node, &system_scalar.node, {7, &system_scalar.node}
&system_scalar.node
}; };
/* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */ /* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
static const struct mib_array_node sys_tem = { static const struct mib_array_node sys_tem = {
@ -751,42 +705,23 @@ static const struct mib_array_node sys_tem = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
7 LWIP_ARRAYSIZE(system_nodes)
}, },
system_ids,
system_nodes system_nodes
}; };
/* mib-2 .1.3.6.1.2.1 */ /* mib-2 .1.3.6.1.2.1 */
static const struct mib_array_node_entry mib2_nodes[] = {
{1, &sys_tem.node},
{2, &interfaces.node},
{3, &at.node},
{4, &mib2_ip.node},
{5, &icmp.node},
#if LWIP_TCP #if LWIP_TCP
#define MIB2_GROUPS 8 {6, &tcp.node},
#else
#define MIB2_GROUPS 7
#endif #endif
const s32_t mib2_ids[MIB2_GROUPS] = {7, &udp.node},
{ {11, &snmp.node}
1,
2,
3,
4,
5,
#if LWIP_TCP
6,
#endif
7,
11
};
static const struct mib_node* const mib2_nodes[MIB2_GROUPS] = {
&sys_tem.node,
&interfaces.node,
&at.node,
&mib2_ip.node,
&icmp.node,
#if LWIP_TCP
&tcp.node,
#endif
&udp.node,
&snmp.node
}; };
static const struct mib_array_node mib2 = { static const struct mib_array_node mib2 = {
@ -796,15 +731,13 @@ static const struct mib_array_node mib2 = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
MIB2_GROUPS LWIP_ARRAYSIZE(mib2_nodes)
}, },
mib2_ids,
mib2_nodes mib2_nodes
}; };
/* mgmt .1.3.6.1.2 */ /* mgmt .1.3.6.1.2 */
const s32_t mgmt_ids[1] = { 1 }; const struct mib_array_node_entry mgmt_nodes[] = { {1, &mib2.node} };
const struct mib_node* const mgmt_nodes[1] = { (const struct mib_node*)&mib2 };
const struct mib_array_node mgmt = { const struct mib_array_node mgmt = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -812,18 +745,20 @@ const struct mib_array_node mgmt = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
1 LWIP_ARRAYSIZE(mgmt_nodes)
}, },
mgmt_ids,
mgmt_nodes mgmt_nodes
}; };
/* internet .1.3.6.1 */ /* internet .1.3.6.1 */
const struct mib_array_node_entry internet_nodes[] = {
{2, &mgmt.node}
#if SNMP_PRIVATE_MIB #if SNMP_PRIVATE_MIB
/* When using a private MIB, you have to create a file 'private_mib.h' that contains /* When using a private MIB, you have to create a file 'private_mib.h' that contains
* a 'struct mib_array_node mib_private' which contains your MIB. */ * a 'struct mib_array_node mib_private' which contains your MIB. */
s32_t internet_ids[2] = { 2, 4 }; , {4, &mib_private.node}
const struct mib_node* const internet_nodes[2] = { (const struct mib_node*)&mgmt, (const struct mib_node*)&mib_private }; #endif /* SNMP_PRIVATE_MIB */
};
const struct mib_array_node internet = { const struct mib_array_node internet = {
{ {
&noleafs_get_object_def, &noleafs_get_object_def,
@ -831,27 +766,10 @@ const struct mib_array_node internet = {
&noleafs_set_test, &noleafs_set_test,
&noleafs_set_value, &noleafs_set_value,
MIB_NODE_AR, MIB_NODE_AR,
2 LWIP_ARRAYSIZE(internet_nodes)
}, },
internet_ids,
internet_nodes internet_nodes
}; };
#else
const s32_t internet_ids[1] = { 2 };
const struct mib_node* const internet_nodes[1] = { (const struct mib_node*)&mgmt };
const struct mib_array_node internet = {
{
&noleafs_get_object_def,
&noleafs_get_value,
&noleafs_set_test,
&noleafs_set_value,
MIB_NODE_AR,
1
},
internet_ids,
internet_nodes
};
#endif
/** mib-2.system.sysObjectID */ /** mib-2.system.sysObjectID */
static const struct snmp_obj_id sysobjid_default = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID}; static const struct snmp_obj_id sysobjid_default = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID};

View File

@ -469,15 +469,15 @@ snmp_search_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
/* array node (internal ROM or RAM, fixed length) */ /* array node (internal ROM or RAM, fixed length) */
an = (const struct mib_array_node *)node; an = (const struct mib_array_node *)node;
i = 0; i = 0;
while ((i < an->node.maxlength) && (an->objid[i] != *ident)) while ((i < an->node.maxlength) && (an->entries[i].objid != *ident))
{ {
i++; i++;
} }
if (i < an->node.maxlength) if (i < an->node.maxlength)
{ {
/* found it, if available proceed to child, otherwise inspect leaf */ /* 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->objid[i],*ident)); LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->entries[i].objid,*ident));
if (an->nptr[i] == NULL) if (an->entries[i].nptr == NULL)
{ {
/* a scalar leaf OR table, /* a scalar leaf OR table,
inspect remaining instance number / table index */ inspect remaining instance number / table index */
@ -490,7 +490,7 @@ snmp_search_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
/* follow next child pointer */ /* follow next child pointer */
ident++; ident++;
ident_len--; ident_len--;
node = an->nptr[i]; node = an->entries[i].nptr;
} }
} }
else else
@ -657,7 +657,7 @@ empty_table(const struct mib_node *node)
{ {
const struct mib_array_node *an; const struct mib_array_node *an;
an = (const struct mib_array_node *)node; an = (const struct mib_array_node *)node;
if ((an->node.maxlength == 0) || (an->nptr == NULL)) if ((an->node.maxlength == 0) || (an->entries == NULL))
{ {
empty = 1; empty = 1;
} }
@ -700,30 +700,30 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
if (ident_len > 0) if (ident_len > 0)
{ {
i = 0; i = 0;
while ((i < an->node.maxlength) && (an->objid[i] < *ident)) while ((i < an->node.maxlength) && (an->entries[i].objid < *ident))
{ {
i++; i++;
} }
if (i < an->node.maxlength) if (i < an->node.maxlength)
{ {
LWIP_DEBUGF(SNMP_MIB_DEBUG,("an->objid[%"U16_F"]==%"S32_F" *ident==%"S32_F"\n",i,an->objid[i],*ident)); 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 */ /* add identifier to oidret */
oidret->id[oidret->len] = an->objid[i]; oidret->id[oidret->len] = an->entries[i].objid;
(oidret->len)++; (oidret->len)++;
if (an->nptr[i] == NULL) if (an->entries[i].nptr == NULL)
{ {
LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n")); LWIP_DEBUGF(SNMP_MIB_DEBUG,("leaf node\n"));
/* leaf node (e.g. in a fixed size table) */ /* leaf node (e.g. in a fixed size table) */
if (an->objid[i] > *ident) if (an->entries[i].objid > *ident)
{ {
return &an->node; return &an->node;
} }
else if ((i + 1) < an->node.maxlength) else if ((i + 1) < an->node.maxlength)
{ {
/* an->objid[i] == *ident */ /* an->entries[i].objid == *ident */
(oidret->len)--; (oidret->len)--;
oidret->id[oidret->len] = an->objid[i + 1]; oidret->id[oidret->len] = an->entries[i + 1].objid;
(oidret->len)++; (oidret->len)++;
return &an->node; return &an->node;
} }
@ -742,15 +742,15 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
/* non-leaf, store right child ptr and id */ /* non-leaf, store right child ptr and id */
LWIP_ASSERT("i < 0xff", i < 0xff); LWIP_ASSERT("i < 0xff", i < 0xff);
j = i + 1; j = i + 1;
while ((j < an->node.maxlength) && (empty_table(an->nptr[j]))) while ((j < an->node.maxlength) && (empty_table(an->entries[j].nptr)))
{ {
j++; j++;
} }
if (j < an->node.maxlength) if (j < an->node.maxlength)
{ {
struct nse cur_node; struct nse cur_node;
cur_node.r_ptr = an->nptr[j]; cur_node.r_ptr = an->entries[j].nptr;
cur_node.r_id = an->objid[j]; cur_node.r_id = an->entries[j].objid;
cur_node.r_nl = 0; cur_node.r_nl = 0;
push_node(&cur_node); push_node(&cur_node);
} }
@ -758,18 +758,18 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
{ {
push_node(&node_null); push_node(&node_null);
} }
if (an->objid[i] == *ident) if (an->entries[i].objid == *ident)
{ {
ident_len--; ident_len--;
ident++; ident++;
} }
else else
{ {
/* an->objid[i] < *ident */ /* an->entries[i].objid < *ident */
ident_len = 0; ident_len = 0;
} }
/* follow next child pointer */ /* follow next child pointer */
node = an->nptr[i]; node = an->entries[i].nptr;
} }
} }
else else
@ -783,16 +783,16 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
u16_t j; u16_t j;
/* ident_len == 0, complete with leftmost '.thing' */ /* ident_len == 0, complete with leftmost '.thing' */
j = 0; j = 0;
while ((j < an->node.maxlength) && empty_table(an->nptr[j])) while ((j < an->node.maxlength) && empty_table(an->entries[j].nptr))
{ {
j++; j++;
} }
if (j < an->node.maxlength) if (j < an->node.maxlength)
{ {
LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->objid[j]==%"S32_F"\n",an->objid[j])); LWIP_DEBUGF(SNMP_MIB_DEBUG,("left an->entries[j].objid==%"S32_F"\n",an->entries[j].objid));
oidret->id[oidret->len] = an->objid[j]; oidret->id[oidret->len] = an->entries[j].objid;
(oidret->len)++; (oidret->len)++;
if (an->nptr[j] == NULL) if (an->entries[j].nptr == NULL)
{ {
/* leaf node */ /* leaf node */
return &an->node; return &an->node;
@ -800,7 +800,7 @@ snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, stru
else else
{ {
/* no leaf, continue */ /* no leaf, continue */
node = an->nptr[j]; node = an->entries[j].nptr;
} }
} }
else else

View File

@ -124,6 +124,13 @@ struct mib_scalar_node
struct mib_node node; struct mib_node node;
}; };
/** describes an array entry (objid/node pair) */
struct mib_array_node_entry
{
s32_t objid;
const struct mib_node *nptr;
};
/** 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
@ -132,8 +139,7 @@ struct mib_array_node
struct mib_node node; struct mib_node node;
/* additional struct members */ /* additional struct members */
const s32_t *objid; const struct mib_array_node_entry * const entries;
const struct mib_node* const *nptr;
}; };
/** derived node, points to a fixed size mem_malloced array /** derived node, points to a fixed size mem_malloced array
@ -144,8 +150,7 @@ struct mib_ram_array_node
struct mib_node node; struct mib_node node;
/* aditional struct members */ /* aditional struct members */
s32_t *objid; struct mib_array_node_entry *entries;
struct mib_node **nptr;
}; };
struct mib_list_node struct mib_list_node