laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/32565 )

Change subject: ctrl: Add getting neighbor list
......................................................................

ctrl: Add getting neighbor list

Change-Id: Icba0b7d92f4c67e617d707ca651d674f0d1ba8a7
---
M src/osmo-bsc/bts_ctrl.c
1 file changed, 44 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  neels: Looks good to me, but someone else must approve
  Jenkins Builder: Verified




diff --git a/src/osmo-bsc/bts_ctrl.c b/src/osmo-bsc/bts_ctrl.c
index 3a502b1..59f3ad0 100644
--- a/src/osmo-bsc/bts_ctrl.c
+++ b/src/osmo-bsc/bts_ctrl.c
@@ -514,6 +514,40 @@

 CTRL_CMD_DEFINE(bts_c0_power_red, "c0-power-reduction");

+static int get_bts_neighbor_list(struct ctrl_cmd *cmd, const struct bitvec 
*neigh_list)
+{
+       int i;
+       char *pos;
+
+       /* The length of "1 2 3 ... 1023" is 4009, so 4096 is enough */
+       cmd->reply = talloc_size(cmd, 4096);
+       if (!cmd->reply) {
+               cmd->reply = "OOM";
+               return CTRL_CMD_ERROR;
+       }
+
+       cmd->reply[0] = '\0';
+
+       pos = cmd->reply;
+
+       for (i = 0; i < neigh_list->data_len * 8; i++) {
+               if (!bitvec_get_bit_pos(neigh_list, i))
+                       continue;
+
+               pos += sprintf(pos, i == 0 ? "%u" : " %u", i);
+       }
+
+       return CTRL_CMD_REPLY;
+}
+
+static int get_bts_neighbor_list_si2(struct ctrl_cmd *cmd, void *data)
+{
+       const struct gsm_bts *bts = cmd->node;
+       return get_bts_neighbor_list(cmd, &bts->si_common.neigh_list);
+}
+
+CTRL_CMD_DEFINE_RO(bts_neighbor_list_si2, "neighbor-list si2");
+
 static int verify_bts_neighbor_list_add_del(struct ctrl_cmd *cmd, const char 
*value, void *_data)
 {
        int arfcn;
@@ -976,6 +1010,7 @@
        rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_rf_state);
        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_neighbor_list_si2);
        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);

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Icba0b7d92f4c67e617d707ca651d674f0d1ba8a7
Gerrit-Change-Number: 32565
Gerrit-PatchSet: 5
Gerrit-Owner: matanp <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-CC: fixeria <[email protected]>
Gerrit-MessageType: merged

Reply via email to