nat: Switch per BSC counters to the rate ctr.
This is switching the simple statistics to the rate counter
and is updating all users...
diff --git a/openbsc/src/nat/bsc_nat_utils.c b/openbsc/src/nat/bsc_nat_utils.c
index eed7f3a..d211853 100644
--- a/openbsc/src/nat/bsc_nat_utils.c
+++ b/openbsc/src/nat/bsc_nat_utils.c
@@ -38,6 +38,20 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+
+static const struct rate_ctr_desc bsc_cfg_ctr_description[] = {
+ [BCFG_CTR_SCCP_CONN] = { "sccp.conn", "SCCP Connections" },
+ [BCFG_CTR_SCCP_CALLS] = { "sccp.calls", "SCCP Assignment Commands"},
+ [BCFG_CTR_NET_RECONN] = { "net.reconnects", "Network reconnects"},
+};
+
+static const struct rate_ctr_group_desc bsc_cfg_ctrg_desc = {
+ .group_name_prefix = "nat.bsc",
+ .group_description = "NAT BSC Statistics",
+ .num_ctr = ARRAY_SIZE(bsc_cfg_ctr_description),
+ .ctr_desc = bsc_cfg_ctr_description,
+};
+
struct bsc_nat *bsc_nat_alloc(void)
{
struct bsc_nat *nat = talloc_zero(tall_bsc_ctx, struct bsc_nat);
@@ -94,9 +108,11 @@
llist_add_tail(&conf->entry, &nat->bsc_configs);
++nat->num_bsc;
- conf->stats.sccp.conn = counter_alloc("nat.bsc.sccp.conn");
- conf->stats.sccp.calls = counter_alloc("nat.bsc.sccp.calls");
- conf->stats.net.reconn = counter_alloc("nat.bsc.net.reconnects");
+ conf->stats.ctrg = rate_ctr_group_alloc(conf, &bsc_cfg_ctrg_desc, conf->lac);
+ if (!conf->stats.ctrg) {
+ talloc_free(conf);
+ return NULL;
+ }
return conf;
}
@@ -489,4 +505,4 @@
llist_add_tail(&entry->list, &lst->fltr_list);
return entry;
-}
\ No newline at end of file
+}