All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
map.h File Reference

Structures and prototypes for maps. More...

#include <freeradius-devel/conffile.h>
#include <freeradius-devel/tmpl.h>
+ Include dependency graph for map.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
 

Detailed Description

Structures and prototypes for maps.

Id:
66c30103539142f7e342223308530d577d1b07fd

Definition in file map.h.


Data Structure Documentation

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).

See Also
vp_tmpl_t

Definition at line 46 of file map.h.

+ Collaboration diagram for vp_map:
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.

Macro Definition Documentation

#define VERIFY_MAP (   _x)    rad_assert((_x)->lhs)

Definition at line 59 of file map.h.

Typedef Documentation

typedef int(* map_validate_t)(vp_map_t *map, void *ctx)

Definition at line 67 of file map.h.

typedef int(* radius_map_getvalue_t)(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx)

Definition at line 68 of file map.h.

typedef struct vp_map vp_map_t

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).

See Also
vp_tmpl_t

Function Documentation

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.

Parameters
ctxwhere to allocate the map.
outWhere to write the new map (must be freed with talloc_free()).
vp_strstring to parse.
dst_request_defto use if attribute isn't qualified.
dst_list_defto use if attribute isn't qualified.
src_request_defto use if attribute isn't qualified.
src_list_defto use if attribute isn't qualified.
Returns
  • 0 on success.
  • < 0 on error.

Definition at line 487 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parameters
[in]ctxfor talloc.
[in]outWhere to write the pointer to the new vp_map_t.
[in]cpto convert to map.
[in]dst_request_defThe default request to insert unqualified attributes into.
[in]dst_list_defThe default list to insert unqualified attributes into.
[in]src_request_defThe default request to resolve attribute references in.
[in]src_list_defThe default list to resolve unqualified attributes in.
Returns
  • vp_map_t if successful.
  • NULL on error.

Definition at line 207 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 
)

+ Here is the caller graph for this function:

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

Parameters
[in]ctxfor talloc
[out]outWhere to store the head of the map.
[in]lhsof the operation
[in]lhs_typetype of the LHS string
[in]opthe operation to perform
[in]rhsof the operation
[in]rhs_typetype of the RHS string
[in]dst_request_defThe default request to insert unqualified attributes into.
[in]dst_list_defThe default list to insert unqualified attributes into.
[in]src_request_defThe default request to resolve attribute references in.
[in]src_list_defThe default list to resolve unqualified attributes in.
Returns
vp_map_t if successful or NULL on error.

Definition at line 434 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
mapto process.
rhs_typequotation type around rhs.
rhsstring to re-parse.

Definition at line 57 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Note
both map->lhs must be TMPL_TYPE_ATTR.
Parameters
afirst map.
bsecond map.

Definition at line 543 of file map.c.

+ Here is the call graph for this function:

void map_debug_log ( REQUEST request,
vp_map_t const *  map,
VALUE_PAIR const *  vp 
)

+ Here is the caller graph for this function:

bool map_dst_valid ( REQUEST request,
vp_map_t const *  map 
)

Check whether the destination of a map is currently valid.

Parameters
requestThe current request.
mapto check.
Returns
  • true if the map resolves to a request and list.
  • false.

Definition at line 1473 of file map.c.

+ Here is the call graph for this function:

size_t map_snprint ( char *  out,
size_t  outlen,
vp_map_t const *  map 
)

Print a map to a string.

Parameters
[out]outBuffer to write string to.
[in]outlenSize of the output buffer.
[in]mapto print.
Returns
  • The number of bytes written to the out buffer.
  • A number >= outlen if truncation has occurred.

Definition at line 1494 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void map_sort ( vp_map_t **  maps,
fr_cmp_t  cmp 
)

Sort a linked list of vp_map_t using merge sort.

Parameters
[in,out]mapsList of vp_map_t to sort.
[in]cmpto sort with

Definition at line 631 of file map.c.

+ Here is the call graph for this function:

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.

Parameters
requestThe current request.
mapspecifying destination attribute and location and src identifier.
functo retrieve module specific values and convert them to VALUE_PAIR.
ctxto be passed to func.
Returns
  • -1 if the operation failed.
  • -2 in the source attribute wasn't valid.
  • 0 on success.

Definition at line 1019 of file map.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int map_to_vp ( TALLOC_CTX *  ctx,
VALUE_PAIR **  out,
REQUEST request,
vp_map_t const *  map,
void *  uctx 
)

+ Here is the caller graph for this function: