[2/3] bsc: Add code to send ip.access reboot command to nanoBTS
diff mbox

Message ID 1458139289-75555-2-git-send-email-holger@freyther.de
State New
Headers show

Commit Message

Holger Freyther March 16, 2016, 2:41 p.m. UTC
From: Holger Hans Peter Freyther <holger@moiji-mobile.com>

The nanoBTS continues to be buggy and seems to have broken BSSGP
when changing SIs across new OML connections. Add an easy command
to force the reboot of the system through OML.
---
 openbsc/src/libbsc/bsc_vty.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

Patch
diff mbox

diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 7fdee05..29f2501 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -3596,6 +3596,44 @@  DEFUN(drop_bts,
 	return CMD_SUCCESS;
 }
 
+DEFUN(restart_bts, restart_bts_cmd,
+      "restart-bts <0-65535>",
+      "Restart ip.access nanoBTS through OML\n"
+      "BTS Number\n")
+{
+	struct gsm_network *gsmnet;
+	struct gsm_bts_trx *trx;
+	struct gsm_bts *bts;
+	unsigned int bts_nr;
+
+	gsmnet = gsmnet_from_vty(vty);
+
+	bts_nr = atoi(argv[0]);
+	if (bts_nr >= gsmnet->num_bts) {
+		vty_out(vty, "BTS number must be between 0 and %d. It was %d.%s",
+			gsmnet->num_bts, bts_nr, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	bts = gsm_bts_num(gsmnet, bts_nr);
+	if (!bts) {
+		vty_out(vty, "BTS Nr. %d could not be found.%s", bts_nr, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	if (!is_ipaccess_bts(bts) || is_sysmobts_v2(bts)) {
+		vty_out(vty, "This command only works for ipaccess nanoBTS.%s",
+			VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+
+	/* go from last TRX to c0 */
+	llist_for_each_entry_reverse(trx, &bts->trx_list, list)
+		abis_nm_ipaccess_restart(trx);
+
+	return CMD_SUCCESS;
+}
+
 DEFUN(smscb_cmd, smscb_cmd_cmd,
 	"bts <0-255> smscb-command <1-4> HEXSTRING",
 	"BTS related commands\n" "BTS Number\n"
@@ -3895,6 +3933,7 @@  int bsc_vty_init(const struct log_info *cat)
 	install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
 
 	install_element(ENABLE_NODE, &drop_bts_cmd);
+	install_element(ENABLE_NODE, &restart_bts_cmd);
 	install_element(ENABLE_NODE, &pdch_act_cmd);
 	install_element(ENABLE_NODE, &smscb_cmd_cmd);