[misc] Utilize rf_locking by setting the nm_state.administrative

* On start the vty code will call the abis_nm method and this
  will set the administrative state to unlock/lock
* During startup the BTS will report its state as well and would
  possible overwrite the set administrative. We are only going
  to update the administrative if it was 0 before. This appears
  to work on all of my tests. In case this will not be the case
  for others we will have to split the administrative into two
  sets one for the BTS and one for the BSC.
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index c0c485e..8272289 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -303,9 +303,6 @@
 		} bs11;
 	};
 	struct gsm_bts_trx_ts ts[TRX_NR_TS];
-
-	/* NM state */
-	int rf_locked;
 };
 
 enum gsm_bts_type {
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index f82dc6f..38c8c2b 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -813,12 +813,17 @@
 	}
 	DEBUGPC(DNM, "\n");
 
-	if (memcmp(&new_state, nm_state, sizeof(new_state))) {
+	if ((new_state.administrative != 0 && nm_state->administrative == 0) ||
+	    new_state.operational != nm_state->operational ||
+	    new_state.availability != nm_state->availability) {
 		/* Update the operational state of a given object in our in-memory data
  		* structures and send an event to the higher layer */
 		void *obj = objclass2obj(bts, foh->obj_class, &foh->obj_inst);
 		rc = nm_state_event(EVT_STATECHG_OPER, foh->obj_class, obj, nm_state, &new_state);
-		*nm_state = new_state;
+		nm_state->operational = new_state.operational;
+		nm_state->availability = new_state.availability;
+		if (nm_state->administrative == 0)
+			nm_state->administrative = new_state.administrative;
 	}
 #if 0
 	if (op_state == 1) {
@@ -2912,7 +2917,7 @@
 {
 	int new_state = locked ? NM_STATE_LOCKED : NM_STATE_UNLOCKED;
 
-	trx->rf_locked = locked;
+	trx->nm_state.administrative = new_state;
 	if (!trx->bts || !trx->bts->oml_link)
 		return;
 
diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c
index cc4a75b..ee81b6a 100644
--- a/openbsc/src/bsc_init.c
+++ b/openbsc/src/bsc_init.c
@@ -431,8 +431,7 @@
 		 * This code is here to make sure that on start
 		 * a TRX remains locked.
 		 */
-		int rc_state = trx->rf_locked ?
-					NM_STATE_LOCKED : NM_STATE_UNLOCKED;
+		int rc_state = trx->nm_state.administrative;
 		/* Patch ARFCN into radio attribute */
 		nanobts_attr_radio[5] &= 0xf0;
 		nanobts_attr_radio[5] |= trx->arfcn >> 8;
diff --git a/openbsc/src/gsm_data.c b/openbsc/src/gsm_data.c
index 21d9e4b..291d407 100644
--- a/openbsc/src/gsm_data.c
+++ b/openbsc/src/gsm_data.c
@@ -128,6 +128,7 @@
 
 	trx->bts = bts;
 	trx->nr = bts->num_trx++;
+	trx->nm_state.administrative = NM_STATE_UNLOCKED;
 
 	for (k = 0; k < TRX_NR_TS; k++) {
 		struct gsm_bts_trx_ts *ts = &trx->ts[k];