aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/core/rate_ctr.h6
-rw-r--r--include/osmocom/core/stat_item.h2
-rw-r--r--src/rate_ctr.c10
-rw-r--r--src/stat_item.c10
4 files changed, 25 insertions, 3 deletions
diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h
index 1669ce49..17ee672f 100644
--- a/include/osmocom/core/rate_ctr.h
+++ b/include/osmocom/core/rate_ctr.h
@@ -61,7 +61,7 @@ struct rate_ctr_group {
const struct rate_ctr_group_desc *desc;
/*! The index of this ctr_group within its class */
unsigned int idx;
- /*! Actual counter structures below */
+ /*! Actual counter structures below. Don't access it directly, use APIs below! */
struct rate_ctr ctr[0];
};
@@ -74,6 +74,8 @@ static inline void rate_ctr_group_upd_idx(struct rate_ctr_group *grp, unsigned i
grp->idx = idx;
}
+struct rate_ctr *rate_ctr_group_get_ctr(struct rate_ctr_group *grp, unsigned int idx);
+
void rate_ctr_group_free(struct rate_ctr_group *grp);
/*! Increment the counter by \a inc
@@ -93,7 +95,7 @@ static inline void rate_ctr_inc(struct rate_ctr *ctr)
* \param idx index into \a ctrg counter group */
static inline void rate_ctr_inc2(struct rate_ctr_group *ctrg, unsigned int idx)
{
- rate_ctr_inc(&ctrg->ctr[idx]);
+ rate_ctr_inc(rate_ctr_group_get_ctr(ctrg, idx));
}
diff --git a/include/osmocom/core/stat_item.h b/include/osmocom/core/stat_item.h
index 29e35ef6..3cace084 100644
--- a/include/osmocom/core/stat_item.h
+++ b/include/osmocom/core/stat_item.h
@@ -79,7 +79,7 @@ static inline void osmo_stat_item_group_udp_idx(
{
grp->idx = idx;
}
-
+struct osmo_stat_item *osmo_stat_item_group_get_item(struct osmo_stat_item_group *grp, unsigned int idx);
void osmo_stat_item_group_free(struct osmo_stat_item_group *statg);
void osmo_stat_item_inc(struct osmo_stat_item *item, int32_t value);
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 9043a2c6..c3a52867 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -263,6 +263,16 @@ void rate_ctr_group_free(struct rate_ctr_group *grp)
talloc_free(grp);
}
+/*! Get rate counter from group, identified by index idx
+ * \param[in] grp Rate counter group
+ * \param[in] idx Index of the counter to retrieve
+ * \returns rate counter requested
+ */
+struct rate_ctr *rate_ctr_group_get_ctr(struct rate_ctr_group *grp, unsigned int idx)
+{
+ return &grp->ctr[idx];
+}
+
/*! Add a number to the counter */
void rate_ctr_add(struct rate_ctr *ctr, int inc)
{
diff --git a/src/stat_item.c b/src/stat_item.c
index 40374a7c..a6f86cb9 100644
--- a/src/stat_item.c
+++ b/src/stat_item.c
@@ -167,6 +167,16 @@ void osmo_stat_item_group_free(struct osmo_stat_item_group *grp)
talloc_free(grp);
}
+/*! Get statistics item from group, identified by index idx
+ * \param[in] grp Rate counter group
+ * \param[in] idx Index of the counter to retrieve
+ * \returns rate counter requested
+ */
+struct osmo_stat_item *osmo_stat_item_group_get_item(struct osmo_stat_item_group *grp, unsigned int idx)
+{
+ return grp->items[idx];
+}
+
/*! Increase the stat_item to the given value.
* This function adds a new value for the given stat_item at the end of
* the FIFO.