aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-11-22 19:32:13 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-11-26 00:06:15 +0100
commitcf6f71aa7feefbac0b745596028bbff9592a7a17 (patch)
tree641a83af0ffee07dd3ca3fb7555dae378c372680 /openbsc
parent70c232f75a4998af9317f7ee885479ab18d34814 (diff)
mid-call: Make the mid-call behavior the default for switching things off
When switching the RF off we will always go through the grace period, add a direct off mode to switch it off directly. Make the query return a 'g' if we are in the process of switching things over.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/bsc/osmo_bsc_rf.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/openbsc/src/bsc/osmo_bsc_rf.c b/openbsc/src/bsc/osmo_bsc_rf.c
index d5a265b01..5cc985b7c 100644
--- a/openbsc/src/bsc/osmo_bsc_rf.c
+++ b/openbsc/src/bsc/osmo_bsc_rf.c
@@ -39,7 +39,8 @@
#define RF_CMD_QUERY '?'
#define RF_CMD_OFF '0'
#define RF_CMD_ON '1'
-#define RF_CMD_GRACE 'g'
+#define RF_CMD_D_OFF 'd'
+#define RF_CMD_ON_G 'g'
static int lock_each_trx(struct gsm_network *net, int lock)
{
@@ -55,25 +56,9 @@ static int lock_each_trx(struct gsm_network *net, int lock)
return 0;
}
-/*
- * Send a '1' when one TRX is online, otherwise send 0
- */
-static void handle_query(struct osmo_bsc_rf_conn *conn)
+static void send_resp(struct osmo_bsc_rf_conn *conn, char send)
{
struct msgb *msg;
- struct gsm_bts *bts;
- char send = RF_CMD_OFF;
-
- llist_for_each_entry(bts, &conn->rf->gsm_network->bts_list, list) {
- struct gsm_bts_trx *trx;
- llist_for_each_entry(trx, &bts->trx_list, list) {
- if (trx->nm_state.availability == NM_AVSTATE_OK &&
- trx->nm_state.operational != NM_STATE_LOCKED) {
- send = RF_CMD_ON;
- break;
- }
- }
- }
msg = msgb_alloc(10, "RF Query");
if (!msg) {
@@ -93,6 +78,35 @@ static void handle_query(struct osmo_bsc_rf_conn *conn)
return;
}
+
+/*
+ * Send a
+ * 'g' when we are in grace mode
+ * '1' when one TRX is online,
+ * '0' otherwise
+ */
+static void handle_query(struct osmo_bsc_rf_conn *conn)
+{
+ struct gsm_bts *bts;
+ char send = RF_CMD_OFF;
+
+ if (conn->rf->policy == S_RF_GRACE)
+ return send_resp(conn, RF_CMD_ON_G);
+
+ llist_for_each_entry(bts, &conn->rf->gsm_network->bts_list, list) {
+ struct gsm_bts_trx *trx;
+ llist_for_each_entry(trx, &bts->trx_list, list) {
+ if (trx->nm_state.availability == NM_AVSTATE_OK &&
+ trx->nm_state.operational != NM_STATE_LOCKED) {
+ send = RF_CMD_ON;
+ break;
+ }
+ }
+ }
+
+ send_resp(conn, send);
+}
+
static void send_signal(struct osmo_bsc_rf *rf, int val)
{
struct rf_signal_data sig;
@@ -152,7 +166,7 @@ static int rf_read_cmd(struct bsc_fd *fd)
case RF_CMD_QUERY:
handle_query(conn);
break;
- case RF_CMD_OFF:
+ case RF_CMD_D_OFF:
bsc_del_timer(&conn->rf->grace_timeout);
switch_rf_off(conn->rf);
break;
@@ -161,7 +175,7 @@ static int rf_read_cmd(struct bsc_fd *fd)
lock_each_trx(conn->rf->gsm_network, 0);
send_signal(conn->rf, S_RF_ON);
break;
- case RF_CMD_GRACE:
+ case RF_CMD_OFF:
enter_grace(conn);
break;
default: