aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-21 00:39:07 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-03-11 00:47:14 +0100
commitbdc55fad62e333951a0eb1fc7b96aaaec16dd6ff (patch)
tree2dde9a0de875f3e21e4e461df5bcb8f74c6c9496 /src
parent8343b4adbbe9afd4294232429696ee9736ec1004 (diff)
implement support for 3-digit MNC with leading zeros
Receive the mnc_3_digits flag from the PCU interface. Bump the PCU interface to 9. This is one part of the three identical pcuif_proto.h patches: - I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts) - I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu) - I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc) Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
Diffstat (limited to 'src')
-rw-r--r--src/gprs_bssgp_pcu.cpp15
-rw-r--r--src/gprs_bssgp_pcu.h2
-rw-r--r--src/pcu_l1_if.cpp11
-rw-r--r--src/pcu_main.cpp6
4 files changed, 21 insertions, 13 deletions
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 3cc86e25..67277358 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -44,6 +44,7 @@ static struct gprs_bssgp_pcu the_pcu = { 0, };
extern void *tall_pcu_ctx;
extern uint16_t spoof_mcc, spoof_mnc;
+extern bool spoof_mnc_3_digits;
static void bvc_timeout(void *_priv);
@@ -876,16 +877,12 @@ int gprs_ns_reconnect(struct gprs_nsvc *nsvc)
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, uint16_t mnc, bool mnc_3_digits, 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 */
if (the_pcu.bctx)
return &the_pcu;
@@ -930,7 +927,13 @@ 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) {
+ the_pcu.bctx->ra_id.mnc = spoof_mnc;
+ the_pcu.bctx->ra_id.mnc_3_digits = spoof_mnc_3_digits;
+ } else {
+ the_pcu.bctx->ra_id.mnc = mnc;
+ the_pcu.bctx->ra_id.mnc_3_digits = mnc_3_digits;
+ }
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 4eda57d6..4127244a 100644
--- a/src/gprs_bssgp_pcu.h
+++ b/src/gprs_bssgp_pcu.h
@@ -77,7 +77,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, uint16_t mnc, bool mnc_3_digits,
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 664a7b7b..85dbfb9a 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -408,6 +408,7 @@ static int pcu_rx_info_ind(struct gsm_pcu_if_info_ind *info_ind)
int rc = 0;
unsigned int trx, ts;
int i;
+ uint16_t cell_id = ntohs(info_ind->cell_id);
if (info_ind->version != PCU_IF_VERSION) {
fprintf(stderr, "PCU interface version number of BTS (%d) is "
@@ -434,11 +435,11 @@ bssgp_failed:
exit(0);
}
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, " mcc=%03u\n", info_ind->mcc);
+ LOGP(DL1IF, LOGL_DEBUG, " mnc=%0*u\n", info_ind->mnc_3_digits, info_ind->mnc);
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));
+ LOGP(DL1IF, LOGL_DEBUG, " cell_id=%d\n", cell_id);
LOGP(DL1IF, LOGL_DEBUG, " bsic=%d\n", info_ind->bsic);
LOGP(DL1IF, LOGL_DEBUG, " nsei=%d\n", info_ind->nsei);
LOGP(DL1IF, LOGL_DEBUG, " nse_timer=%d %d %d %d %d %d %d\n",
@@ -488,8 +489,8 @@ bssgp_failed:
pcu = gprs_bssgp_create_and_connect(bts, info_ind->local_port[0],
info_ind->remote_ip[0], info_ind->remote_port[0],
info_ind->nsei, info_ind->nsvci[0], info_ind->bvci,
- info_ind->mcc, info_ind->mnc, info_ind->lac, info_ind->rac,
- info_ind->cell_id);
+ info_ind->mcc, info_ind->mnc, info_ind->mnc_3_digits, info_ind->lac, info_ind->rac,
+ cell_id);
if (!pcu) {
LOGP(DL1IF, LOGL_NOTICE, "SGSN not available\n");
goto bssgp_failed;
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp
index 0c3a4142..84ade6f3 100644
--- a/src/pcu_main.cpp
+++ b/src/pcu_main.cpp
@@ -52,6 +52,7 @@ extern "C" {
extern struct gprs_nsvc *nsvc;
uint16_t spoof_mcc = 0, spoof_mnc = 0;
+bool spoof_mnc_3_digits = false;
static int config_given = 0;
static char *config_file = strdup("osmo-pcu.cfg");
extern struct vty_app_info pcu_vty_info;
@@ -114,7 +115,10 @@ static void handle_options(int argc, char **argv)
spoof_mcc = atoi(optarg);
break;
case 'n':
- spoof_mnc = atoi(optarg);
+ if (osmo_mnc_from_str(optarg, &spoof_mnc, &spoof_mnc_3_digits)) {
+ fprintf(stderr, "Error decoding MNC '%s'\n", optarg);
+ exit(1);
+ }
break;
case 'V':
print_version(1);