$Revision: 1.15 $
Radix payload (rp) - user level functions for storing data in radix trees
rp_search = search the loaded radix trees using an ascii key
Motto: "And all that for inetnums..."
Status: NOT REVIEWED, TESTED
Design and implementation by: Marek Bukowy
Included Files
pthread_mutex_t Lock
search.
2 approaches:
1. (most modes): look up all less specifics of beginning and end of range,
compare/select/etc.
2. More spec mode: break up the query range into prefixes, [erform a search
for each of them. Add all results together.
translates a query into a binary prefix (or prefixes, if range).
for registry+space (or if they are zero, for all
registries/spaces)
finds tree
calls RX_bin_search (returning node copies).
will not put duplicate entries (composed inetnums).
returns some sort of error code :-)
Cuts the number of answers from RX_bin_search down to max_count,
but since some of the answers may have been "normalized" in the
underlying functions (multiple occurences removed),
the result is _at_most_ max_count.
appends to a given list of data blocks (not nodes!)
The EXLESS search on inetnum tree should return the shortest range
that was found, by means of comparing span (size) of the range.
If there are more of size equal to the smallest one, they are also
returned.
returns RX_OK or a code from an underlying function
er_ret_t RP_asc_search ( rx_srch_mt search_mode, int par_a, int par_b, char* key, rp_regid_t reg_id, rp_attr_t attr, GList** finallist, int max_count )
- rx_srch_mt search_mode
- &nbs;
- int par_a
- &nbs;
- int par_b
- &nbs;
- char* key
- search term: (string) prefix/range/IP
- rp_regid_t reg_id
- &nbs;
- rp_attr_t attr
- extra tree id (within the same reg/spc/fam
- GList** finallist
- answers go here, please
- int max_count
- max # of answers. RX_ALLANS == unlimited
appends the element pointed to by datref to finallist
static er_ret_t rp_asc_append_datref ( rx_datref_t* refptr, GList** finallist )
rp_asc_process_datlist() - helper for RP_asc_search()
fetches the copies of objects from the radix tree into datlist
ASSUMES LOCKED TREE
the behaviour for a default inetnum (range) query is:
do an exact match;
if it fails, do an exless match on the encompassing prefix
for routes(prefixes):
do an exless match
So if it's the default search mode on an inetnum tree,
and the key is a range,
then an exact search is performed on one of the composing prefixes.
Then the resulting data leaves are checked for exact matching with
the range queried for.
Any dataleaves that do not match are discarded, and if none are left,
the procedure falls back to searching for the encompassing prefix.
(calculated in the smart_conv routine).
Add the dataleaf copies to the list of answers,
taking span into account
static er_ret_t rp_asc_process_datlist ( rx_srch_mt search_mode, int par_a, rx_fam_t fam_id, int prefnumber, GList** datlist, ip_range_t* testrang, int* hits )
static void rp_begend_preselection ( GList** datlist, rx_fam_t fam_id, ip_range_t* testrang )
static void rp_exclude_datlink ( GList** datlist, GList* element )
static void rp_exclude_exact_match ( GList** datlist, ip_range_t* testrang )
static int rp_find_longest_prefix ( GList** datlist )
this is a helper: goes through a datlist and returns the smallest
size of a range
works for IPv4 only
static ip_rangesize_t rp_find_smallest_span ( GList* datlist )
static int rp_leaf_occ_inc ( GHashTable* hash, rx_dataleaf_t* leafptr )
helper:
this routine goes through the list of prefixes and performs a bin_search
on each of them; attaches the results to datlist.
static er_ret_t rp_preflist_search ( rx_srch_mt search_mode, int par_a, int par_b, rx_tree_t* mytree, GList** preflist, GList** datlist )
goes through datlist (list of references "datref") and add copies of
leaves referenced to the finallist
maintains its own uniqhash which holds pointers to copied dataleaves.
modifies: finallist
returns: error from wr_malloc
static er_ret_t rp_srch_copyresults ( GList* datlist, GList** finallist, int maxcount )