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

Valuepair functions that are radiusd-specific and as such do not belong in the library. More...

#include <ctype.h>
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
+ Include dependency graph for pair.c:

Go to the source code of this file.

Data Structures

struct  cmp
 

Functions

void debug_pair (VALUE_PAIR *vp)
 Print a single valuepair to stderr or error log. More...
 
void module_failure_msg (REQUEST *request, char const *fmt,...)
 
static bool otherattr (fr_dict_attr_t const *attribute, fr_dict_attr_t const **from)
 See what attribute we want to compare with. More...
 
int paircompare (REQUEST *request, VALUE_PAIR *req_list, VALUE_PAIR *check, VALUE_PAIR **rep_list)
 Compare two pair lists except for the password information. More...
 
int paircompare_register (fr_dict_attr_t const *attribute, fr_dict_attr_t const *from, bool first_only, RAD_COMPARE_FUNC func, void *instance)
 Register a function as compare function. More...
 
int paircompare_register_byname (char const *name, fr_dict_attr_t const *from, bool first_only, RAD_COMPARE_FUNC func, void *instance)
 Register a function as compare function. More...
 
void paircompare_unregister (fr_dict_attr_t const *attribute, RAD_COMPARE_FUNC func)
 Unregister comparison function for an attribute. More...
 
void paircompare_unregister_instance (void *instance)
 Unregister comparison function for a module. More...
 
int radius_callback_compare (REQUEST *request, VALUE_PAIR *req, VALUE_PAIR *check, VALUE_PAIR *check_pairs, VALUE_PAIR **reply_pairs)
 Compare check and vp. More...
 
int radius_compare_vps (UNUSED REQUEST *request, VALUE_PAIR *check, VALUE_PAIR *vp)
 Compares check and vp by value. More...
 
int radius_copy_vp (TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, char const *name)
 Copy VP(s) from the specified request. More...
 
int radius_find_compare (fr_dict_attr_t const *attribute)
 Find a comparison function for two attributes. More...
 
int radius_get_vp (VALUE_PAIR **out, REQUEST *request, char const *name)
 Return a VP from the specified request. More...
 
VALUE_PAIRradius_pair_create (TALLOC_CTX *ctx, VALUE_PAIR **vps, unsigned int attribute, unsigned int vendor)
 Create a VALUE_PAIR and add it to a list of VALUE_PAIR s. More...
 
int radius_xlat_do (REQUEST *request, VALUE_PAIR *vp)
 Expands an attribute marked with fr_pair_mark_xlat. More...
 
void rdebug_pair (log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
 Print a single valuepair to stderr or error log. More...
 
void rdebug_pair_list (log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
 Print a list of VALUE_PAIRs. More...
 
void rdebug_proto_pair_list (log_lvl_t level, REQUEST *request, VALUE_PAIR *vp, char const *prefix)
 Print a list of protocol VALUE_PAIRs. More...
 
void vmodule_failure_msg (REQUEST *request, char const *fmt, va_list ap)
 Add a module failure message VALUE_PAIR to the request. More...
 

Variables

static struct cmpcmp
 

Detailed Description

Valuepair functions that are radiusd-specific and as such do not belong in the library.

Id:
8e5224bbcef33e06938684bb69e42626b0a43072

Definition in file pair.c.


Data Structure Documentation

struct cmp

Definition at line 37 of file pair.c.

+ Collaboration diagram for cmp:
Data Fields
fr_dict_attr_t const * attribute
RAD_COMPARE_FUNC compare
bool first_only
fr_dict_attr_t const * from
void * instance
struct cmp * next

Function Documentation

void debug_pair ( VALUE_PAIR vp)

Print a single valuepair to stderr or error log.

Parameters
[in]vplist to print.

Definition at line 725 of file pair.c.

+ Here is the call graph for this function:

void module_failure_msg ( REQUEST request,
char const *  fmt,
  ... 
)

Definition at line 858 of file pair.c.

+ Here is the call graph for this function:

static bool otherattr ( fr_dict_attr_t const *  attribute,
fr_dict_attr_t const **  from 
)
static

See what attribute we want to compare with.

Parameters
attributeto find comparison function for.
fromreference to compare with
Returns
  • true if the comparison callback require a matching attribute in the request.
  • false.

Definition at line 325 of file pair.c.

+ Here is the caller graph for this function:

int paircompare ( REQUEST request,
VALUE_PAIR req_list,
VALUE_PAIR check,
VALUE_PAIR **  rep_list 
)

Compare two pair lists except for the password information.

For every element in "check" at least one matching copy must be present in "reply".

Parameters
[in]requestCurrent request.
[in]req_listrequest valuepairs.
[in]checkCheck/control valuepairs.
[in,out]rep_listReply value pairs.
Returns
0 on match.

Definition at line 479 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int paircompare_register ( fr_dict_attr_t const *  attribute,
fr_dict_attr_t const *  from,
bool  first_only,
RAD_COMPARE_FUNC  func,
void *  instance 
)

Register a function as compare function.

Parameters
attributeto register comparison function for.
fromthe attribute we want to compare with. Normally this is the same as attribute. If null call the comparison function on every attributes in the request if first_only is false.
first_onlywill decide if we loop over the request attributes or stop on the first one.
funccomparison function.
instanceargument to comparison function.
Returns
0

Definition at line 395 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int paircompare_register_byname ( char const *  name,
fr_dict_attr_t const *  from,
bool  first_only,
RAD_COMPARE_FUNC  func,
void *  instance 
)

Register a function as compare function.

Parameters
namethe attribute comparison to register
fromthe attribute we want to compare with. Normally this is the same as attribute. If null call the comparison function on every attributes in the request if first_only is false.
first_onlywill decide if we loop over the request attributes or stop on the first one.
funccomparison function.
instanceargument to comparison function.
Returns
0

Definition at line 351 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void paircompare_unregister ( fr_dict_attr_t const *  attribute,
RAD_COMPARE_FUNC  func 
)

Unregister comparison function for an attribute.

Parameters
attributedict reference to unregister for.
funccomparison function to remove.

Definition at line 422 of file pair.c.

+ Here is the caller graph for this function:

void paircompare_unregister_instance ( void *  instance)

Unregister comparison function for a module.

All paircompare() functions for this module will be unregistered.

Parameters
instancethe module instance

Definition at line 451 of file pair.c.

+ Here is the caller graph for this function:

int radius_callback_compare ( REQUEST request,
VALUE_PAIR req,
VALUE_PAIR check,
VALUE_PAIR check_pairs,
VALUE_PAIR **  reply_pairs 
)

Compare check and vp.

May call the attribute comparison function.

Unlike radius_compare_vps() this function will call any attribute-specific comparison functions registered.

Parameters
requestCurrent request.
reqlist pairs.
checkitem to compare.
check_pairslist.
reply_pairslist.
Returns
  • 0 if check and vp are equal.
  • -1 if vp value is less than check value.
  • 1 is vp value is more than check value.

Definition at line 265 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_compare_vps ( UNUSED REQUEST request,
VALUE_PAIR check,
VALUE_PAIR vp 
)

Compares check and vp by value.

Does not call any per-attribute comparison function, but does honour check.operator. Basically does "vp.value check.op check.value".

Parameters
requestCurrent request.
checkrvalue, and operator.
vplvalue.
Returns
  • 0 if check and vp are equal
  • -1 if vp value is less than check value.
  • 1 is vp value is more than check value.
  • -2 on error.

Definition at line 64 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_copy_vp ( TALLOC_CTX *  ctx,
VALUE_PAIR **  out,
REQUEST request,
char const *  name 
)

Copy VP(s) from the specified request.

Parameters
ctxto alloc new VALUE_PAIRs in.
outwhere to write the pointer to the copied VP. Will be NULL if the attribute couldn't be resolved.
requestcurrent request.
nameattribute name including qualifiers.
Returns
  • -4 if either the attribute or qualifier were invalid.
  • The same error codes as tmpl_find_vp for other error conditions.

Definition at line 842 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_find_compare ( fr_dict_attr_t const *  attribute)

Find a comparison function for two attributes.

Todo:
this should probably take DA's.
Parameters
attributeto find comparison function for.
Returns
  • true if a comparison function was found
  • false.

Definition at line 303 of file pair.c.

+ Here is the caller graph for this function:

int radius_get_vp ( VALUE_PAIR **  out,
REQUEST request,
char const *  name 
)

Return a VP from the specified request.

Parameters
outwhere to write the pointer to the resolved VP. Will be NULL if the attribute couldn't be resolved.
requestcurrent request.
nameattribute name including qualifiers.
Returns
  • -4 if either the attribute or qualifier were invalid.
  • The same error codes as tmpl_find_vp for other error conditions.

Definition at line 815 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* radius_pair_create ( TALLOC_CTX *  ctx,
VALUE_PAIR **  vps,
unsigned int  attribute,
unsigned int  vendor 
)

Create a VALUE_PAIR and add it to a list of VALUE_PAIR s.

Note
This function ALWAYS returns. If we're OOM, then it causes the
server to exit, so you don't need to check the return value.
Parameters
[in]ctxfor talloc
[out]vpsList to add new VALUE_PAIR to, if NULL will just return VALUE_PAIR.
[in]attributenumber.
[in]vendornumber.
Returns
a new VALUE_PAIR or causes server to exit on error.

Definition at line 704 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_xlat_do ( REQUEST request,
VALUE_PAIR vp 
)

Expands an attribute marked with fr_pair_mark_xlat.

Writes the new value to the vp.

Parameters
requestCurrent request.
vpto expand.
Returns
On failure pair will still no longer be marked for xlat expansion.
  • 0 if successful.
  • -1 On xlat failure.
  • -2 On parse failure.

Definition at line 655 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rdebug_pair ( log_lvl_t  level,
REQUEST request,
VALUE_PAIR vp,
char const *  prefix 
)

Print a single valuepair to stderr or error log.

Parameters
[in]levelDebug level (1-4).
[in]requestto read logging params from.
[in]vpto print.
[in]prefix(optional).

Definition at line 739 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rdebug_pair_list ( log_lvl_t  level,
REQUEST request,
VALUE_PAIR vp,
char const *  prefix 
)

Print a list of VALUE_PAIRs.

Parameters
[in]levelDebug level (1-4).
[in]requestto read logging params from.
[in]vpto print.
[in]prefix(optional).

Definition at line 757 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rdebug_proto_pair_list ( log_lvl_t  level,
REQUEST request,
VALUE_PAIR vp,
char const *  prefix 
)

Print a list of protocol VALUE_PAIRs.

Parameters
[in]levelDebug level (1-4).
[in]requestto read logging params from.
[in]vpto print.
[in]prefix(optional).

Definition at line 784 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void vmodule_failure_msg ( REQUEST request,
char const *  fmt,
va_list  ap 
)

Add a module failure message VALUE_PAIR to the request.

Definition at line 869 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

struct cmp* cmp
static

Definition at line 45 of file pair.c.