[MERGED] libosmocore[master]: Fix retrieving rate_ctr over control interface

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Jun 14 22:21:24 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Fix retrieving rate_ctr over control interface
......................................................................


Fix retrieving rate_ctr over control interface

Allow getting either particular
counter (e. g. rate_ctr.per_hour.e1inp.0.hdlc.abort) or entire rate
counter group for a given index (e. g. rate_ctr.per_hour.e1inp.0).

Change-Id: I2b0109536170f7b5388d3236df30b98f457aa98d
Fixes: OS#1730
Reviewed-on: https://gerrit.osmocom.org/274
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge at gnumonks.org>
---
M src/ctrl/control_if.c
1 file changed, 7 insertions(+), 13 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index bde245d..6d9a9fb 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -552,35 +552,29 @@
 	}
 
 	ctr_group = strtok_r(NULL, ".", &saveptr);
-	tmp = strtok_r(NULL, ".", &saveptr);
-	if (!ctr_group || !tmp) {
+	ctr_idx = strtok_r(NULL, ".", &saveptr);
+	if (!ctr_group || !ctr_idx) {
 		talloc_free(dup);
-		cmd->reply = "Counter group must be of form a.b";
+		cmd->reply = "Counter group must be of name.index form e. g. "
+			"e1inp.0";
 		goto err;
 	}
-	ctr_group[strlen(ctr_group)] = '.';
 
-	ctr_idx = strtok_r(NULL, ".", &saveptr);
-	if (!ctr_idx) {
-		talloc_free(dup);
-		return get_rate_ctr_group(ctr_group, intv, cmd);
-	}
 	idx = atoi(ctr_idx);
 
 	ctrg = rate_ctr_get_group_by_name_idx(ctr_group, idx);
 	if (!ctrg) {
 		talloc_free(dup);
-		cmd->reply = "Counter group not found.";
+		cmd->reply = "Counter group with given name and index not found";
 		goto err;
 	}
 
-	ctr_name = strtok_r(NULL, "\0", &saveptr);
-	if (!ctr_name) {
+	if (!strlen(saveptr)) {
 		talloc_free(dup);
 		return get_rate_ctr_group_idx(ctrg, intv, cmd);
 	}
 
-	ctr = rate_ctr_get_by_name(ctrg, ctr_name);
+	ctr = rate_ctr_get_by_name(ctrg, saveptr);
 	if (!ctr) {
 		cmd->reply = "Counter name not found.";
 		talloc_free(dup);

-- 
To view, visit https://gerrit.osmocom.org/274
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b0109536170f7b5388d3236df30b98f457aa98d
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list