aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/pcu/pcuif_proto.h6
-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
-rw-r--r--tests/alloc/AllocTest.cpp1
-rw-r--r--tests/alloc/MslotTest.cpp1
-rw-r--r--tests/edge/EdgeTest.cpp1
-rw-r--r--tests/emu/pcu_emu.cpp3
-rw-r--r--tests/fn/FnTest.cpp1
-rw-r--r--tests/llc/LlcTest.cpp1
-rw-r--r--tests/ms/MsTest.cpp1
-rw-r--r--tests/tbf/TbfTest.cpp11
-rw-r--r--tests/types/TypesTest.cpp1
14 files changed, 40 insertions, 21 deletions
diff --git a/include/osmocom/pcu/pcuif_proto.h b/include/osmocom/pcu/pcuif_proto.h
index 00b7bd54..b06077c3 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -5,7 +5,7 @@
#define PCU_SOCK_DEFAULT "/tmp/pcu_bts"
-#define PCU_IF_VERSION 0x08
+#define PCU_IF_VERSION 0x09
#define TXT_MAX_LEN 128
/* msg_type */
@@ -122,7 +122,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, mnc;
+ uint8_t mnc_3_digits;
+ uint16_t lac, rac;
/* NSE */
uint16_t nsei;
uint8_t nse_timer[7];
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);
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 1c98e462..9f6e6c46 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -36,6 +36,7 @@ extern "C" {
/* globals used by the code */
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static gprs_rlcmac_tbf *tbf_alloc(struct gprs_rlcmac_bts *bts,
GprsMs *ms, gprs_rlcmac_tbf_direction dir,
diff --git a/tests/alloc/MslotTest.cpp b/tests/alloc/MslotTest.cpp
index 92f92fae..ebe04cad 100644
--- a/tests/alloc/MslotTest.cpp
+++ b/tests/alloc/MslotTest.cpp
@@ -37,6 +37,7 @@ extern "C" {
/* globals used by the code */
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static inline void test_all_classes(struct gprs_rlcmac_trx *trx, bool clear_masks)
{
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index eb9ef42a..cd80c05f 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -46,6 +46,7 @@ extern "C" {
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mode)
{
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index 957ddf60..4cc37f38 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -40,6 +40,7 @@ static size_t current_test;
/* Extern data to please the underlying code */
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
extern void test_replay_gprs_attach(struct gprs_bssgp_pcu *pcu);
extern void test_replay_gprs_data(struct gprs_bssgp_pcu *, struct msgb *, struct tlv_parsed *);
@@ -99,7 +100,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, 901, 99, false, 1, 0, 0);
pcu->on_unblock_ack = bvci_unblocked;
pcu->on_dl_unit_data = bssgp_data;
}
diff --git a/tests/fn/FnTest.cpp b/tests/fn/FnTest.cpp
index 279903c8..1e3ff113 100644
--- a/tests/fn/FnTest.cpp
+++ b/tests/fn/FnTest.cpp
@@ -34,6 +34,7 @@ extern "C" {
/* globals used by the code */ void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static uint32_t calc_fn(BTS * bts, uint32_t rfn)
{
diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp
index f827ef14..eb693f56 100644
--- a/tests/llc/LlcTest.cpp
+++ b/tests/llc/LlcTest.cpp
@@ -40,6 +40,7 @@ extern "C" {
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static void enqueue_data(gprs_llc_queue *queue, const uint8_t *data, size_t len,
gprs_llc_queue::MetaInfo *info = 0)
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index ac35998a..46015045 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -41,6 +41,7 @@ extern "C" {
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static void test_ms_state()
{
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index fb9158f9..662708a6 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -47,6 +47,7 @@ extern "C" {
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static void check_tbf(gprs_rlcmac_tbf *tbf)
{
@@ -449,7 +450,7 @@ static void test_tbf_exhaustion()
bts = the_bts.bts_data();
setup_bts(&the_bts, ts_no);
gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
- 1234, 1234, 1234, 1, 1, 0, 0, 0);
+ 1234, 1234, 1234, 1, 1, false, 0, 0, 0);
for (i = 0; i < 1024; i++) {
uint32_t tlli = 0xc0000000 + i;
@@ -492,7 +493,7 @@ static void test_tbf_dl_llc_loss()
bts->ms_idle_sec = 10; /* keep the MS object */
gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
- 1234, 1234, 1234, 1, 1, 0, 0, 0);
+ 1234, 1234, 1234, 1, 1, false, 0, 0, 0);
/* Handle LLC frame 1 */
memset(buf, 1, sizeof(buf));
@@ -2161,7 +2162,7 @@ static void test_tbf_gprs_egprs()
bts->egprs_enabled = 1;
gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
- 1234, 1234, 1234, 1, 1, 0, 0, 0);
+ 1234, 1234, 1234, 1, 1, false, 0, 0, 0);
/* Does not support EGPRS */
rc = gprs_rlcmac_dl_tbf::handle(bts, tlli, 0, imsi, ms_class, 0,
@@ -2223,7 +2224,7 @@ static void test_tbf_ws()
bts->trx[0].pdch[5].enable();
gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
- 1234, 1234, 1234, 1, 1, 0, 0, 0);
+ 1234, 1234, 1234, 1, 1, false, 0, 0, 0);
/* Does no support EGPRS */
dl_tbf = tbf_alloc_dl_tbf(bts, NULL, 0, ms_class, 0, false);
@@ -2261,7 +2262,7 @@ static void test_tbf_update_ws(void)
bts->trx[0].pdch[5].enable();
gprs_bssgp_create_and_connect(bts, 33001, 0, 33001,
- 1234, 1234, 1234, 1, 1, 0, 0, 0);
+ 1234, 1234, 1234, 1, 1, false, 0, 0, 0);
/* EGPRS-only */
bts->egprs_enabled = 1;
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index 5c4da221..3a43897b 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -44,6 +44,7 @@ extern "C" {
void *tall_pcu_ctx;
int16_t spoof_mnc = 0, spoof_mcc = 0;
+bool spoof_mnc_3_digits = false;
static void test_llc(void)
{