implement bts->cell_barred feature, configurable in VTY
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index dd501d7..1a6a72a 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -301,6 +301,7 @@
 	/* should the channel allocator allocate channels from high TRX to TRX0,
 	 * rather than starting from TRX0 and go upwards? */
 	int chan_alloc_reverse;
+	int cell_barred;
 
 	/* how do we talk OML with this TRX? */
 	struct gsm_e1_subslot oml_e1_link;
diff --git a/openbsc/src/bsc_hack.c b/openbsc/src/bsc_hack.c
index d08c145..7ff6333 100644
--- a/openbsc/src/bsc_hack.c
+++ b/openbsc/src/bsc_hack.c
@@ -872,6 +872,10 @@
 	u_int8_t arfcn_low = bts->c0->arfcn & 0xff;
 	u_int8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f;
 	/* covert the raw packet to the struct */
+	struct gsm48_system_information_type_1 *type_1 =
+		(struct gsm48_system_information_type_1*)&si1;
+	struct gsm48_system_information_type_2 *type_2 =
+		(struct gsm48_system_information_type_2*)&si2;
 	struct gsm48_system_information_type_3 *type_3 =
 		(struct gsm48_system_information_type_3*)&si3;
 	struct gsm48_system_information_type_4 *type_4 =
@@ -923,6 +927,18 @@
 	/* patch MS max power for CCH */
 	type_4->cell_sel_par.ms_txpwr_max_ccch =
 			ms_pwr_ctl_lvl(bts->band, 20 /* dBm == 100mW */);
+
+	if (bts->cell_barred) {
+		type_1->rach_control.cell_bar = 1;
+		type_2->rach_control.cell_bar = 1;
+		type_3->rach_control.cell_bar = 1;
+		type_4->rach_control.cell_bar = 1;
+	} else {
+		type_1->rach_control.cell_bar = 0;
+		type_2->rach_control.cell_bar = 0;
+		type_3->rach_control.cell_bar = 0;
+		type_4->rach_control.cell_bar = 0;
+	}
 }
 
 
diff --git a/openbsc/src/vty_interface.c b/openbsc/src/vty_interface.c
index 9b35e6b..9c07ce9 100644
--- a/openbsc/src/vty_interface.c
+++ b/openbsc/src/vty_interface.c
@@ -129,6 +129,8 @@
 		bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
 		bts->location_area_code, bts->bsic, bts->tsc, 
 		bts->num_trx, VTY_NEWLINE);
+	if (bts->cell_barred)
+		vty_out(vty, "  CELL IS BARRED%s", VTY_NEWLINE);
 	if (is_ipaccess_bts(bts))
 		vty_out(vty, "  Unit ID: %u/%u/0%s",
 			bts->ip_access.site_id, bts->ip_access.bts_id,
@@ -234,6 +236,8 @@
 	vty_out(vty, "  channel allocator %s%s",
 		bts->chan_alloc_reverse ? "descending" : "ascending",
 		VTY_NEWLINE);
+	if (bts->cell_barred)
+		vty_out(vty, "  cell barred 1%s", VTY_NEWLINE);
 	if (is_ipaccess_bts(bts))
 		vty_out(vty, "  ip.access unit_id %u %u%s",
 			bts->ip_access.site_id, bts->ip_access.bts_id, VTY_NEWLINE);
@@ -960,6 +964,17 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bts_cell_barred, cfg_bts_cell_barred_cmd,
+      "cell barred (0|1)",
+      "Should this cell be barred from access?")
+{
+	struct gsm_bts *bts = vty->index;
+
+	bts->cell_barred = atoi(argv[0]);
+
+	return CMD_SUCCESS;
+}
+
 
 /* per TRX configuration */
 DEFUN(cfg_trx,
@@ -1349,6 +1364,7 @@
 	install_element(BTS_NODE, &cfg_bts_oml_e1_cmd);
 	install_element(BTS_NODE, &cfg_bts_oml_e1_tei_cmd);
 	install_element(BTS_NODE, &cfg_bts_challoc_cmd);
+	install_element(BTS_NODE, &cfg_bts_cell_barred_cmd);
 
 
 	install_element(BTS_NODE, &cfg_trx_cmd);