The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Functions
stats.c File Reference

Map internal data structures to statistics. More...

#include <freeradius-devel/util/stats.h>
+ Include dependency graph for stats.c:

Go to the source code of this file.

Macros

#define add(_type, _out, _in)
 
#define COPY(_type, _field)
 

Functions

int fr_stats_from_pairs (TALLOC_CTX *ctx, fr_stats_instance_t *inst, fr_pair_list_t const *list)
 Convert a statistics structure to fr_pair_t.
 
int fr_stats_index_to_value_box (TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_instance_t const *inst, unsigned int index)
 Convert the statistic at an index to a value-box.
 
void fr_stats_iter_init (fr_stats_instance_t const *inst, fr_stats_iter_t *iter)
 Initialize an iterator over a structure.
 
bool fr_stats_iter_next (fr_stats_iter_t *iter)
 Go to the next entry in a structure.
 
int fr_stats_iter_to_value_box (TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_iter_t *iter)
 Convert the statistic at the current iterator to a value-box.
 
int fr_stats_merge_instance (fr_stats_instance_t *out, fr_stats_instance_t const *in)
 Public API for merging two statistics structures.
 
int fr_stats_merge_value_box (fr_value_box_t *dst, fr_value_box_t const *src)
 Public API for merging two value-boxes based on their enums.
 
int fr_stats_name_to_value_box (TALLOC_CTX *ctx, fr_value_box_t **out, fr_stats_instance_t const *inst, char const *name)
 Convert the statistic of a given name to a value-box.
 
int fr_stats_to_pairs (TALLOC_CTX *ctx, fr_pair_list_t *out, fr_stats_instance_t const *inst)
 Convert a statistics structure to fr_pair_t.
 
static int stats_merge_internal (fr_stats_link_t const *def, void *out, void const *in)
 Merge to statistics structures.
 

Detailed Description

Map internal data structures to statistics.

Definition in file stats.c.

Macro Definition Documentation

◆ add

#define add (   _type,
  _out,
  _in 
)
Value:
do { \
_type _a, _b, _sum; \
memcpy(&_a, &_out, sizeof(_a)); \
memcpy(&_b, &_in, sizeof(_b)); \
_sum = _a + _b; \
memcpy(&_out, &_sum, sizeof(_sum)); \
} while (0)

Definition at line 187 of file stats.c.

◆ COPY

#define COPY (   _type,
  _field 
)
Value:
case _type: \
memcpy(field, &vp->vp_ ## _field, sizeof(vp->vp_ ##_field)); \
break
fr_pair_t * vp

Function Documentation

◆ fr_stats_from_pairs()

int fr_stats_from_pairs ( TALLOC_CTX *  ctx,
fr_stats_instance_t inst,
fr_pair_list_t const *  list 
)

Convert a statistics structure to fr_pair_t.

Parameters
[in]ctxtalloc ctx
[out]instwhere the output pairs will be stored
[in]listpairs where we read the pairs from

Definition at line 114 of file stats.c.

+ Here is the call graph for this function:

◆ fr_stats_index_to_value_box()

int fr_stats_index_to_value_box ( TALLOC_CTX *  ctx,
fr_value_box_t **  out,
fr_stats_instance_t const *  inst,
unsigned int  index 
)

Convert the statistic at an index to a value-box.

Parameters
[in]ctxthe talloc context
[out]outthe value-box to return
[in]instdata structure defining this instance of the statistics
[in]indexthe field index of the structure to use
Returns
  • 0 for success, and *out is non-NULL
  • <0 for error (memory allocation failed, index is invalid, etc), and *out is NULL

Definition at line 343 of file stats.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_stats_iter_init()

void fr_stats_iter_init ( fr_stats_instance_t const *  inst,
fr_stats_iter_t iter 
)

Initialize an iterator over a structure.

Parameters
[in]instdata structure defining this instance of the statistics
[out]iterthe initialized iterator

Definition at line 309 of file stats.c.

◆ fr_stats_iter_next()

bool fr_stats_iter_next ( fr_stats_iter_t iter)

Go to the next entry in a structure.

Parameters
[in]iterthe iterator
Returns
  • true for continue the iteration
  • false for the iteration is done

Definition at line 322 of file stats.c.

◆ fr_stats_iter_to_value_box()

int fr_stats_iter_to_value_box ( TALLOC_CTX *  ctx,
fr_value_box_t **  out,
fr_stats_iter_t iter 
)

Convert the statistic at the current iterator to a value-box.

Parameters
[in]ctxthe talloc context
[out]outthe value-box to return
[in]iterthe iterator, which points to the current entry.
Returns
  • 0 for success, and *out is non-NULL
  • <0 for error (memory allocation failed, index is invalid, etc), and *out is NULL

Definition at line 416 of file stats.c.

+ Here is the call graph for this function:

◆ fr_stats_merge_instance()

int fr_stats_merge_instance ( fr_stats_instance_t out,
fr_stats_instance_t const *  in 
)

Public API for merging two statistics structures.

Parameters
[out]outwhere the merged stats are written to
[in]insource stats to merge into out
Returns
  • 0 on success
  • <0 on the two instances are not compatible.

Definition at line 241 of file stats.c.

+ Here is the call graph for this function:

◆ fr_stats_merge_value_box()

int fr_stats_merge_value_box ( fr_value_box_t dst,
fr_value_box_t const *  src 
)

Public API for merging two value-boxes based on their enums.

Parameters
[in,out]dstwhere the merged stats are written to
[in]srcsource stats to merge into dst
Returns
  • 0 on success
  • <0 on the two boxes are not compatible, or we cannot merge the given data type

Definition at line 260 of file stats.c.

◆ fr_stats_name_to_value_box()

int fr_stats_name_to_value_box ( TALLOC_CTX *  ctx,
fr_value_box_t **  out,
fr_stats_instance_t const *  inst,
char const *  name 
)

Convert the statistic of a given name to a value-box.

Parameters
[in]ctxthe talloc context
[out]outthe value-box to return
[in]instdata structure defining this instance of the statistics
[in]namethe field name in the structure
Returns
  • 0 for success, and *out is non-NULL
  • <0 for error (memory allocation failed, name is invalid, etc), and *out is NULL

Definition at line 435 of file stats.c.

+ Here is the call graph for this function:

◆ fr_stats_to_pairs()

int fr_stats_to_pairs ( TALLOC_CTX *  ctx,
fr_pair_list_t out,
fr_stats_instance_t const *  inst 
)

Convert a statistics structure to fr_pair_t.

Parameters
[in]ctxtalloc ctx
[out]outwhere the output pairs will be stored
[in]instdata structure defining this instance of the statistics

Definition at line 33 of file stats.c.

+ Here is the call graph for this function:

◆ stats_merge_internal()

static int stats_merge_internal ( fr_stats_link_t const *  def,
void *  out,
void const *  in 
)
static

Merge to statistics structures.

Todo:
  • ensure that the struct magic is the same as the def magic

Definition at line 201 of file stats.c.

+ Here is the caller graph for this function: