diff options
author | Max <msuraev@sysmocom.de> | 2018-11-22 18:13:28 +0100 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2018-11-22 18:13:28 +0100 |
commit | 655ef10975ab61648eb5b8c2d537ba25491f0cd4 (patch) | |
tree | cc3ad55632b72dc18e927cca5faf123790b16cbb /src | |
parent | fffd6cb0d8011442bb69974675f86ad087b7d8db (diff) |
gbproxy: add number-of-peers ctrl command
Return number of BTS peers. This is especially useful when no peers are
available because "gbproxy-state" command returns empty sstring in this
case.
Change-Id: I29b0664e60f7c81c3c7b495c1c8f2700e3f7e033
Related: SYS#2655
Diffstat (limited to 'src')
-rw-r--r-- | src/gprs/gb_proxy_ctrl.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/gprs/gb_proxy_ctrl.c b/src/gprs/gb_proxy_ctrl.c index 694a2f7f5..829d6f6a1 100644 --- a/src/gprs/gb_proxy_ctrl.c +++ b/src/gprs/gb_proxy_ctrl.c @@ -76,10 +76,23 @@ static int get_gbproxy_state(struct ctrl_cmd *cmd, void *data) CTRL_CMD_DEFINE_RO(gbproxy_state, "gbproxy-state"); +static int get_num_peers(struct ctrl_cmd *cmd, void *data) +{ + struct gbproxy_config *cfg = data; + + cmd->reply = talloc_strdup(cmd, ""); + cmd->reply = talloc_asprintf_append(cmd->reply, "%u", llist_count(&cfg->bts_peers)); + + return CTRL_CMD_REPLY; +} +CTRL_CMD_DEFINE_RO(num_peers, "number-of-peers"); + int gb_ctrl_cmds_install(void) { int rc = 0; rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_nsvc_state); rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_gbproxy_state); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_num_peers); + return rc; } |