stat,rate_ctr: Introduce new API to get counter at given index

Having this API and forcing apps to use it will allow easily adding new
members to the group structure without having so much impact in users of
this struct.

Related: SYS#5456
Change-Id: Iebbf401f11e36645f8964d389460918eb9e0910e
diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h
index 1669ce4..17ee672 100644
--- a/include/osmocom/core/rate_ctr.h
+++ b/include/osmocom/core/rate_ctr.h
@@ -61,7 +61,7 @@
 	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 @@
 	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 @@
  *  \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));
 }