The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions | Variables
rlm_csv.c File Reference

Read and map CSV files. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/util/htrie.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/server/map_proc.h>
+ Include dependency graph for rlm_csv.c:

Go to the source code of this file.

Data Structures

struct  rlm_csv_entry_s
 
struct  rlm_csv_t
 

Macros

#define CSV_MAX_ATTRMAP   (128)
 

Typedefs

typedef struct rlm_csv_entry_s rlm_csv_entry_t
 

Functions

static bool buf2entry (rlm_csv_t *inst, char *buf, char **out)
 
static int8_t csv_cmp (void const *one, void const *two)
 
static uint32_t csv_hash (void const *data)
 
static int csv_map_getvalue (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)
 
static int csv_map_verify (map_t *map, void *instance)
 
static int csv_maps_verify (CONF_SECTION *cs, void const *mod_inst, UNUSED void *proc_inst, tmpl_t const *src, map_list_t const *maps)
 
static int csv_to_key (uint8_t **out, size_t *outlen, void const *data)
 
static bool duplicate_entry (CONF_SECTION *conf, rlm_csv_t *inst, rlm_csv_entry_t *old, char *p, int lineno)
 
static int fieldname2offset (rlm_csv_t const *inst, char const *field_name, int *array_offset)
 
static bool file2csv (CONF_SECTION *conf, rlm_csv_t *inst, int lineno, char *buffer)
 
static bool insert_entry (CONF_SECTION *conf, rlm_csv_t *inst, rlm_csv_entry_t *e, int lineno)
 
static int mod_bootstrap (module_inst_ctx_t const *mctx)
 
static int mod_instantiate (module_inst_ctx_t const *mctx)
 Instantiate the module. More...
 
static rlm_rcode_t mod_map_apply (rlm_csv_t const *inst, request_t *request, fr_value_box_t const *key, map_list_t const *maps)
 Perform a search and map the result of the search to server attributes. More...
 
static unlang_action_t mod_map_proc (rlm_rcode_t *p_result, void const *mod_inst, UNUSED void *proc_inst, request_t *request, fr_value_box_list_t *key, map_list_t const *maps)
 Perform a search and map the result of the search to server attributes. More...
 
static unlang_action_t mod_process (rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
 

Variables

static const conf_parser_t module_config []
 
module_rlm_t rlm_csv
 

Detailed Description

Read and map CSV files.

Id
853bde97c05416d2b4df74c6f09b3a019a81517e

Definition in file rlm_csv.c.


Data Structure Documentation

◆ rlm_csv_entry_s

struct rlm_csv_entry_s

Definition at line 71 of file rlm_csv.c.

+ Collaboration diagram for rlm_csv_entry_s:
Data Fields
char * data[]
fr_value_box_t * key
rlm_csv_entry_t * next
fr_rb_node_t node

◆ rlm_csv_t

struct rlm_csv_t

Definition at line 44 of file rlm_csv.c.

+ Collaboration diagram for rlm_csv_t:
Data Fields
bool allow_multiple_keys
char const * delimiter
char const ** field_names
int * field_offsets
fr_type_t * field_types
char const * fields
char const * filename
bool header
int index_field
char const * index_field_name
tmpl_t * key
fr_type_t key_data_type
map_list_t map if there is an "update" section in the configuration.
bool multiple_index_fields
int num_fields
fr_rb_tree_t * tree
fr_htrie_t * trie
int used_fields

Macro Definition Documentation

◆ CSV_MAX_ATTRMAP

#define CSV_MAX_ATTRMAP   (128)

Definition at line 386 of file rlm_csv.c.

Typedef Documentation

◆ rlm_csv_entry_t

Definition at line 34 of file rlm_csv.c.

Function Documentation

◆ buf2entry()

static bool buf2entry ( rlm_csv_t inst,
char *  buf,
char **  out 
)
static

Definition at line 95 of file rlm_csv.c.

+ Here is the caller graph for this function:

◆ csv_cmp()

static int8_t csv_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 164 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ csv_hash()

static uint32_t csv_hash ( void const *  data)
static

Definition at line 172 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ csv_map_getvalue()

static int csv_map_getvalue ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
request_t request,
map_t const *  map,
void *  uctx 
)
static

Definition at line 840 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ csv_map_verify()

static int csv_map_verify ( map_t map,
void *  instance 
)
static

Definition at line 391 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ csv_maps_verify()

static int csv_maps_verify ( CONF_SECTION cs,
void const *  mod_inst,
UNUSED void *  proc_inst,
tmpl_t const *  src,
map_list_t const *  maps 
)
static

Definition at line 484 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ csv_to_key()

static int csv_to_key ( uint8_t **  out,
size_t outlen,
void const *  data 
)
static

Definition at line 179 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate_entry()

static bool duplicate_entry ( CONF_SECTION conf,
rlm_csv_t inst,
rlm_csv_entry_t old,
char *  p,
int  lineno 
)
static

Definition at line 222 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fieldname2offset()

static int fieldname2offset ( rlm_csv_t const *  inst,
char const *  field_name,
int *  array_offset 
)
static

Definition at line 366 of file rlm_csv.c.

+ Here is the caller graph for this function:

◆ file2csv()

static bool file2csv ( CONF_SECTION conf,
rlm_csv_t inst,
int  lineno,
char *  buffer 
)
static

Definition at line 256 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert_entry()

static bool insert_entry ( CONF_SECTION conf,
rlm_csv_t inst,
rlm_csv_entry_t e,
int  lineno 
)
static

Definition at line 188 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 515 of file rlm_csv.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Instantiate the module.

Creates a new instance of the module reading parameters from a configuration section.

Parameters
[in]mctxconfiguration data.
Returns
  • 0 on success.
  • < 0 on failure.

Definition at line 754 of file rlm_csv.c.

+ Here is the call graph for this function:

◆ mod_map_apply()

static rlm_rcode_t mod_map_apply ( rlm_csv_t const *  inst,
request_t request,
fr_value_box_t const *  key,
map_list_t const *  maps 
)
static

Perform a search and map the result of the search to server attributes.

Parameters
[in]instrlm_csv_t.
[in,out]requestThe current request.
[in]keykey to look for
[in]mapsHead of the map list.
Returns

Definition at line 898 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_map_proc()

static unlang_action_t mod_map_proc ( rlm_rcode_t p_result,
void const *  mod_inst,
UNUSED void *  proc_inst,
request_t request,
fr_value_box_list_t *  key,
map_list_t const *  maps 
)
static

Perform a search and map the result of the search to server attributes.

Parameters
[out]p_resultResult of applying map:
[in]mod_instrlm_csv_t.
[in]proc_instmapping map entries to field numbers.
[in,out]requestThe current request.
[in]keykey to look for
[in]mapsHead of the map list.
Returns
UNLANG_ACTION_CALCULATE_RESULT

Definition at line 978 of file rlm_csv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_process()

static unlang_action_t mod_process ( rlm_rcode_t p_result,
module_ctx_t const *  mctx,
request_t request 
)
static

Definition at line 1003 of file rlm_csv.c.

+ Here is the call graph for this function:

Variable Documentation

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET_FLAGS("delimiter", CONF_FLAG_NOT_EMPTY, rlm_csv_t, delimiter), .dflt = "," },
{ FR_CONF_OFFSET("fields", rlm_csv_t, fields) },
{ FR_CONF_OFFSET("header", rlm_csv_t, header) },
{ FR_CONF_OFFSET("allow_multiple_keys", rlm_csv_t, allow_multiple_keys) },
{ FR_CONF_OFFSET_FLAGS("index_field", CONF_FLAG_REQUIRED | CONF_FLAG_NOT_EMPTY, rlm_csv_t, index_field_name) },
{ FR_CONF_OFFSET("key", rlm_csv_t, key) },
}
#define CONF_PARSER_TERMINATOR
Definition: cf_parse.h:627
#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
Definition: cf_parse.h:268
#define FR_CONF_OFFSET_FLAGS(_name, _flags, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
Definition: cf_parse.h:256
@ CONF_FLAG_REQUIRED
Error out if no matching CONF_PAIR is found, and no dflt value is set.
Definition: cf_parse.h:405
@ CONF_FLAG_FILE_INPUT
File matching value must exist, and must be readable.
Definition: cf_parse.h:411
@ CONF_FLAG_NOT_EMPTY
CONF_PAIR is required to have a non zero length value.
Definition: cf_parse.h:420

Definition at line 81 of file rlm_csv.c.

◆ rlm_csv

module_rlm_t rlm_csv
Initial value:
= {
.common = {
.name = "csv",
.inst_size = sizeof(rlm_csv_t),
.bootstrap = mod_bootstrap,
},
.method_group = {
.bindings = (module_method_binding_t[]){
{ .section = SECTION_NAME(CF_IDENT_ANY, CF_IDENT_ANY), .method = mod_process },
}
}
}
#define CF_IDENT_ANY
Definition: cf_util.h:78
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition: dl_module.h:63
static const conf_parser_t config[]
Definition: base.c:183
static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
Definition: rlm_csv.c:1003
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition: rlm_csv.c:515
static const conf_parser_t module_config[]
Definition: rlm_csv.c:81
static int mod_instantiate(module_inst_ctx_t const *mctx)
Instantiate the module.
Definition: rlm_csv.c:754
static int instantiate(module_inst_ctx_t const *mctx)
Definition: rlm_rest.c:1302
#define SECTION_NAME(_name1, _name2)
Define a section name consisting of a verb and a noun.
Definition: section.h:40
@ MODULE_TYPE_DYNAMIC_UNSAFE
Instances of this module cannot be created at runtime.
Definition: module.h:52
#define MODULE_BINDING_TERMINATOR
Terminate a module binding list.
Definition: module.h:151
Named methods exported by a module.
Definition: module.h:173

Definition at line 1051 of file rlm_csv.c.