summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Kluchnikov <kluchnikovi@gmail.com>2014-04-11 13:22:23 +0400
committerIvan Kluchnikov <kluchnikovi@gmail.com>2014-05-06 15:40:30 +0400
commite4448ac1496ff19e38709d897b4ba97e8626837d (patch)
treefe396fb4df97be02d45e2f2da5155a02a7a5469e
parent6c88e127d02c6c89e0889ba3078019d6928b951f (diff)
nitb/ctrl: Add ctrl command to get/set band
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c33
-rw-r--r--openbsc/tests/ctrl_test_runner.py19
2 files changed, 52 insertions, 0 deletions
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index 3cb77cccb..bbd4fbd54 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -183,6 +183,37 @@ oom:
}
CTRL_CMD_DEFINE(net_mcc_mnc_apply, "mcc-mnc-apply");
+/* BTS related commands below here */
+static int verify_bts_band(struct ctrl_cmd *cmd, const char *value, void *data)
+{
+
+ if ((int)gsm_band_parse(value) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static int get_bts_band(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts *bts = cmd->node;
+ cmd->reply = talloc_asprintf(cmd, "%s", gsm_band_name(bts->band));
+ if (!cmd->reply) {
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+ }
+ return CTRL_CMD_REPLY;
+}
+
+static int set_bts_band(struct ctrl_cmd *cmd, void *data)
+{
+ struct gsm_bts *bts = cmd->node;
+ bts->band = gsm_band_parse(cmd->value);
+ return get_bts_band(cmd, data);
+}
+
+CTRL_CMD_DEFINE(bts_band, "band");
+
/* 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)
@@ -234,6 +265,8 @@ 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_BTS, &cmd_bts_band);
+
rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power);
return rc;
}
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index f24d52af7..243ac0f15 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -380,6 +380,25 @@ class TestCtrlNITB(TestCtrlBase):
self.assertEquals(r['mtype'], 'ERROR')
self.assertEquals(r['error'], 'Value failed verification.')
+ def testBtsBand(self):
+ bands = ['GSM450', 'GSM480', 'GSM750', 'GSM810',
+ 'GSM850', 'GSM900', 'DCS1800', 'PCS1900']
+
+ for band in bands:
+ r = self.do_set('bts.0.band', band)
+ self.assertEquals(r['mtype'], 'SET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.band')
+ self.assertEquals(r['value'], band)
+
+ r = self.do_get('bts.0.band')
+ self.assertEquals(r['mtype'], 'GET_REPLY')
+ self.assertEquals(r['var'], 'bts.0.band')
+ self.assertEquals(r['value'], band)
+
+ r = self.do_set('bts.0.band', 'qwerty')
+ self.assertEquals(r['mtype'], 'ERROR')
+ self.assertEquals(r['error'], 'Value failed verification.')
+
def testSubscriberAddRemove(self):
r = self.do_set('subscriber-modify-v1', '2620345,445566')
self.assertEquals(r['mtype'], 'SET_REPLY')