Change in osmo-bsc[master]: bsc_ctrl_commands: change neighbor-list mode/arfcn via control interface

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Wed Oct 27 15:47:39 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/25996 )


Change subject: bsc_ctrl_commands: change neighbor-list mode/arfcn via control interface
......................................................................

bsc_ctrl_commands: change neighbor-list mode/arfcn via control interface

It is possible to change the neighbor-list mode via the VTY from
automatic mode to manual neighbor-list configuration. In the manual
mode, the user can add ARFCN values manually. This command can be found
under the bts node. Lets add pendant of this command on the control
interface as well.

Related: SYS#5641
Change-Id: Id97bc0d31a358db6221c385761773fb48670c921
---
M doc/manuals/chapters/control.adoc
M src/osmo-bsc/bsc_ctrl_commands.c
M tests/ctrl_test_runner.py
3 files changed, 160 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/96/25996/1

diff --git a/doc/manuals/chapters/control.adoc b/doc/manuals/chapters/control.adoc
index cf3110b..8e54561 100644
--- a/doc/manuals/chapters/control.adoc
+++ b/doc/manuals/chapters/control.adoc
@@ -69,6 +69,9 @@
 |[bts.N.]handover2.retries|RW|No|<0-9>,"default"|Number of times to immediately retry a failed handover/assignment, before a penalty time is applied.
 |handover2.congestion-check|RW|No|"disabled",<1-999>,"now"|Congestion check interval in seconds, "now" triggers immediate congestion check.
 |bts.N.resend-si|WO|No|Ignored|Resend system information to BTS.
+|bts.N.neighbor-list.mode|WO|No|"automatic","manual","manual-si5"|Mode of Neighbor List generation.
+|bts.N.neighbor-list.add|WO|No|<0-1023>|Add to manual neighbor list.
+|bts.N.neighbor-list.del|WO|No|<0-1023>|Delete from manual neighbor list.
 |===
 
 [[notif]]
diff --git a/src/osmo-bsc/bsc_ctrl_commands.c b/src/osmo-bsc/bsc_ctrl_commands.c
index f2ba5af..456fcd9 100644
--- a/src/osmo-bsc/bsc_ctrl_commands.c
+++ b/src/osmo-bsc/bsc_ctrl_commands.c
@@ -683,6 +683,120 @@
 
 CTRL_CMD_DEFINE_WO_NOVRF(bts_resend_si, "resend-si");
 
+static int verify_bts_neighbor_list_add_del(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+	int arfcn;
+
+	if (osmo_str_to_int(&arfcn, value, 10, 0, 1023) < 0) {
+		cmd->reply = "Invalid ARFCN value";
+		return 1;
+	}
+
+	return 0;
+}
+
+static int set_bts_neighbor_list_add_del(struct ctrl_cmd *cmd, void *data, bool add)
+{
+	struct gsm_bts *bts = cmd->node;
+	struct bitvec *bv = &bts->si_common.neigh_list;
+	int arfcn_int;
+	uint16_t arfcn;
+	enum gsm_band unused;
+
+	if (osmo_str_to_int(&arfcn_int, cmd->value, 10, 0, 1023) < 0) {
+		cmd->reply = "Failed to parse ARFCN value";
+		return CTRL_CMD_ERROR;
+	}
+	arfcn = (uint16_t) arfcn_int;
+
+	if (bts->neigh_list_manual_mode == NL_MODE_AUTOMATIC) {
+		cmd->reply = "Neighbor list not in manual mode";
+		return CTRL_CMD_ERROR;
+	}
+
+	if (gsm_arfcn2band_rc(arfcn, &unused) < 0) {
+		cmd->reply = "Invalid arfcn detected";
+		return CTRL_CMD_ERROR;
+	}
+
+	if (add)
+		bitvec_set_bit_pos(bv, arfcn, 1);
+	else
+		bitvec_set_bit_pos(bv, arfcn, 0);
+
+	cmd->reply = "OK";
+	return CTRL_CMD_REPLY;
+}
+
+static int verify_bts_neighbor_list_add(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+	return verify_bts_neighbor_list_add_del(cmd, value, _data);
+}
+
+static int set_bts_neighbor_list_add(struct ctrl_cmd *cmd, void *data)
+{
+	return set_bts_neighbor_list_add_del(cmd, data, true);
+}
+
+CTRL_CMD_DEFINE_WO(bts_neighbor_list_add, "neighbor-list add");
+
+static int verify_bts_neighbor_list_del(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+	return verify_bts_neighbor_list_add_del(cmd, value, _data);
+}
+
+static int set_bts_neighbor_list_del(struct ctrl_cmd *cmd, void *data)
+{
+	return set_bts_neighbor_list_add_del(cmd, data, false);
+}
+
+CTRL_CMD_DEFINE_WO(bts_neighbor_list_del, "neighbor-list del");
+
+static int verify_bts_neighbor_list_mode(struct ctrl_cmd *cmd, const char *value, void *_data)
+{
+	if (!strcmp(value, "automatic"))
+		return 0;
+	if (!strcmp(value, "manual"))
+		return 0;
+	if (!strcmp(value, "manual-si5"))
+		return 0;
+
+	cmd->reply = "Invalid mode";
+	return 1;
+}
+
+static int set_bts_neighbor_list_mode(struct ctrl_cmd *cmd, void *data)
+{
+	struct gsm_bts *bts = cmd->node;
+	int mode;
+
+	if (!strcmp(cmd->value, "automatic"))
+		mode = NL_MODE_AUTOMATIC;
+	else if (!strcmp(cmd->value, "manual"))
+		mode = NL_MODE_MANUAL;
+	else if (!strcmp(cmd->value, "manual-si5"))
+		mode = NL_MODE_MANUAL_SI5SEP;
+
+	switch (mode) {
+	case NL_MODE_MANUAL_SI5SEP:
+	case NL_MODE_MANUAL:
+		/* make sure we clear the current list when switching to
+		 * manual mode */
+		if (bts->neigh_list_manual_mode == 0)
+			memset(&bts->si_common.data.neigh_list, 0, sizeof(bts->si_common.data.neigh_list));
+		break;
+	default:
+		break;
+	}
+
+	bts->neigh_list_manual_mode = mode;
+
+	cmd->reply = "OK";
+	return CTRL_CMD_REPLY;
+}
+
+CTRL_CMD_DEFINE_WO(bts_neighbor_list_mode, "neighbor-list mode");
+
 int bsc_base_ctrl_cmds_install(void)
 {
 	int rc = 0;
@@ -708,6 +822,9 @@
 	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_rf_states);
 	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_c0_power_red);
 	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_resend_si);
+	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_neighbor_list_add);
+	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_neighbor_list_del);
+	rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_neighbor_list_mode);
 
 	rc |= neighbor_ident_ctrl_init();
 
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index 5e9bcef..4c07d5e 100755
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -525,6 +525,46 @@
         self.assertEqual(r['var'], 'apply-config-file')
         self.assertEqual(r['value'], 'OK')
 
+    def testNeighborList(self):
+	# Enter manual neighbor-list mode
+        r = self.do_set('bts.0.neighbor-list.mode', 'manual')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'SET_REPLY')
+        self.assertEqual(r['var'], 'bts.0.neighbor-list.mode')
+        self.assertEqual(r['value'], 'OK')
+
+	# Add an ARFCN
+        r = self.do_set('bts.0.neighbor-list.add', '123')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'SET_REPLY')
+        self.assertEqual(r['var'], 'bts.0.neighbor-list.add')
+        self.assertEqual(r['value'], 'OK')
+
+	# Delete the ARFCN again
+        r = self.do_set('bts.0.neighbor-list.del', '123')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'SET_REPLY')
+        self.assertEqual(r['var'], 'bts.0.neighbor-list.del')
+        self.assertEqual(r['value'], 'OK')
+
+	# Go back to automatic neighbor-list mode
+        r = self.do_set('bts.0.neighbor-list.mode', 'automatic')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'SET_REPLY')
+        self.assertEqual(r['var'], 'bts.0.neighbor-list.mode')
+        self.assertEqual(r['value'], 'OK')
+
+	# This must not work as we are in automatic neighbor-list mode
+        r = self.do_set('bts.0.neighbor-list.add', '123')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'ERROR')
+        self.assertEqual(r['error'], 'Neighbor list not in manual mode')
+
+	# Try an invalid neighbor-list mode
+        r = self.do_set('bts.0.neighbor-list.mode', 'qwertzuiop')
+        print('respose: ' + str(r))
+        self.assertEqual(r['mtype'], 'ERROR')
+        self.assertEqual(r['error'], 'Invalid mode')
 
 class TestCtrlBSCNeighbor(TestCtrlBase):
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/25996
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Id97bc0d31a358db6221c385761773fb48670c921
Gerrit-Change-Number: 25996
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211027/f0570429/attachment.htm>


More information about the gerrit-log mailing list