Add user-configurable BSIC setting

diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h
index 071b1c6..2c05260 100644
--- a/include/openbsc/gsm_data.h
+++ b/include/openbsc/gsm_data.h
@@ -15,6 +15,7 @@
 
 #define HARDCODED_ARFCN 123
 #define HARDCODED_TSC	7
+#define HARDCODED_BSIC	0x3f	/* NCC = 7 / BCC = 7 */
 
 enum gsm_hooks {
 	GSM_HOOK_NM_SWLOAD,
@@ -274,6 +275,8 @@
 	u_int8_t location_area_code;
 	/* Training Sequence Code */
 	u_int8_t tsc;
+	/* Base Station Identification Code (BSIC) */
+	u_int8_t bsic;
 	/* type of BTS */
 	enum gsm_bts_type type;
 	/* how do we talk OML with this TRX? */
diff --git a/src/bsc_hack.c b/src/bsc_hack.c
index 68080ce..d4a4778 100644
--- a/src/bsc_hack.c
+++ b/src/bsc_hack.c
@@ -880,6 +880,10 @@
 
 	/* patch Control Channel Description 10.5.2.11 */
 	type_3->control_channel_desc = bts->chan_desc;
+
+	/* patch BSIC */
+	msg_2[6] = bts->bsic;
+	nanobts_attr_bts[sizeof(nanobts_attr_bts)-1] = bts->bsic;
 }
 
 
diff --git a/src/gsm_data.c b/src/gsm_data.c
index 78f9765..a78425f 100644
--- a/src/gsm_data.c
+++ b/src/gsm_data.c
@@ -109,6 +109,7 @@
 		bts->nr = i;
 		bts->type = bts_type;
 		bts->tsc = HARDCODED_TSC;
+		bts->bsic = HARDCODED_BSIC;
 
 		for (j = 0; j < BTS_MAX_TRX; j++) {
 			struct gsm_bts_trx *trx = &bts->trx[j];
diff --git a/src/vty_interface.c b/src/vty_interface.c
index 6ff3b0c..b63c774 100644
--- a/src/vty_interface.c
+++ b/src/vty_interface.c
@@ -105,9 +105,9 @@
 
 static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
 {
-	vty_out(vty, "BTS %u is of %s type, has LAC %u, TSC %u and %u TRX%s",
+	vty_out(vty, "BTS %u is of %s type, has LAC %u, BSIC %u, TSC %u and %u TRX%s",
 		bts->nr, btstype2str(bts->type), bts->location_area_code,
-		bts->tsc, bts->num_trx, VTY_NEWLINE);
+		bts->bsic, bts->tsc, bts->num_trx, 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,
@@ -633,6 +633,25 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(cfg_bts_bsic,
+      cfg_bts_bsic_cmd,
+      "base_station_id_code <0-63>",
+      "Set the Base Station Identity Code (BSIC) of this BTS\n")
+{
+	struct gsm_bts *bts = vty->index;
+	int bsic = atoi(argv[0]);
+
+	if (bsic < 0 || bsic > 0x3f) {
+		vty_out(vty, "%% TSC %d is not in the valid range (0-255)%s",
+			bsic, VTY_NEWLINE);
+		return CMD_WARNING;
+	}
+	bts->bsic = bsic;
+
+	return CMD_SUCCESS;
+}
+
+
 DEFUN(cfg_bts_unit_id,
       cfg_bts_unit_id_cmd,
       "unit_id <0-65534> <0-255>",