summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-02-10 21:55:37 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-02-10 21:55:37 +0100
commitca4151984c37fa24a97f15aaee43b6d105a43fb3 (patch)
tree0db35b8164631a04c8eeec8f03aaba3b1c1690ac
parent349c40f47bc893d089cbbdec2614bf4d2f75d379 (diff)
ctrl: Add a command to check how many bts are configured
This can be used to query how many bts are configured to check if all of them are locked or not.
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c10
-rw-r--r--openbsc/tests/ctrl_test_runner.py6
2 files changed, 16 insertions, 0 deletions
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index 572fb98..30d0a52 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -419,6 +419,15 @@ static int verify_net_rf_lock(struct ctrl_cmd *cmd, const char *value, void *dat
}
CTRL_CMD_DEFINE(net_rf_lock, "rf_locked");
+static int get_net_bts_num(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_network *net = cmd->node;
+
+ cmd->reply = talloc_asprintf(cmd, "%u", net->num_bts);
+ return CTRL_CMD_REPLY;
+}
+CTRL_CMD_DEFINE_RO(net_bts_num, "number-of-bts");
+
/* TRX related commands below here */
CTRL_HELPER_GET_INT(trx_max_power, struct gsm_bts_trx, max_power_red);
static int verify_trx_max_power(struct ctrl_cmd *cmd, const char *value, void *_data)
@@ -470,6 +479,7 @@ int bsc_base_ctrl_cmds_install(void)
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc_mnc_apply);
rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_rf_lock);
+ rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_bts_num);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_lac);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_ci);
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index 502da76..160333d 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -453,6 +453,12 @@ class TestCtrlNITB(TestCtrlBase):
def ctrl_app(self):
return (4249, "./src/osmo-nitb/osmo-nitb", "OsmoBSC", "nitb")
+ def testNumberOfBTS(self):
+ r = self.do_get('number-of-bts')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'number-of-bts')
+ self.assertEquals(r['value'], '1')
+
def testSubscriberAddRemove(self):
r = self.do_set('subscriber-modify-v1', '2620345,445566')
self.assertEquals(r['mtype'], 'SET_REPLY')