summaryrefslogtreecommitdiff
path: root/pceplib/pcep_utils_counters.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2024-01-10 15:26:05 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2024-01-18 22:04:05 +0100
commit09047d2bf614d7794fb855923caa94cbfeb94ceb (patch)
tree3550cb1119ba8a4c598f2e245f33355e84eab447 /pceplib/pcep_utils_counters.c
parent94178edac3b36c6b2ebc09173a589b14419cf04e (diff)
pceplib: add json string option to subgroup counter
The created counters in pceplib library are structures with a string attribute which is used for further display. This string information is not formatted for json output. Add a second option in the create_subgroup_counter() creation API to provide the json attribute output. Create a json naming compatible with caml format for each subgroup counter used. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'pceplib/pcep_utils_counters.c')
-rw-r--r--pceplib/pcep_utils_counters.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/pceplib/pcep_utils_counters.c b/pceplib/pcep_utils_counters.c
index badef9351a..1ab341c69c 100644
--- a/pceplib/pcep_utils_counters.c
+++ b/pceplib/pcep_utils_counters.c
@@ -139,7 +139,8 @@ clone_counters_subgroup(struct counters_subgroup *subgroup,
if (counter != NULL) {
create_subgroup_counter(cloned_subgroup,
counter->counter_id,
- counter->counter_name);
+ counter->counter_name,
+ counter->counter_name_json);
}
}
@@ -180,7 +181,8 @@ bool add_counters_subgroup(struct counters_group *group,
}
bool create_subgroup_counter(struct counters_subgroup *subgroup,
- uint32_t counter_id, const char *counter_name)
+ uint32_t counter_id, const char *counter_name,
+ const char *counter_name_json)
{
if (subgroup == NULL) {
pcep_log(
@@ -212,7 +214,9 @@ bool create_subgroup_counter(struct counters_subgroup *subgroup,
counter->counter_id = counter_id;
strlcpy(counter->counter_name, counter_name,
sizeof(counter->counter_name));
-
+ if (counter_name_json)
+ strlcpy(counter->counter_name_json, counter_name_json,
+ sizeof(counter->counter_name_json));
subgroup->num_counters++;
subgroup->counters[counter->counter_id] = counter;