aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/bsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-22 19:09:38 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-26 00:06:01 +0100
commit70c232f75a4998af9317f7ee885479ab18d34814 (patch)
tree7b01b06fc5747180c439e88c16681e8d03f9df53 /openbsc/src/bsc
parentbb62b3f053cacc5c18b7b62936251a5bcef826ec (diff)
mid-call: Implement a timer to go from grace to off.
Start the timer... switch it off when we do the final tranistion by a command.
Diffstat (limited to 'openbsc/src/bsc')
-rw-r--r--openbsc/src/bsc/osmo_bsc_rf.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/openbsc/src/bsc/osmo_bsc_rf.c b/openbsc/src/bsc/osmo_bsc_rf.c
index 06c84666c..d5a265b01 100644
--- a/openbsc/src/bsc/osmo_bsc_rf.c
+++ b/openbsc/src/bsc/osmo_bsc_rf.c
@@ -25,6 +25,7 @@
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/signal.h>
+#include <openbsc/osmo_msc_data.h>
#include <osmocore/talloc.h>
#include <osmocore/protocol/gsm_12_21.h>
@@ -92,15 +93,45 @@ static void handle_query(struct osmo_bsc_rf_conn *conn)
return;
}
-static void send_signal(struct osmo_bsc_rf_conn *conn, int val)
+static void send_signal(struct osmo_bsc_rf *rf, int val)
{
struct rf_signal_data sig;
- sig.net = conn->rf->gsm_network;
+ sig.net = rf->gsm_network;
- conn->rf->policy = val;
+ rf->policy = val;
dispatch_signal(SS_RF, val, &sig);
}
+static int switch_rf_off(struct osmo_bsc_rf *rf)
+{
+ lock_each_trx(rf->gsm_network, 1);
+ send_signal(rf, S_RF_OFF);
+
+ return 0;
+}
+
+static void grace_timeout(void *_data)
+{
+ struct osmo_bsc_rf *rf = (struct osmo_bsc_rf *) _data;
+
+ LOGP(DINP, LOGL_NOTICE, "Grace timeout. Disabling the TRX.\n");
+ switch_rf_off(rf);
+}
+
+static int enter_grace(struct osmo_bsc_rf_conn *conn)
+{
+ struct osmo_bsc_rf *rf = conn->rf;
+
+ rf->grace_timeout.cb = grace_timeout;
+ rf->grace_timeout.data = rf;
+ bsc_schedule_timer(&rf->grace_timeout, rf->gsm_network->msc_data->mid_call_timeout, 0);
+ LOGP(DINP, LOGL_NOTICE, "Going to switch RF off in %d seconds.\n",
+ rf->gsm_network->msc_data->mid_call_timeout);
+
+ send_signal(conn->rf, S_RF_GRACE);
+ return 0;
+}
+
static int rf_read_cmd(struct bsc_fd *fd)
{
struct osmo_bsc_rf_conn *conn = fd->data;
@@ -122,15 +153,16 @@ static int rf_read_cmd(struct bsc_fd *fd)
handle_query(conn);
break;
case RF_CMD_OFF:
- lock_each_trx(conn->rf->gsm_network, 1);
- send_signal(conn, S_RF_OFF);
+ bsc_del_timer(&conn->rf->grace_timeout);
+ switch_rf_off(conn->rf);
break;
case RF_CMD_ON:
+ bsc_del_timer(&conn->rf->grace_timeout);
lock_each_trx(conn->rf->gsm_network, 0);
- send_signal(conn, S_RF_ON);
+ send_signal(conn->rf, S_RF_ON);
break;
case RF_CMD_GRACE:
- send_signal(conn, S_RF_GRACE);
+ enter_grace(conn);
break;
default:
LOGP(DINP, LOGL_ERROR, "Unknown command %d\n", buf[0]);