File rx/rx_node.c

  $Revision: 1.35 $

Radix tree (rx). rx_node.c - functions to operate on nodes of the tree (creation/deletion).
Status: NOT REVUED, TESTED, INCOMPLETE
Design and implementation by: Marek Bukowy

Included Files


Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/release/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
   pm/pm_serials.c
   pm/protocol_mirror.c
   pr/properties.c
   pw/protocol_whois.c
   qc/mg_getopt.c
   qc/query_command.c
   qi/query_instructions.c
   rp/rp_convert.c
   rp/rp_load.c
   rp/rp_search.c
   rp/rp_tree.c
   rp/rp_update.c
   rx/rx_node.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

Global Function RX_in_node()

  performs the actual update for inetnums (possibly composed of many prefixes).
  Decomposes the ranges into prefixes and then falls back to rx_bin_node
  to perform changes at the nodes.

Requires/returns - practically the same as rx_bin_node.
er_ret_t RX_in_node ( rx_oper_mt mode, ip_range_t* rang, rx_tree_t* tree, rx_dataleaf_t* leafptr )
rx_oper_mt mode
MODE={cre|mod|del}
ip_range_t* rang
range of IP addresses
rx_tree_t* tree
pointer to the tree structure
rx_dataleaf_t* leafptr
dataleaf to attach at the node
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: ER_dbg_va()er/er.c
  ER_is_traced()er/er.c
  ER_perror()er/er.c
  IP_rang_b2a()ip/ip.c
  IP_rang_decomp()ip/ip.c
  rx_bin_node()rx/rx_node.c
  g_list_length(), g_list_nth_data(), wr_real_clear_list()
Called by: RP_uni_node_l()rp/rp_update.c

Global Function RX_rt_node()

er_ret_t RX_rt_node ( rx_oper_mt mode, ip_prefix_t* newpref, rx_tree_t* tree, rx_dataleaf_t* leafptr )
rx_oper_mt mode
MODE={cre|mod|del}
ip_prefix_t* newpref
prefix of the node
rx_tree_t* tree
pointer to the tree structure
rx_dataleaf_t* leafptr
dataleaf to attach at the node
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: IP_pref_2_rang()ip/ip.c
  IP_pref_b2_len()ip/ip.c
  rx_bin_node()rx/rx_node.c
Called by: RP_uni_node_l()rp/rp_update.c

Global Function rx_bin_node()

  General function to operate on dataleaves attached to a single node
  (create / modify / delete).

searches tree, finds and creates/deletes a node, copies modified nodes to disk using rx_sql_node_set (not yet implemented). Updates memory rollback info.



creation: Add a dataleaf at the node defined by prefix. Create a new node if it doesn't exist yet.

MT notes: requires the tree to be locked.
Returns: RX_OK or error code.
Errors from: rx_bin_search, memory alloc routines.
- no such node (if not in create mode)
- too many nodes found (strange).
er_ret_t rx_bin_node ( rx_oper_mt mode, ip_prefix_t* newpref, rx_tree_t* tree, rx_dataleaf_t* dataleaf )
rx_oper_mt mode
MODE={cre|mod|del}
ip_prefix_t* newpref
prefix of the node
rx_tree_t* tree
pointer to the tree structure
rx_dataleaf_t* dataleaf
dataleaf to attach at the node
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: ER_dbg_va()er/er.c
  ER_is_traced()er/er.c
  IP_pref_b2a()ip/ip.c
  IP_pref_bit_fix()ip/ip.c
  IP_sizebits()ip/ip.c
  rx_creat_node()rx/rx_node.c
  rx_delete_node()rx/rx_node.c
  __eprintf(), fprintf(), g_list_length(), g_list_nth_data(), g_list_prepend(), rx_build_stack(), rx_nod_search(), wr_real_clear_list()
Called by: AC_acc_load()ac/access_control.c
  AC_findcreate_account_l()ac/access_control.c
  AC_findcreate_acl_l()ac/access_control.c
  AC_persistence_load()ac/ac_persistence.c
  AC_prune()ac/access_control.c
  RX_in_node()rx/rx_node.c
  RX_rt_node()rx/rx_node.c

Global Function rx_delete_node()

 an auxiliary function to delete data from a node 
 (and delete the node or turn it into a glue afterwards)

takes
tree tree curnode pointer to the node dataleaf pointer to a dataleaf with ObjectID (dataleaf->data_key) set; which is used to choose the right dataleaf when browsing data leaves. It is never assumed to be allocated via malloc, can be a local variable as well.
If the composed flag of the dataleaf in the tree (being the reference count at the same time) is non zero, decrements the count. Deletes the dataleaf when it reaches zero.
suceeds always or dies when dataleaf with such data cannot be found in the node
RX_FAM_IP implies there's no dataleaf!!! The structure in place of a dataleaf is payload
void rx_delete_node ( rx_tree_t* tree, rx_node_t* curnode, rx_dataleaf_t* dataleaf )
Calls: ER_dbg_va()er/er.c
  UT_free_real(), __eprintf(), fprintf(), g_list_first(), g_list_remove()
Called by: rx_bin_node()rx/rx_node.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function rx_creat_node()

  rx_creat_node = create a new data node 
  (empty{glue} nodes get created automatically).

Takes a pointer to the (already allocated) data leaf to be included in the list of data nodes (presumably empty as the node is only now being created).
Requires a stack of nodes created in CREAT mode (with glue nodes, until deep enough and the last node being non-glue).
MT notes: requires the tree to be locked.
Returns: RX_OK or error code.
static er_ret_t rx_creat_node ( ip_prefix_t* newpref, rx_tree_t* tree, rx_dataleaf_t* dataleaf, rx_nodcpy_t stack[], int stackdepth )
ip_prefix_t* newpref
prefix of the node to be added
rx_tree_t* tree
tree the new node goes to
rx_dataleaf_t* dataleaf
dataleaf to attach at this node
rx_nodcpy_t stack[]
stack==array of node_copies
int stackdepth
length of the stack
Calls: ER_dbg_va()er/er.c
  ER_is_traced()er/er.c
  IP_addr_bit_get()ip/ip.c
  IP_pref_bit_fix()ip/ip.c
  IP_sizebits()ip/ip.c
  UT_calloc_real(), fprintf(), g_list_prepend(), rx_nod_print()
Called by: rx_bin_node()rx/rx_node.c

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()