$Revision: 1.14 $
Radix tree (rx). rx_tree.c - functions to operate on trees
(creation/deletion/finding).
Status: NOT REVUED, TESTED, INCOMPLETE
Design and implementation by: Marek Bukowy
Included Files
- #include <include/erroutines.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <assert.h>
- #include <time.h>
- #include <stdarg.h>
- #include <strings.h>
- #include <include/bitmask.h>
- #include <include/er_aspects.h>
- #include <include/stubs.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "include/er_facilities.h"
- #include <include/iproutines.h>
- #include </space/dbdev/marek/include/glib.h>
- #include </space/dbdev/marek/lib/glib/include/glibconfig.h>
- #include <limits.h>
- #include <float.h>
- #include <stdarg.h>
- #include <include/erroutines.h>
- #include <include/memwrap.h>
- #include <include/erroutines.h>
- #include <include/rxroutines.h>
- #include <glib.h>
- #include <pthread.h>
- #include <stubs.h>
- #include <memwrap.h>
- #include <stdio.h>
- #include <iproutines.h>
- #include <include/rx_globals.h>
- #include <stddef.h>
- #include <glib.h>
- #include "include/socket.h"
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <netdb.h>
- #include <signal.h>
- #include <stdio.h>
- #include <iproutines.h>
- #include "include/thread.h"
Preprocessor definitions
#define RX_IMPL
void RX_attach2forest ( rx_tree_t* newtree )
finds a tree matching the specified criteria(registry+space+family).
MT-note: locks/unlocks forest (still to be done)
Returns: RX_OK or RX_NOTREE if no such tree can be found.
er_ret_t RX_get_tree ( rx_tree_t** treeptr, rx_regid_t reg_id, ip_space_t spc_id, rx_fam_t fam_id )
- rx_tree_t** treeptr
- answer goes here, please
- rx_regid_t reg_id
- id of the registry
- ip_space_t spc_id
- type of space (ipv4/ipv6)
- rx_fam_t fam_id
- family of objects (route/inetnum)
creates a (top) tree for the space, fills out sql table of trees
generates a tablename for a tree (if NONE)
updates LL of trees
MT-note: locks/unlocks the forest (still to be done)
er_ret_t RX_tree_cre ( rx_regid_t reg_id, ip_space_t spc_id, rx_fam_t fam_id, char* prefixstr, rx_mem_mt mem_mode, rx_subtree_mt subtrees, rx_tree_t** treestore )
- rx_regid_t reg_id
- id of the registry
- ip_space_t spc_id
- space id, one of IPv4 IPv6.
- rx_fam_t fam_id
- family of objects (route/inetnum)
- char* prefixstr
- prefix the tree will cover (string)
- rx_mem_mt mem_mode
-
- rx_subtree_mt subtrees
- one of NONE, AUTO, HAND
- rx_tree_t** treestore
-
er_ret_t RX_treecheck ( rx_tree_t* tree, int datatoo, rx_treecheck_t* errorfound, void )
int rx_check_walk_tree ( rx_node_t* node, rx_node_t* parent_node, int nodecounter, rx_treecheck_t* checkstruct )
go down the tree calling func on every node.
(func takes the node pointer and the current level)
the function is called recursively with level increased
it stops recursing when no child nodes are found or maxlevel is reached.
therefore the initial call must set level to 0.
the nodecounter increments at every node, and is the return value
of the function. So start with 0 to get the number of nodes traversed.
ERROR HANDLING IS DIFFERENT HERE!
Unlike other functions it is not the return value:
The error code from the func function IF DEFINED (== not NULL ) goes
to the variable pointed to by the last parameter.
int rx_walk_tree ( rx_node_t* node, er_ret_t (*func)(rx_node_t* node,int level,int nodecounter,void* userptr), rx_walk_mt walk_mode, int maxlevel, int level, int nodecounter, void* userptr, er_ret_t* err )