[3/3] nitb/ctrl: Add ctrl command to get/set arfcn
diff mbox

Message ID 1399390559-22655-3-git-send-email-kluchnikovi@gmail.com
State Changes Requested
Headers show

Commit Message

Ivan Kluchnikov May 6, 2014, 3:35 p.m. UTC
---
 openbsc/src/libbsc/bsc_ctrl_commands.c |    2 ++
 openbsc/tests/ctrl_test_runner.py      |   15 +++++++++++++++
 2 files changed, 17 insertions(+)

Comments

Holger Freyther May 7, 2014, 7:26 a.m. UTC | #1
On Tue, May 06, 2014 at 07:35:59PM +0400, Ivan Kluchnikov wrote:

Hi again,


> +CTRL_CMD_DEFINE_RANGE(trx_arfcn, "arfcn", struct gsm_bts_trx, arfcn, 0, 1023);


Please look at cfg_trx_arfcn_cmd in src/libbsc/bsc_vty.c. There are
plenty of "FIXME" in the code and they all apply here. There are two
separate issues that your patch is touching.

1.) Align VTY and CTRL command. My approach so far was to move the
"handling" into a common method that is used by CTRL/VTY.

2.) The general question of "when" to apply the configuration. For
some commands it is immediate, for some comments it is after a BTS
is bootstrapped again and for some it requires a re-start of the
NITB application.

3.) Make it impossible to configure a "broken" system. For your code
and the VTY command it is possible to create and later save/write a
config that will not be parsed on re-start.

So this patch at least needs to do:

* Make the CTRL and VTY share a routine to "set" the ARFCN
* Move the FIXMEs into this routine
* Verify that the BAND + ARFCN would be compatible (so we would
  still have three FIXMEs left).

cheers
	holger

Patch
diff mbox

diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index bbd4fbd..d1edf29 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -253,6 +253,7 @@  static int set_trx_max_power(struct ctrl_cmd *cmd, void *_data)
 	return get_trx_max_power(cmd, _data);
 }
 CTRL_CMD_DEFINE(trx_max_power, "max-power-reduction");
+CTRL_CMD_DEFINE_RANGE(trx_arfcn, "arfcn", struct gsm_bts_trx, arfcn, 0, 1023);
 
 int bsc_base_ctrl_cmds_install(void)
 {
@@ -268,5 +269,6 @@  int bsc_base_ctrl_cmds_install(void)
 	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_band);
 
 	rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power);
+	rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_arfcn);
 	return rc;
 }
diff --git a/openbsc/tests/ctrl_test_runner.py b/openbsc/tests/ctrl_test_runner.py
index 243ac0f..0dc9800 100644
--- a/openbsc/tests/ctrl_test_runner.py
+++ b/openbsc/tests/ctrl_test_runner.py
@@ -399,6 +399,21 @@  class TestCtrlNITB(TestCtrlBase):
         self.assertEquals(r['mtype'], 'ERROR')
         self.assertEquals(r['error'], 'Value failed verification.')
 
+    def testTrxArfcn(self):
+        r = self.do_set('bts.0.trx.0.arfcn', '51')
+        self.assertEquals(r['mtype'], 'SET_REPLY')
+        self.assertEquals(r['var'], 'bts.0.trx.0.arfcn')
+        self.assertEquals(r['value'], '51')
+        
+        r = self.do_get('bts.0.trx.0.arfcn')
+        self.assertEquals(r['mtype'], 'GET_REPLY')
+        self.assertEquals(r['var'], 'bts.0.trx.0.arfcn')
+        self.assertEquals(r['value'], '51')
+        
+        r = self.do_set('bts.0.trx.0.arfcn', '3000')
+        self.assertEquals(r['mtype'], 'ERROR')
+        self.assertEquals(r['error'], 'Input not within the range')
+
     def testSubscriberAddRemove(self):
         r = self.do_set('subscriber-modify-v1', '2620345,445566')
         self.assertEquals(r['mtype'], 'SET_REPLY')