blob: 18493277e99169499e5765600cc04da3c87439fb [file] [log] [blame]
Harald Welteec8b4502010-02-20 20:34:29 +01001#ifndef _STATISTICS_H
2#define _STATISTICS_H
3
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +02004struct osmo_counter {
Harald Welteec8b4502010-02-20 20:34:29 +01005 struct llist_head list;
6 const char *name;
7 const char *description;
8 unsigned long value;
9};
10
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020011static inline void osmo_counter_inc(struct osmo_counter *ctr)
Harald Welteec8b4502010-02-20 20:34:29 +010012{
13 ctr->value++;
14}
15
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020016static inline unsigned long osmo_counter_get(struct osmo_counter *ctr)
Harald Welteec8b4502010-02-20 20:34:29 +010017{
18 return ctr->value;
19}
20
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020021static inline void osmo_counter_reset(struct osmo_counter *ctr)
Harald Welteec8b4502010-02-20 20:34:29 +010022{
23 ctr->value = 0;
24}
25
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020026struct osmo_counter *osmo_counter_alloc(const char *name);
27void osmo_counter_free(struct osmo_counter *ctr);
Harald Welteec8b4502010-02-20 20:34:29 +010028
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020029int osmo_counters_for_each(int (*handle_counter)(struct osmo_counter *, void *), void *data);
Harald Welteec8b4502010-02-20 20:34:29 +010030
Pablo Neira Ayuso220abab2011-05-07 12:43:04 +020031struct osmo_counter *osmo_counter_get_by_name(const char *name);
Daniel Willmann334c8e12011-04-08 10:46:19 +020032
Harald Welteec8b4502010-02-20 20:34:29 +010033#endif /* _STATISTICS_H */