summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-01-09 15:44:16 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-10-23 21:29:06 +0200
commitc7fc2cdd2a2b105f51ca86e974e1096f0a8d4202 (patch)
tree83b034fd9beb5399e1ec6a766fe2b2fd499bab6d
parentf9ffd1fa1811914ce6b19f1d17e7a908e550d358 (diff)
HACK: Allow each BTS to have a different MCC/MNC for testing purposeszecke/hacks/multiple-mnc-mcc2
-rw-r--r--openbsc/configure.ac2
-rw-r--r--openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg8
-rw-r--r--openbsc/include/openbsc/gsm_data.h7
-rw-r--r--openbsc/include/openbsc/gsm_data_shared.h6
-rw-r--r--openbsc/include/openbsc/gsm_subscriber.h2
-rw-r--r--openbsc/src/ipaccess/ipaccess-config.c2
-rw-r--r--openbsc/src/libbsc/bsc_ctrl_commands.c42
-rw-r--r--openbsc/src/libbsc/bsc_init.c8
-rw-r--r--openbsc/src/libbsc/bsc_vty.c63
-rw-r--r--openbsc/src/libbsc/paging.c20
-rw-r--r--openbsc/src/libbsc/system_information.c12
-rw-r--r--openbsc/src/libcommon/gsm_data.c9
-rw-r--r--openbsc/src/libcommon/gsm_data_shared.c6
-rw-r--r--openbsc/src/libmsc/db.c16
-rw-r--r--openbsc/src/libmsc/gsm_04_08.c21
-rw-r--r--openbsc/src/libmsc/gsm_subscriber.c2
-rw-r--r--openbsc/src/libmsc/vty_interface_layer3.c8
-rw-r--r--openbsc/src/utils/bs11_config.c2
-rw-r--r--openbsc/tests/channel/channel_test.c2
19 files changed, 137 insertions, 101 deletions
diff --git a/openbsc/configure.ac b/openbsc/configure.ac
index 5e705c767..3391eb401 100644
--- a/openbsc/configure.ac
+++ b/openbsc/configure.ac
@@ -45,7 +45,7 @@ AC_ARG_ENABLE([osmo-bsc], [AS_HELP_STRING([--enable-osmo-bsc], [Build the Osmo B
if test "$osmo_ac_build_bsc" = "yes" ; then
PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.6)
fi
-AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "xyes")
+AM_CONDITIONAL(BUILD_BSC, test "x$osmo_ac_build_bsc" = "NOT_DISABLED")
AC_SUBST(osmo_ac_build_bsc)
# Enable/disable smpp support in the nitb?
diff --git a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
index 7a443087c..e222255a0 100644
--- a/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
+++ b/openbsc/doc/examples/osmo-nitb/nanobts/openbsc.cfg
@@ -9,10 +9,6 @@ line vty
e1_input
e1_line 0 driver ipa
network
- network country code 1
- mobile network code 1
- short name OpenBSC
- long name OpenBSC
auth policy closed
location updating reject cause 13
encryption a5 0
@@ -38,6 +34,10 @@ network
timer t3119 0
timer t3141 0
bts 0
+ network country code 1
+ mobile network code 1
+ short name OpenBSC
+ long name OpenBSC
type nanobts
band DCS1800
cell_identity 0
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index 254feaf86..523641a86 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -205,10 +205,6 @@ enum gsm_auth_policy {
struct gsm_network {
/* global parameters */
- uint16_t country_code;
- uint16_t network_code;
- char *name_long;
- char *name_short;
enum gsm_auth_policy auth_policy;
enum gsm48_reject_value reject_cause;
int a5_encryption;
@@ -328,8 +324,7 @@ struct gsm_sms {
char text[SMS_TEXT_SIZE];
};
-struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
- int (*mncc_recv)(struct gsm_network *, struct msgb *));
+struct gsm_network *gsm_network_init(int (*mncc_recv)(struct gsm_network *, struct msgb *));
int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type);
/* Get reference to a neighbor cell on a given BCCH ARFCN */
diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h
index 0704bd753..217474f17 100644
--- a/openbsc/include/openbsc/gsm_data_shared.h
+++ b/openbsc/include/openbsc/gsm_data_shared.h
@@ -731,6 +731,12 @@ struct gsm_bts {
struct bts_codec_conf codec;
#endif /* ROLE_BSC */
void *role;
+
+ /* hacks for some network tweaks... */
+ uint16_t country_code;
+ uint16_t network_code;
+ char *name_long;
+ char *name_short;
};
diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index 7aae4c332..8622aff07 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -36,6 +36,8 @@ struct gsm_subscriber {
long long unsigned int id;
char imsi[GSM_IMSI_LENGTH];
uint32_t tmsi;
+ uint16_t mnc;
+ uint16_t mcc;
uint16_t lac;
char name[GSM_NAME_LENGTH];
char extension[GSM_EXTENSION_LENGTH];
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index c42c7bb9c..d74d45ec9 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -983,7 +983,7 @@ int main(int argc, char **argv)
}
libosmo_abis_init(tall_ctx_config);
- bsc_gsmnet = gsm_network_init(1, 1, NULL);
+ bsc_gsmnet = gsm_network_init(NULL);
if (!bsc_gsmnet)
exit(1);
diff --git a/openbsc/src/libbsc/bsc_ctrl_commands.c b/openbsc/src/libbsc/bsc_ctrl_commands.c
index 3cd0ee379..a9ea4f14b 100644
--- a/openbsc/src/libbsc/bsc_ctrl_commands.c
+++ b/openbsc/src/libbsc/bsc_ctrl_commands.c
@@ -61,10 +61,10 @@ static int verify_vty_description_string(struct ctrl_cmd *cmd,
return 0;
}
-CTRL_CMD_DEFINE_RANGE(net_mnc, "mnc", struct gsm_network, network_code, 0, 999);
-CTRL_CMD_DEFINE_RANGE(net_mcc, "mcc", struct gsm_network, country_code, 1, 999);
-CTRL_CMD_VTY_STRING(net_short_name, "short-name", struct gsm_network, name_short);
-CTRL_CMD_VTY_STRING(net_long_name, "long-name", struct gsm_network, name_long);
+CTRL_CMD_DEFINE_RANGE(bts_mnc, "mnc", struct gsm_bts, network_code, 0, 999);
+CTRL_CMD_DEFINE_RANGE(bts_mcc, "mcc", struct gsm_bts, country_code, 1, 999);
+CTRL_CMD_VTY_STRING(bts_short_name, "short-name", struct gsm_bts, name_short);
+CTRL_CMD_VTY_STRING(bts_long_name, "long-name", struct gsm_bts, name_long);
static int verify_net_apply_config(struct ctrl_cmd *cmd, const char *v, void *d)
{
@@ -95,7 +95,7 @@ static int set_net_apply_config(struct ctrl_cmd *cmd, void *data)
CTRL_CMD_DEFINE(net_apply_config, "apply-configuration");
-static int verify_net_mcc_mnc_apply(struct ctrl_cmd *cmd, const char *value, void *d)
+static int verify_bts_mcc_mnc_apply(struct ctrl_cmd *cmd, const char *value, void *d)
{
char *tmp, *saveptr, *mcc, *mnc;
@@ -112,15 +112,15 @@ static int verify_net_mcc_mnc_apply(struct ctrl_cmd *cmd, const char *value, voi
return 0;
}
-static int get_net_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data)
+static int get_bts_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data)
{
cmd->reply = "Write only attribute";
return CTRL_CMD_ERROR;
}
-static int set_net_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data)
+static int set_bts_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data)
{
- struct gsm_network *net = cmd->node;
+ struct gsm_bts *bts = cmd->node;
char *tmp, *saveptr, *mcc_str, *mnc_str;
int mcc, mnc;
@@ -137,21 +137,25 @@ static int set_net_mcc_mnc_apply(struct ctrl_cmd *cmd, void *data)
talloc_free(tmp);
- if (net->network_code == mnc && net->country_code == mcc) {
+ if (bts->network_code == mnc && bts->country_code == mcc) {
cmd->reply = "Nothing changed";
return CTRL_CMD_REPLY;
}
- net->network_code = mnc;
- net->country_code = mcc;
+ bts->network_code = mnc;
+ bts->country_code = mcc;
+
+ if (is_ipaccess_bts(bts))
+ ipaccess_drop_oml(bts);
- return set_net_apply_config(cmd, data);
+ cmd->reply = "Tried to drop the BTS";
+ return CTRL_CMD_REPLY;
oom:
cmd->reply = "OOM";
return CTRL_CMD_ERROR;
}
-CTRL_CMD_DEFINE(net_mcc_mnc_apply, "mcc-mnc-apply");
+CTRL_CMD_DEFINE(bts_mcc_mnc_apply, "mcc-mnc-apply");
/* TRX related commands below here */
CTRL_HELPER_GET_INT(trx_max_power, struct gsm_bts_trx, max_power_red);
@@ -196,12 +200,12 @@ CTRL_CMD_DEFINE(trx_max_power, "max-power-reduction");
int bsc_base_ctrl_cmds_install(void)
{
int rc = 0;
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mnc);
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc);
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_short_name);
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_long_name);
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_apply_config);
- rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_net_mcc_mnc_apply);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_net_apply_config);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_mnc);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_mcc);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_short_name);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_long_name);
+ rc |= ctrl_cmd_install(CTRL_NODE_BTS, &cmd_bts_mcc_mnc_apply);
rc |= ctrl_cmd_install(CTRL_NODE_TRX, &cmd_trx_max_power);
return rc;
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 796d02793..8781b947e 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -261,8 +261,8 @@ static void bootstrap_rsl(struct gsm_bts_trx *trx)
LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for BTS/TRX (%u/%u) "
"on ARFCN %u using MCC=%u MNC=%u LAC=%u CID=%u BSIC=%u TSC=%u\n",
- trx->bts->nr, trx->nr, trx->arfcn, bsc_gsmnet->country_code,
- bsc_gsmnet->network_code, trx->bts->location_area_code,
+ trx->bts->nr, trx->nr, trx->arfcn, trx->bts->country_code,
+ trx->bts->network_code, trx->bts->location_area_code,
trx->bts->cell_identity, trx->bts->bsic, trx->bts->tsc);
if (trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE) {
@@ -464,12 +464,10 @@ int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *),
int rc;
/* initialize our data structures */
- bsc_gsmnet = gsm_network_init(1, 1, mncc_recv);
+ bsc_gsmnet = gsm_network_init(mncc_recv);
if (!bsc_gsmnet)
return -ENOMEM;
- bsc_gsmnet->name_long = talloc_strdup(bsc_gsmnet, "OpenBSC");
- bsc_gsmnet->name_short = talloc_strdup(bsc_gsmnet, "OpenBSC");
/* our vty command code expects vty->priv to point to a telnet_connection */
dummy_conn.priv = bsc_gsmnet;
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 9129059e5..9220a6007 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -182,13 +182,8 @@ static void net_dump_vty(struct vty *vty, struct gsm_network *net)
{
struct pchan_load pl;
- vty_out(vty, "BSC is on Country Code %u, Network Code %u "
- "and has %u BTS%s", net->country_code, net->network_code,
+ vty_out(vty, "BSC has %u BTS%s",
net->num_bts, VTY_NEWLINE);
- vty_out(vty, " Long network name: '%s'%s",
- net->name_long, VTY_NEWLINE);
- vty_out(vty, " Short network name: '%s'%s",
- net->name_short, VTY_NEWLINE);
vty_out(vty, " Authentication policy: %s%s",
gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE);
vty_out(vty, " Location updating reject cause: %u%s",
@@ -251,12 +246,16 @@ static void bts_dump_vty(struct vty *vty, struct gsm_bts *bts)
{
struct pchan_load pl;
- vty_out(vty, "BTS %u is of %s type in band %s, has CI %u LAC %u, "
+ vty_out(vty, "BTS %u is of %s type in band %s, has CI %u MCC %u MNC %u LAC %u, "
"BSIC %u, TSC %u and %u TRX%s",
bts->nr, btstype2str(bts->type), gsm_band_name(bts->band),
- bts->cell_identity,
+ bts->cell_identity, bts->country_code, bts->network_code,
bts->location_area_code, bts->bsic, bts->tsc,
bts->num_trx, VTY_NEWLINE);
+ vty_out(vty, "Long network name: '%s'%s",
+ bts->name_long, VTY_NEWLINE);
+ vty_out(vty, "Short network name: '%s'%s",
+ bts->name_short, VTY_NEWLINE);
vty_out(vty, "Description: %s%s",
bts->description ? bts->description : "(null)", VTY_NEWLINE);
vty_out(vty, "MS Max power: %u dBm%s", bts->ms_max_power, VTY_NEWLINE);
@@ -487,6 +486,10 @@ static void config_write_bts_single(struct vty *vty, struct gsm_bts *bts)
vty_out(vty, " type %s%s", btstype2str(bts->type), VTY_NEWLINE);
if (bts->description)
vty_out(vty, " description %s%s", bts->description, VTY_NEWLINE);
+ vty_out(vty, " network country code %u%s", bts->country_code, VTY_NEWLINE);
+ vty_out(vty, " mobile network code %u%s", bts->network_code, VTY_NEWLINE);
+ vty_out(vty, " short name %s%s", bts->name_short, VTY_NEWLINE);
+ vty_out(vty, " long name %s%s", bts->name_long, VTY_NEWLINE);
vty_out(vty, " band %s%s", gsm_band_name(bts->band), VTY_NEWLINE);
vty_out(vty, " cell_identity %u%s", bts->cell_identity, VTY_NEWLINE);
vty_out(vty, " location_area_code %u%s", bts->location_area_code,
@@ -669,10 +672,6 @@ static int config_write_net(struct vty *vty)
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
vty_out(vty, "network%s", VTY_NEWLINE);
- vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE);
- vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE);
- vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE);
- vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE);
vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE);
vty_out(vty, " location updating reject cause %u%s",
gsmnet->reject_cause, VTY_NEWLINE);
@@ -1209,55 +1208,55 @@ DEFUN(cfg_net,
return CMD_SUCCESS;
}
-DEFUN(cfg_net_ncc,
- cfg_net_ncc_cmd,
+DEFUN(cfg_bts_ncc,
+ cfg_bts_ncc_cmd,
"network country code <1-999>",
"Set the GSM network country code\n"
"Country commands\n"
CODE_CMD_STR
"Network Country Code to use\n")
{
- struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ struct gsm_bts *bts = vty->index;
- gsmnet->country_code = atoi(argv[0]);
+ bts->country_code = atoi(argv[0]);
return CMD_SUCCESS;
}
-DEFUN(cfg_net_mnc,
- cfg_net_mnc_cmd,
+DEFUN(cfg_bts_mnc,
+ cfg_bts_mnc_cmd,
"mobile network code <0-999>",
"Set the GSM mobile network code\n"
"Network Commands\n"
CODE_CMD_STR
"Mobile Network Code to use\n")
{
- struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ struct gsm_bts *bts = vty->index;
- gsmnet->network_code = atoi(argv[0]);
+ bts->network_code = atoi(argv[0]);
return CMD_SUCCESS;
}
-DEFUN(cfg_net_name_short,
- cfg_net_name_short_cmd,
+DEFUN(cfg_bts_name_short,
+ cfg_bts_name_short_cmd,
"short name NAME",
"Set the short GSM network name\n" NAME_CMD_STR NAME_STR)
{
- struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ struct gsm_bts *bts = vty->index;
- bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
+ bsc_replace_string(bts, &bts->name_short, argv[0]);
return CMD_SUCCESS;
}
-DEFUN(cfg_net_name_long,
- cfg_net_name_long_cmd,
+DEFUN(cfg_bts_name_long,
+ cfg_bts_name_long_cmd,
"long name NAME",
"Set the long GSM network name\n" NAME_CMD_STR NAME_STR)
{
- struct gsm_network *gsmnet = gsmnet_from_vty(vty);
+ struct gsm_bts *bts = vty->index;
- bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
+ bsc_replace_string(bts, &bts->name_long, argv[0]);
return CMD_SUCCESS;
}
@@ -3281,10 +3280,6 @@ int bsc_vty_init(const struct log_info *cat)
install_element(CONFIG_NODE, &cfg_net_cmd);
install_node(&net_node, config_write_net);
vty_install_default(GSMNET_NODE);
- install_element(GSMNET_NODE, &cfg_net_ncc_cmd);
- install_element(GSMNET_NODE, &cfg_net_mnc_cmd);
- install_element(GSMNET_NODE, &cfg_net_name_short_cmd);
- install_element(GSMNET_NODE, &cfg_net_name_long_cmd);
install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd);
install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd);
install_element(GSMNET_NODE, &cfg_net_encryption_cmd);
@@ -3317,6 +3312,10 @@ int bsc_vty_init(const struct log_info *cat)
install_element(GSMNET_NODE, &cfg_bts_cmd);
install_node(&bts_node, config_write_bts);
vty_install_default(BTS_NODE);
+ install_element(BTS_NODE, &cfg_bts_ncc_cmd);
+ install_element(BTS_NODE, &cfg_bts_mnc_cmd);
+ install_element(BTS_NODE, &cfg_bts_name_short_cmd);
+ install_element(BTS_NODE, &cfg_bts_name_long_cmd);
install_element(BTS_NODE, &cfg_bts_type_cmd);
install_element(BTS_NODE, &cfg_description_cmd);
install_element(BTS_NODE, &cfg_no_description_cmd);
diff --git a/openbsc/src/libbsc/paging.c b/openbsc/src/libbsc/paging.c
index 286c57ba9..6ce17f896 100644
--- a/openbsc/src/libbsc/paging.c
+++ b/openbsc/src/libbsc/paging.c
@@ -303,9 +303,23 @@ int paging_request_bts(struct gsm_bts *bts, struct gsm_subscriber *subscr,
{
int rc;
+ /* not the right network */
+ if (bts->network_code != subscr->mnc || bts->country_code != subscr->mcc) {
+ LOGP(DPAG, LOGL_DEBUG,
+ "BTS(%d) is not of the right network mnc(%d/%d) mcc(%d/%d)\n",
+ bts->nr,
+ bts->network_code, subscr->mnc,
+ bts->country_code, subscr->mcc);
+ return 0;
+ }
+
/* skip all currently inactive TRX */
- if (!trx_is_usable(bts->c0))
+ if (!trx_is_usable(bts->c0)) {
+ LOGP(DPAG, LOGL_DEBUG,
+ "BTS(%d) is not usable.\n",
+ bts->nr);
return 0;
+ }
/* maybe it is the first time we use it */
paging_init_if_needed(bts);
@@ -393,6 +407,10 @@ void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
if (!bts)
break;
+ /* not the right network */
+ if (bts->network_code != subscr->mnc || bts->country_code != subscr->mcc)
+ continue;
+
/* Stop paging */
if (bts != _bts)
_paging_request_stop(bts, subscr, NULL, NULL);
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index a3deefc73..a9d6e7060 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -531,8 +531,8 @@ static int generate_si3(uint8_t *output, struct gsm_bts *bts)
si3->header.system_information = GSM48_MT_RR_SYSINFO_3;
si3->cell_identity = htons(bts->cell_identity);
- gsm48_generate_lai(&si3->lai, bts->network->country_code,
- bts->network->network_code,
+ gsm48_generate_lai(&si3->lai, bts->country_code,
+ bts->network_code,
bts->location_area_code);
si3->control_channel_desc = bts->si_common.chan_desc;
si3->cell_options = bts->si_common.cell_options;
@@ -570,8 +570,8 @@ static int generate_si4(uint8_t *output, struct gsm_bts *bts)
si4->header.skip_indicator = 0;
si4->header.system_information = GSM48_MT_RR_SYSINFO_4;
- gsm48_generate_lai(&si4->lai, bts->network->country_code,
- bts->network->network_code,
+ gsm48_generate_lai(&si4->lai, bts->country_code,
+ bts->network_code,
bts->location_area_code);
si4->cell_sel_par = bts->si_common.cell_sel_par;
si4->rach_control = bts->si_common.rach_control;
@@ -728,8 +728,8 @@ static int generate_si6(uint8_t *output, struct gsm_bts *bts)
si6->skip_indicator = 0;
si6->system_information = GSM48_MT_RR_SYSINFO_6;
si6->cell_identity = htons(bts->cell_identity);
- gsm48_generate_lai(&si6->lai, bts->network->country_code,
- bts->network->network_code,
+ gsm48_generate_lai(&si6->lai, bts->country_code,
+ bts->network_code,
bts->location_area_code);
si6->cell_options = bts->si_common.cell_options;
si6->ncc_permitted = bts->si_common.ncc_permitted;
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index 51444e7f5..b8e962995 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -70,8 +70,7 @@ int gsm_bts_model_register(struct gsm_bts_model *model)
return 0;
}
-struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code,
- int (*mncc_recv)(struct gsm_network *, struct msgb *))
+struct gsm_network *gsm_network_init(int (*mncc_recv)(struct gsm_network *, struct msgb *))
{
struct gsm_network *net;
@@ -90,8 +89,6 @@ struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_cod
net->bsc_data->network = net;
INIT_LLIST_HEAD(&net->bsc_data->mscs);
- net->country_code = country_code;
- net->network_code = network_code;
net->num_bts = 0;
net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED;
net->T3101 = GSM_T3101_DEFAULT;
@@ -404,8 +401,8 @@ struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_typ
void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
{
- raid->mcc = bts->network->country_code;
- raid->mnc = bts->network->network_code;
+ raid->mcc = bts->country_code;
+ raid->mnc = bts->network_code;
raid->lac = bts->location_area_code;
raid->rac = bts->gprs.rac;
}
diff --git a/openbsc/src/libcommon/gsm_data_shared.c b/openbsc/src/libcommon/gsm_data_shared.c
index 8d5d0f85d..97f4c5fb4 100644
--- a/openbsc/src/libcommon/gsm_data_shared.c
+++ b/openbsc/src/libcommon/gsm_data_shared.c
@@ -276,6 +276,12 @@ struct gsm_bts *gsm_bts_alloc(void *ctx)
bts->rach_ldavg_slots = -1;
bts->paging.free_chans_need = -1;
+ /* hacks */
+ bts->network_code = 1;
+ bts->country_code = 1;
+ bts->name_long = talloc_strdup(bts, "OpenBSC");
+ bts->name_short = talloc_strdup(bts, "OpenBSC");
+
return bts;
}
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c
index 656c661b7..2905ab580 100644
--- a/openbsc/src/libmsc/db.c
+++ b/openbsc/src/libmsc/db.c
@@ -82,6 +82,8 @@ static const char *create_stmts[] = {
"extension TEXT UNIQUE, "
"authorized INTEGER NOT NULL DEFAULT 0, "
"tmsi TEXT UNIQUE, "
+ "mnc INTEGER NOT NULL DEFAULT 0, "
+ "mcc INTEGER NOT NULL DEFAULT 0, "
"lac INTEGER NOT NULL DEFAULT 0, "
"expire_lu TIMESTAMP DEFAULT NULL"
")",
@@ -817,6 +819,8 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result)
strncpy(subscr->extension, string, GSM_EXTENSION_LENGTH);
subscr->lac = dbi_result_get_ulonglong(result, "lac");
+ subscr->mcc = dbi_result_get_uint(result, "mcc");
+ subscr->mnc = dbi_result_get_uint(result, "mnc");
if (!dbi_result_field_is_null(result, "expire_lu"))
subscr->expire_lu = dbi_result_get_datetime(result, "expire_lu");
@@ -889,9 +893,9 @@ struct gsm_subscriber *db_get_subscriber(enum gsm_subscriber_field field,
subscr->id = dbi_result_get_ulonglong(result, "id");
db_set_from_query(subscr, result);
- DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', TMSI %u, EXTEN '%s', LAC %hu, AUTH %u\n",
+ DEBUGP(DDB, "Found Subscriber: ID %llu, IMSI %s, NAME '%s', TMSI %u, EXTEN '%s', LAC %hu, MNC %u, MCC %u, AUTH %u\n",
subscr->id, subscr->imsi, subscr->name, subscr->tmsi, subscr->extension,
- subscr->lac, subscr->authorized);
+ subscr->lac, subscr->mnc, subscr->mcc, subscr->authorized);
dbi_result_free(result);
get_equipment_by_subscr(subscr);
@@ -956,6 +960,8 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber)
"authorized = %i, "
"tmsi = %s, "
"lac = %i, "
+ "mnc = %u, "
+ "mcc = %u, "
"expire_lu = NULL "
"WHERE imsi = %s ",
q_name,
@@ -963,6 +969,8 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber)
subscriber->authorized,
q_tmsi,
subscriber->lac,
+ subscriber->mnc,
+ subscriber->mcc,
subscriber->imsi);
} else {
result = dbi_conn_queryf(conn,
@@ -973,6 +981,8 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber)
"authorized = %i, "
"tmsi = %s, "
"lac = %i, "
+ "mnc = %u, "
+ "mcc = %u, "
"expire_lu = datetime(%i, 'unixepoch') "
"WHERE imsi = %s ",
q_name,
@@ -980,6 +990,8 @@ int db_sync_subscriber(struct gsm_subscriber *subscriber)
subscriber->authorized,
q_tmsi,
subscriber->lac,
+ subscriber->mnc,
+ subscriber->mcc,
(int) subscriber->expire_lu,
subscriber->imsi);
}
diff --git a/openbsc/src/libmsc/gsm_04_08.c b/openbsc/src/libmsc/gsm_04_08.c
index db6fc5f70..cafeb4ce1 100644
--- a/openbsc/src/libmsc/gsm_04_08.c
+++ b/openbsc/src/libmsc/gsm_04_08.c
@@ -448,8 +448,8 @@ int gsm0408_loc_upd_acc(struct gsm_subscriber_connection *conn, uint32_t tmsi)
gh->msg_type = GSM48_MT_MM_LOC_UPD_ACCEPT;
lai = (struct gsm48_loc_area_id *) msgb_put(msg, sizeof(*lai));
- gsm48_generate_lai(lai, bts->network->country_code,
- bts->network->network_code, bts->location_area_code);
+ gsm48_generate_lai(lai, bts->country_code,
+ bts->network_code, bts->location_area_code);
mid = msgb_put(msg, GSM48_MID_TMSI_LEN);
gsm48_generate_mid_from_tmsi(mid, tmsi);
@@ -673,7 +673,6 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
{
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
- struct gsm_network *net = conn->bts->network;
struct gsm_bts *bts = conn->bts;
uint8_t *ptr8;
int name_len, name_pad;
@@ -690,7 +689,7 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
gh->proto_discr = GSM48_PDISC_MM;
gh->msg_type = GSM48_MT_MM_INFO;
- if (net->name_long) {
+ if (bts->name_long) {
#if 0
name_len = strlen(net->name_long);
/* 10.5.3.5a */
@@ -706,8 +705,8 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
/* FIXME: Use Cell Broadcast, not UCS-2, since
* UCS-2 is only supported by later revisions of the spec */
#endif
- name_len = (strlen(net->name_long)*7)/8;
- name_pad = (8 - strlen(net->name_long)*7)%8;
+ name_len = (strlen(bts->name_long)*7)/8;
+ name_pad = (8 - strlen(bts->name_long)*7)%8;
if (name_pad > 0)
name_len++;
/* 10.5.3.5a */
@@ -717,11 +716,11 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
ptr8[2] = 0x80 | name_pad; /* Cell Broadcast DCS, no CI */
ptr8 = msgb_put(msg, name_len);
- gsm_7bit_encode(ptr8, net->name_long);
+ gsm_7bit_encode(ptr8, bts->name_long);
}
- if (net->name_short) {
+ if (bts->name_short) {
#if 0
name_len = strlen(net->name_short);
/* 10.5.3.5a */
@@ -734,8 +733,8 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
for (i = 0; i < name_len; i++)
ptr16[i] = htons(net->name_short[i]);
#endif
- name_len = (strlen(net->name_short)*7)/8;
- name_pad = (8 - strlen(net->name_short)*7)%8;
+ name_len = (strlen(bts->name_short)*7)/8;
+ name_pad = (8 - strlen(bts->name_short)*7)%8;
if (name_pad > 0)
name_len++;
/* 10.5.3.5a */
@@ -745,7 +744,7 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn)
ptr8[2] = 0x80 | name_pad; /* Cell Broadcast DCS, no CI */
ptr8 = msgb_put(msg, name_len);
- gsm_7bit_encode(ptr8, net->name_short);
+ gsm_7bit_encode(ptr8, bts->name_short);
}
diff --git a/openbsc/src/libmsc/gsm_subscriber.c b/openbsc/src/libmsc/gsm_subscriber.c
index bc6f3cf55..4fe0b30cc 100644
--- a/openbsc/src/libmsc/gsm_subscriber.c
+++ b/openbsc/src/libmsc/gsm_subscriber.c
@@ -373,6 +373,8 @@ int subscr_update(struct gsm_subscriber *s, struct gsm_bts *bts, int reason)
s->net = bts->network;
/* Indicate "attached to LAC" */
s->lac = bts->location_area_code;
+ s->mnc = bts->network_code;
+ s->mcc = bts->country_code;
LOGP(DMM, LOGL_INFO, "Subscriber %s ATTACHED LAC=%u\n",
subscr_name(s), s->lac);
diff --git a/openbsc/src/libmsc/vty_interface_layer3.c b/openbsc/src/libmsc/vty_interface_layer3.c
index 8890099c6..a220a31a8 100644
--- a/openbsc/src/libmsc/vty_interface_layer3.c
+++ b/openbsc/src/libmsc/vty_interface_layer3.c
@@ -381,15 +381,13 @@ DEFUN(subscriber_silent_call_start,
type = RSL_CHANNEED_ANY; /* Defaults to ANY */
rc = gsm_silent_call_start(subscr, vty, type);
+ subscr_put(subscr);
if (rc <= 0) {
- vty_out(vty, "%% Subscriber not attached%s",
- VTY_NEWLINE);
- subscr_put(subscr);
+ vty_out(vty, "%% Subscriber not attached: %d%s",
+ rc, VTY_NEWLINE);
return CMD_WARNING;
}
- subscr_put(subscr);
-
return CMD_SUCCESS;
}
diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c
index e8acb461a..65811e9dc 100644
--- a/openbsc/src/utils/bs11_config.c
+++ b/openbsc/src/utils/bs11_config.c
@@ -893,7 +893,7 @@ int main(int argc, char **argv)
handle_options(argc, argv);
bts_model_bs11_init();
- gsmnet = gsm_network_init(1, 1, NULL);
+ gsmnet = gsm_network_init(NULL);
if (!gsmnet) {
fprintf(stderr, "Unable to allocate gsm network\n");
exit(1);
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index 9fb1e9e9a..c0a7f7028 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
printf("Testing the gsm_subscriber chan logic\n");
/* Create a dummy network */
- network = gsm_network_init(1, 1, NULL);
+ network = gsm_network_init(NULL);
if (!network)
exit(1);
bts = gsm_bts_alloc(network);