Changed index structs to mib_list_node structs to place the table index trees directly in the mib tree.

This commit is contained in:
christiaans 2006-09-01 07:14:50 +00:00
parent 1485edf8e1
commit 130d39cc03
7 changed files with 746 additions and 240 deletions

View File

@ -48,7 +48,6 @@
struct netif *netif_list = NULL;
struct netif *netif_default = NULL;
u16_t netif_cnt = 0;
/**
* Add a network interface to the list of lwIP netifs.
@ -92,7 +91,8 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
/* add this netif to the list */
netif->next = netif_list;
netif_list = netif;
netif_cnt++;
snmp_inc_iflist();
LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
netif->name[0], netif->name[1]));
ip_addr_debug_print(NETIF_DEBUG, ipaddr);
@ -117,10 +117,12 @@ void netif_remove(struct netif * netif)
{
if ( netif == NULL ) return;
snmp_delete_ipaddridx_tree(netif);
/* is it the first netif? */
if (netif_list == netif) {
netif_list = netif->next;
netif_cnt--;
snmp_dec_iflist();
}
else {
/* look for netif further down the list */
@ -128,7 +130,7 @@ void netif_remove(struct netif * netif)
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
if (tmpNetif->next == netif) {
tmpNetif->next = netif->next;
netif_cnt--;
snmp_dec_iflist();
break;
}
}
@ -203,7 +205,13 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
}
}
#endif
snmp_delete_ipaddridx_tree(netif);
snmp_delete_iprteidx_tree(0,netif);
/* set new IP address to netif */
ip_addr_set(&(netif->ip_addr), ipaddr);
snmp_insert_ipaddridx_tree(netif);
snmp_insert_iprteidx_tree(0,netif);
#if 0 /* only allowed for Ethernet interfaces TODO: how can we check? */
/** For Ethernet network interfaces, we would like to send a
* "gratuitous ARP"; this is an ARP packet sent by a node in order
@ -235,7 +243,10 @@ netif_set_gw(struct netif *netif, struct ip_addr *gw)
void
netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
{
snmp_delete_iprteidx_tree(0, netif);
/* set new netmask to netif */
ip_addr_set(&(netif->netmask), netmask);
snmp_insert_iprteidx_tree(0, netif);
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n",
netif->name[0], netif->name[1],
ip4_addr1(&netif->netmask),
@ -247,6 +258,16 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
void
netif_set_default(struct netif *netif)
{
if (netif == NULL)
{
/* remove default route */
snmp_delete_iprteidx_tree(1, netif);
}
else
{
/* install default route */
snmp_insert_iprteidx_tree(1, netif);
}
netif_default = netif;
LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
@ -297,6 +318,5 @@ void
netif_init(void)
{
netif_list = netif_default = NULL;
netif_cnt = 0;
}

View File

@ -48,6 +48,7 @@
#include "lwip/udp.h"
#include "lwip/snmp_asn1.h"
#include "lwip/snmp_structs.h"
/**
* IANA assigned enterprise ID for lwIP is 26381
* @see http://www.iana.org/assignments/enterprise-numbers
@ -69,19 +70,6 @@
#define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
#endif
/**
* @todo
* table entry availability test in struct mib_node {},
* also we need to be able to expand entry from a partial index
* ifTable, use netif_cnt
* atTable, use ?
* ipAddrTable, use ?
* ipRouteTable, use ?
* ipNetToMediaTable, use ?
* tcpConnTable, use ?
* udpTable, use ?
*/
static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
static void system_get_value(struct obj_def *od, u16_t len, void *value);
static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
@ -113,6 +101,7 @@ static void udpentry_get_value(struct obj_def *od, u16_t len, void *value);
static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
/* snmp .1.3.6.1.2.1.11 */
const s32_t snmp_ids[28] = {
1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
@ -136,13 +125,23 @@ const struct mib_array_node snmp = {
/* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
/* udp .1.3.6.1.2.1.7 */
/** index root node for udpTable */
struct mib_list_rootnode udp_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t udpentry_ids[2] = { 1, 2 };
struct mib_node* const udpentry_nodes[2] = {
NULL, NULL,
(struct mib_node* const)&udp_root, (struct mib_node* const)&udp_root,
};
const struct mib_array_node udpentry = {
&udpentry_get_object_def,
&udpentry_get_value,
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
2,
udpentry_ids,
@ -176,6 +175,16 @@ const struct mib_array_node udp = {
/* tcp .1.3.6.1.2.1.6 */
#if LWIP_TCP
/* only if the TCP protocol is available may implement this group */
/** index root node for tcpConnTable */
struct mib_list_rootnode tcpconntree_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
struct mib_node* const tcpconnentry_nodes[5] = {
NULL, NULL, NULL, NULL, NULL
@ -230,13 +239,24 @@ const struct mib_array_node icmp = {
icmp_nodes
};
/** index root node for ipNetToMediaTable */
struct mib_list_rootnode ipntomtree_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 };
struct mib_node* const ipntomentry_nodes[4] = {
NULL, NULL, NULL, NULL
(struct mib_node* const)&ipntomtree_root, (struct mib_node* const)&ipntomtree_root,
(struct mib_node* const)&ipntomtree_root, (struct mib_node* const)&ipntomtree_root
};
const struct mib_array_node ipntomentry = {
&ip_ntomentry_get_object_def,
&ip_ntomentry_get_value,
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
4,
ipntomentry_ids,
@ -254,14 +274,29 @@ const struct mib_array_node ipntomtable = {
&ipntomtable_node
};
/** index root node for ipRouteTable */
struct mib_list_rootnode iprtetree_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
struct mib_node* const iprteentry_nodes[13] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root, (struct mib_node* const)&iprtetree_root,
(struct mib_node* const)&iprtetree_root
};
const struct mib_array_node iprteentry = {
&ip_rteentry_get_object_def,
&ip_rteentry_get_value,
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
13,
iprteentry_ids,
@ -279,13 +314,27 @@ const struct mib_array_node iprtetable = {
&iprtetable_node
};
/** index root node for ipAddrTable */
struct mib_list_rootnode ipaddrtree_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 };
struct mib_node* const ipaddrentry_nodes[5] = {
NULL, NULL, NULL, NULL, NULL
(struct mib_node* const)&ipaddrtree_root,
(struct mib_node* const)&ipaddrtree_root,
(struct mib_node* const)&ipaddrtree_root,
(struct mib_node* const)&ipaddrtree_root,
(struct mib_node* const)&ipaddrtree_root
};
const struct mib_array_node ipaddrentry = {
&ip_addrentry_get_object_def,
&ip_addrentry_get_value,
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
5,
ipaddrentry_ids,
@ -319,13 +368,25 @@ const struct mib_array_node ip = {
ip_nodes
};
/** index root node for atTable */
struct mib_list_rootnode arptree_root = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
const s32_t atentry_ids[3] = { 1, 2, 3 };
struct mib_node* const atentry_nodes[3] = {
NULL, NULL, NULL
(struct mib_node* const)&arptree_root,
(struct mib_node* const)&arptree_root,
(struct mib_node* const)&arptree_root
};
const struct mib_array_node atentry = {
&atentry_get_object_def,
&atentry_get_value,
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
3,
atentry_ids,
@ -355,14 +416,33 @@ const struct mib_array_node at = {
&at_node
};
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 };
struct mib_node* const ifentry_nodes[22] = {
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 ifentry = {
/** index root node for ifTable */
struct mib_list_rootnode iflist_root = {
&ifentry_get_object_def,
&ifentry_get_value,
MIB_NODE_LR,
0,
NULL,
NULL,
0
};
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 };
struct mib_node* const ifentry_nodes[22] = {
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root,
(struct mib_node* const)&iflist_root, (struct mib_node* const)&iflist_root
};
const struct mib_array_node ifentry = {
&noleafs_get_object_def,
&noleafs_get_value,
MIB_NODE_AR,
22,
ifentry_ids,
@ -520,7 +600,7 @@ static const struct snmp_obj_id ifspecific = {2, {0, 0}};
/** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */
static const struct snmp_obj_id iprouteinfo = {2, {0, 0}};
static struct idx_root_node arptree_root = {NULL, NULL, 0};
/* mib-2.system counter(s) */
static u32_t sysuptime = 0;
@ -782,68 +862,110 @@ void snmp_inc_ifoutdiscards(struct netif *ni)
(ni->ifoutdiscards)++;
}
void snmp_inc_iflist(void)
{
struct mib_list_node *if_node = NULL;
snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
}
void snmp_dec_iflist(void)
{
snmp_mib_node_delete(&iflist_root, iflist_root.tail);
}
/**
* Inserts ARP table indexes (.xIfIndex.xNetAddress)
* into arp table index tree.
* into arp table index trees (both atTable and ipNetToMediaTable).
*/
void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip)
{
struct idx_root_node *at_rn;
struct idx_node *at_node;
struct mib_list_rootnode *at_rn;
struct mib_list_node *at_node;
struct ip_addr hip;
s32_t arpidx[5];
u8_t level;
u8_t level, tree;
LWIP_ASSERT("ni != NULL", ni != NULL);
snmp_netiftoifindex(ni, &arpidx[0]);
hip.addr = ntohl(ip->addr);
snmp_iptooid(&hip, &arpidx[1]);
level = 0;
for (tree = 0; tree < 2; tree++)
{
if (tree == 0)
{
at_rn = &arptree_root;
while (level < 5)
}
else
{
at_rn = &ipntomtree_root;
}
for (level = 0; level < 5; level++)
{
at_node = NULL;
snmp_idx_node_insert(at_rn, arpidx[level], &at_node);
snmp_mib_node_insert(at_rn, arpidx[level], &at_node);
if ((level != 4) && (at_node != NULL))
{
if (at_node->nptr == NULL)
{
at_rn = snmp_idx_root_node_alloc();
at_node->nptr = at_rn;
at_rn = snmp_mib_lrn_alloc();
at_node->nptr = (struct mib_node*)at_rn;
if (level == 3)
{
if (tree == 0)
{
at_rn->get_object_def = atentry_get_object_def;
at_rn->get_value = atentry_get_value;
}
else
{
at_rn = at_node->nptr;
at_rn->get_object_def = ip_ntomentry_get_object_def;
at_rn->get_value = ip_ntomentry_get_value;
}
}
}
else
{
at_rn = (struct mib_list_rootnode*)at_node->nptr;
}
}
}
level++;
}
}
/**
* Removes ARP table indexes (.xIfIndex.xNetAddress)
* from arp table index tree.
* from arp table index trees.
*/
void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
{
struct idx_node *at_n, *del_n[5];
struct idx_root_node *at_rn, *next, *del_rn[5];
struct mib_list_rootnode *at_rn, *next, *del_rn[5];
struct mib_list_node *at_n, *del_n[5];
struct ip_addr hip;
s32_t arpidx[5];
u8_t fc, level, del_cnt;
u8_t fc, tree, level, del_cnt;
snmp_netiftoifindex(ni, &arpidx[0]);
hip.addr = ntohl(ip->addr);
snmp_iptooid(&hip, &arpidx[1]);
for (tree = 0; tree < 2; tree++)
{
/* mark nodes for deletion */
if (tree == 0)
{
at_rn = &arptree_root;
}
else
{
at_rn = &ipntomtree_root;
}
level = 0;
del_cnt = 0;
at_rn = &arptree_root;
while ((level < 5) && (at_rn != NULL))
{
fc = snmp_idx_node_find(at_rn, arpidx[level], &at_n);
fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n);
if (fc == 0)
{
/* arpidx[level] does not exist */
@ -855,13 +977,13 @@ void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
del_rn[del_cnt] = at_rn;
del_n[del_cnt] = at_n;
del_cnt++;
at_rn = at_n->nptr;
at_rn = (struct mib_list_rootnode*)(at_n->nptr);
}
else if (fc == 2)
{
/* reset delete (2 or more childs) */
del_cnt = 0;
at_rn = at_n->nptr;
at_rn = (struct mib_list_rootnode*)(at_n->nptr);
}
level++;
}
@ -873,11 +995,12 @@ void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
at_rn = del_rn[del_cnt];
at_n = del_n[del_cnt];
next = snmp_idx_node_delete(at_rn, at_n);
next = snmp_mib_node_delete(at_rn, at_n);
if (next != NULL)
{
LWIP_ASSERT("next_count == 0",next->count == 0);
snmp_idx_root_node_free(next);
snmp_mib_lrn_free(next);
}
}
}
}
@ -967,6 +1090,251 @@ void snmp_inc_iproutingdiscards(void)
iproutingdiscards++;
}
/**
* Inserts ipAddrTable indexes (.ipAdEntAddr)
* into index tree.
*/
void snmp_insert_ipaddridx_tree(struct netif *ni)
{
struct mib_list_rootnode *ipa_rn;
struct mib_list_node *ipa_node;
struct ip_addr ip;
s32_t ipaddridx[4];
u8_t level;
LWIP_ASSERT("ni != NULL", ni != NULL);
ip.addr = ntohl(ni->ip_addr.addr);
snmp_iptooid(&ip, &ipaddridx[0]);
level = 0;
ipa_rn = &ipaddrtree_root;
while (level < 4)
{
ipa_node = NULL;
snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node);
if ((level != 3) && (ipa_node != NULL))
{
if (ipa_node->nptr == NULL)
{
ipa_rn = snmp_mib_lrn_alloc();
ipa_node->nptr = (struct mib_node*)ipa_rn;
if (level == 2)
{
ipa_rn->get_object_def = ip_addrentry_get_object_def;
ipa_rn->get_value = ip_addrentry_get_value;
}
}
else
{
ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr;
}
}
level++;
}
}
/**
* Removes ipAddrTable indexes (.ipAdEntAddr)
* from index tree.
*/
void snmp_delete_ipaddridx_tree(struct netif *ni)
{
struct mib_list_rootnode *ipa_rn, *next, *del_rn[4];
struct mib_list_node *ipa_n, *del_n[4];
struct ip_addr ip;
s32_t ipaddridx[4];
u8_t fc, level, del_cnt;
LWIP_ASSERT("ni != NULL", ni != NULL);
ip.addr = ntohl(ni->ip_addr.addr);
snmp_iptooid(&ip, &ipaddridx[0]);
/* mark nodes for deletion */
level = 0;
del_cnt = 0;
ipa_rn = &ipaddrtree_root;
while ((level < 4) && (ipa_rn != NULL))
{
fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n);
if (fc == 0)
{
/* ipaddridx[level] does not exist */
del_cnt = 0;
ipa_rn = NULL;
}
else if (fc == 1)
{
del_rn[del_cnt] = ipa_rn;
del_n[del_cnt] = ipa_n;
del_cnt++;
ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
}
else if (fc == 2)
{
/* reset delete (2 or more childs) */
del_cnt = 0;
ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
}
level++;
}
/* delete marked index nodes */
while (del_cnt > 0)
{
del_cnt--;
ipa_rn = del_rn[del_cnt];
ipa_n = del_n[del_cnt];
next = snmp_mib_node_delete(ipa_rn, ipa_n);
if (next != NULL)
{
LWIP_ASSERT("next_count == 0",next->count == 0);
snmp_mib_lrn_free(next);
}
}
}
/**
* Inserts ipRouteTable indexes (.ipRouteDest)
* into index tree.
*
* @param dflt non-zero for the default rte, zero for network rte
* @param netif points to network interface for this rte
*/
void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
{
u8_t insert = 0;
struct ip_addr dst;
if (dflt != 0)
{
/* the default route 0.0.0.0 */
dst.addr = 0;
insert = 1;
}
else
{
/* route to the network address */
dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
/* exclude 0.0.0.0 network (reserved for default rte) */
if (dst.addr != 0) insert = 1;
}
if (insert)
{
struct mib_list_rootnode *iprte_rn;
struct mib_list_node *iprte_node;
s32_t iprteidx[4];
u8_t level;
snmp_iptooid(&dst, &iprteidx[0]);
level = 0;
iprte_rn = &iprtetree_root;
while (level < 4)
{
iprte_node = NULL;
snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node);
if ((level != 3) && (iprte_node != NULL))
{
if (iprte_node->nptr == NULL)
{
iprte_rn = snmp_mib_lrn_alloc();
iprte_node->nptr = (struct mib_node*)iprte_rn;
if (level == 2)
{
iprte_rn->get_object_def = ip_rteentry_get_object_def;
iprte_rn->get_value = ip_rteentry_get_value;
}
}
else
{
iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr;
}
}
level++;
}
}
}
/**
* Removes ipRouteTable indexes (.ipRouteDest)
* from index tree.
*
* @param dflt non-zero for the default rte, zero for network rte
* @param netif points to network interface for this rte or NULL
* for default route to be removed.
*/
void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
{
u8_t delete = 0;
struct ip_addr dst;
if (dflt != 0)
{
/* the default route 0.0.0.0 */
dst.addr = 0;
delete = 1;
}
else
{
/* route to the network address */
dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
/* exclude 0.0.0.0 network (reserved for default rte) */
if (dst.addr != 0) delete = 1;
}
if (delete)
{
struct mib_list_rootnode *iprte_rn, *next, *del_rn[4];
struct mib_list_node *iprte_n, *del_n[4];
s32_t iprteidx[4];
u8_t fc, level, del_cnt;
snmp_iptooid(&dst, &iprteidx[0]);
/* mark nodes for deletion */
level = 0;
del_cnt = 0;
iprte_rn = &iprtetree_root;
while ((level < 4) && (iprte_rn != NULL))
{
fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n);
if (fc == 0)
{
/* iprteidx[level] does not exist */
del_cnt = 0;
iprte_rn = NULL;
}
else if (fc == 1)
{
del_rn[del_cnt] = iprte_rn;
del_n[del_cnt] = iprte_n;
del_cnt++;
iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
}
else if (fc == 2)
{
/* reset delete (2 or more childs) */
del_cnt = 0;
iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
}
level++;
}
/* delete marked index nodes */
while (del_cnt > 0)
{
del_cnt--;
iprte_rn = del_rn[del_cnt];
iprte_n = del_n[del_cnt];
next = snmp_mib_node_delete(iprte_rn, iprte_n);
if (next != NULL)
{
LWIP_ASSERT("next_count == 0",next->count == 0);
snmp_mib_lrn_free(next);
}
}
}
}
void snmp_inc_icmpinmsgs(void)
{
@ -1163,6 +1531,111 @@ void snmp_inc_udpoutdatagrams(void)
udpoutdatagrams++;
}
/**
* Inserts udpTable indexes (.udpLocalAddress.udpLocalPort)
* into index tree.
*/
void snmp_insert_udpidx_tree(struct udp_pcb *pcb)
{
struct mib_list_rootnode *udp_rn;
struct mib_list_node *udp_node;
struct ip_addr ip;
s32_t udpidx[5];
u8_t level;
LWIP_ASSERT("pcb != NULL", pcb != NULL);
ip.addr = ntohl(pcb->local_ip.addr);
snmp_iptooid(&ip, &udpidx[0]);
udpidx[4] = pcb->local_port;
udp_rn = &udp_root;
for (level = 0; level < 5; level++)
{
udp_node = NULL;
snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node);
if ((level != 4) && (udp_node != NULL))
{
if (udp_node->nptr == NULL)
{
udp_rn = snmp_mib_lrn_alloc();
udp_node->nptr = (struct mib_node*)udp_rn;
if (level == 3)
{
udp_rn->get_object_def = udpentry_get_object_def;
udp_rn->get_value = udpentry_get_value;
}
}
else
{
udp_rn = (struct mib_list_rootnode*)udp_node->nptr;
}
}
}
}
/**
* Removes udpTable indexes (.udpLocalAddress.udpLocalPort)
* from index tree.
*/
void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
{
struct mib_list_rootnode *udp_rn, *next, *del_rn[5];
struct mib_list_node *udp_n, *del_n[5];
struct ip_addr ip;
s32_t udpidx[5];
u8_t fc, level, del_cnt;
LWIP_ASSERT("pcb != NULL", pcb != NULL);
ip.addr = ntohl(pcb->local_ip.addr);
snmp_iptooid(&ip, &udpidx[0]);
udpidx[4] = pcb->local_port;
/* mark nodes for deletion */
level = 0;
del_cnt = 0;
udp_rn = &udp_root;
while ((level < 5) && (udp_rn != NULL))
{
fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n);
if (fc == 0)
{
/* udpidx[level] does not exist */
del_cnt = 0;
udp_rn = NULL;
}
else if (fc == 1)
{
del_rn[del_cnt] = udp_rn;
del_n[del_cnt] = udp_n;
del_cnt++;
udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
}
else if (fc == 2)
{
/* reset delete (2 or more childs) */
del_cnt = 0;
udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
}
level++;
}
/* delete marked index nodes */
while (del_cnt > 0)
{
del_cnt--;
udp_rn = del_rn[del_cnt];
udp_n = del_n[del_cnt];
next = snmp_mib_node_delete(udp_rn, udp_n);
if (next != NULL)
{
LWIP_ASSERT("next_count == 0",next->count == 0);
snmp_mib_lrn_free(next);
}
}
}
void snmp_inc_snmpinpkts(void)
{
snmpinpkts++;
@ -1327,9 +1800,6 @@ noleafs_get_value(struct obj_def *od, u16_t len, void *value)
if (value){}
}
/**
* Returns systems object definitions.
*
@ -1452,6 +1922,7 @@ system_get_value(struct obj_def *od, u16_t len, void *value)
};
}
/**
* Returns interfaces.ifnumber object definition.
*
@ -1494,7 +1965,7 @@ interfaces_get_value(struct obj_def *od, u16_t len, void *value)
if (od->id_inst_ptr[0] == 1)
{
s32_t *sint_ptr = value;
*sint_ptr = netif_cnt;
*sint_ptr = iflist_root.count;
}
}
@ -1510,7 +1981,10 @@ ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
u8_t id;
if ((ident_len == 2) && (ident[1] > 0) && (ident[1] <= netif_cnt))
/* 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_ptr = ident;
@ -1520,6 +1994,9 @@ ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
switch (id)
{
case 1: /* ifIndex */
case 3: /* ifType */
case 4: /* ifMtu */
case 8: /* ifOperStatus */
od->instance = MIB_OBJECT_TAB;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
@ -1532,14 +2009,6 @@ ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
/** @todo this should be some sort of sizeof(struct netif.name) */
od->v_len = 2;
break;
case 3: /* ifType */
case 4: /* ifMtu */
case 8: /* ifOperStatus */
od->instance = MIB_OBJECT_TAB;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
od->v_len = sizeof(s32_t);
break;
case 5: /* ifSpeed */
case 21: /* ifOutQLen */
od->instance = MIB_OBJECT_TAB;
@ -1549,16 +2018,9 @@ ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
break;
case 6: /* ifPhysAddress */
{
struct netif *netif = netif_list;
u16_t i, ifidx;
struct netif *netif;
ifidx = ident[1] - 1;
i = 0;
while ((netif != NULL) && (i < ifidx))
{
netif = netif->next;
i++;
}
snmp_ifindextonetif(ident[1], &netif);
od->instance = MIB_OBJECT_TAB;
od->access = MIB_OBJECT_READ_ONLY;
od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
@ -1624,17 +2086,10 @@ ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
static void
ifentry_get_value(struct obj_def *od, u16_t len, void *value)
{
struct netif *netif = netif_list;
u16_t i, ifidx;
struct netif *netif;
u8_t id;
ifidx = od->id_inst_ptr[1] - 1;
i = 0;
while ((netif != NULL) && (i < ifidx))
{
netif = netif->next;
i++;
}
snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
id = od->id_inst_ptr[0];
switch (id)
{
@ -1772,26 +2227,25 @@ ifentry_get_value(struct obj_def *od, u16_t len, void *value)
* @param od points to object definition.
*
* @todo std says objects are writeable, can we ignore it?
*
* @todo the etharp_find_addr could be a lot smarter
* if our arp index tree provided pointers or index to the requested item
*/
static void
atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
if ((ident_len == 6) &&
(ident[1] > 0) && (ident[1] <= netif_cnt))
/* return to object name, adding index depth (5) */
ident_len += 5;
ident -= 5;
if (ident_len == 6)
{
struct eth_addr* ethaddr_ret;
struct ip_addr* ipaddr_ret;
struct ip_addr ip;
struct netif *netif = netif_list;
u16_t i, ifidx;
struct netif *netif;
ifidx = ident[1] - 1;
i = 0;
while ((netif != NULL) && (i < ifidx))
{
netif = netif->next;
i++;
}
snmp_ifindextonetif(ident[1], &netif);
snmp_oidtoip(&ident[2], &ip);
ip.addr = htonl(ip.addr);
@ -1876,7 +2330,6 @@ atentry_get_value(struct obj_def *od, u16_t len, void *value)
}
}
static void
ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
@ -2089,6 +2542,10 @@ ip_get_value(struct obj_def *od, u16_t len, void *value)
static void
ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
/* return to object name, adding index depth (4) */
ident_len += 4;
ident -= 4;
if (ident_len == 5)
{
struct ip_addr ip;
@ -2227,6 +2684,10 @@ ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
u8_t id;
/* return to object name, adding index depth (4) */
ident_len += 4;
ident -= 4;
if (ident_len == 5)
{
struct ip_addr dest;
@ -2457,22 +2918,18 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
static void
ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
if ((ident_len == 6) &&
(ident[1] > 0) && (ident[1] <= netif_cnt))
/* return to object name, adding index depth (5) */
ident_len += 5;
ident -= 5;
if (ident_len == 6)
{
struct eth_addr* ethaddr_ret;
struct ip_addr* ipaddr_ret;
struct ip_addr ip;
struct netif *netif = netif_list;
u16_t i, ifidx;
struct netif *netif;
ifidx = ident[1] - 1;
i = 0;
while ((netif != NULL) && (i < ifidx))
{
netif = netif->next;
i++;
}
snmp_ifindextonetif(ident[1], &netif);
snmp_oidtoip(&ident[2], &ip);
ip.addr = htonl(ip.addr);
@ -2815,6 +3272,8 @@ tcp_get_value(struct obj_def *od, u16_t len, void *value)
static void
tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
/** @todo adjust ident_len and ident after table index traversal */
if (ident_len == 11)
{
u8_t id;
@ -2828,7 +3287,7 @@ tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
rip.addr = htonl(rip.addr);
rport = ident[10];
/* @todo find matching PCB */
/** @todo find matching PCB */
od->id_inst_len = ident_len;
od->id_inst_ptr = ident;
@ -2926,6 +3385,10 @@ udp_get_value(struct obj_def *od, u16_t len, void *value)
static void
udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
{
/* return to object name, adding index depth (5) */
ident_len += 5;
ident -= 5;
if (ident_len == 6)
{
struct udp_pcb *pcb;

View File

@ -158,47 +158,51 @@ snmp_iptooid(struct ip_addr *ip, s32_t *ident)
ident[3] = trnc & 0xff;
}
struct idx_node *
snmp_idx_node_alloc(s32_t id)
struct mib_list_node *
snmp_mib_ln_alloc(s32_t id)
{
struct idx_node *in;
struct mib_list_node *ln;
in = (struct idx_node*)mem_malloc(sizeof(struct idx_node));
if (in != NULL)
ln = (struct mib_list_node *)mem_malloc(sizeof(struct mib_list_node));
if (ln != NULL)
{
in->next = NULL;
in->prev = NULL;
in->objid = id;
in->nptr = NULL;
ln->prev = NULL;
ln->next = NULL;
ln->objid = id;
ln->nptr = NULL;
}
return in;
return ln;
}
void
snmp_idx_node_free(struct idx_node *in)
snmp_mib_ln_free(struct mib_list_node *ln)
{
mem_free(in);
mem_free(ln);
}
struct idx_root_node *
snmp_idx_root_node_alloc(void)
struct mib_list_rootnode *
snmp_mib_lrn_alloc(void)
{
struct idx_root_node *irn;
struct mib_list_rootnode *lrn;
irn = (struct idx_root_node*)mem_malloc(sizeof(struct idx_root_node));
if (irn != NULL)
lrn = (struct mib_list_rootnode*)mem_malloc(sizeof(struct mib_list_rootnode));
if (lrn != NULL)
{
irn->head = NULL;
irn->tail = NULL;
irn->count = 0;
lrn->get_object_def = noleafs_get_object_def;
lrn->get_value = noleafs_get_value;
lrn->node_type = MIB_NODE_LR;
lrn->maxlength = 0;
lrn->head = NULL;
lrn->tail = NULL;
lrn->count = 0;
}
return irn;
return lrn;
}
void
snmp_idx_root_node_free(struct idx_root_node *irn)
snmp_mib_lrn_free(struct mib_list_rootnode *lrn)
{
mem_free(irn);
mem_free(lrn);
}
/**
@ -213,9 +217,9 @@ snmp_idx_root_node_free(struct idx_root_node *irn)
* @return -1 if failed, 1 if success.
*/
s8_t
snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **insn)
snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn)
{
struct idx_node *nn;
struct mib_list_node *nn;
s8_t insert;
LWIP_ASSERT("rn != NULL",rn != NULL);
@ -226,7 +230,7 @@ snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **in
{
/* empty list, add first node */
LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc empty list objid==%"S32_F"\n",objid));
nn = snmp_idx_node_alloc(objid);
nn = snmp_mib_ln_alloc(objid);
if (nn != NULL)
{
rn->head = nn;
@ -241,7 +245,7 @@ snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **in
}
else
{
struct idx_node *n;
struct mib_list_node *n;
/* at least one node is present */
n = rn->head;
while ((n != NULL) && (insert == 0))
@ -259,7 +263,7 @@ snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **in
{
/* alloc and insert at the tail */
LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins tail objid==%"S32_F"\n",objid));
nn = snmp_idx_node_alloc(objid);
nn = snmp_mib_ln_alloc(objid);
if (nn != NULL)
{
nn->next = NULL;
@ -287,7 +291,7 @@ snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **in
/* n->objid > objid */
/* alloc and insert between n->prev and n */
LWIP_DEBUGF(SNMP_MIB_DEBUG,("alloc ins n->prev, objid==%"S32_F", n\n",objid));
nn = snmp_idx_node_alloc(objid);
nn = snmp_mib_ln_alloc(objid);
if (nn != NULL)
{
if (n->prev == NULL)
@ -332,13 +336,13 @@ snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **in
* @param objid is the object sub identifier
* @param fn returns pointer to found node
* @return 0 if not found, 1 if deletable,
* 2 can't delete (2 or more children)
* 2 can't delete (2 or more children), 3 not a list_node
*/
s8_t
snmp_idx_node_find(struct idx_root_node *rn, s32_t objid, struct idx_node **fn)
snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn)
{
s8_t fc;
struct idx_node *n;
struct mib_list_node *n;
LWIP_ASSERT("rn != NULL",rn != NULL);
n = rn->head;
@ -355,7 +359,14 @@ snmp_idx_node_find(struct idx_root_node *rn, s32_t objid, struct idx_node **fn)
/* leaf, can delete node */
fc = 1;
}
else if (n->nptr->count > 1)
else
{
struct mib_list_rootnode *rn;
if (n->nptr->node_type == MIB_NODE_LR)
{
rn = (struct mib_list_rootnode *)n->nptr;
if (rn->count > 1)
{
/* can't delete node */
fc = 2;
@ -365,6 +376,13 @@ snmp_idx_node_find(struct idx_root_node *rn, s32_t objid, struct idx_node **fn)
/* count <= 1, can delete node */
fc = 1;
}
}
else
{
/* other node type */
fc = 3;
}
}
*fn = n;
return fc;
}
@ -377,16 +395,16 @@ snmp_idx_node_find(struct idx_root_node *rn, s32_t objid, struct idx_node **fn)
* @param n points to the node to delete
* @return the nptr to be freed by caller
*/
struct idx_root_node *
snmp_idx_node_delete(struct idx_root_node *rn, struct idx_node *n)
struct mib_list_rootnode *
snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n)
{
struct idx_root_node *next;
struct mib_list_rootnode *next;
LWIP_ASSERT("rn != NULL",rn != NULL);
LWIP_ASSERT("n != NULL",n != NULL);
/* caller must remove this sub-tree */
next = n->nptr;
next = (struct mib_list_rootnode*)(n->nptr);
rn->count -= 1;
if (n == rn->head)
@ -414,7 +432,7 @@ snmp_idx_node_delete(struct idx_root_node *rn, struct idx_node *n)
n->next->prev = n->prev;
}
LWIP_DEBUGF(SNMP_MIB_DEBUG,("free list objid==%"S32_F"\n",n->objid));
snmp_idx_node_free(n);
snmp_mib_ln_free(n);
return next;
}
@ -754,6 +772,10 @@ snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snm
}
}
}
else if(node_type == MIB_NODE_LR)
{
/** @todo need this for indexing tables */
}
else
{
/* unknown/unhandled node_type */

View File

@ -489,6 +489,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
}
}
pcb->local_port = port;
snmp_insert_udpidx_tree(pcb);
/* pcb not active yet? */
if (rebind == 0) {
/* place the PCB on the active list if not already there */
@ -602,6 +603,8 @@ void
udp_remove(struct udp_pcb *pcb)
{
struct udp_pcb *pcb2;
snmp_delete_udpidx_tree(pcb);
/* pcb to be removed is first in list? */
if (udp_pcbs == pcb) {
/* make list start at 2nd pcb */

View File

@ -132,8 +132,6 @@ struct netif {
extern struct netif *netif_list;
/** The default network interface. */
extern struct netif *netif_default;
/** Count of network interfaces currently in the netif_list. */
extern u16_t netif_cnt;
/* netif_init() must be called first. */
void netif_init(void);

View File

@ -35,6 +35,7 @@
#include "lwip/opt.h"
#include "lwip/netif.h"
#include "lwip/udp.h"
/* SNMP support available? */
#if defined(LWIP_SNMP) && (LWIP_SNMP > 0)
@ -58,10 +59,6 @@ void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen);
void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen);
void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen);
/* ARP */
void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip);
void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip);
/* network interface */
void snmp_add_ifinoctets(struct netif *ni, u32_t value);
void snmp_inc_ifinucastpkts(struct netif *ni);
@ -71,6 +68,12 @@ void snmp_add_ifoutoctets(struct netif *ni, u32_t value);
void snmp_inc_ifoutucastpkts(struct netif *ni);
void snmp_inc_ifoutnucastpkts(struct netif *ni);
void snmp_inc_ifoutdiscards(struct netif *ni);
void snmp_inc_iflist(void);
void snmp_dec_iflist(void);
/* ARP (for atTable and ipNetToMediaTable) */
void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip);
void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip);
/* IP */
void snmp_inc_ipinreceives(void);
@ -90,6 +93,10 @@ void snmp_inc_ipfragoks(void);
void snmp_inc_ipfragfails(void);
void snmp_inc_ipfragcreates(void);
void snmp_inc_iproutingdiscards(void);
void snmp_insert_ipaddridx_tree(struct netif *ni);
void snmp_delete_ipaddridx_tree(struct netif *ni);
void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni);
void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni);
/* ICMP */
void snmp_inc_icmpinmsgs(void);
@ -135,6 +142,8 @@ void snmp_inc_udpindatagrams(void);
void snmp_inc_udpnoports(void);
void snmp_inc_udpinerrors(void);
void snmp_inc_udpoutdatagrams(void);
void snmp_insert_udpidx_tree(struct udp_pcb *pcb);
void snmp_delete_udpidx_tree(struct udp_pcb *pcb);
/* SNMP */
void snmp_inc_snmpinpkts(void);
@ -177,10 +186,6 @@ void snmp_set_snmpenableauthentraps(u8_t *value);
#define snmp_inc_sysuptime()
#define snmp_get_sysuptime(value)
/* ARP */
#define snmp_insert_arpidx_tree(ni,ip)
#define snmp_delete_arpidx_tree(ni,ip)
/* network interface */
#define snmp_add_ifinoctets(ni,value)
#define snmp_inc_ifinucastpkts(ni)
@ -190,6 +195,12 @@ void snmp_set_snmpenableauthentraps(u8_t *value);
#define snmp_inc_ifoutucastpkts(ni)
#define snmp_inc_ifoutnucastpkts(ni)
#define snmp_inc_ifoutdiscards(ni)
#define snmp_inc_iflist()
#define snmp_dec_iflist()
/* ARP */
#define snmp_insert_arpidx_tree(ni,ip)
#define snmp_delete_arpidx_tree(ni,ip)
/* IP */
#define snmp_inc_ipinreceives()
@ -209,6 +220,10 @@ void snmp_set_snmpenableauthentraps(u8_t *value);
#define snmp_inc_ipfragfails()
#define snmp_inc_ipfragcreates()
#define snmp_inc_iproutingdiscards()
#define snmp_insert_ipaddridx_tree(ni)
#define snmp_delete_ipaddridx_tree(ni)
#define snmp_insert_iprteidx_tree(ni)
#define snmp_delete_iprteidx_tree(ni)
/* ICMP */
#define snmp_inc_icmpinmsgs()
@ -253,6 +268,8 @@ void snmp_set_snmpenableauthentraps(u8_t *value);
#define snmp_inc_udpnoports()
#define snmp_inc_udpinerrors()
#define snmp_inc_udpoutdatagrams()
#define snmp_insert_udpidx_tree(pcb)
#define snmp_delete_udpidx_tree(pcb)
/* SNMP */
#define snmp_inc_snmpinpkts()

View File

@ -105,9 +105,10 @@ struct mib_node
of sub-identifiers plus a 'child' pointer */
struct mib_array_node
{
/* inherited "base class" */
/* inherited "base class" members */
void (* const get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
void (* const get_value)(struct obj_def *od, u16_t len, void *value);
const u8_t node_type;
const u16_t maxlength;
@ -120,9 +121,10 @@ struct mib_array_node
of sub-identifiers plus a 'child' pointer */
struct mib_ram_array_node
{
/* inherited "base class" */
/* inherited "base class" members */
void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
void (*get_value)(struct obj_def *od, u16_t len, void *value);
u8_t node_type;
u16_t maxlength;
@ -143,9 +145,10 @@ struct mib_list_node
of sub-identifiers plus a 'child' pointer */
struct mib_list_rootnode
{
/* inherited "base class" */
/* inherited "base class" members */
void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
void (*get_value)(struct obj_def *od, u16_t len, void *value);
u8_t node_type;
u16_t maxlength;
@ -160,9 +163,10 @@ struct mib_list_rootnode
using index ('idx'), with a range 0 .. (count - 1) to address these objects */
struct mib_external_node
{
/* inherited "base class" */
/* inherited "base class" members */
void (*get_object_def)(u8_t ident_len, s32_t *ident, struct obj_def *od);
void (*get_value)(struct obj_def *od, u16_t len, void *value);
u8_t node_type;
u16_t maxlength;
@ -182,44 +186,23 @@ struct mib_external_node
/** export MIB tree from mib2.c */
extern const struct mib_array_node internet;
/** export for use in private mib */
/** dummy function pointers for non-leaf MIB nodes from mib2.c */
void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
/** forward decl */
struct idx_root_node;
/** "index" tree node */
struct idx_node
{
struct idx_node* next;
struct idx_node* prev;
/* child id */
s32_t objid;
/* tree child pointer */
struct idx_root_node *nptr;
};
/** "index" tree root node */
struct idx_root_node
{
struct idx_node *head;
struct idx_node *tail;
u16_t count;
};
void snmp_oidtoip(s32_t *ident, struct ip_addr *ip);
void snmp_iptooid(struct ip_addr *ip, s32_t *ident);
void snmp_ifindextonetif(s32_t ifindex, struct netif **netif);
void snmp_netiftoifindex(struct netif *netif, s32_t *ifidx);
struct idx_node* snmp_idx_node_alloc(s32_t id);
void snmp_idx_node_free(struct idx_node *in);
struct idx_root_node* snmp_idx_root_node_alloc(void);
void snmp_idx_root_node_free(struct idx_root_node *irn);
struct mib_list_node* snmp_mib_ln_alloc(s32_t id);
void snmp_mib_ln_free(struct mib_list_node *ln);
struct mib_list_rootnode* snmp_mib_lrn_alloc(void);
void snmp_mib_lrn_free(struct mib_list_rootnode *lrn);
s8_t snmp_idx_node_insert(struct idx_root_node *rn, s32_t objid, struct idx_node **insn);
s8_t snmp_idx_node_find(struct idx_root_node *rn, s32_t objid, struct idx_node **fn);
struct idx_root_node *snmp_idx_node_delete(struct idx_root_node *rn, struct idx_node *n);
s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **insn);
s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct obj_def *object_def);
struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);