aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gprs_bssgp_pcu.cpp12
-rw-r--r--src/gprs_bssgp_pcu.h2
-rw-r--r--src/pcu_l1_if.cpp3
-rw-r--r--src/pcu_main.cpp7
-rw-r--r--src/pcuif_proto.h4
-rw-r--r--tests/emu/pcu_emu.cpp2
6 files changed, 19 insertions, 11 deletions
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 6c5d72c3..8837ee86 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 @@ static void bvc_timeout(void *_priv)
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 @@ struct gprs_bssgp_pcu *gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts *bts
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 32b6728d..55bad7b9 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -71,7 +71,7 @@ struct gprs_bssgp_pcu {
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 0cb79eb6..4b543b0b 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -329,7 +329,8 @@ bssgp_failed:
}
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 8631ad33..07a533f0 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -35,7 +35,8 @@ extern "C" {
}
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 @@ static void handle_options(int argc, char **argv)
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 @@ int main(int argc, char *argv[])
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 9d740ac1..7b68e164 100644
--- a/src/pcuif_proto.h
+++ b/src/pcuif_proto.h
@@ -84,7 +84,9 @@ struct gsm_pcu_if_info_ind {
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 ed0abbe6..b0c8f2fa 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -99,7 +99,7 @@ void create_and_connect_bssgp(struct gprs_rlcmac_bts *bts,
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;
}