Cross reference for modules/rx/rx_node.c of index.

# File modules/rx/rx_node.c

      $Revision: 1.10 $

      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

- `#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 "include/er_facilities.h"`
    - `#include <include/erroutines.h>`
    - `#include "include/er_ER_errors.h"`
    - `#include "include/er_IP_errors.h"`
    - `#include "include/er_RX_errors.h"`
    - `#include "include/er_UT_errors.h"`
    - `#include "include/er_WH_errors.h"`
    - `#include "include/erroutines.h"`

- `#include <include/rxroutines.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 <pthread.h>`
  - `#include <stubs.h>`
  - `#include <include/memwrap.h>`
    - `#include <include/erroutines.h>`
  - `#include <stdio.h>`
  - `#include <include/iproutines.h>`
    - `#include <glib.h>`
    - `#include <include/erroutines.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"`
    - `#include <pthread.h>`

- `#include <memwrap.h>`

- `#include <stubs.h>`

- `#include <glib.h>`

- `#include <include/comparisons.h>`

## Global Function RX_asc_node()

      translates ranges/prefixes into binary prefixes.
      finds tree, locks it.
      initiates memory rollback structure (???)

      builds a dataleaf and puts into the node(s),
      calling rx_bin_node for every prefix.

      checks rollback condition and (possibly) rolls back ???

      MT-note: locks/unlocks the tree.

      Possible errors
      - all errors from:
        ip_asc_2_bin,
        rx_get_tree,
        rx_bin_node,
        wr_free

`er_ret_t RX_asc_node ( rx_oper_mt mode, char* rangstr, rx_regid_t reg_id, ip_space_t spc_id, rx_fam_t fam_id, void* data )`

`rx_oper_mt mode`
  MODE={cre|mod|del}
`char* rangstr`
  string prefix/range/IP
`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)
`void* data`
  pointer to the payload

Prototyped in: | include/rxroutines.h
Calls: | ER_dbg_va() | modules/er/er.c
| IP_addr_t2b() | modules/ip/ip.c
| IP_pref_t2b() | modules/ip/ip.c
| IP_rang_classful() | modules/ip/ip.c
| IP_rang_t2b() | modules/ip/ip.c
| RX_bin_node() | modules/rx/rx_node.c
| RX_inum_node() | modules/rx/rx_node.c
| RX_get_tree(), fprintf(), wr_calloc(), wr_free()

## Global Function RX_bin_node()

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

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

      Currently only creation is implemented.

      Add a dataleaf at 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: | include/rxroutines.h
Calls: | ER_dbg_va() | modules/er/er.c
| ER_is_traced() | modules/er/er.c
| IP_pref_b2a() | modules/ip/ip.c
| IP_pref_bit_fix() | modules/ip/ip.c
| IP_sizebits() | modules/ip/ip.c
| rx_creat_node() | modules/rx/rx_node.c
| __eprintf(), fprintf(), g_list_foreach(), g_list_length(), g_list_nth_data(), g_list_prepend(), rx_build_stack(), rx_nod_search(), wr_free(), wr_malloc()
Called by: | AC_acc_load() | modules/ac/access_control.c
| AC_commit() | modules/ac/access_control.c
| RX_asc_node() | modules/rx/rx_node.c
| RX_inum_node() | modules/rx/rx_node.c
References Functions: | rx_free_list_element() | modules/rx/rx_node.c

## Global Function RX_inum_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_inum_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: | include/rxroutines.h
Calls: | ER_dbg_va() | modules/er/er.c
| ER_is_traced() | modules/er/er.c
| IP_rang_b2a() | modules/ip/ip.c
| IP_rang_decomp() | modules/ip/ip.c
| RX_bin_node() | modules/rx/rx_node.c
| g_list_foreach(), g_list_free(), g_list_length(), g_list_nth_data()
Called by: | RX_asc_node() | modules/rx/rx_node.c
References Functions: | rx_free_list_element() | modules/rx/rx_node.c

## Global Function rx_free_list_element()

     hook for g_list_foreach to free a list element

`void rx_free_list_element ( void* cpy, void* trash )`

Prototyped in: | include/rxroutines.h
Calls: | wr_free()
Used in: | RX_bin_node() | modules/rx/rx_node.c
| RX_inum_node() | modules/rx/rx_node.c
| insert_radix_serials() | modules/qi/query_instructions.c
| write_radix_immediate() | modules/qi/query_instructions.c

## 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() | modules/er/er.c
| ER_is_traced() | modules/er/er.c
| IP_addr_bit_get() | modules/ip/ip.c
| IP_pref_bit_fix() | modules/ip/ip.c
| IP_sizebits() | modules/ip/ip.c
| fprintf(), g_list_prepend(), rx_nod_print(), wr_calloc()
Called by: | RX_bin_node() | modules/rx/rx_node.c