aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-08-19 19:38:31 +0200
committerDaniel Willmann <daniel@totalueberwachung.de>2011-08-25 14:36:01 +0200
commit7c6405b5cea5a7e7e28d83c1738a054ba64b9892 (patch)
tree2c404a89f88a99b7cc59b0cf3686c68e906bdbfb
parentefda919e2da1a566cf449b6925df97d4fd2e9b02 (diff)
osmo-bsc: Include rf stati in the location-state TRAP as well
The first fields are still the location up to the height. The next field is "operational" if any of the trx are operational, otherwise "inoperational" The second to last field contains "locked" if all of the trx are in the admin state, otherwise "unlocked". The last field represents the rf policy currently in effect. It is one of (on|off|grace|unknown). <tstamp>,<valid>,<lat>,<lon>,<height>,<oper>,<admin>,<policy>
-rw-r--r--openbsc/include/openbsc/osmo_bsc_rf.h22
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_ctrl.c28
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_rf.c45
3 files changed, 95 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/osmo_bsc_rf.h b/openbsc/include/openbsc/osmo_bsc_rf.h
index 6db28cd64..e39359612 100644
--- a/openbsc/include/openbsc/osmo_bsc_rf.h
+++ b/openbsc/include/openbsc/osmo_bsc_rf.h
@@ -1,9 +1,28 @@
#ifndef OSMO_BSC_RF
#define OSMO_BSC_RF
+#include <openbsc/gsm_data.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/timer.h>
+enum osmo_bsc_rf_opstate {
+ OSMO_BSC_RF_OPSTATE_INOPERATIONAL,
+ OSMO_BSC_RF_OPSTATE_OPERATIONAL,
+};
+
+enum osmo_bsc_rf_adminstate {
+ OSMO_BSC_RF_ADMINSTATE_UNLOCKED,
+ OSMO_BSC_RF_ADMINSTATE_LOCKED,
+};
+
+enum osmo_bsc_rf_policy {
+ OSMO_BSC_RF_POLICY_OFF,
+ OSMO_BSC_RF_POLICY_ON,
+ OSMO_BSC_RF_POLICY_GRACE,
+ OSMO_BSC_RF_POLICY_UNKNOWN,
+};
+
+
struct gsm_network;
struct osmo_bsc_rf {
@@ -30,6 +49,9 @@ struct osmo_bsc_rf_conn {
struct osmo_bsc_rf *rf;
};
+enum osmo_bsc_rf_opstate osmo_bsc_rf_get_opstate_by_bts(struct gsm_bts *bts);
+enum osmo_bsc_rf_adminstate osmo_bsc_rf_get_adminstate_by_bts(struct gsm_bts *bts);
+enum osmo_bsc_rf_policy osmo_bsc_rf_get_policy_by_bts(struct gsm_bts *bts);
struct osmo_bsc_rf *osmo_bsc_rf_create(const char *path, struct gsm_network *net);
#endif
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
index 58a281818..d08637708 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -53,6 +53,7 @@ static int get_bts_loc(struct ctrl_cmd *cmd, void *data);
static void generate_location_state_trap(struct gsm_bts *bts, struct bsc_msc_connection *msc_con)
{
struct ctrl_cmd *cmd;
+ char *oper, *admin, *policy;
cmd = ctrl_cmd_create(msc_con, CTRL_TYPE_TRAP);
@@ -63,6 +64,33 @@ static void generate_location_state_trap(struct gsm_bts *bts, struct bsc_msc_con
cmd->node = bts;
get_bts_loc(cmd, NULL);
+ if (osmo_bsc_rf_get_opstate_by_bts(bts) == OSMO_BSC_RF_OPSTATE_OPERATIONAL)
+ oper = "operational";
+ else
+ oper = "inoperational";
+
+ if (osmo_bsc_rf_get_adminstate_by_bts(bts) == OSMO_BSC_RF_ADMINSTATE_LOCKED)
+ admin = "locked";
+ else
+ admin = "unlocked";
+
+ switch (osmo_bsc_rf_get_policy_by_bts(bts)) {
+ case OSMO_BSC_RF_POLICY_OFF:
+ policy = "off";
+ break;
+ case OSMO_BSC_RF_POLICY_ON:
+ policy = "on";
+ break;
+ case OSMO_BSC_RF_POLICY_GRACE:
+ policy = "grace";
+ break;
+ case OSMO_BSC_RF_POLICY_UNKNOWN:
+ policy = "unknown";
+ break;
+ }
+
+ cmd->reply = talloc_asprintf_append(cmd->reply, ",%s,%s,%s", oper, admin, policy);
+
osmo_bsc_send_trap(cmd, msc_con);
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_rf.c b/openbsc/src/osmo-bsc/osmo_bsc_rf.c
index dc61a045d..d3f84ab4c 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_rf.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_rf.c
@@ -42,6 +42,51 @@
#define RF_CMD_D_OFF 'd'
#define RF_CMD_ON_G 'g'
+enum osmo_bsc_rf_opstate osmo_bsc_rf_get_opstate_by_bts(struct gsm_bts *bts)
+{
+ struct gsm_bts_trx *trx;
+
+ llist_for_each_entry(trx, &bts->trx_list, list) {
+ if (trx->mo.nm_state.operational == NM_OPSTATE_ENABLED)
+ return OSMO_BSC_RF_OPSTATE_OPERATIONAL;
+ }
+
+ /* No trx were active, so this bts is disabled */
+ return OSMO_BSC_RF_OPSTATE_INOPERATIONAL;
+}
+
+enum osmo_bsc_rf_adminstate osmo_bsc_rf_get_adminstate_by_bts(struct gsm_bts *bts)
+{
+ struct gsm_bts_trx *trx;
+
+ llist_for_each_entry(trx, &bts->trx_list, list) {
+ if (trx->mo.nm_state.administrative == NM_STATE_UNLOCKED)
+ return OSMO_BSC_RF_ADMINSTATE_UNLOCKED;
+ }
+
+ /* All trx administrative states were locked */
+ return OSMO_BSC_RF_ADMINSTATE_LOCKED;
+}
+
+enum osmo_bsc_rf_policy osmo_bsc_rf_get_policy_by_bts(struct gsm_bts *bts)
+{
+ struct osmo_msc_data *msc_data = bts->network->msc_data;
+
+ if (!msc_data || !msc_data->rf_ctrl)
+ return OSMO_BSC_RF_POLICY_UNKNOWN;
+
+ switch (msc_data->rf_ctrl->policy) {
+ case S_RF_ON:
+ return OSMO_BSC_RF_POLICY_ON;
+ case S_RF_OFF:
+ return OSMO_BSC_RF_POLICY_OFF;
+ case S_RF_GRACE:
+ return OSMO_BSC_RF_POLICY_GRACE;
+ default:
+ return OSMO_BSC_RF_POLICY_UNKNOWN;
+ }
+}
+
static int lock_each_trx(struct gsm_network *net, int lock)
{
struct gsm_bts *bts;