bsc: Auto RF Off in case of missing MSC connection

For short IP failures we want the RF to stay up and wait for
the re-connect but in case the A-link is gone too long it is
good to switch off the RF and wait for commands to enable it
again.
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index f502683..8cd80f9 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -168,6 +168,10 @@
 		vty_out(vty, " bsc-rf-socket %s%s",
 			bsc->rf_ctrl_name, VTY_NEWLINE);
 
+	if (bsc->auto_off_timeout != -1)
+		vty_out(vty, " bsc-auto-rf-off %d%s",
+			bsc->auto_off_timeout, VTY_NEWLINE);
+
 	return CMD_SUCCESS;
 }
 
@@ -462,6 +466,26 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_net_rf_off_time,
+      cfg_net_rf_off_time_cmd,
+      "bsc-auto-rf-off <1-65000>",
+      "Disable RF on MSC Connection\n" "Timeout\n")
+{
+	struct osmo_bsc_data *data = osmo_bsc_data(vty);
+	data->auto_off_timeout = atoi(argv[0]);
+	return CMD_SUCCESS;
+}
+
+DEFUN(cfg_net_no_rf_off_time,
+      cfg_net_no_rf_off_time_cmd,
+      "no bsc-auto-rf-off",
+      NO_STR "Disable RF on MSC Connection\n")
+{
+	struct osmo_bsc_data *data = osmo_bsc_data(vty);
+	data->auto_off_timeout = -1;
+	return CMD_SUCCESS;
+}
+
 DEFUN(show_statistics,
       show_statistics_cmd,
       "show statistics",
@@ -498,8 +522,8 @@
 	install_element(BSC_NODE, &cfg_net_bsc_mid_call_text_cmd);
 	install_element(BSC_NODE, &cfg_net_bsc_mid_call_timeout_cmd);
 	install_element(BSC_NODE, &cfg_net_rf_socket_cmd);
-
-
+	install_element(BSC_NODE, &cfg_net_rf_off_time_cmd);
+	install_element(BSC_NODE, &cfg_net_no_rf_off_time_cmd);
 
 	install_node(&msc_node, config_write_msc);
 	install_default(MSC_NODE);