arehbein has submitted this change. (
https://gerrit.osmocom.org/c/osmo-bsc/+/31282 )
Change subject: bsc_ctrl_commands: Add GET for bts neighbor-list (local bts numbers)
......................................................................
bsc_ctrl_commands: Add GET for bts neighbor-list (local bts numbers)
Related: SYS#6287
Change-Id: I79aeffd93089086f57c66787fe20b439a4d8b6b4
---
M src/osmo-bsc/neighbor_ident_ctrl.c
M tests/ctrl/osmo-bsc-neigh-test.cfg
M tests/ctrl_test_runner.py
3 files changed, 115 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/osmo-bsc/neighbor_ident_ctrl.c b/src/osmo-bsc/neighbor_ident_ctrl.c
index 8e5e048..a9d7b5d 100644
--- a/src/osmo-bsc/neighbor_ident_ctrl.c
+++ b/src/osmo-bsc/neighbor_ident_ctrl.c
@@ -21,6 +21,7 @@
*/
#include <errno.h>
+#include <inttypes.h>
#include <time.h>
#include <osmocom/ctrl/control_cmd.h>
@@ -94,6 +95,44 @@
return verify_neighbor_bts(cmd, value, _data);
}
+static int get_neighbor_bts_list(struct ctrl_cmd *cmd, void *data)
+{
+ /* Max. 256 BTS neighbors (as of now, any bts can be its own neighbor per cfg)
comma-separated ->
+ * max. 255 commas * + trailing '\0': 256
+ * 10 of those numbers (0...9) are 1-digit numbers: + 10 = 266
+ * 90 of those numbers are 2-digit numbers (10...99): + 90 = 356
+ * 255 - 100 + 1 = 156 are 3-digit numbers (100...255): + 156 = 512 bytes
+ * Double BTS num entries are not possible (check exists and is being tested against in
python tests). */
+ char log_buf[512];
+ struct osmo_strbuf reply = { .buf = log_buf,
+ .len = sizeof(log_buf),
+ .pos = log_buf
+ };
+ struct gsm_bts *neighbor_bts, *bts = (struct gsm_bts *)cmd->node;
+ if (!bts) {
+ cmd->reply = "BTS not found";
+ return CTRL_CMD_ERROR;
+ }
+ struct neighbor *n;
+ llist_for_each_entry(n, &bts->neighbors, entry)
+ if (resolve_local_neighbor(&neighbor_bts, bts, n) == 0)
+ OSMO_STRBUF_PRINTF(reply, "%" PRIu8 ",", neighbor_bts->nr);
+ if (reply.buf == reply.pos)
+ cmd->reply = "";
+ else { /* Get rid of trailing comma */
+ reply.pos[-1] = '\0';
+ if (!(cmd->reply = talloc_strdup(cmd, reply.buf)))
+ goto oom;
+ }
+ return CTRL_CMD_REPLY;
+
+oom:
+ cmd->reply = "OOM";
+ return CTRL_CMD_ERROR;
+}
+
+CTRL_CMD_DEFINE_RO(neighbor_bts_list, "neighbor-bts list");
+
static int set_neighbor_bts_add(struct ctrl_cmd *cmd, void *data)
{
struct gsm_bts *bts = cmd->node;
@@ -705,6 +744,7 @@
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_lac_ci_del);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_cgi_add);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_cgi_del);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_bts_list);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_cgi_ps_add);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_cgi_ps_del);
rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_neighbor_clear);
diff --git a/tests/ctrl/osmo-bsc-neigh-test.cfg b/tests/ctrl/osmo-bsc-neigh-test.cfg
index 8956c0b..80acd64 100644
--- a/tests/ctrl/osmo-bsc-neigh-test.cfg
+++ b/tests/ctrl/osmo-bsc-neigh-test.cfg
@@ -100,6 +100,62 @@
gprs mode gprs
gprs routing area 6
neighbor bts 0
+ neighbor bts 1
+ neighbor bts 2
+ neighbor bts 2
+ trx 0
+ rf_locked 0
+ arfcn 880
+ nominal power 23
+ ! to use full TRX power, set max_power_red 0
+ max_power_red 20
+ rsl e1 tei 0
+ timeslot 0
+ phys_chan_config CCCH+SDCCH4
+ hopping enabled 0
+ timeslot 1
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 2
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 3
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 4
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 5
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 6
+ phys_chan_config TCH/F
+ hopping enabled 0
+ timeslot 7
+ phys_chan_config TCH/F
+ hopping enabled 0
+ bts 2
+ type osmo-bts
+ band DCS1800
+ cell_identity 123
+ location_area_code 0x0001
+ base_station_id_code 55
+ ms max power 15
+ cell reselection hysteresis 4
+ rxlev access min 0
+ radio-link-timeout 32
+ channel allocator mode set-all ascending
+ rach tx integer 9
+ rach max transmission 7
+ channel-description attach 1
+ channel-description bs-pa-mfrms 5
+ channel-description bs-ag-blks-res 1
+ early-classmark-sending forbidden
+ ipa unit-id 55 0
+ oml ipa stream-id 255 line 0
+ codec-support fr
+ gprs mode gprs
+ gprs routing area 6
trx 0
rf_locked 0
arfcn 880
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index 4c07d5e..587f9e2 100755
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -616,6 +616,25 @@
def ctrl_app(self):
return (4249, "./src/osmo-bsc/osmo-bsc", "OsmoBSC",
"bsc")
+ def testCtrlListBTS(self):
+ # Get BTS local neighbors (configured via 'neighbor cgi-ps ...')
+ r = self.do_get('bts.0.neighbor-bts.list')
+ self.assertEqual(r['mtype'], 'GET_REPLY')
+ self.assertEqual(r['var'], 'bts.0.neighbor-bts.list')
+ self.assertEqual(r['value'], '1')
+
+ # Get BTS locally configured neighbors (when none configured)
+ r = self.do_get('bts.2.neighbor-bts.list')
+ self.assertEqual(r['mtype'], 'GET_REPLY')
+ self.assertEqual(r['var'], 'bts.2.neighbor-bts.list')
+ self.assertEqual(r['value'], None)
+
+ # Get BTS locally configured neighbors
+ r = self.do_get('bts.1.neighbor-bts.list')
+ self.assertEqual(r['mtype'], 'GET_REPLY')
+ self.assertEqual(r['var'], 'bts.1.neighbor-bts.list')
+ self.assertEqual(r['value'], '0,2')
+
def testCtrlAddDelBTS(self):
r = self.do_set('bts.0.neighbor-bts.add', '1')
print('respose: ' + str(r))
--
To view, visit
https://gerrit.osmocom.org/c/osmo-bsc/+/31282
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: 2023q1
Gerrit-Change-Id: I79aeffd93089086f57c66787fe20b439a4d8b6b4
Gerrit-Change-Number: 31282
Gerrit-PatchSet: 1
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged