23 RCSID(
"$Id: efca3c5792829c563310161ae4feb280a12d3741 $")
25 #include <freeradius-devel/util/debug.h>
26 #include <freeradius-devel/util/htrie.h>
27 #include <freeradius-devel/util/table.h>
29 #define FUNC(_prefix, _op) ._op = (fr_htrie_ ##_op ## _t) fr_##_prefix##_## _op
42 FUNC(hash_table, find),
43 FUNC(hash_table, insert),
44 FUNC(hash_table, replace),
45 FUNC(hash_table, remove),
46 FUNC(hash_table,
delete),
47 FUNC(hash_table, num_elements)
65 FUNC(trie, num_elements)
110 if (!hash_data || !cmp_data) {
151 fr_assert_msg(0,
"FR_HTRIE_AUTO must be resolved to a concrete htype value using fr_htrie_hint()");
#define L(_str)
Helper for initialising arrays of string literals.
static fr_ring_buffer_t * rb
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
void * fr_hash_table_find(fr_hash_table_t *ht, void const *data)
uint32_t(* fr_hash_t)(void const *)
#define fr_hash_table_alloc(_ctx, _hash_node, _cmp_node, _free_node)
static fr_htrie_funcs_t const default_funcs[]
size_t fr_htrie_type_table_len
fr_htrie_t * fr_htrie_alloc(TALLOC_CTX *ctx, fr_htrie_type_t type, fr_hash_t hash_data, fr_cmp_t cmp_data, fr_trie_key_t get_key, fr_free_t free_data)
An abstraction over our internal hashes, rb trees, and prefix tries.
fr_table_num_sorted_t const fr_htrie_type_table[]
#define FUNC(_prefix, _op)
@ FR_HTRIE_RB
Data is stored in a rb tree.
@ FR_HTRIE_TRIE
Data is stored in a prefix trie.
@ FR_HTRIE_HASH
Data is stored in a hash.
@ FR_HTRIE_AUTO
Automatically choose the best type.
void *(* fr_htrie_find_t)(void *ht, void const *data)
void * store
What we're using to store node data.
fr_htrie_type_t type
type of the htrie
fr_htrie_find_t match
exact prefix match
fr_htrie_funcs_t funcs
Function pointers for the various operations.
Which functions are used for the different operations.
A hash/rb/prefix trie abstraction.
int8_t(* fr_cmp_t)(void const *a, void const *b)
void(* fr_free_t)(void *)
#define fr_rb_alloc(_ctx, _data_cmp, _data_free)
Allocs a red black tree.
void * fr_rb_find(fr_rb_tree_t const *tree, void const *data)
fr_aka_sim_id_type_t type
An element in a lexicographically sorted array of name to num mappings.
fr_trie_t * fr_trie_alloc(TALLOC_CTX *ctx, fr_trie_key_t get_key, fr_free_t free_data)
Allocate a trie.
int(* fr_trie_key_t)(uint8_t **out, size_t *outlen, void const *data)
void * fr_trie_match(fr_trie_t *ft, void const *data)
#define fr_strerror_const(_msg)