[PATCH 3/4] ctrl: Remember last 'rf_locked' control command

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Wed Sep 11 08:46:57 UTC 2013


This stores the last SET rf_locked control command along with a
timestamp. The 'show network' vty command is extended to show
this information.

Ticket: OW#659
---
 openbsc/include/openbsc/osmo_bsc_rf.h |    2 ++
 openbsc/src/libbsc/bsc_rf_ctrl.c      |    1 +
 openbsc/src/libbsc/bsc_vty.c          |    4 ++++
 openbsc/src/osmo-bsc/osmo_bsc_ctrl.c  |   18 +++++++++++++++---
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h
index a67e1bd..19ccd08 100644
--- a/openbsc/include/openbsc/osmo_bsc_rf.h
+++ b/openbsc/include/openbsc/osmo_bsc_rf.h
@@ -33,6 +33,8 @@ struct osmo_bsc_rf {
 
 	const char *last_state_command;
 
+	char *last_rf_lock_ctrl_command;
+
 	/* delay the command */
 	char last_request;
 	struct osmo_timer_list delay_cmd;
diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c
index bd36e18..bce91e4 100644
--- a/openbsc/src/libbsc/bsc_rf_ctrl.c
+++ b/openbsc/src/libbsc/bsc_rf_ctrl.c
@@ -504,6 +504,7 @@ struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net
 	rf->gsm_network = net;
 	rf->policy = S_RF_ON;
 	rf->last_state_command = "";
+	rf->last_rf_lock_ctrl_command = talloc_asprintf(rf, "");
 
 	/* check the rf state */
 	rf->rf_check.data = rf;
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 55564b6..3fb8516 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -210,6 +210,10 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net)
 		vty_out(vty, "  Last RF Command: %s%s",
 			net->bsc_data->rf_ctrl->last_state_command,
 			VTY_NEWLINE);
+	if (net->bsc_data && net->bsc_data->rf_ctrl)
+		vty_out(vty, "  Last RF Lock Command: %s%s",
+			net->bsc_data->rf_ctrl->last_rf_lock_ctrl_command,
+			VTY_NEWLINE);
 }
 
 DEFUN(show_net, show_net_cmd, "show network",
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 72abcf4..4e104db 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -35,6 +35,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#define TIME_FORMAT_RFC2822 "%a, %d %b %Y %T %z"
+
 void osmo_bsc_send_trap(struct ctrl_cmd *cmd, struct bsc_msc_connection *msc_con)
 {
 	struct ctrl_cmd *trap;
@@ -420,18 +422,28 @@ static int set_net_rf_lock(struct ctrl_cmd *cmd, void *data)
 {
 	int locked = atoi(cmd->value);
 	struct gsm_network *net = cmd->node;
+	time_t now = time(NULL);
+	char now_buf[64];
+	struct osmo_bsc_rf *rf;
+
 	if (!net) {
 		cmd->reply = "net not found.";
 		return CTRL_CMD_ERROR;
 	}
 
-	if (!net->bsc_data->rf_ctrl) {
+	rf = net->bsc_data->rf_ctrl;
+
+	if (!rf) {
 		cmd->reply = "RF Ctrl is not enabled in the BSC Configuration";
 		return CTRL_CMD_ERROR;
 	}
 
-	osmo_bsc_rf_schedule_lock(net->bsc_data->rf_ctrl,
-			locked == 1 ? '0' : '1');
+	talloc_free(rf->last_rf_lock_ctrl_command);
+	strftime(now_buf, sizeof(now_buf), TIME_FORMAT_RFC2822, gmtime(&now));
+	rf->last_rf_lock_ctrl_command = 
+		talloc_asprintf(rf, "rf_locked %u (%s)", locked, now_buf);
+
+	osmo_bsc_rf_schedule_lock(rf, locked == 1 ? '0' : '1');
 
 	cmd->reply = talloc_asprintf(cmd, "%u", locked);
 	if (!cmd->reply) {
-- 
1.7.9.5





More information about the OpenBSC mailing list