Structures and prototypes for maps. More...
#include <freeradius-devel/conffile.h>
#include <freeradius-devel/tmpl.h>
Go to the source code of this file.
Data Structures | |
struct | vp_map |
Value pair map. More... | |
Macros | |
#define | VERIFY_MAP(_x) rad_assert((_x)->lhs) |
Typedefs | |
typedef int(* | map_validate_t )(vp_map_t *map, void *ctx) |
typedef int(* | radius_map_getvalue_t )(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx) |
typedef struct vp_map | vp_map_t |
Value pair map. More... | |
Functions | |
int int | map_afrom_attr_str (TALLOC_CTX *ctx, vp_map_t **out, char const *raw, request_refs_t dst_request_def, pair_lists_t dst_list_def, request_refs_t src_request_def, pair_lists_t src_list_def) |
Convert a value pair string to valuepair map. More... | |
int | map_afrom_cp (TALLOC_CTX *ctx, vp_map_t **out, CONF_PAIR *cp, request_refs_t dst_request_def, pair_lists_t dst_list_def, request_refs_t src_request_def, pair_lists_t src_list_def) |
Convert CONFIG_PAIR (which may contain refs) to vp_map_t. More... | |
int | map_afrom_cs (vp_map_t **out, CONF_SECTION *cs, pair_lists_t dst_list_def, pair_lists_t src_list_def, map_validate_t validate, void *ctx, unsigned int max) CC_HINT(nonnull(1 |
int | map_afrom_fields (TALLOC_CTX *ctx, vp_map_t **out, char const *lhs, FR_TOKEN lhs_type, FR_TOKEN op, char const *rhs, FR_TOKEN rhs_type, request_refs_t dst_request_def, pair_lists_t dst_list_def, request_refs_t src_request_def, pair_lists_t src_list_def) |
Convert strings to vp_map_t. More... | |
void bool | map_cast_from_hex (vp_map_t *map, FR_TOKEN rhs_type, char const *rhs) |
re-parse a map where the lhs is an unknown attribute. More... | |
int8_t | map_cmp_by_lhs_attr (void const *a, void const *b) |
Compare map where LHS is TMPL_TYPE_ATTR. More... | |
void | map_debug_log (REQUEST *request, vp_map_t const *map, VALUE_PAIR const *vp) CC_HINT(nonnull(1 |
bool | map_dst_valid (REQUEST *request, vp_map_t const *map) |
Check whether the destination of a map is currently valid. More... | |
size_t | map_snprint (char *out, size_t outlen, vp_map_t const *map) |
Print a map to a string. More... | |
void | map_sort (vp_map_t **maps, fr_cmp_t cmp) |
Sort a linked list of vp_map_t using merge sort. More... | |
int int | map_to_request (REQUEST *request, vp_map_t const *map, radius_map_getvalue_t func, void *ctx) |
Convert vp_map_t to VALUE_PAIR (s) and add them to a REQUEST. More... | |
int | map_to_vp (TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx) CC_HINT(nonnull(2 |
Structures and prototypes for maps.
Definition in file map.h.
struct vp_map |
Value pair map.
Value pair maps contain a pair of templates, that describe a src attribute or value, and a destination attribute.
Neither src or dst need to be an FR attribute, and their type can be inferred from whether map->da is NULL (not FR).
Data Fields | ||
---|---|---|
CONF_ITEM * | ci |
Config item that the map was created from. Mainly used for logging validation errors. |
vp_tmpl_t * | lhs | Typically describes the attribute to add, modify or compare. |
struct vp_map * | next | The next valuepair map. |
FR_TOKEN | op | The operator that controls insertion of the dst attribute. |
vp_tmpl_t * | rhs | Typically describes a literal value or a src attribute to copy or compare. |
#define VERIFY_MAP | ( | _x | ) | rad_assert((_x)->lhs) |
typedef int(* radius_map_getvalue_t)(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx) |
Value pair map.
Value pair maps contain a pair of templates, that describe a src attribute or value, and a destination attribute.
Neither src or dst need to be an FR attribute, and their type can be inferred from whether map->da is NULL (not FR).
int int map_afrom_attr_str | ( | TALLOC_CTX * | ctx, |
vp_map_t ** | out, | ||
char const * | vp_str, | ||
request_refs_t | dst_request_def, | ||
pair_lists_t | dst_list_def, | ||
request_refs_t | src_request_def, | ||
pair_lists_t | src_list_def | ||
) |
Convert a value pair string to valuepair map.
Takes a valuepair string with list and request qualifiers and converts it into a vp_map_t.
ctx | where to allocate the map. |
out | Where to write the new map (must be freed with talloc_free()). |
vp_str | string to parse. |
dst_request_def | to use if attribute isn't qualified. |
dst_list_def | to use if attribute isn't qualified. |
src_request_def | to use if attribute isn't qualified. |
src_list_def | to use if attribute isn't qualified. |
Definition at line 487 of file map.c.
int map_afrom_cp | ( | TALLOC_CTX * | ctx, |
vp_map_t ** | out, | ||
CONF_PAIR * | cp, | ||
request_refs_t | dst_request_def, | ||
pair_lists_t | dst_list_def, | ||
request_refs_t | src_request_def, | ||
pair_lists_t | src_list_def | ||
) |
Convert CONFIG_PAIR (which may contain refs) to vp_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 vp_map_t. |
[in] | cp | to convert to map. |
[in] | dst_request_def | The default request to insert unqualified attributes into. |
[in] | dst_list_def | The default list to insert unqualified attributes into. |
[in] | src_request_def | The default request to resolve attribute references in. |
[in] | src_list_def | The default list to resolve unqualified attributes in. |
Definition at line 207 of file map.c.
int map_afrom_cs | ( | vp_map_t ** | out, |
CONF_SECTION * | cs, | ||
pair_lists_t | dst_list_def, | ||
pair_lists_t | src_list_def, | ||
map_validate_t | validate, | ||
void * | ctx, | ||
unsigned int | max | ||
) |
int map_afrom_fields | ( | TALLOC_CTX * | ctx, |
vp_map_t ** | out, | ||
char const * | lhs, | ||
FR_TOKEN | lhs_type, | ||
FR_TOKEN | op, | ||
char const * | rhs, | ||
FR_TOKEN | rhs_type, | ||
request_refs_t | dst_request_def, | ||
pair_lists_t | dst_list_def, | ||
request_refs_t | src_request_def, | ||
pair_lists_t | src_list_def | ||
) |
Convert strings to vp_map_t.
Treatment of operands 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 |
[out] | out | Where to store the head of the map. |
[in] | lhs | of the operation |
[in] | lhs_type | type of the LHS string |
[in] | op | the operation to perform |
[in] | rhs | of the operation |
[in] | rhs_type | type of the RHS string |
[in] | dst_request_def | The default request to insert unqualified attributes into. |
[in] | dst_list_def | The default list to insert unqualified attributes into. |
[in] | src_request_def | The default request to resolve attribute references in. |
[in] | src_list_def | The default list to resolve unqualified attributes in. |
Definition at line 434 of file map.c.
int8_t map_cmp_by_lhs_attr | ( | void const * | a, |
void const * | b | ||
) |
Compare map where LHS is TMPL_TYPE_ATTR.
Compares maps by lhs->tmpl_da, lhs->tmpl_tag, lhs->tmpl_num
a | first map. |
b | second map. |
Definition at line 543 of file map.c.
void map_debug_log | ( | REQUEST * | request, |
vp_map_t const * | map, | ||
VALUE_PAIR const * | vp | ||
) |
size_t map_snprint | ( | char * | out, |
size_t | outlen, | ||
vp_map_t const * | map | ||
) |
Print a map to a string.
[out] | out | Buffer to write string to. |
[in] | outlen | Size of the output buffer. |
[in] | map | to print. |
Definition at line 1494 of file map.c.
int int map_to_request | ( | REQUEST * | request, |
vp_map_t const * | map, | ||
radius_map_getvalue_t | func, | ||
void * | ctx | ||
) |
Convert vp_map_t to VALUE_PAIR (s) and add them to a REQUEST.
Takes a single vp_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 VALUE_PAIR. |
ctx | to be passed to func. |
Definition at line 1019 of file map.c.
int map_to_vp | ( | TALLOC_CTX * | ctx, |
VALUE_PAIR ** | out, | ||
REQUEST * | request, | ||
vp_map_t const * | map, | ||
void * | uctx | ||
) |