The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Structures and prototypes for maps. More...
#include <freeradius-devel/server/cf_util.h>
#include <freeradius-devel/server/tmpl.h>
#include <freeradius-devel/util/dlist.h>
Go to the source code of this file.
Data Structures | |
struct | map_s |
Value pair map. More... | |
struct | vp_list_mod_s |
A list modification. More... | |
Macros | |
#define | MAP_LHS_TERMINALS |
Single character tokens used as terminals for the LHS operand. More... | |
#define | MAP_VERIFY(_x) fr_assert((_x)->lhs) |
Typedefs | |
typedef struct map_s | map_t |
typedef int(* | map_validate_t) (map_t *map, void *ctx) |
typedef int(* | radius_map_getvalue_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx) |
typedef struct vp_list_mod_s | vp_list_mod_t |
Functions | |
typedef | FR_DLIST_HEAD (map_list) map_list_t |
Given these are used in so many places, it's more friendly to have a proper type. More... | |
int | map_afrom_attr_str (TALLOC_CTX *ctx, map_t **out, char const *raw, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules) |
Convert a value pair string to valuepair map. More... | |
int | map_afrom_cp (TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, bool edit) |
Convert CONFIG_PAIR (which may contain refs) to map_t. More... | |
int | map_afrom_cs (TALLOC_CTX *ctx, map_list_t *out, CONF_SECTION *cs, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, map_validate_t validate, void *uctx, unsigned int max)) |
Convert a config section into an attribute map. More... | |
int | map_afrom_cs_edit (TALLOC_CTX *ctx, map_list_t *out, CONF_SECTION *cs, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, map_validate_t validate, void *uctx, unsigned int max)) |
Convert a config section into an attribute map for editing. More... | |
int | map_afrom_fields (TALLOC_CTX *ctx, map_t **out, map_t **parent_p, request_t *request, char const *lhs, char const *op, char const *rhs, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules) |
Convert a fr_pair_t into a map. More... | |
ssize_t | map_afrom_substr (TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuff_t *in, fr_table_num_sorted_t const *op_table, size_t op_table_len, tmpl_rules_t const *lhs_rules, tmpl_rules_t const *rhs_rules, fr_sbuff_parse_rules_t const *p_rules) |
Parse sbuff into (which may contain refs) to map_t. More... | |
int | map_afrom_value_box (TALLOC_CTX *ctx, map_t **out, char const *lhs, fr_token_t lhs_type, tmpl_rules_t const *lhs_rules, fr_token_t op, fr_value_box_t *rhs, bool steal_rhs_buffs) |
Convert a value box to a map. More... | |
int | map_afrom_vp (TALLOC_CTX *ctx, map_t **out, fr_pair_t *vp, tmpl_rules_t const *rules) |
Convert a fr_pair_t into a map. More... | |
void | map_debug_log (request_t *request, map_t const *map, fr_pair_t const *vp)) |
int | map_list_afrom_cs (TALLOC_CTX *ctx, map_list_t *out, CONF_SECTION *cs, tmpl_rules_t const *t_rules, map_validate_t validate, void *uctx, unsigned int max) |
Convert a config section into a list of { a, b, c, d, ... More... | |
int | map_list_mod_apply (request_t *request, vp_list_mod_t const *vlm) |
Apply the output of map_to_list_mod to a request. More... | |
ssize_t | map_print (fr_sbuff_t *out, map_t const *map) |
Print a map to a string. More... | |
int | map_to_list_mod (TALLOC_CTX *ctx, vp_list_mod_t **out, request_t *request, map_t const *map, fr_value_box_list_t *lhs_result, fr_value_box_list_t *rhs_result) |
Evaluate a map creating a new map with TMPL_TYPE_ATTR LHS and TMPL_TYPE_DATA RHS. More... | |
int | map_to_request (request_t *request, map_t const *map, radius_map_getvalue_t func, void *ctx) |
Convert map_t to fr_pair_t (s) and add them to a request_t. More... | |
int | map_to_vp (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx)) |
Variables | |
fr_table_num_sorted_t const | map_assignment_op_table [] |
size_t | map_assignment_op_table_len |
fr_sbuff_parse_rules_t const | map_parse_rules_bareword_quoted |
fr_sbuff_parse_rules_t const * | map_parse_rules_quoted [T_TOKEN_LAST] |
Structures and prototypes for maps.
Definition in file map.h.
struct vp_list_mod_s |
Data Fields | ||
---|---|---|
fr_dlist_t | entry | Entry into dlist. |
map_t const * | map | Original map describing the change to be made. |
map_list_t | mod | New map containing the destination (LHS) and values (RHS). |
#define MAP_LHS_TERMINALS |
typedef int(* radius_map_getvalue_t) (TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *request, map_t const *map, void *uctx) |
typedef struct vp_list_mod_s vp_list_mod_t |
typedef FR_DLIST_HEAD | ( | map_list | ) |
Given these are used in so many places, it's more friendly to have a proper type.
int map_afrom_attr_str | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
char const * | vp_str, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | rhs_rules | ||
) |
Convert a value pair string to valuepair map.
Takes a valuepair string with list and request qualifiers and converts it into a map_t.
Attribute string is in the format (where
<qu>
is a quotation char ['"]):
[<list>.][<qu>]<attribute>[<qu>] <op> [<qu>]<value>[<qu>]
[in] | ctx | where to allocate the map. |
[out] | out | Where to write the new map. |
[in] | vp_str | string to parse. |
[in] | lhs_rules | rules for parsing LHS attribute references. |
[in] | rhs_rules | rules for parsing RHS attribute references. |
Definition at line 1319 of file map.c.
int map_afrom_cp | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
map_t * | parent, | ||
CONF_PAIR * | cp, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | input_rhs_rules, | ||
bool | edit | ||
) |
Convert CONFIG_PAIR (which may contain refs) to map_t.
Treats the left operand as an attribute reference
<request>.<list>.<attribute>
Treatment of left operand depends on quotation, barewords are treated as attribute references, double quoted values are treated as expandable strings, single quoted values are treated as literal strings.
Return must be freed with talloc_free
[in] | ctx | for talloc. |
[in] | out | Where to write the pointer to the new map_t. |
[in] | parent | the parent map |
[in] | cp | to convert to map. |
[in] | lhs_rules | rules for parsing LHS attribute references. |
[in] | input_rhs_rules | rules for parsing RHS attribute references. |
[in] | edit | treat the map as an edit |
Definition at line 109 of file map.c.
int map_afrom_cs | ( | TALLOC_CTX * | ctx, |
map_list_t * | out, | ||
CONF_SECTION * | cs, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | rhs_rules, | ||
map_validate_t | validate, | ||
void * | uctx, | ||
unsigned int | max | ||
) |
Convert a config section into an attribute map.
For "update" sections, Uses 'name2' of section to set default request and lists.
[in] | ctx | for talloc. |
[out] | out | Where to store the allocated map. |
[in] | cs | the update section |
[in] | lhs_rules | rules for parsing LHS attribute references. |
[in] | rhs_rules | rules for parsing RHS attribute references. |
[in] | validate | map using this callback (may be NULL). |
[in] | uctx | to pass to callback. |
[in] | max | number of mappings to process. |
Definition at line 1014 of file map.c.
int map_afrom_cs_edit | ( | TALLOC_CTX * | ctx, |
map_list_t * | out, | ||
CONF_SECTION * | cs, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | rhs_rules, | ||
map_validate_t | validate, | ||
void * | uctx, | ||
unsigned int | max | ||
) |
Convert a config section into an attribute map for editing.
[in] | ctx | for talloc. |
[out] | out | Where to store the allocated map. |
[in] | cs | the update section |
[in] | lhs_rules | rules for parsing LHS attribute references. |
[in] | rhs_rules | rules for parsing RHS attribute references. |
[in] | validate | map using this callback (may be NULL). |
[in] | uctx | to pass to callback. |
[in] | max | number of mappings to process. |
Definition at line 1045 of file map.c.
int map_afrom_fields | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
map_t ** | parent_p, | ||
request_t * | request, | ||
char const * | lhs, | ||
char const * | op_str, | ||
char const * | rhs, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | rhs_rules | ||
) |
Convert a fr_pair_t into a map.
[in] | ctx | where to allocate the map. |
[out] | out | Where to write the new map (must be freed with talloc_free()). |
[in,out] | parent_p | the parent map, updated for relative maps |
[in] | request | the request |
[in] | lhs | of map |
[in] | op_str | operator for map |
[in] | rhs | of map |
[in] | lhs_rules | for parsing the LHS |
[in] | rhs_rules | for parsing the RHS |
Definition at line 2439 of file map.c.
ssize_t map_afrom_substr | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
map_t ** | parent_p, | ||
fr_sbuff_t * | in, | ||
fr_table_num_sorted_t const * | op_table, | ||
size_t | op_table_len, | ||
tmpl_rules_t const * | lhs_rules, | ||
tmpl_rules_t const * | rhs_rules, | ||
fr_sbuff_parse_rules_t const * | p_rules | ||
) |
Parse sbuff into (which may contain refs) to map_t.
This function uses the legacy operator meanings. The maps created here should only be used with radius_legacy_map_cmp() and radius_legacy_map_apply()
The left operand MUST be an attribute reference
<request>.<list>.<attribute>
The op_table should be #cond_cmp_op_table for check items, and map_assignment_op_table for reply items.
Return must be freed with talloc_free
[in] | ctx | for talloc. |
[in] | out | Where to write the pointer to the new map_t. |
[in,out] | parent_p | the parent map, updated for relative maps |
[in] | in | the data to parse for creating the map. |
[in] | op_table | for lhs OP rhs |
[in] | op_table_len | length of op_table |
[in] | lhs_rules | rules for parsing LHS attribute references. |
[in] | rhs_rules | rules for parsing RHS attribute references. |
[in] | p_rules | a list of terminals which will stop string parsing. |
Definition at line 427 of file map.c.
int map_afrom_value_box | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
char const * | lhs, | ||
fr_token_t | lhs_quote, | ||
tmpl_rules_t const * | lhs_rules, | ||
fr_token_t | op, | ||
fr_value_box_t * | rhs, | ||
bool | steal_rhs_buffs | ||
) |
Convert a value box to a map.
This is mainly used in IO modules, where another function is used to convert between the foreign value type and internal values, and the destination attribute is provided as a string.
[in] | ctx | for talloc |
[out] | out | Where to store the head of the map. |
[in] | lhs | of the operation |
[in] | lhs_quote | type of the LHS string |
[in] | lhs_rules | rules that control parsing of the LHS string. |
[in] | op | the operation to perform |
[in] | rhs | of the operation |
[in] | steal_rhs_buffs | Whether we attempt to save allocs by stealing the buffers from the rhs fr_value_box_t. |
Definition at line 1269 of file map.c.
int map_afrom_vp | ( | TALLOC_CTX * | ctx, |
map_t ** | out, | ||
fr_pair_t * | vp, | ||
tmpl_rules_t const * | rules | ||
) |
Convert a fr_pair_t into a map.
[in] | ctx | where to allocate the map. |
[out] | out | Where to write the new map (must be freed with talloc_free()). |
[in] | vp | to convert. |
[in] | rules | to insert attributes into. |
Definition at line 1350 of file map.c.
int map_list_afrom_cs | ( | TALLOC_CTX * | ctx, |
map_list_t * | out, | ||
CONF_SECTION * | cs, | ||
tmpl_rules_t const * | t_rules, | ||
map_validate_t | validate, | ||
void * | uctx, | ||
unsigned int | max | ||
) |
Convert a config section into a list of { a, b, c, d, ...
}
[in] | ctx | for talloc. |
[out] | out | Where to store the allocated map. |
[in] | cs | the update section |
[in] | t_rules | rules for parsing the data. |
[in] | validate | map using this callback (may be NULL). |
[in] | uctx | to pass to callback. |
[in] | max | number of mappings to process. |
Definition at line 1238 of file map.c.
int map_list_mod_apply | ( | request_t * | request, |
vp_list_mod_t const * | vlm | ||
) |
Apply the output of map_to_list_mod to a request.
request | to modify. |
vlm | VP List Modification to apply. |
Definition at line 922 of file map_async.c.
ssize_t map_print | ( | fr_sbuff_t * | out, |
map_t const * | map | ||
) |
Print a map to a string.
[out] | out | Buffer to write string to. |
[in] | map | to print. |
Definition at line 2295 of file map.c.
int map_to_list_mod | ( | TALLOC_CTX * | ctx, |
vp_list_mod_t ** | out, | ||
request_t * | request, | ||
map_t const * | original, | ||
fr_value_box_list_t * | lhs_result, | ||
fr_value_box_list_t * | rhs_result | ||
) |
Evaluate a map creating a new map with TMPL_TYPE_ATTR LHS and TMPL_TYPE_DATA RHS.
This function creates maps for consumption by map_to_request.
[in,out] | ctx | to allocate modification maps in. |
[out] | out | Where to write the fr_pair_t (s), which may be NULL if not found |
[in] | request | The current request. |
[in] | original | the map. The LHS (dst) has to be TMPL_TYPE_ATTR. |
[in] | lhs_result | of previous stack based rhs evaluation. Must be provided for rhs types:
|
[in] | rhs_result | of previous stack based rhs evaluation. Must be provided for rhs types:
|
Definition at line 251 of file map_async.c.
int map_to_request | ( | request_t * | request, |
map_t const * | map, | ||
radius_map_getvalue_t | func, | ||
void * | ctx | ||
) |
Convert map_t to fr_pair_t (s) and add them to a request_t.
Takes a single map_t, resolves request and list identifiers to pointers in the current request, then attempts to retrieve module specific value(s) using callback, and adds the resulting values to the correct request/list.
request | The current request. |
map | specifying destination attribute and location and src identifier. |
func | to retrieve module specific values and convert them to fr_pair_t. |
ctx | to be passed to func. |
Definition at line 1781 of file map.c.
int map_to_vp | ( | TALLOC_CTX * | ctx, |
fr_pair_list_t * | out, | ||
request_t * | request, | ||
map_t const * | map, | ||
void * | uctx | ||
) |
|
extern |
|
extern |
|
extern |