libosmocore 0.9.6-23.20170220git32ee5af8.fc42
Osmocom core library
|
Files | |
file | rate_ctr.h |
file | rate_ctr.c |
Data Structures | |
struct | rate_ctr_per_intv |
data we keep for each of the intervals More... | |
struct | rate_ctr |
data we keep for each actual value More... | |
struct | rate_ctr_desc |
rate counter description More... | |
struct | rate_ctr_group_desc |
description of a rate counter group More... | |
struct | rate_ctr_group |
One instance of a counter group class. More... | |
Macros | |
#define | RATE_CTR_INTV_NUM 4 |
Number of rate counter intervals. | |
Typedefs | |
typedef int(* | rate_ctr_handler_t) (struct rate_ctr_group *, struct rate_ctr *, const struct rate_ctr_desc *, void *) |
typedef int(* | rate_ctr_group_handler_t) (struct rate_ctr_group *, void *) |
Enumerations | |
enum | rate_ctr_intv { RATE_CTR_INTV_SEC , RATE_CTR_INTV_MIN , RATE_CTR_INTV_HOUR , RATE_CTR_INTV_DAY } |
Rate counter interval. More... | |
Functions | |
struct rate_ctr_group * | rate_ctr_group_alloc (void *ctx, const struct rate_ctr_group_desc *desc, unsigned int idx) |
Allocate a new group of counters according to description. | |
static void | rate_ctr_group_upd_idx (struct rate_ctr_group *grp, unsigned int idx) |
void | rate_ctr_group_free (struct rate_ctr_group *grp) |
Free the memory for the specified group of counters. | |
void | rate_ctr_add (struct rate_ctr *ctr, int inc) |
Increment the counter by inc. | |
static void | rate_ctr_inc (struct rate_ctr *ctr) |
Increment the counter by 1. | |
int64_t | rate_ctr_difference (struct rate_ctr *ctr) |
Return the counter difference since the last call to this function. | |
int | rate_ctr_init (void *tall_ctx) |
Initialize the counter module. | |
struct rate_ctr_group * | rate_ctr_get_group_by_name_idx (const char *name, const unsigned int idx) |
Search for counter group based on group name and index. | |
const struct rate_ctr * | rate_ctr_get_by_name (const struct rate_ctr_group *ctrg, const char *name) |
Search for counter based on group + name. | |
int | rate_ctr_for_each_counter (struct rate_ctr_group *ctrg, rate_ctr_handler_t handle_counter, void *data) |
Iterate over all counters. | |
int | rate_ctr_for_each_group (rate_ctr_group_handler_t handle_group, void *data) |
Iterate over all counter groups. | |
static | LLIST_HEAD (rate_ctr_groups) |
static void | interval_expired (struct rate_ctr *ctr, enum rate_ctr_intv intv) |
static void | rate_ctr_group_intv (struct rate_ctr_group *grp) |
static void | rate_ctr_timer_cb (void *data) |
Variables | |
static void * | tall_rate_ctr_ctx |
static struct osmo_timer_list | rate_ctr_timer |
static uint64_t | timer_ticks |
enum rate_ctr_intv |
void rate_ctr_add | ( | struct rate_ctr * | ctr, |
int | inc ) |
Increment the counter by inc.
Add a number to the counter.
ctr | Rate counters to increment |
inc | quantity to increment ctr by |
References current.
Referenced by rate_ctr_inc().
int rate_ctr_for_each_counter | ( | struct rate_ctr_group * | ctrg, |
rate_ctr_handler_t | handle_counter, | ||
void * | data ) |
Iterate over all counters.
Iterate over each counter in group and call function.
[in] | handle_item | Call-back function, aborts if rc < 0 |
[in] | data | Private data handed through to handle_counter |
[in] | counter | group over whose counter to iterate |
[in] | handle_counter | function pointer |
[in] | data | Data to hand transparently to handle_counter |
References rate_ctr_group::ctr, rate_ctr_group_desc::ctr_desc, rate_ctr_group::desc, and rate_ctr_group_desc::num_ctr.
int rate_ctr_for_each_group | ( | rate_ctr_group_handler_t | handle_group, |
void * | data ) |
Iterate over all counter groups.
[in] | handle_group | function pointer of callback function |
[in] | data | Data to hand transparently to handle_group |
References rate_ctr_group::list, and llist_for_each_entry.
const struct rate_ctr * rate_ctr_get_by_name | ( | const struct rate_ctr_group * | ctrg, |
const char * | name ) |
Search for counter based on group + name.
[in] | ctrg | pointer to rate_ctr_group |
[in] | name | name of counter inside group |
References rate_ctr_group::ctr, rate_ctr_group_desc::ctr_desc, rate_ctr_group::desc, rate_ctr_desc::name, and rate_ctr_group_desc::num_ctr.
struct rate_ctr_group * rate_ctr_get_group_by_name_idx | ( | const char * | name, |
const unsigned int | idx ) |
Search for counter group based on group name and index.
[in] | name | Name of the counter group you're looking for |
[in] | idx | Index inside the counter group |
References rate_ctr_group::desc, rate_ctr_group_desc::group_name_prefix, rate_ctr_group::idx, rate_ctr_group::list, and llist_for_each_entry.
struct rate_ctr_group * rate_ctr_group_alloc | ( | void * | ctx, |
const struct rate_ctr_group_desc * | desc, | ||
unsigned int | idx ) |
Allocate a new group of counters according to description.
[in] | ctx | talloc context |
[in] | desc | Rate counter group description |
[in] | idx | Index of new counter group |
References rate_ctr_group::desc, rate_ctr_group::idx, rate_ctr_group::list, and llist_add().
|
inlinestatic |
Increment the counter by 1.
ctr | Rate counters to increment |
References rate_ctr_group::ctr, and rate_ctr_add().