aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-06-14 18:17:06 +0200
committerHarald Welte <laforge@gnumonks.org>2016-06-14 22:21:24 +0000
commit22886d9e320ecf734d2827d825a191b977f70d2c (patch)
tree40e6aed5cbe3530baf582cdaf6b49a6d6b749b88
parentad580ba7c400835fdff0226700dd02c7ffff32c6 (diff)
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@gnumonks.org>
-rw-r--r--src/ctrl/control_if.c20
1 files changed, 7 insertions, 13 deletions
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 @@ static int get_rate_ctr(struct ctrl_cmd *cmd, void *data)
}
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);