rate_ctr: Add functions to reset rate counter (groups)
Change-Id: If2f806d044cd0fb6929dac44ef8f8a15941ffe9b
Related: SYS#4877
diff --git a/TODO-RELEASE b/TODO-RELEASE
index e2fd830..3696681 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -15,3 +15,4 @@
gsm API/ABI change add new member to lapd_datalink
gsm new API new gsm0808_create_common_id()
gb new API new bssgp_tx_bvc_reset2()
+core new API new rate_ctr_reset(), rate_ctr_group_reset()
diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h
index f7e6e22..1669ce4 100644
--- a/include/osmocom/core/rate_ctr.h
+++ b/include/osmocom/core/rate_ctr.h
@@ -116,4 +116,7 @@
int rate_ctr_for_each_group(rate_ctr_group_handler_t handle_group, void *data);
+void rate_ctr_reset(struct rate_ctr *ctr);
+void rate_ctr_group_reset(struct rate_ctr_group *ctrg);
+
/*! @} */
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 026670b..9043a2c 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -426,4 +426,25 @@
return rc;
}
+/*! Reset a rate counter back to zero
+ * \param[in] ctr counter to reset
+ */
+void rate_ctr_reset(struct rate_ctr *ctr)
+{
+ memset(ctr, 0, sizeof(*ctr));
+}
+
+/*! Reset all counters in a group
+ * \param[in] ctrg counter group to reset
+ */
+void rate_ctr_group_reset(struct rate_ctr_group *ctrg)
+{
+ int i;
+
+ for (i = 0; i < ctrg->desc->num_ctr; i++) {
+ struct rate_ctr *ctr = &ctrg->ctr[i];
+ rate_ctr_reset(ctr);
+ }
+}
+
/*! @} */