31RCSID(
"$Id: b095d598276c0cb09d804e6f6acd3c1ba1e7358f $")
33#define LOG_PREFIX mctx->mi->name
35#include <freeradius-devel/server/base.h>
36#include <freeradius-devel/server/module.h>
37#include <freeradius-devel/server/module_rlm.h>
38#include <freeradius-devel/unlang/xlat_func.h>
40#include <freeradius-devel/util/htrie.h>
90 { .required =
true, .single =
true, .type =
FR_TYPE_VOID },
114 if (key->type !=
in->type) {
115 RWDEBUG(
"Invalid key data type %s - expected %s",
130 pthread_mutex_lock(&
inst->mutex);
133 pthread_mutex_unlock(&
inst->mutex);
135 REDEBUG(
"Failed inserting (key=%pV, value=%pV)", key,
value);
142 (void) rlm_kv_list_insert_head(&
inst->list,
data);
150 (void) rlm_kv_list_remove(&
inst->list, old);
157 }
else if (rlm_kv_list_num_elements(&
inst->list) >=
in->max_entries) {
158 old = rlm_kv_list_pop_tail(&
inst->list);
164 pthread_mutex_unlock(&
inst->mutex);
185 if (key->type !=
in->type) {
186 RWDEBUG(
"Invalid key data type %s - expected %s",
191 pthread_mutex_lock(&
inst->mutex);
194 pthread_mutex_unlock(&
inst->mutex);
195 RDEBUG(
"Failed to find entry for key %pV", key);
205 (void) rlm_kv_list_remove(&
inst->list,
data);
206 (void) rlm_kv_list_insert_head(&
inst->list,
data);
208 pthread_mutex_unlock(&
inst->mutex);
233 if (key->type !=
in->type) {
234 RWDEBUG(
"Invalid key data type %s - expected %s",
246 pthread_mutex_lock(&
inst->mutex);
249 pthread_mutex_unlock(&
inst->mutex);
252 (void) rlm_kv_list_remove(&
inst->list,
data);
254 pthread_mutex_unlock(&
inst->mutex);
267 pthread_mutex_destroy(&mutable->mutex);
303 if (!
inst->mutable->tree)
return -1;
305 pthread_mutex_init(&
inst->mutable->mutex, NULL);
308 rlm_kv_list_init(&
inst->mutable->list);
#define CONF_PARSER_TERMINATOR
#define FR_INTEGER_BOUND_CHECK(_name, _var, _op, _bound)
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Defines a CONF_PAIR to C data type mapping.
#define cf_log_err(_cf, _fmt,...)
static int fr_dcursor_append(fr_dcursor_t *cursor, void *v)
Insert a single item at the end of the list.
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
#define FR_DLIST_TYPES(_name)
Define type specific wrapper structs for dlists.
#define FR_DLIST_FUNCS(_name, _element_type, _element_entry)
Define type specific wrapper functions for dlists.
#define FR_DLIST_TYPEDEFS(_name, _head, _entry)
Define friendly names for type specific dlist head and entry structures.
uint32_t(* fr_hash_t)(void const *)
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.
static fr_htrie_type_t fr_htrie_hint(fr_type_t type)
static int fr_htrie_replace(void **old, fr_htrie_t *ht, void const *data)
Replace data in a htrie, freeing previous data if free_data cb was passed to fr_htrie_alloc.
static void * fr_htrie_find(fr_htrie_t *ht, void const *data)
Find data in a htrie.
static void * fr_htrie_remove(fr_htrie_t *ht, void const *data)
Remove data from a htrie without freeing it.
A hash/rb/prefix trie abstraction.
@ FR_TYPE_NULL
Invalid (uninitialised) attribute type.
int8_t(* fr_cmp_t)(void const *a, void const *b)
module_instance_t const * mi
Instance of the module being instantiated.
module_instance_t * mi
Module instance to detach.
module_instance_t * mi
Instance of the module being instantiated.
Temporary structure to hold arguments for detach calls.
Temporary structure to hold arguments for instantiation calls.
xlat_t * module_rlm_xlat_register(TALLOC_CTX *ctx, module_inst_ctx_t const *mctx, char const *name, xlat_func_t func, fr_type_t return_type)
module_t common
Common fields presented by all modules.
static const conf_parser_t config[]
static int mod_detach(module_detach_ctx_t const *mctx)
static xlat_action_t kv_delete_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
Delete an entry from the KV.
char const * key_type
data type of the key
static xlat_arg_parser_t const kv_write_xlat_args[]
static int mod_bootstrap(module_inst_ctx_t const *mctx)
rlm_kv_entry_t entry
for expiration
rlm_kv_list_t list
for expiring old entries
static int mod_mutable_free(rlm_kv_mutable_t *mutable)
static xlat_arg_parser_t const kv_read_xlat_args[]
fr_htrie_t * tree
for kv stores.
pthread_mutex_t mutex
for thread locking.
fr_value_box_t key
indexed key
static xlat_action_t kv_read_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
Read an entry from the KV.
fr_value_box_t value
value to store
static const conf_parser_t module_config[]
static xlat_action_t kv_write_xlat(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
Write an entry to the KV.
static int mod_instantiate(module_inst_ctx_t const *mctx)
Mutable data structure which is shared across all threads.
CONF_SECTION * conf
Module's instance configuration.
size_t inst_size
Size of the module's instance data.
void * data
Module's instance data.
void * boot
Data allocated during the boostrap phase.
eap_aka_sim_process_conf_t * inst
eap_type_t type
The preferred EAP-Type of this instance of the EAP-SIM/AKA/AKA' state machine.
int(* fr_trie_key_t)(uint8_t **out, size_t *outlen, void const *data)
#define XLAT_ARGS(_list,...)
Populate local variables with value boxes from the input list.
unsigned int required
Argument must be present, and non-empty.
#define XLAT_ARG_PARSER_TERMINATOR
@ XLAT_ACTION_FAIL
An xlat function failed.
@ XLAT_ACTION_DONE
We're done evaluating this level of nesting.
Definition for a single argument consumend by an xlat function.
static char const * fr_type_to_str(fr_type_t type)
Return a static string containing the type name.
static fr_type_t fr_type_from_str(char const *type)
Return the constant value representing a type.
uint32_t fr_value_box_hash(fr_value_box_t const *vb)
Hash the contents of a value box.
int8_t fr_value_box_cmp(fr_value_box_t const *a, fr_value_box_t const *b)
Compare two values.
int fr_value_box_copy(TALLOC_CTX *ctx, fr_value_box_t *dst, const fr_value_box_t *src)
Copy value data verbatim duplicating any buffers.
int fr_value_box_to_key(uint8_t **out, size_t *outlen, fr_value_box_t const *value)
Get a key from a value box.
static fr_value_box_t * fr_value_box_acopy(TALLOC_CTX *ctx, fr_value_box_t const *src)
Copy an existing box, allocating a new box to hold its contents.
static size_t char ** out
module_ctx_t const * mctx
Synthesised module calling ctx.
int xlat_func_args_set(xlat_t *x, xlat_arg_parser_t const args[])
Register the arguments of an xlat.