Changes to compile with mnc_t.

Signed-off-by: Michael McTernan <mike.mcternan@wavemobile.com>
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 6c5d72c..8837ee8 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -27,7 +27,8 @@
 static struct gprs_bssgp_pcu the_pcu = { 0, };
 
 extern void *tall_pcu_ctx;
-extern uint16_t spoof_mcc, spoof_mnc;
+extern uint16_t spoof_mcc;
+extern gsm_mnc_t spoof_mnc;
 
 static void bvc_timeout(void *_priv);
 
@@ -468,14 +469,13 @@
 struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts *bts,
 	uint16_t local_port, uint32_t sgsn_ip,
 	uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci,
-	uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,
+	uint16_t mcc, gsm_mnc_t mnc, uint16_t lac, uint16_t rac,
 	uint16_t cell_id)
 {
 	struct sockaddr_in dest;
 	int rc;
 
 	mcc = ((mcc & 0xf00) >> 8) * 100 + ((mcc & 0x0f0) >> 4) * 10 + (mcc & 0x00f);
-	mnc = ((mnc & 0xf00) >> 8) * 100 + ((mnc & 0x0f0) >> 4) * 10 + (mnc & 0x00f);
 	cell_id = ntohs(cell_id);
 
 	/* if already created... return the current address */
@@ -520,7 +520,11 @@
 		return NULL;
 	}
 	the_pcu.bctx->ra_id.mcc = spoof_mcc ? : mcc;
-	the_pcu.bctx->ra_id.mnc = spoof_mnc ? : mnc;
+	if (spoof_mnc.network_code)
+		the_pcu.bctx->ra_id.mnc = spoof_mnc;
+	else
+		the_pcu.bctx->ra_id.mnc = mnc;
+
 	the_pcu.bctx->ra_id.lac = lac;
 	the_pcu.bctx->ra_id.rac = rac;
 	the_pcu.bctx->cell_id = cell_id;
diff --git a/src/gprs_bssgp_pcu.h b/src/gprs_bssgp_pcu.h
index 32b6728..55bad7b 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -71,7 +71,7 @@
 struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts *bts,
 		uint16_t local_port,
 		uint32_t sgsn_ip, uint16_t sgsn_port, uint16_t nsei,
-		uint16_t nsvci, uint16_t bvci, uint16_t mcc, uint16_t mnc,
+		uint16_t nsvci, uint16_t bvci, uint16_t mcc, gsm_mnc_t mnc,
 		uint16_t lac, uint16_t rac, uint16_t cell_id);
 
 void gprs_bssgp_destroy(void);
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 0cb79eb..4b543b0 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -329,7 +329,8 @@
 	}
 	LOGP(DL1IF, LOGL_INFO, "BTS available\n");
 	LOGP(DL1IF, LOGL_DEBUG, " mcc=%x\n", info_ind->mcc);
-	LOGP(DL1IF, LOGL_DEBUG, " mnc=%x\n", info_ind->mnc);
+	LOGP(DL1IF, LOGL_DEBUG, " mnc=%0*u\n",
+		 info_ind->mnc.two_digits ? 2 : 3, info_ind->mnc.network_code);
 	LOGP(DL1IF, LOGL_DEBUG, " lac=%d\n", info_ind->lac);
 	LOGP(DL1IF, LOGL_DEBUG, " rac=%d\n", info_ind->rac);
 	LOGP(DL1IF, LOGL_DEBUG, " cell_id=%d\n", ntohs(info_ind->cell_id));
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 8631ad3..07a533f 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -35,7 +35,8 @@
 }
 
 extern struct gprs_nsvc *nsvc;
-uint16_t spoof_mcc = 0, spoof_mnc = 0;
+uint16_t spoof_mcc = 0;
+gsm_mnc_t spoof_mnc = { 0, false };
 static int config_given = 0;
 static char *config_file = strdup("osmo-pcu.cfg");
 extern struct vty_app_info pcu_vty_info;
@@ -94,7 +95,7 @@
 			spoof_mcc = atoi(optarg);
 			break;
 		case 'n':
-			spoof_mnc = atoi(optarg);
+			spoof_mnc = gsm48_str_to_mnc(optarg);
 			break;
 		case 'V':
 			print_version(1);
@@ -181,7 +182,7 @@
 	pcu_vty_init(&gprs_log_info);
 
 	handle_options(argc, argv);
-	if ((!!spoof_mcc) + (!!spoof_mnc) == 1) {
+	if ((!!spoof_mcc) + (!!spoof_mnc.network_code) == 1) {
 		fprintf(stderr, "--mcc and --mnc must be specified "
 			"together.\n");
 		exit(0);
diff --git a/src/pcuif_proto.h b/src/pcuif_proto.h
index 9d740ac..7b68e16 100644
--- a/src/pcuif_proto.h
+++ b/src/pcuif_proto.h
@@ -84,7 +84,9 @@
 	struct gsm_pcu_if_info_trx trx[8];	/* TRX infos per BTS */
 	uint8_t		bsic;
 	/* RAI */
-	uint16_t	mcc, mnc, lac, rac;
+	uint16_t	mcc;
+	gsm_mnc_t   mnc;
+	uint16_t    lac, rac;
 	/* NSE */
 	uint16_t	nsei;
 	uint8_t		nse_timer[7];
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index ed0abbe..b0c8f2f 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -99,7 +99,7 @@
 	struct gprs_bssgp_pcu *pcu;
 
 	pcu = gprs_bssgp_create_and_connect(bts, 0, sgsn_ip, sgsn_port,
-					20, 20, 20, 0x901, 0x99, 1, 0, 0);
+					20, 20, 20, 0x901, gsm48_str_to_mnc("99"), 1, 0, 0);
 	pcu->on_unblock_ack = bvci_unblocked;
 	pcu->on_dl_unit_data = bssgp_data;
 }