summaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-09-11 10:46:57 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-09-11 20:27:08 +0200
commit779a72819dd0242a906acd776367f5622b7a8e79 (patch)
treece4200f9d8150675ec0a4c8b7d24019232fba846 /openbsc/src/osmo-bsc
parent733bec862627d6ecc934fd928eb5b3a2e22771b8 (diff)
ctrl: Remember last 'rf_locked' control command
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
Diffstat (limited to 'openbsc/src/osmo-bsc')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_ctrl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 72abcf4..39859d6 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) {