6 #include <osmocore/linuxlist.h>
8 #define RATE_CTR_INTV_NUM 4
17 /* for each of the intervals, we keep the following values */
18 struct rate_ctr_per_intv {
23 /* for each actual value, we keep the following data */
26 struct rate_ctr_per_intv intv[RATE_CTR_INTV_NUM];
29 struct rate_ctr_desc {
31 const char *description;
34 /* Describe a counter group class */
35 struct rate_ctr_group_desc {
36 /* The prefix to the name of all counters in this group */
37 const char *group_name_prefix;
38 /* The human-readable description of the group */
39 const char *group_description;
40 /* The number of counters in this group */
41 const unsigned int num_ctr;
42 /* Pointer to array of counter names */
43 const struct rate_ctr_desc *ctr_desc;
46 /* One instance of a counter group class */
47 struct rate_ctr_group {
48 /* Linked list of all counter groups in the system */
49 struct llist_head list;
50 /* Pointer to the counter group class */
51 const struct rate_ctr_group_desc *desc;
52 /* The index of this ctr_group within its class */
54 /* Actual counter structures below */
55 struct rate_ctr ctr[0];
58 /* Allocate a new group of counters according to description */
59 struct rate_ctr_group *rate_ctr_group_alloc(void *ctx,
60 const struct rate_ctr_group_desc *desc,
63 /* Free the memory for the specified group of counters */
64 void rate_ctr_group_free(struct rate_ctr_group *grp);
66 /* Add a number to the counter */
67 void rate_ctr_add(struct rate_ctr *ctr, int inc);
69 /* Increment the counter by 1 */
70 static inline void rate_ctr_inc(struct rate_ctr *ctr)
75 /* Initialize the counter module */
76 int rate_ctr_init(void *tall_ctx);
79 void vty_out_rate_ctr_group(struct vty *vty, const char *prefix,
80 struct rate_ctr_group *ctrg);
81 #endif /* RATE_CTR_H */