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

AVP manipulation and search API. More...

#include <freeradius-devel/libradius.h>
+ Include dependency graph for pair.h:

Go to the source code of this file.

Data Structures

struct  value_data
 
union  value_data.__unnamed__
 
struct  value_pair
 Stores an attribute, a value and various bits of other data. More...
 
union  value_pair.__unnamed__
 
struct  value_pair_raw
 A VALUE_PAIR in string format. More...
 
struct  vp_cursor
 Abstraction to allow iterating over different configurations of VALUE_PAIRs. More...
 

Macros

#define ATTRIBUTE_EQ(_x, _y)   ((_x && _y) && (_x->da == _y->da) && (!_x->da->flags.has_tag || TAG_EQ(_x->tag, _y->tag)))
 
#define debug_pair(vp)
 
#define fr_pair_cmp_op(_op, _a, _b)   value_data_cmp_op(_op, _a->da->type, &_a->data, _b->da->type, &_b->data)
 Compare two attributes using and operator. More...
 
#define NUM_ALL   (INT_MIN + 1)
 
#define NUM_ANY   INT_MIN
 
#define NUM_COUNT   (INT_MIN + 2)
 
#define NUM_LAST   (INT_MIN + 3)
 
#define TAG_ANY   INT8_MIN
 
#define TAG_EQ(_x, _y)   ((_x == _y) || (_x == TAG_ANY) || ((_x == TAG_NONE) && (_y == TAG_ANY)))
 Check if tags are equal. More...
 
#define TAG_NONE   0
 
#define TAG_VALID(x)   ((x) > 0 && (x) < 0x20)
 
#define TAG_VALID_ZERO(x)   ((x) < 0x20)
 
#define VERIFY_LIST(_x)   fr_assert(_x)
 
#define VERIFY_PACKET(_x)   fr_assert(_x)
 
#define VERIFY_VP(_x)   fr_assert(_x)
 
#define vp_byte   data.byte
 
#define vp_date   data.date
 
#define vp_decimal   data.decimal
 
#define vp_ether   data.ether
 
#define vp_filter   data.filter
 
#define vp_ifid   data.ifid
 
#define vp_integer   data.integer
 
#define vp_integer64   data.integer64
 
#define vp_ipaddr   data.ipaddr.s_addr
 
#define vp_ipv4prefix   data.ipv4prefix
 
#define vp_ipv6addr   data.ipv6addr
 
#define vp_ipv6prefix   data.ipv6prefix
 
#define vp_length   data.length
 
#define vp_octets   data.octets
 
#define vp_short   data.ushort
 
#define vp_signed   data.sinteger
 
#define vp_strvalue   data.strvalue
 

Typedefs

typedef int8_t(* fr_cmp_t )(void const *a, void const *b)
 
typedef struct value_data value_data_t
 Union containing all data types supported by the server. More...
 
typedef struct value_pair VALUE_PAIR
 Stores an attribute, a value and various bits of other data. More...
 
typedef struct value_pair_raw VALUE_PAIR_RAW
 A VALUE_PAIR in string format. More...
 
typedef enum value_type value_type_t
 The type of value a VALUE_PAIR contains. More...
 
typedef struct vp_cursor vp_cursor_t
 Abstraction to allow iterating over different configurations of VALUE_PAIRs. More...
 

Enumerations

enum  value_type {
  VT_NONE = 0,
  VT_SET,
  VT_LIST,
  VT_DATA,
  VT_XLAT
}
 The type of value a VALUE_PAIR contains. More...
 

Functions

void fr_pair_add (VALUE_PAIR **head, VALUE_PAIR *vp)
 Add a VP to the end of the list. More...
 
VALUE_PAIRfr_pair_afrom_da (TALLOC_CTX *ctx, fr_dict_attr_t const *da)
 Dynamically allocate a new attribute. More...
 
VALUE_PAIRfr_pair_afrom_num (TALLOC_CTX *ctx, unsigned int vendor, unsigned int attr)
 Create a new valuepair. More...
 
char * fr_pair_asprint (TALLOC_CTX *ctx, VALUE_PAIR const *vp, char quote)
 Print one attribute and value to a string. More...
 
int fr_pair_cmp (VALUE_PAIR *a, VALUE_PAIR *b)
 Compare two pairs, using the operator from "a". More...
 
int8_t fr_pair_cmp_by_da_tag (void const *a, void const *b)
 
VALUE_PAIRfr_pair_copy (TALLOC_CTX *ctx, VALUE_PAIR const *vp)
 Copy a single valuepair. More...
 
void fr_pair_delete_by_num (VALUE_PAIR **head, unsigned int vendor, unsigned int attr, int8_t tag)
 Delete matching pairs. More...
 
VALUE_PAIRfr_pair_find_by_da (VALUE_PAIR *head, fr_dict_attr_t const *da, int8_t tag)
 Find the pair with the matching DAs. More...
 
VALUE_PAIRfr_pair_find_by_num (VALUE_PAIR *head, unsigned int vendor, unsigned int attr, int8_t tag)
 Find the pair with the matching attribute. More...
 
void fr_pair_fprint (FILE *, VALUE_PAIR const *vp)
 Print one attribute and value to FP. More...
 
int fr_pair_list_afrom_file (TALLOC_CTX *ctx, VALUE_PAIR **out, FILE *fp, bool *pfiledone)
 
FR_TOKEN fr_pair_list_afrom_str (TALLOC_CTX *ctx, char const *buffer, VALUE_PAIR **head)
 Read one line of attribute/value pairs into a list. More...
 
int fr_pair_list_cmp (VALUE_PAIR *a, VALUE_PAIR *b)
 Determine equality of two lists. More...
 
VALUE_PAIRfr_pair_list_copy (TALLOC_CTX *ctx, VALUE_PAIR *from)
 Copy a pairlist. More...
 
VALUE_PAIRfr_pair_list_copy_by_num (TALLOC_CTX *ctx, VALUE_PAIR *from, unsigned int vendor, unsigned int attr, int8_t tag)
 Copy matching pairs. More...
 
void fr_pair_list_fprint (FILE *, VALUE_PAIR const *vp)
 Print a list of attributes and enumv. More...
 
void fr_pair_list_free (VALUE_PAIR **)
 Free memory used by a valuepair list. More...
 
void fr_pair_list_mcopy_by_num (TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from, unsigned int vendor, unsigned int attr, int8_t tag)
 Copy / delete matching pairs between VALUE_PAIR lists. More...
 
void fr_pair_list_move (TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from)
 Move pairs from source list to destination list respecting operator. More...
 
void fr_pair_list_move_by_num (TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from, unsigned int vendor, unsigned int attr, int8_t tag)
 Move matching pairs between VALUE_PAIR lists. More...
 
void fr_pair_list_sort (VALUE_PAIR **vps, fr_cmp_t cmp)
 Sort a linked list of VALUE_PAIRs using merge sort. More...
 
VALUE_PAIRfr_pair_make (TALLOC_CTX *ctx, VALUE_PAIR **vps, char const *attribute, char const *value, FR_TOKEN op)
 Create a VALUE_PAIR from ASCII strings. More...
 
int fr_pair_mark_xlat (VALUE_PAIR *vp, char const *value)
 Mark a valuepair for xlat expansion. More...
 
FR_TOKEN fr_pair_raw_from_str (char const **ptr, VALUE_PAIR_RAW *raw)
 Read a single valuepair from a buffer, and advance the pointer. More...
 
void fr_pair_replace (VALUE_PAIR **head, VALUE_PAIR *add)
 Replace all matching VPs. More...
 
size_t fr_pair_snprint (char *out, size_t outlen, VALUE_PAIR const *vp)
 Print one attribute and value to a string. More...
 
void fr_pair_steal (TALLOC_CTX *ctx, VALUE_PAIR *vp)
 Steal one VP. More...
 
int fr_pair_to_unknown (VALUE_PAIR *vp)
 Mark malformed or unrecognised attributed as unknown. More...
 
char * fr_pair_type_snprint (TALLOC_CTX *ctx, PW_TYPE type)
 
int fr_pair_update_by_num (TALLOC_CTX *ctx, VALUE_PAIR **list, unsigned int vendor, unsigned int attr, int8_t tag, PW_TYPE type, value_data_t *value)
 Create a new VALUE_PAIR or replace the value of the head pair in the specified list. More...
 
bool fr_pair_validate (VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAIR *list)
 Uses fr_pair_cmp to verify all VALUE_PAIRs in list match the filter defined by check. More...
 
void fr_pair_validate_debug (TALLOC_CTX *ctx, VALUE_PAIR const *failed[2])
 Write an error to the library errorbuff detailing the mismatch. More...
 
bool fr_pair_validate_relaxed (VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAIR *list)
 Uses fr_pair_cmp to verify all VALUE_PAIRs in list match the filter defined by check. More...
 
char * fr_pair_value_asprint (TALLOC_CTX *ctx, VALUE_PAIR const *vp, char quote)
 Print one attribute value to a string. More...
 
void fr_pair_value_bstrncpy (VALUE_PAIR *vp, void const *src, size_t len)
 Copy data into an "string" data type. More...
 
int fr_pair_value_from_str (VALUE_PAIR *vp, char const *value, size_t len)
 Convert string value to native attribute value. More...
 
void fr_pair_value_memcpy (VALUE_PAIR *vp, uint8_t const *src, size_t len)
 Copy data into an "octets" data type. More...
 
void fr_pair_value_memsteal (VALUE_PAIR *vp, uint8_t const *src)
 Reparent an allocated octet buffer to a VALUE_PAIR. More...
 
void size_t fr_pair_value_snprint (char *out, size_t outlen, VALUE_PAIR const *vp, char quote)
 Print the value of an attribute to a string. More...
 
size_t fr_pair_value_snprint_json (char *out, size_t outlen, VALUE_PAIR const *vp)
 
void fr_pair_value_snprintf (VALUE_PAIR *vp, char const *fmt,...) CC_HINT(format(printf
 
void fr_pair_value_strcpy (VALUE_PAIR *vp, char const *src)
 Copy data into an "string" data type. More...
 
void fr_pair_value_strnsteal (VALUE_PAIR *vp, char *src, size_t len)
 Reparent an allocated char buffer to a VALUE_PAIR reallocating the buffer to the correct size. More...
 
void fr_pair_value_strsteal (VALUE_PAIR *vp, char const *src)
 Reparent an allocated char buffer to a VALUE_PAIR. More...
 

Detailed Description

AVP manipulation and search API.

Id:
24c64235b1a55c1b35ed06a94f417d242b18f2a0

Definition in file pair.h.


Data Structure Documentation

struct value_data

Definition at line 57 of file pair.h.

+ Collaboration diagram for value_data:
Data Fields
union value_data __unnamed__
size_t length Length of value data.
value_data_t * next Next in a series of value_data.
union value_data.__unnamed__

Definition at line 58 of file pair.h.

Data Fields
bool boolean A truth value.
uint8_t byte 8bit unsigned integer.
uint32_t date Date (32bit Unix timestamp).
double decimal Double precision float.
uint8_t ether[6] Ethernet (MAC) address.
size_t filter[32/sizeof(size_t)] Ascend binary format a packed data structure.
uint8_t ifid[8] IPv6 interface ID (should be struct?).
uint32_t integer 32bit unsigned integer.
uint64_t integer64 64bit unsigned integer.
struct in_addr ipaddr IPv4 Address.
uint8_t ipv4prefix[6] IPv4 prefix (should be struct?).
struct in6_addr ipv6addr IPv6 Address.
uint8_t ipv6prefix[18] IPv6 prefix (should be struct?).
uint8_t const * octets Pointer to binary string.
void * ptr generic pointer.
int32_t sinteger 32bit signed integer.
char const * strvalue Pointer to UTF-8 string.
uint16_t ushort 16bit unsigned integer.
struct value_pair

Stores an attribute, a value and various bits of other data.

VALUE_PAIRs are the main data structure used in the server

They also specify what behaviour should be used when the attribute is merged into a new list/tree.

Definition at line 112 of file pair.h.

+ Collaboration diagram for value_pair:
Data Fields
union value_pair __unnamed__
fr_dict_attr_t const * da Dictionary attribute defines the attribute.

number, vendor and type of the attribute.

value_data_t data
struct value_pair * next
FR_TOKEN op Operator to use when moving or inserting valuepair into a list.
int8_t tag Tag value used to group valuepairs.
value_type_t type Type of pointer in value union.
union value_pair.__unnamed__

Definition at line 123 of file pair.h.

Data Fields
char const * xlat < multivalued attribute.

Source string for xlat expansion.

struct value_pair_raw

A VALUE_PAIR in string format.

Used to represent pairs in the legacy 'users' file format.

Definition at line 156 of file pair.h.

Data Fields
char l_opand[256] Left hand side of the pair.
FR_TOKEN op Operator.
FR_TOKEN quote Type of quoting around the r_opand.
char r_opand[1024] Right hand side of the pair.
struct vp_cursor

Abstraction to allow iterating over different configurations of VALUE_PAIRs.

This allows functions which do not care about the structure of collections of VALUE_PAIRs to iterate over all members in a collection.

Field within a vp_cursor should not be accessed directly, and vp_cursors should only be manipulated with the pair* functions.

Definition at line 144 of file pair.h.

+ Collaboration diagram for vp_cursor:
Data Fields
VALUE_PAIR * current The current attribute.
VALUE_PAIR ** first
VALUE_PAIR * found pairfind marker.
VALUE_PAIR * last Temporary only used for fr_cursor_insert.
VALUE_PAIR * next Next attribute to process.

Macro Definition Documentation

#define ATTRIBUTE_EQ (   _x,
  _y 
)    ((_x && _y) && (_x->da == _y->da) && (!_x->da->flags.has_tag || TAG_EQ(_x->tag, _y->tag)))

Definition at line 199 of file pair.h.

#define debug_pair (   vp)
Value:
do { if (fr_debug_lvl && fr_log_fp) { \
} \
} while(0)
FILE * fr_log_fp
Definition: radius.c:81
void fr_pair_fprint(FILE *, VALUE_PAIR const *vp)
Print one attribute and value to FP.
Definition: pair.c:2232
int fr_debug_lvl
Definition: misc.c:40

Definition at line 184 of file pair.h.

#define fr_pair_cmp_op (   _op,
  _a,
  _b 
)    value_data_cmp_op(_op, _a->da->type, &_a->data, _b->da->type, &_b->data)

Compare two attributes using and operator.

Returns
  • 1 if equal.
  • 0 if not equal.
  • -1 on failure.

Definition at line 236 of file pair.h.

#define NUM_ALL   (INT_MIN + 1)

Definition at line 202 of file pair.h.

#define NUM_ANY   INT_MIN

Definition at line 201 of file pair.h.

#define NUM_COUNT   (INT_MIN + 2)

Definition at line 203 of file pair.h.

#define NUM_LAST   (INT_MIN + 3)

Definition at line 204 of file pair.h.

#define TAG_ANY   INT8_MIN

Definition at line 191 of file pair.h.

#define TAG_EQ (   _x,
  _y 
)    ((_x == _y) || (_x == TAG_ANY) || ((_x == TAG_NONE) && (_y == TAG_ANY)))

Check if tags are equal.

Parameters
_xtag were matching on.
_ytag belonging to the attribute were checking.

Definition at line 198 of file pair.h.

#define TAG_NONE   0

Definition at line 192 of file pair.h.

#define TAG_VALID (   x)    ((x) > 0 && (x) < 0x20)

Definition at line 189 of file pair.h.

#define TAG_VALID_ZERO (   x)    ((x) < 0x20)

Definition at line 190 of file pair.h.

#define VERIFY_LIST (   _x)    fr_assert(_x)

Definition at line 45 of file pair.h.

#define VERIFY_PACKET (   _x)    fr_assert(_x)

Definition at line 46 of file pair.h.

#define VERIFY_VP (   _x)    fr_assert(_x)

Definition at line 44 of file pair.h.

#define vp_byte   data.byte

Definition at line 174 of file pair.h.

#define vp_date   data.date

Definition at line 168 of file pair.h.

#define vp_decimal   data.decimal

Definition at line 180 of file pair.h.

#define vp_ether   data.ether

Definition at line 176 of file pair.h.

#define vp_filter   data.filter

Definition at line 169 of file pair.h.

#define vp_ifid   data.ifid

Definition at line 171 of file pair.h.

#define vp_integer   data.integer

Definition at line 166 of file pair.h.

#define vp_integer64   data.integer64

Definition at line 178 of file pair.h.

#define vp_ipaddr   data.ipaddr.s_addr

Definition at line 167 of file pair.h.

#define vp_ipv4prefix   data.ipv4prefix

Definition at line 179 of file pair.h.

#define vp_ipv6addr   data.ipv6addr

Definition at line 172 of file pair.h.

#define vp_ipv6prefix   data.ipv6prefix

Definition at line 173 of file pair.h.

#define vp_length   data.length

Definition at line 182 of file pair.h.

#define vp_octets   data.octets

Definition at line 170 of file pair.h.

#define vp_short   data.ushort

Definition at line 175 of file pair.h.

#define vp_signed   data.sinteger

Definition at line 177 of file pair.h.

#define vp_strvalue   data.strvalue

Definition at line 165 of file pair.h.

Typedef Documentation

typedef int8_t(* fr_cmp_t)(void const *a, void const *b)

Definition at line 227 of file pair.h.

typedef struct value_data value_data_t

Union containing all data types supported by the server.

This union contains all data types that can be represented by VALUE_PAIRs. It may also be used in other parts of the server where values of different types need to be stored.

PW_TYPE should be an enumeration of the values in this union.

Definition at line 56 of file pair.h.

typedef struct value_pair VALUE_PAIR

Stores an attribute, a value and various bits of other data.

VALUE_PAIRs are the main data structure used in the server

They also specify what behaviour should be used when the attribute is merged into a new list/tree.

A VALUE_PAIR in string format.

Used to represent pairs in the legacy 'users' file format.

typedef enum value_type value_type_t

The type of value a VALUE_PAIR contains.

This is used to add structure to nested VALUE_PAIRs and specifies what type of node it is (set, list, data).

xlat is another type of data node which must first be expanded before use.

typedef struct vp_cursor vp_cursor_t

Abstraction to allow iterating over different configurations of VALUE_PAIRs.

This allows functions which do not care about the structure of collections of VALUE_PAIRs to iterate over all members in a collection.

Field within a vp_cursor should not be accessed directly, and vp_cursors should only be manipulated with the pair* functions.

Enumeration Type Documentation

enum value_type

The type of value a VALUE_PAIR contains.

This is used to add structure to nested VALUE_PAIRs and specifies what type of node it is (set, list, data).

xlat is another type of data node which must first be expanded before use.

Enumerator
VT_NONE 

VALUE_PAIR has no value.

VT_SET 

VALUE_PAIR has children.

VT_LIST 

VALUE_PAIR has multiple values.

VT_DATA 

VALUE_PAIR has a single value.

VT_XLAT 

valuepair value must be xlat expanded when it's added to VALUE_PAIR tree.

Definition at line 97 of file pair.h.

Function Documentation

void fr_pair_add ( VALUE_PAIR **  head,
VALUE_PAIR add 
)

Add a VP to the end of the list.

Locates the end of 'head', and links an additional VP 'add' at the end.

Parameters
[in]headVP in linked list. Will add new VP to the end of this list.
[in]addVP to add to list.

Definition at line 659 of file pair.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_afrom_da ( TALLOC_CTX *  ctx,
fr_dict_attr_t const *  da 
)

Dynamically allocate a new attribute.

Allocates a new attribute and a new dictionary attr if no DA is provided.

Parameters
[in]ctxfor allocated memory, usually a pointer to a RADIUS_PACKET
[in]daSpecifies the dictionary attribute to build the VALUE_PAIR from.
Returns

Definition at line 58 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_afrom_num ( TALLOC_CTX *  ctx,
unsigned int  vendor,
unsigned int  attr 
)

Create a new valuepair.

If attr and vendor match a dictionary entry then a VP with that fr_dict_attr_t will be returned.

If attr or vendor are uknown will call dict_attruknown to create a dynamic fr_dict_attr_t of PW_TYPE_OCTETS.

Which type of fr_dict_attr_t the VALUE_PAIR was created with can be determined by checking

vp->da->flags.is_unknown 

.

Parameters
[in]ctxfor allocated memory, usually a pointer to a RADIUS_PACKET.
[in]attrnumber.
[in]vendornumber.
Returns

Definition at line 106 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* fr_pair_asprint ( TALLOC_CTX *  ctx,
VALUE_PAIR const *  vp,
char  quote 
)

Print one attribute and value to a string.

Print a VALUE_PAIR in the format:

        <attribute_name>[:tag] <op> <value>

to a string.

Parameters
ctxto allocate string in.
vpto print.
[in]quotethe quotation character
Returns
a talloced buffer with the attribute operator and value.

Definition at line 2291 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_cmp ( VALUE_PAIR a,
VALUE_PAIR b 
)

Compare two pairs, using the operator from "a".

i.e. given two attributes, it does:

(b->data) (a->operator) (a->data)

e.g. "foo" != "bar"

Parameters
[in]athe head attribute
[in]bthe second attribute
Returns
  • 1 if true.
  • 0 if false.
  • -1 on failure.

Definition at line 850 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int8_t fr_pair_cmp_by_da_tag ( void const *  a,
void const *  b 
)

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* fr_pair_copy ( TALLOC_CTX *  ctx,
VALUE_PAIR const *  vp 
)

Copy a single valuepair.

Allocate a new valuepair and copy the da from the old vp.

Parameters
[in]ctxfor talloc
[in]vpto copy.
Returns
  • A copy of the input VP.
  • NULL on error.

Definition at line 129 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_delete_by_num ( VALUE_PAIR **  head,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag 
)

Delete matching pairs.

Delete matching pairs from the attribute list.

Parameters
[in,out]headVP in list.
[in]attrto match.
[in]vendorto match.
[in]tagto match. TAG_ANY matches any tag, TAG_NONE matches tagless VPs.
Todo:
should take DAs and do a point comparison.

Definition at line 797 of file pair.c.

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_find_by_da ( VALUE_PAIR head,
fr_dict_attr_t const *  da,
int8_t  tag 
)

Find the pair with the matching DAs.

Definition at line 624 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_find_by_num ( VALUE_PAIR head,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag 
)

Find the pair with the matching attribute.

Todo:
should take DAs and do a pointer comparison.

Definition at line 639 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_fprint ( FILE *  fp,
VALUE_PAIR const *  vp 
)

Print one attribute and value to FP.

Complete string with '\t' and '\n' is written to buffer before printing to avoid issues when running with multiple threads.

Parameters
fpto output to.
vpto print.

Definition at line 2232 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_list_afrom_file ( TALLOC_CTX *  ctx,
VALUE_PAIR **  out,
FILE *  fp,
bool *  pfiledone 
)

Definition at line 1333 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FR_TOKEN fr_pair_list_afrom_str ( TALLOC_CTX *  ctx,
char const *  buffer,
VALUE_PAIR **  list 
)

Read one line of attribute/value pairs into a list.

The line may specify multiple attributes separated by commas.

Note
If the function returns T_INVALID, an error has occurred and
the valuepair list should probably be freed.
Parameters
ctxfor talloc
bufferto read valuepairs from.
listwhere the parsed VALUE_PAIRs will be appended.
Returns
the last token parsed, or T_INVALID

Definition at line 1261 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_list_cmp ( VALUE_PAIR a,
VALUE_PAIR b 
)

Determine equality of two lists.

This is useful for comparing lists of attributes inserted into a binary tree.

Parameters
ahead list of VALUE_PAIR.
bsecond list of VALUE_PAIR.
Returns
  • -1 if a < b.
  • 0 if the two lists are equal.
  • 1 if a > b.
  • -2 on error.

Definition at line 927 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_list_copy ( TALLOC_CTX *  ctx,
VALUE_PAIR from 
)

Copy a pairlist.

Copy all pairs from 'from' regardless of tag, attribute or vendor.

Parameters
[in]ctxfor new VALUE_PAIR (s) to be allocated in.
[in]fromwhence to copy VALUE_PAIR (s).
Returns
the head of the new VALUE_PAIR list or NULL on error.

Definition at line 1394 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_list_copy_by_num ( TALLOC_CTX *  ctx,
VALUE_PAIR from,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag 
)

Copy matching pairs.

Copy pairs of a matching attribute number, vendor number and tag from the the input list to a new list, and returns the head of this list.

Parameters
[in]ctxfor talloc
[in]fromwhence to copy VALUE_PAIR.
[in]attrto match, if 0 input list will not be filtered by attr.
[in]vendorto match.
[in]tagto match, TAG_ANY matches any tag, TAG_NONE matches tagless VPs.
Returns
the head of the new VALUE_PAIR list or NULL on error.

Definition at line 1428 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_list_fprint ( FILE *  fp,
VALUE_PAIR const *  const_vp 
)

Print a list of attributes and enumv.

Parameters
fpto output to.
const_vpto print.

Definition at line 2266 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_list_free ( VALUE_PAIR **  vps)

Free memory used by a valuepair list.

Todo:
TLV: needs to free all dependents of each VP freed.

Definition at line 544 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_list_mcopy_by_num ( TALLOC_CTX *  ctx,
VALUE_PAIR **  to,
VALUE_PAIR **  from,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag 
)

Copy / delete matching pairs between VALUE_PAIR lists.

Move pairs of a matching attribute number, vendor number and tag from the the input list to the output list. Like fr_pair_list_move_by_num(), but instead does copy / delete.

Note
The pair is NOT reparented. It is copied and deleted.
fr_pair_list_free should be called on the head of the old list to free unmoved attributes (if they're no longer needed).
Parameters
[in]ctxfor talloc
[in,out]todestination list.
[in,out]fromsource list.
[in]attrto match. If attribute PW_VENDOR_SPECIFIC and vendor 0, will match (and therefore copy) only VSAs. If attribute 0 and vendor 0 will match (and therefore copy) all attributes.
[in]vendorto match.
[in]tagto match, TAG_ANY matches any tag, TAG_NONE matches tagless VPs.

Definition at line 1823 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_list_move ( TALLOC_CTX *  ctx,
VALUE_PAIR **  to,
VALUE_PAIR **  from 
)

Move pairs from source list to destination list respecting operator.

Note
This function does some additional magic that's probably not needed in most places. Consider using radius_pairmove in server code.
fr_pair_list_free should be called on the head of the source list to free unmoved attributes (if they're no longer needed).
Does not respect tags when matching.
Parameters
[in]ctxfor talloc
[in,out]todestination list.
[in,out]fromsource list.
See Also
radius_pairmove

Definition at line 1508 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_list_move_by_num ( TALLOC_CTX *  ctx,
VALUE_PAIR **  to,
VALUE_PAIR **  from,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag 
)

Move matching pairs between VALUE_PAIR lists.

Move pairs of a matching attribute number, vendor number and tag from the the input list to the output list.

Note
pairs which are moved have their parent changed to ctx.
fr_pair_list_free should be called on the head of the old list to free unmoved attributes (if they're no longer needed).
Parameters
[in]ctxfor talloc
[in,out]todestination list.
[in,out]fromsource list.
[in]attrto match. If attribute PW_VENDOR_SPECIFIC and vendor 0, will match (and therefore copy) only VSAs. If attribute 0 and vendor 0 will match (and therefore copy) all attributes.
[in]vendorto match.
[in]tagto match, TAG_ANY matches any tag, TAG_NONE matches tagless VPs.

Definition at line 1795 of file pair.c.

+ Here is the call graph for this function:

void fr_pair_list_sort ( VALUE_PAIR **  vps,
fr_cmp_t  cmp 
)

Sort a linked list of VALUE_PAIRs using merge sort.

Parameters
[in,out]vpsList of VALUE_PAIRs to sort.
[in]cmpto sort with

Definition at line 1036 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

VALUE_PAIR* fr_pair_make ( TALLOC_CTX *  ctx,
VALUE_PAIR **  vps,
char const *  attribute,
char const *  value,
FR_TOKEN  op 
)

Create a VALUE_PAIR from ASCII strings.

Converts an attribute string identifier (with an optional tag qualifier) and value string into a VALUE_PAIR.

The string value is parsed according to the type of VALUE_PAIR being created.

Parameters
[in]ctxfor talloc.
[in]vpslist where the attribute will be added (optional)
[in]attributename.
[in]valueattribute value (may be NULL if value will be set later).
[in]opto assign to new VALUE_PAIR.
Returns
a new VALUE_PAIR.

Definition at line 338 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_mark_xlat ( VALUE_PAIR vp,
char const *  value 
)

Mark a valuepair for xlat expansion.

Copies xlat source (unprocessed) string to valuepair value, and sets value type.

Parameters
vpto mark for expansion.
valueto expand.
Returns
  • 0 if marking succeeded.
  • -1 if VALUE_PAIR already had a value, or OOM.

Definition at line 598 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FR_TOKEN fr_pair_raw_from_str ( char const **  ptr,
VALUE_PAIR_RAW raw 
)

Read a single valuepair from a buffer, and advance the pointer.

Returns T_EOL if end of line was encountered.

Parameters
[in,out]ptrto read from and update.
[out]rawThe struct to write the raw VALUE_PAIR to.
Returns
the last token read.

Definition at line 2335 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_replace ( VALUE_PAIR **  head,
VALUE_PAIR replace 
)

Replace all matching VPs.

Walks over 'head', and replaces the head VP that matches 'replace'.

Note
Memory used by the VP being replaced will be freed.
Will not work with unknown attributes.
Parameters
[in,out]headVP in linked list. Will search and replace in this list.
[in]replaceVP to replace.

Definition at line 696 of file pair.c.

+ Here is the caller graph for this function:

size_t fr_pair_snprint ( char *  out,
size_t  outlen,
VALUE_PAIR const *  vp 
)

Print one attribute and value to a string.

Print a VALUE_PAIR in the format:

        <attribute_name>[:tag] <op> <value>

to a string.

Parameters
outWhere to write the string.
outlenLenth of output buffer.
vpto print.
Returns
  • Length of data written to out.
  • value >= outlen on truncation.

Definition at line 2189 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_steal ( TALLOC_CTX *  ctx,
VALUE_PAIR vp 
)

Steal one VP.

Parameters
[in]ctxto move VALUE_PAIR into
[in]vpVALUE_PAIR to move into the new context.

Definition at line 184 of file pair.c.

+ Here is the caller graph for this function:

int fr_pair_to_unknown ( VALUE_PAIR vp)

Mark malformed or unrecognised attributed as unknown.

Parameters
vpto change fr_dict_attr_t of.
Returns
  • 0 on success (or if already unknown).
  • -1 on failure.

Definition at line 570 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* fr_pair_type_snprint ( TALLOC_CTX *  ctx,
PW_TYPE  type 
)

Definition at line 2130 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_update_by_num ( TALLOC_CTX *  ctx,
VALUE_PAIR **  list,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag,
PW_TYPE  type,
value_data_t value 
)

Create a new VALUE_PAIR or replace the value of the head pair in the specified list.

Note
Any buffers associated with value, will be stolen to the context of the VALUE_PAIR we create, or find.
Parameters
[in]ctxto allocate new VALUE_PAIR in.
[in,out]listin search and insert into it.
[in]attrNumber of attribute to update.
[in]vendorof attribute to update.
[in]tagof attribute to update.
[in]typeof value.
[in]valueto set.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 761 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool fr_pair_validate ( VALUE_PAIR const *  failed[2],
VALUE_PAIR filter,
VALUE_PAIR list 
)

Uses fr_pair_cmp to verify all VALUE_PAIRs in list match the filter defined by check.

Note
will sort both filter and list in place.
Parameters
failedpointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL.
filterattributes to check list against.
listattributes, probably a request or reply

Definition at line 1117 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_validate_debug ( TALLOC_CTX *  ctx,
VALUE_PAIR const *  failed[2] 
)

Write an error to the library errorbuff detailing the mismatch.

Retrieve output with fr_strerror();

Todo:
add thread specific talloc contexts.
Parameters
ctxa hack until we have thread specific talloc contexts.
failedpair of attributes which didn't match.

Definition at line 1068 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool fr_pair_validate_relaxed ( VALUE_PAIR const *  failed[2],
VALUE_PAIR filter,
VALUE_PAIR list 
)

Uses fr_pair_cmp to verify all VALUE_PAIRs in list match the filter defined by check.

Note
will sort both filter and list in place.
Parameters
failedpointer to an array to write the pointers of the filter/list attributes that didn't match. May be NULL.
filterattributes to check list against.
listattributes, probably a request or reply

Definition at line 1184 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* fr_pair_value_asprint ( TALLOC_CTX *  ctx,
VALUE_PAIR const *  vp,
char  quote 
)

Print one attribute value to a string.

Parameters
ctxto allocate string in.
vpto print.
[in]quotethe quotation character
Returns
a talloced buffer with the attribute operator and value.

Definition at line 2123 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_value_bstrncpy ( VALUE_PAIR vp,
void const *  src,
size_t  len 
)

Copy data into an "string" data type.

Note
unlike the original strncpy, this function does not stop if it finds \0 bytes embedded in the string.
Parameters
[in,out]vpto update.
[in]srcdata to copy.
[in]lenof data to copy.

Definition at line 2043 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int fr_pair_value_from_str ( VALUE_PAIR vp,
char const *  value,
size_t  inlen 
)

Convert string value to native attribute value.

Parameters
vpto assign value to.
valuestring to convert. Binary safe for variable length values if len is provided.
inlenmay be < 0 in which case strlen(len) is used to determine length, else inline should be the length of the string or sub string to parse.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1840 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_value_memcpy ( VALUE_PAIR vp,
uint8_t const *  src,
size_t  size 
)

Copy data into an "octets" data type.

Parameters
[in,out]vpto update
[in]srcdata to copy
[in]sizeof the data, may be 0 in which case previous value will be freed.

Definition at line 1905 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_value_memsteal ( VALUE_PAIR vp,
uint8_t const *  src 
)

Reparent an allocated octet buffer to a VALUE_PAIR.

Parameters
[in,out]vpto update
[in]srcbuffer to steal.

Definition at line 1933 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void size_t fr_pair_value_snprint ( char *  out,
size_t  outlen,
VALUE_PAIR const *  vp,
char  quote 
)

Print the value of an attribute to a string.

Parameters
[out]outWhere to write the string.
[in]outlenSize of outlen (must be at least 3 bytes).
[in]vpto print.
[in]quoteChar to add before and after printed value, if 0 no char will be added, if < 0 raw string will be added.
Returns
  • Length of data written to out.
  • Value >= outlen on truncation.

Definition at line 2107 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t fr_pair_value_snprint_json ( char *  out,
size_t  outlen,
VALUE_PAIR const *  vp 
)
void fr_pair_value_snprintf ( VALUE_PAIR vp,
char const *  fmt,
  ... 
)

+ Here is the caller graph for this function:

void fr_pair_value_strcpy ( VALUE_PAIR vp,
char const *  src 
)

Copy data into an "string" data type.

Parameters
[in,out]vpto update
[in]srcdata to copy

Definition at line 2013 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_value_strnsteal ( VALUE_PAIR vp,
char *  src,
size_t  len 
)

Reparent an allocated char buffer to a VALUE_PAIR reallocating the buffer to the correct size.

If len is larger than the current buffer, the additional space will be filled with '\0'

Parameters
[in,out]vpto update
[in]srcbuffer to steal.
[in]lenof data in buffer.

Definition at line 1980 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void fr_pair_value_strsteal ( VALUE_PAIR vp,
char const *  src 
)

Reparent an allocated char buffer to a VALUE_PAIR.

Parameters
[in,out]vpto update
[in]srcbuffer to steal.

Definition at line 1955 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: