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

Go to the source code of this file.

Macros

#define CHECK(_type)
 
#define PW_TYPE_BOUNDED
 Match all fixed length types in case statements. More...
 
#define PW_TYPE_UNBOUNDED
 Match all variable length types in case statements. More...
 

Functions

char * value_data_asprint (TALLOC_CTX *ctx, PW_TYPE type, fr_dict_attr_t const *enumv, value_data_t const *data, char quote)
 Print one attribute value to a string. More...
 
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. More...
 
static int value_data_cidr_cmp_op (FR_TOKEN op, int bytes, uint8_t a_net, uint8_t const *a, uint8_t b_net, uint8_t const *b)
 
int value_data_cmp (PW_TYPE a_type, value_data_t const *a, PW_TYPE b_type, value_data_t const *b)
 Compare two values. More...
 
int value_data_cmp_op (FR_TOKEN op, PW_TYPE a_type, value_data_t const *a, PW_TYPE b_type, value_data_t const *b)
 Compare two attributes using an operator. More...
 
int value_data_copy (TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE src_type, const value_data_t *src)
 Copy value data verbatim duplicating any buffers. More...
 
int value_data_from_str (TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE *src_type, fr_dict_attr_t const *src_enumv, char const *src, ssize_t src_len, char quote)
 Convert string value to a value_data_t type. More...
 
static void value_data_hton (value_data_t *dst, PW_TYPE type, void const *src, size_t src_len)
 Performs byte order reversal for types that need it. More...
 
size_t value_data_snprint (char *out, size_t outlen, PW_TYPE type, fr_dict_attr_t const *enumv, value_data_t const *data, char quote)
 Print the value of an attribute to a string. More...
 
int value_data_steal (TALLOC_CTX *ctx, value_data_t *dst, PW_TYPE src_type, const value_data_t *src)
 Copy value data verbatim moving any buffers to the specified context. More...
 

Variables

static char const hextab [] = "0123456789abcdef"
 

Macro Definition Documentation

#define CHECK (   _type)
Value:
if (a->_type < b->_type) { compare = -1; \
} else if (a->_type > b->_type) { compare = +1; }
#define PW_TYPE_BOUNDED
Value:
case PW_TYPE_SHORT: \
case PW_TYPE_DATE: \
case PW_TYPE_IFID: \
Time value (struct timeval), only for config items.
Definition: radius.h:55
32 Bit signed integer.
Definition: radius.h:45
WiMAX IPv4 or IPv6 address depending on length.
Definition: radius.h:46
WiMAX IPv4 or IPv6 address prefix depending on length.
Definition: radius.h:57
8 Bit unsigned integer.
Definition: radius.h:42
Interface ID.
Definition: radius.h:39
Double precision floating point.
Definition: radius.h:58
48 Bit Mac-Address.
Definition: radius.h:44
A truth value.
Definition: radius.h:56
32 Bit unsigned integer.
Definition: radius.h:34
64 Bit unsigned integer.
Definition: radius.h:51
32 Bit Unix timestamp.
Definition: radius.h:36
16 Bit unsigned integer.
Definition: radius.h:43

Match all fixed length types in case statements.

Note
This should be used for switch statements in printing and casting functions that need to deal with all types representing values

Definition at line 410 of file value.c.

#define PW_TYPE_UNBOUNDED
Value:
128 Bit IPv6 Address.
Definition: radius.h:40
Ascend binary format a packed data structure.
Definition: radius.h:37
IPv6 Prefix.
Definition: radius.h:41
IPv4 Prefix.
Definition: radius.h:52
String of printable characters.
Definition: radius.h:33
32 Bit IPv4 Address.
Definition: radius.h:35
Raw octets.
Definition: radius.h:38

Match all variable length types in case statements.

Note
This should be used for switch statements in printing and casting functions that need to deal with all types representing values

Definition at line 430 of file value.c.

Function Documentation

char* value_data_asprint ( TALLOC_CTX *  ctx,
PW_TYPE  type,
fr_dict_attr_t const *  enumv,
value_data_t const *  data,
char  quote 
)

Print one attribute value to a string.

Definition at line 1543 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Note
This should be the canonical function used to convert between data types.
Parameters
ctxto allocate buffers in (usually the same as dst)
dstWhere to write result of casting.
dst_typeto cast to.
dst_enumvEnumerated values used to converts strings to integers.
src_typeto cast from.
src_enumvEnumerated values used to convert integers to strings.
srcInput data.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1073 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int value_data_cidr_cmp_op ( FR_TOKEN  op,
int  bytes,
uint8_t  a_net,
uint8_t const *  a,
uint8_t  b_net,
uint8_t const *  b 
)
static

Definition at line 180 of file value.c.

+ Here is the caller graph for this function:

int value_data_cmp ( PW_TYPE  a_type,
value_data_t const *  a,
PW_TYPE  b_type,
value_data_t const *  b 
)

Compare two values.

Parameters
[in]a_typeof data to compare.
[in]aValue to compare.
[in]b_typeof data to compare.
[in]bValue to compare.
Returns
  • -1 if a is less than b.
  • 0 if both are equal.
  • 1 if a is more than b.
  • < -1 on failure.

Definition at line 40 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_cmp_op ( FR_TOKEN  op,
PW_TYPE  a_type,
value_data_t const *  a,
PW_TYPE  b_type,
value_data_t const *  b 
)

Compare two attributes using an operator.

Parameters
[in]opto use in comparison.
[in]a_typeof data to compare.
[in]aValue to compare.
[in]b_typeof data to compare.
[in]bValue to compare.
Returns
  • 1 if true
  • 0 if false
  • -1 on failure.

Definition at line 299 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_copy ( TALLOC_CTX *  ctx,
value_data_t dst,
PW_TYPE  src_type,
const value_data_t src 
)

Copy value data verbatim duplicating any buffers.

Parameters
ctxTo allocate buffers in.
dstWhere to copy value_data to.
src_typeType of src.
srcWhere to copy value_data from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1479 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_from_str ( TALLOC_CTX *  ctx,
value_data_t dst,
PW_TYPE src_type,
fr_dict_attr_t const *  src_enumv,
char const *  src,
ssize_t  src_len,
char  quote 
)

Convert string value to a value_data_t type.

Parameters
[in]ctxto alloc strings in.
[out]dstwhere to write parsed value.
[in,out]src_typeof value data to create/type of value created.
[in]src_enumvfr_dict_attr_t with string aliases for integer values.
[in]srcString to convert. Binary safe for variable length values if len is provided.
[in]src_lenmay be < 0 in which case strlen(len) is used to determine length, else src_len should be the length of the string or sub string to parse.
[in]quotequotation character used to drive de-escaping
Returns
  • 0 on success.
  • -1 on parse error.

Definition at line 455 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void value_data_hton ( value_data_t dst,
PW_TYPE  type,
void const *  src,
size_t  src_len 
)
static

Performs byte order reversal for types that need it.

Definition at line 1028 of file value.c.

+ Here is the caller graph for this function:

size_t value_data_snprint ( char *  out,
size_t  outlen,
PW_TYPE  type,
fr_dict_attr_t const *  enumv,
value_data_t const *  data,
char  quote 
)

Print the value of an attribute to a string.

Note
return value should be checked with is_truncated.
Will always \0 terminate unless outlen == 0.
Parameters
outWhere to write the printed version of the attribute value.
outlenLength of the output buffer.
typeof data being printed.
enumvEnumerated string values for integer types.
datato print.
quotechar to escape in string output.
Returns
  • The number of bytes written to the out buffer.
  • A number >= outlen if truncation has occurred.

Definition at line 1727 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int value_data_steal ( TALLOC_CTX *  ctx,
value_data_t dst,
PW_TYPE  src_type,
const value_data_t src 
)

Copy value data verbatim moving any buffers to the specified context.

Parameters
ctxTo allocate buffers in.
dstWhere to copy value_data to.
src_typeType of src.
srcWhere to copy value_data from.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1512 of file value.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char const hextab[] = "0123456789abcdef"
static

Definition at line 439 of file value.c.