All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
evaluate.c File Reference
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/parser.h>
#include <freeradius-devel/rad_assert.h>
#include <ctype.h>
+ Include dependency graph for evaluate.c:

Go to the source code of this file.

Macros

#define CAST(_s)
 
#define CHECK_INT_CAST(_l, _r)
 
#define EVAL_DEBUG(...)
 

Functions

static bool all_digits (char const *string)
 
static int cond_cmp_values (REQUEST *request, fr_cond_t const *c, PW_TYPE lhs_type, value_data_t const *lhs, PW_TYPE rhs_type, value_data_t const *rhs)
 Call the correct data comparison function for the condition. More...
 
static int cond_normalise_and_cmp (REQUEST *request, fr_cond_t const *c, PW_TYPE lhs_type, fr_dict_attr_t const *lhs_enumv, value_data_t const *lhs)
 Convert both operands to the same type. More...
 
int radius_evaluate_cond (REQUEST *request, int modreturn, int depth, fr_cond_t const *c)
 Evaluate a fr_cond_t;. More...
 
int radius_evaluate_map (REQUEST *request, UNUSED int modreturn, UNUSED int depth, fr_cond_t const *c)
 Evaluate a map. More...
 
int radius_evaluate_tmpl (REQUEST *request, int modreturn, UNUSED int depth, vp_tmpl_t const *vpt)
 Evaluate a template. More...
 
void radius_pairmove (REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from, bool do_xlat)
 

Variables

FR_NAME_NUMBER const modreturn_table []
 

Macro Definition Documentation

#define CAST (   _s)
Value:
do {\
if ((cast_type != PW_TYPE_INVALID) && (_s ## _type != PW_TYPE_INVALID) && (cast_type != _s ## _type)) {\
EVAL_DEBUG("CASTING " #_s " FROM %s TO %s",\
fr_int2str(dict_attr_types, _s ## _type, "<INVALID>"),\
fr_int2str(dict_attr_types, cast_type, "<INVALID>"));\
if (value_data_cast(request, &_s ## _cast, cast_type, cast, _s ## _type, _s ## _enumv, _s) < 0) {\
REDEBUG("Failed casting " #_s " operand: %s", fr_strerror());\
rcode = -1;\
goto finish;\
}\
if (cast && cast->flags.is_pointer) _s ## _cast_buff = _s ## _cast.ptr;\
_s ## _type = cast_type;\
_s = &_s ## _cast;\
}\
} while (0)
#define EVAL_DEBUG(...)
Definition: evaluate.c:37
int value_data_cast(TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE dst_type, fr_dict_attr_t const *dst_enumv, PW_TYPE src_type, fr_dict_attr_t const *src_enumv, value_data_t const *src)
Convert one type of value_data_t to another.
Definition: value.c:1073
const FR_NAME_NUMBER dict_attr_types[]
Map data types to names representing those types.
Definition: dict.c:85
Invalid (uninitialised) attribute type.
Definition: radius.h:32
char const * fr_strerror(void)
Get the last library error.
Definition: log.c:212
#define REDEBUG(fmt,...)
Definition: log.h:254
char const * fr_int2str(FR_NAME_NUMBER const *table, int number, char const *def)
Definition: token.c:506
#define CHECK_INT_CAST (   _l,
  _r 
)
Value:
do {\
if ((cast_type == PW_TYPE_INVALID) &&\
_l && (_l ## _type == PW_TYPE_STRING) &&\
_r && (_r ## _type == PW_TYPE_STRING) &&\
all_digits(lhs->strvalue) && all_digits(rhs->strvalue)) {\
cast_type = PW_TYPE_INTEGER64;\
EVAL_DEBUG("OPERANDS ARE NUMBER STRINGS, SETTING CAST TO integer64");\
}\
} while (0)
#define EVAL_DEBUG(...)
Definition: evaluate.c:37
Invalid (uninitialised) attribute type.
Definition: radius.h:32
64 Bit unsigned integer.
Definition: radius.h:51
static bool all_digits(char const *string)
Definition: evaluate.c:54
String of printable characters.
Definition: radius.h:33
#define EVAL_DEBUG (   ...)

Definition at line 37 of file evaluate.c.

Function Documentation

static bool all_digits ( char const *  string)
static

Definition at line 54 of file evaluate.c.

static int cond_cmp_values ( REQUEST request,
fr_cond_t const *  c,
PW_TYPE  lhs_type,
value_data_t const *  lhs,
PW_TYPE  rhs_type,
value_data_t const *  rhs 
)
static

Call the correct data comparison function for the condition.

Deals with regular expression comparisons, virtual attribute comparisons, and data comparisons.

Returns
  • -1 on failure.
  • 0 for "no match".
  • 1 for "match".

Definition at line 288 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int cond_normalise_and_cmp ( REQUEST request,
fr_cond_t const *  c,
PW_TYPE  lhs_type,
fr_dict_attr_t const *  lhs_enumv,
value_data_t const *  lhs 
)
static

Convert both operands to the same type.

If casting is successful, we call cond_cmp_values to do the comparison

Returns
  • -1 on failure.
  • 0 for "no match".
  • 1 for "match".

Definition at line 367 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_evaluate_cond ( REQUEST request,
int  modreturn,
int  depth,
fr_cond_t const *  c 
)

Evaluate a fr_cond_t;.

Parameters
[in]requestthe REQUEST
[in]modreturnthe previous module return code
[in]depthof the recursion (only used for debugging)
[in]cthe condition to evaluate
Returns
  • -1 on failure.
  • -2 on attribute not found.
  • 0 for "no match".
  • 1 for "match".

Definition at line 701 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_evaluate_map ( REQUEST request,
UNUSED int  modreturn,
UNUSED int  depth,
fr_cond_t const *  c 
)

Evaluate a map.

Parameters
[in]requestthe REQUEST
[in]modreturnthe previous module return code
[in]depthof the recursion (only used for debugging)
[in]cthe condition to evaluate
Returns
  • -1 on failure.
  • 0 for "no match".
  • 1 for "match".

Definition at line 593 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_evaluate_tmpl ( REQUEST request,
int  modreturn,
UNUSED int  depth,
vp_tmpl_t const *  vpt 
)

Evaluate a template.

Converts a vp_tmpl_t to a boolean value.

Parameters
[in]requestthe REQUEST
[in]modreturnthe previous module return code
[in]depthof the recursion (only used for debugging)
[in]vptthe template to evaluate
Returns
  • -1 on failure.
  • 0 for "no match".
  • 1 for "match".

Definition at line 82 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void radius_pairmove ( REQUEST request,
VALUE_PAIR **  to,
VALUE_PAIR from,
bool  do_xlat 
)

Definition at line 774 of file evaluate.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

FR_NAME_NUMBER const modreturn_table[]
Initial value:
= {
{ "reject", RLM_MODULE_REJECT },
{ "fail", RLM_MODULE_FAIL },
{ "ok", RLM_MODULE_OK },
{ "handled", RLM_MODULE_HANDLED },
{ "invalid", RLM_MODULE_INVALID },
{ "userlock", RLM_MODULE_USERLOCK },
{ "notfound", RLM_MODULE_NOTFOUND },
{ "noop", RLM_MODULE_NOOP },
{ "updated", RLM_MODULE_UPDATED },
{ NULL, 0 }
}
The module is OK, continue.
Definition: radiusd.h:91
The module considers the request invalid.
Definition: radiusd.h:93
Reject the request (user is locked out).
Definition: radiusd.h:94
Immediately reject the request.
Definition: radiusd.h:89
Module succeeded without doing anything.
Definition: radiusd.h:96
Module failed, don't reply.
Definition: radiusd.h:90
User not found.
Definition: radiusd.h:95
OK (pairs modified).
Definition: radiusd.h:97
The module handled the request, so stop.
Definition: radiusd.h:92

Definition at line 40 of file evaluate.c.