This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
daniel gerrit-no-reply at lists.osmocom.orgdaniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/19294 )
Change subject: rate_ctr: Add functions to reset rate counter (groups)
......................................................................
rate_ctr: Add functions to reset rate counter (groups)
Change-Id: If2f806d044cd0fb6929dac44ef8f8a15941ffe9b
Related: SYS#4877
---
M TODO-RELEASE
M include/osmocom/core/rate_ctr.h
M src/rate_ctr.c
3 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/19294/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index e2fd830..61fd1cf 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 net API new rate_ctr_reset_{ctr,group}()
diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h
index f7e6e22..2f89ed2 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_ctr(struct rate_ctr *ctr);
+void rate_ctr_reset_group(struct rate_ctr_group *ctrg);
+
/*! @} */
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 026670b..13c366f 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -426,4 +426,26 @@
return rc;
}
+/*! Reset a rate counter back to zero
+ * \param[in] ctr counter to reset
+ */
+void rate_ctr_reset_ctr(struct rate_ctr *ctr)
+{
+ memset(ctr, 0, sizeof(*ctr));
+}
+
+static int reset_rate_ctr_handler(struct rate_ctr_group *ctrg_, struct rate_ctr *ctr, const struct rate_ctr_desc *desc_, void *sctx_)
+{
+ rate_ctr_reset_ctr(ctr);
+ return 0;
+}
+
+/*! Reset all counters in a groupV
+ * \param[in] ctrg counter group to reset
+ */
+void rate_ctr_reset_ctr_group(struct rate_ctr_group *ctrg)
+{
+ rate_ctr_for_each_counter(ctrg, reset_rate_ctr_handler, NULL);
+}
+
/*! @} */
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/19294
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If2f806d044cd0fb6929dac44ef8f8a15941ffe9b
Gerrit-Change-Number: 19294
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200716/731c5ec5/attachment.htm>