All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
pair.c File Reference
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/regex.h>
#include <ctype.h>
+ Include dependency graph for pair.c:

Go to the source code of this file.

Functions

static int _fr_pair_free (VALUE_PAIR *vp)
 Free a VALUE_PAIR. More...
 
void fr_pair_add (VALUE_PAIR **head, VALUE_PAIR *add)
 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 *fp, VALUE_PAIR const *vp)
 Print one attribute and value to FP. More...
 
static VALUE_PAIRfr_pair_from_unknown (TALLOC_CTX *ctx, VALUE_PAIR *vp, fr_dict_attr_t const *da)
 
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 **list)
 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 *fp, VALUE_PAIR const *const_vp)
 Print a list of attributes and enumv. More...
 
void fr_pair_list_free (VALUE_PAIR **vps)
 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...
 
static void fr_pair_list_move_by_num_internal (TALLOC_CTX *ctx, VALUE_PAIR **to, VALUE_PAIR **from, unsigned int vendor, unsigned int attr, int8_t tag, bool move)
 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...
 
static VALUE_PAIRfr_pair_list_sort_merge (VALUE_PAIR *a, VALUE_PAIR *b, fr_cmp_t cmp)
 
static void fr_pair_list_sort_split (VALUE_PAIR *source, VALUE_PAIR **front, VALUE_PAIR **back)
 
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...
 
static VALUE_PAIRfr_pair_make_unknown (TALLOC_CTX *ctx, char const *attribute, char const *value, FR_TOKEN op)
 Create a valuepair from an ASCII attribute and value. 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 *replace)
 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 inlen)
 Convert string value to native attribute value. More...
 
void fr_pair_value_memcpy (VALUE_PAIR *vp, uint8_t const *src, size_t size)
 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...
 
static void fr_pair_value_set_type (VALUE_PAIR *vp)
 Set the type of the VALUE_PAIR value buffer to match it's fr_dict_attr_t. More...
 
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...
 
void fr_pair_value_snprintf (VALUE_PAIR *vp, char const *fmt,...)
 Print data into an "string" data type. More...
 
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...
 

Function Documentation

static int _fr_pair_free ( VALUE_PAIR vp)
static

Free a VALUE_PAIR.

Note
Do not call directly, use talloc_free instead.
Parameters
vpto free.
Returns
0

Definition at line 37 of file pair.c.

+ Here is the caller graph for this function:

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:

static VALUE_PAIR* fr_pair_from_unknown ( TALLOC_CTX *  ctx,
VALUE_PAIR vp,
fr_dict_attr_t const *  da 
)
static

Definition at line 213 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:

static void fr_pair_list_move_by_num_internal ( TALLOC_CTX *  ctx,
VALUE_PAIR **  to,
VALUE_PAIR **  from,
unsigned int  vendor,
unsigned int  attr,
int8_t  tag,
bool  move 
)
static

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
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.
[in]moveif set to "true", VPs are moved. If set to "false", VPs are copied, and the old one deleted.

Definition at line 1663 of file pair.c.

+ Here is the call graph for this function:

+ Here is the caller 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:

static VALUE_PAIR* fr_pair_list_sort_merge ( VALUE_PAIR a,
VALUE_PAIR b,
fr_cmp_t  cmp 
)
static

Definition at line 1010 of file pair.c.

+ Here is the caller graph for this function:

static void fr_pair_list_sort_split ( VALUE_PAIR source,
VALUE_PAIR **  front,
VALUE_PAIR **  back 
)
static

Definition at line 975 of file pair.c.

+ 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:

static VALUE_PAIR* fr_pair_make_unknown ( TALLOC_CTX *  ctx,
char const *  attribute,
char const *  value,
FR_TOKEN  op 
)
static

Create a valuepair from an ASCII attribute and value.

Where the attribute name is in the form:

  • Attr-d
  • Attr-d.d.d...
  • Vendor-d-Attr-d
  • VendorName-Attr-d
Parameters
ctxfor talloc
attributename to parse.
valueto parse (must be a hex string).
opto assign to new valuepair.
Returns
new VALUE_PAIR or NULL on error.

Definition at line 261 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:

static void fr_pair_value_set_type ( VALUE_PAIR vp)
inlinestatic

Set the type of the VALUE_PAIR value buffer to match it's fr_dict_attr_t.

Parameters
vpto fixup.

Definition at line 1881 of file pair.c.

+ Here is the caller graph for this function:

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:

void fr_pair_value_snprintf ( VALUE_PAIR vp,
char const *  fmt,
  ... 
)

Print data into an "string" data type.

Parameters
[in,out]vpto update
[in]fmtthe format string

Definition at line 2071 of file pair.c.

+ Here is the call graph for this function:

+ 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: