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
This commit is contained in:
parent
8343b4adbb
commit
bdc55fad62
|
@ -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];
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue