2009-08-17 04:55:10 +00:00
|
|
|
/* A hackish minimal BSC (+MSC +HLR) implementation */
|
|
|
|
|
2010-05-16 18:52:23 +00:00
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
2009-08-17 04:55:10 +00:00
|
|
|
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2009-08-17 04:55:10 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2009-08-17 04:55:10 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-08-17 04:55:10 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <openbsc/gsm_data.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/gsm/gsm_utils.h>
|
2009-08-17 04:55:10 +00:00
|
|
|
#include <openbsc/gsm_04_08.h>
|
|
|
|
#include <openbsc/abis_rsl.h>
|
|
|
|
#include <openbsc/abis_nm.h>
|
|
|
|
#include <openbsc/debug.h>
|
|
|
|
#include <openbsc/misdn.h>
|
2010-05-19 17:45:32 +00:00
|
|
|
#include <osmocom/vty/telnet_interface.h>
|
2009-12-01 12:34:30 +00:00
|
|
|
#include <openbsc/system_information.h>
|
2009-08-17 04:55:10 +00:00
|
|
|
#include <openbsc/paging.h>
|
|
|
|
#include <openbsc/signal.h>
|
2010-04-15 09:21:02 +00:00
|
|
|
#include <openbsc/chan_alloc.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2010-11-15 19:43:02 +00:00
|
|
|
#include <openbsc/ipaccess.h>
|
2009-08-17 04:55:10 +00:00
|
|
|
|
|
|
|
/* global pointer to the gsm network data structure */
|
|
|
|
extern struct gsm_network *bsc_gsmnet;
|
2011-04-07 21:34:54 +00:00
|
|
|
extern int hsl_setup(struct gsm_network *gsmnet);
|
2009-08-17 04:55:10 +00:00
|
|
|
|
|
|
|
/* Callback function for NACK on the OML NM */
|
2010-07-13 18:08:35 +00:00
|
|
|
static int oml_msg_nack(struct nm_nack_signal_data *nack)
|
2009-08-17 04:55:10 +00:00
|
|
|
{
|
2010-11-15 19:43:02 +00:00
|
|
|
int i;
|
|
|
|
|
2010-07-13 18:08:35 +00:00
|
|
|
if (nack->mt == NM_MT_SET_BTS_ATTR_NACK) {
|
2010-11-15 19:43:02 +00:00
|
|
|
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DNM, LOGL_FATAL, "Failed to set BTS attributes. That is fatal. "
|
2009-08-17 04:55:10 +00:00
|
|
|
"Was the bts type and frequency properly specified?\n");
|
|
|
|
exit(-1);
|
2010-11-15 19:43:02 +00:00
|
|
|
} else {
|
|
|
|
LOGP(DNM, LOGL_ERROR, "Got a NACK going to drop the OML links.\n");
|
|
|
|
for (i = 0; i < bsc_gsmnet->num_bts; ++i) {
|
|
|
|
struct gsm_bts *bts = gsm_bts_num(bsc_gsmnet, i);
|
|
|
|
if (is_ipaccess_bts(bts))
|
|
|
|
ipaccess_drop_oml(bts);
|
|
|
|
}
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback function to be called every time we receive a signal from NM */
|
|
|
|
static int nm_sig_cb(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
|
|
|
{
|
2010-07-13 18:08:35 +00:00
|
|
|
struct nm_nack_signal_data *nack;
|
2009-11-17 05:09:56 +00:00
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
switch (signal) {
|
|
|
|
case S_NM_NACK:
|
2010-07-13 18:08:35 +00:00
|
|
|
nack = signal_data;
|
|
|
|
return oml_msg_nack(nack);
|
2009-08-17 04:55:10 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int bsc_shutdown_net(struct gsm_network *net)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
|
|
|
|
llist_for_each_entry(bts, &net->bts_list, list) {
|
2011-01-14 14:55:42 +00:00
|
|
|
LOGP(DNM, LOGL_NOTICE, "shutting down OML for BTS %u\n", bts->nr);
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_BTS_CLOSE_OM, bts);
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
static int generate_and_rsl_si(struct gsm_bts_trx *trx, enum osmo_sysinfo_type i)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts = trx->bts;
|
2011-03-04 12:41:31 +00:00
|
|
|
int si_len, rc, j;
|
2010-06-15 14:44:12 +00:00
|
|
|
|
2010-07-30 09:50:09 +00:00
|
|
|
/* Only generate SI if this SI is not in "static" (user-defined) mode */
|
|
|
|
if (!(bts->si_mode_static & (1 << i))) {
|
|
|
|
rc = gsm_generate_si(bts, i);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2011-03-04 12:41:31 +00:00
|
|
|
si_len = rc;
|
2010-07-30 09:50:09 +00:00
|
|
|
}
|
2010-06-15 14:44:12 +00:00
|
|
|
|
2011-05-24 13:02:20 +00:00
|
|
|
DEBUGP(DRR, "SI%s: %s\n", get_value_string(osmo_sitype_strs, i),
|
2011-05-07 10:12:48 +00:00
|
|
|
osmo_hexdump(GSM_BTS_SI(bts, i), GSM_MACBLOCK_LEN));
|
2010-06-15 14:44:12 +00:00
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case SYSINFO_TYPE_5:
|
|
|
|
case SYSINFO_TYPE_5bis:
|
|
|
|
case SYSINFO_TYPE_5ter:
|
|
|
|
case SYSINFO_TYPE_6:
|
2011-03-04 12:41:31 +00:00
|
|
|
if (trx->bts->type == GSM_BTS_TYPE_HSL_FEMTO) {
|
|
|
|
/* HSL has mistaken SACCH INFO MODIFY for SACCH FILLING,
|
|
|
|
* so we need a special workaround here */
|
|
|
|
/* This assumes a combined BCCH and TCH on TS1...7 */
|
|
|
|
for (j = 0; j < 4; j++)
|
|
|
|
rsl_sacch_info_modify(&trx->ts[0].lchan[j],
|
2011-05-24 13:02:20 +00:00
|
|
|
osmo_sitype2rsl(i),
|
2011-03-04 12:41:31 +00:00
|
|
|
GSM_BTS_SI(bts, i), si_len);
|
|
|
|
for (j = 1; j < 8; j++) {
|
|
|
|
rsl_sacch_info_modify(&trx->ts[j].lchan[0],
|
2011-05-24 13:02:20 +00:00
|
|
|
osmo_sitype2rsl(i),
|
2011-03-04 12:41:31 +00:00
|
|
|
GSM_BTS_SI(bts, i), si_len);
|
|
|
|
rsl_sacch_info_modify(&trx->ts[j].lchan[1],
|
2011-05-24 13:02:20 +00:00
|
|
|
osmo_sitype2rsl(i),
|
2011-03-04 12:41:31 +00:00
|
|
|
GSM_BTS_SI(bts, i), si_len);
|
|
|
|
}
|
|
|
|
} else
|
2011-05-24 13:02:20 +00:00
|
|
|
rc = rsl_sacch_filling(trx, osmo_sitype2rsl(i),
|
2011-03-04 12:41:31 +00:00
|
|
|
GSM_BTS_SI(bts, i), rc);
|
2010-06-15 14:44:12 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-05-24 13:02:20 +00:00
|
|
|
rc = rsl_bcch_info(trx, osmo_sitype2rsl(i),
|
2010-06-15 14:44:12 +00:00
|
|
|
GSM_BTS_SI(bts, i), rc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
/* set all system information types */
|
|
|
|
static int set_system_infos(struct gsm_bts_trx *trx)
|
|
|
|
{
|
2009-12-01 12:34:30 +00:00
|
|
|
int i, rc;
|
2009-12-21 22:12:19 +00:00
|
|
|
struct gsm_bts *bts = trx->bts;
|
|
|
|
|
|
|
|
bts->si_common.cell_sel_par.ms_txpwr_max_ccch =
|
|
|
|
ms_pwr_ctl_lvl(bts->band, bts->ms_max_power);
|
|
|
|
bts->si_common.cell_sel_par.neci = bts->network->neci;
|
2009-08-17 04:55:10 +00:00
|
|
|
|
2010-07-30 09:50:09 +00:00
|
|
|
/* First, we determine which of the SI messages we actually need */
|
|
|
|
|
2010-06-15 14:44:12 +00:00
|
|
|
if (trx == bts->c0) {
|
2010-07-30 09:50:09 +00:00
|
|
|
/* 1...4 are always present on a C0 TRX */
|
|
|
|
for (i = SYSINFO_TYPE_1; i <= SYSINFO_TYPE_4; i++)
|
|
|
|
bts->si_valid |= (1 << i);
|
|
|
|
|
|
|
|
/* 13 is always present on a C0 TRX of a GPRS BTS */
|
|
|
|
if (bts->gprs.mode != BTS_GPRS_NONE)
|
|
|
|
bts->si_valid |= (1 << SYSINFO_TYPE_13);
|
2009-12-21 16:02:32 +00:00
|
|
|
}
|
|
|
|
|
2010-07-30 09:50:09 +00:00
|
|
|
/* 5 and 6 are always present on every TRX */
|
|
|
|
bts->si_valid |= (1 << SYSINFO_TYPE_5);
|
|
|
|
bts->si_valid |= (1 << SYSINFO_TYPE_6);
|
|
|
|
|
|
|
|
/* Second, we generate and send the selected SI via RSL */
|
|
|
|
for (i = SYSINFO_TYPE_1; i < _MAX_SYSINFO_TYPE; i++) {
|
|
|
|
if (!(bts->si_valid & (1 << i)))
|
|
|
|
continue;
|
2009-12-01 12:34:30 +00:00
|
|
|
|
2010-07-30 09:50:09 +00:00
|
|
|
rc = generate_and_rsl_si(trx, i);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err_out;
|
|
|
|
}
|
2009-08-17 04:55:10 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-12-01 12:34:30 +00:00
|
|
|
err_out:
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRR, LOGL_ERROR, "Cannot generate SI %u for BTS %u, most likely "
|
2009-12-01 12:34:30 +00:00
|
|
|
"a problem with neighbor cell list generation\n",
|
2010-06-15 14:44:12 +00:00
|
|
|
i, bts->nr);
|
2009-12-01 12:34:30 +00:00
|
|
|
return rc;
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
|
2010-06-15 06:52:12 +00:00
|
|
|
/* Produce a MA as specified in 10.5.2.21 */
|
|
|
|
static int generate_ma_for_ts(struct gsm_bts_trx_ts *ts)
|
|
|
|
{
|
|
|
|
/* we have three bitvecs: the per-timeslot ARFCNs, the cell chan ARFCNs
|
|
|
|
* and the MA */
|
|
|
|
struct bitvec *cell_chan = &ts->trx->bts->si_common.cell_alloc;
|
|
|
|
struct bitvec *ts_arfcn = &ts->hopping.arfcns;
|
|
|
|
struct bitvec *ma = &ts->hopping.ma;
|
2010-06-15 14:45:51 +00:00
|
|
|
unsigned int num_cell_arfcns, bitnum, n_chan;
|
2010-06-15 06:52:12 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* re-set the MA to all-zero */
|
|
|
|
ma->cur_bit = 0;
|
2010-06-15 14:45:51 +00:00
|
|
|
ts->hopping.ma_len = 0;
|
2010-06-15 06:52:12 +00:00
|
|
|
memset(ma->data, 0, ma->data_len);
|
|
|
|
|
|
|
|
if (!ts->hopping.enabled)
|
|
|
|
return 0;
|
|
|
|
|
2010-06-15 14:45:51 +00:00
|
|
|
/* count the number of ARFCNs in the cell channel allocation */
|
|
|
|
num_cell_arfcns = 0;
|
|
|
|
for (i = 1; i < 1024; i++) {
|
|
|
|
if (bitvec_get_bit_pos(cell_chan, i))
|
|
|
|
num_cell_arfcns++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pad it to octet-aligned number of bits */
|
|
|
|
ts->hopping.ma_len = num_cell_arfcns / 8;
|
|
|
|
if (num_cell_arfcns % 8)
|
|
|
|
ts->hopping.ma_len++;
|
|
|
|
|
|
|
|
n_chan = 0;
|
2010-06-15 06:52:12 +00:00
|
|
|
for (i = 1; i < 1024; i++) {
|
|
|
|
if (!bitvec_get_bit_pos(cell_chan, i))
|
|
|
|
continue;
|
2010-06-15 14:45:51 +00:00
|
|
|
/* set the corresponding bit in the MA */
|
|
|
|
bitnum = (ts->hopping.ma_len * 8) - 1 - n_chan;
|
2010-06-15 06:52:12 +00:00
|
|
|
if (bitvec_get_bit_pos(ts_arfcn, i))
|
2010-06-15 14:45:51 +00:00
|
|
|
bitvec_set_bit_pos(ma, bitnum, 1);
|
2010-06-15 06:52:12 +00:00
|
|
|
else
|
2010-06-15 14:45:51 +00:00
|
|
|
bitvec_set_bit_pos(ma, bitnum, 0);
|
2010-06-20 13:56:50 +00:00
|
|
|
n_chan++;
|
2010-06-15 06:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ARFCN 0 is special: It is coded last in the bitmask */
|
|
|
|
if (bitvec_get_bit_pos(cell_chan, 0)) {
|
2010-06-15 14:45:51 +00:00
|
|
|
n_chan++;
|
|
|
|
/* set the corresponding bit in the MA */
|
|
|
|
bitnum = (ts->hopping.ma_len * 8) - 1 - n_chan;
|
2010-06-15 06:52:12 +00:00
|
|
|
if (bitvec_get_bit_pos(ts_arfcn, 0))
|
2010-06-15 14:45:51 +00:00
|
|
|
bitvec_set_bit_pos(ma, bitnum, 1);
|
2010-06-15 06:52:12 +00:00
|
|
|
else
|
2010-06-15 14:45:51 +00:00
|
|
|
bitvec_set_bit_pos(ma, bitnum, 0);
|
2010-06-15 06:52:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
static void bootstrap_rsl(struct gsm_bts_trx *trx)
|
|
|
|
{
|
2010-06-15 06:52:12 +00:00
|
|
|
unsigned int i;
|
|
|
|
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "bootstrapping RSL for BTS/TRX (%u/%u) "
|
2009-12-24 12:39:34 +00:00
|
|
|
"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->cell_identity, trx->bts->bsic, trx->bts->tsc);
|
2009-08-17 04:55:10 +00:00
|
|
|
set_system_infos(trx);
|
2010-06-15 06:52:12 +00:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(trx->ts); i++)
|
|
|
|
generate_ma_for_ts(&trx->ts[i]);
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:55:42 +00:00
|
|
|
/* Callback function to be called every time we receive a signal from INPUT */
|
|
|
|
static int inp_sig_cb(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
2009-08-17 04:55:10 +00:00
|
|
|
{
|
2011-01-14 14:55:42 +00:00
|
|
|
struct input_signal_data *isd = signal_data;
|
|
|
|
struct gsm_bts_trx *trx = isd->trx;
|
2010-04-15 09:21:02 +00:00
|
|
|
int ts_no, lchan_no;
|
|
|
|
|
2011-01-14 14:55:42 +00:00
|
|
|
if (subsys != SS_INPUT)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
switch (signal) {
|
|
|
|
case S_INP_TEI_UP:
|
|
|
|
if (isd->link_type == E1INP_SIGN_RSL)
|
2009-08-17 04:55:10 +00:00
|
|
|
bootstrap_rsl(trx);
|
|
|
|
break;
|
2011-01-14 14:55:42 +00:00
|
|
|
case S_INP_TEI_DN:
|
|
|
|
LOGP(DMI, LOGL_ERROR, "Lost some E1 TEI link: %d %p\n", isd->link_type, trx);
|
2010-04-15 09:21:02 +00:00
|
|
|
|
2011-01-14 14:55:42 +00:00
|
|
|
if (isd->link_type == E1INP_SIGN_OML)
|
2011-05-06 10:13:10 +00:00
|
|
|
osmo_counter_inc(trx->bts->network->stats.bts.oml_fail);
|
2011-01-14 14:55:42 +00:00
|
|
|
else if (isd->link_type == E1INP_SIGN_RSL)
|
2011-05-06 10:13:10 +00:00
|
|
|
osmo_counter_inc(trx->bts->network->stats.bts.rsl_fail);
|
2010-04-12 08:45:52 +00:00
|
|
|
|
2010-04-15 09:21:02 +00:00
|
|
|
/*
|
|
|
|
* free all allocated channels. change the nm_state so the
|
|
|
|
* trx and trx_ts becomes unusable and chan_alloc.c can not
|
|
|
|
* allocate from it.
|
|
|
|
*/
|
|
|
|
for (ts_no = 0; ts_no < ARRAY_SIZE(trx->ts); ++ts_no) {
|
|
|
|
struct gsm_bts_trx_ts *ts = &trx->ts[ts_no];
|
|
|
|
|
|
|
|
for (lchan_no = 0; lchan_no < ARRAY_SIZE(ts->lchan); ++lchan_no) {
|
2010-08-25 04:29:24 +00:00
|
|
|
if (ts->lchan[lchan_no].state != LCHAN_S_NONE)
|
2010-04-15 09:21:02 +00:00
|
|
|
lchan_free(&ts->lchan[lchan_no]);
|
|
|
|
lchan_reset(&ts->lchan[lchan_no]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-29 14:49:03 +00:00
|
|
|
gsm_bts_mo_reset(trx->bts);
|
2010-11-15 19:50:42 +00:00
|
|
|
|
|
|
|
abis_nm_clear_queue(trx->bts);
|
2009-08-17 04:55:10 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-01-14 14:55:42 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int bootstrap_bts(struct gsm_bts *bts)
|
|
|
|
{
|
2010-04-28 19:31:29 +00:00
|
|
|
int i, n;
|
|
|
|
|
bsc: on-demand setup of nanoBTS and HSL femto sockets
The daemons set up nanoBTS and HSL femto sockets by default, ie. the
three sockets to support these two drivers are open even if we have
no BTS of that kind.
This patch enables on-demand socket creation, ie. we only enable them
if we have one BTS at least that requires it.
I added two new attributes to the gsm_bts object, they are:
* the start() function includes the code that we need to run to start
the BTS. This new function contains the socket creation in the
particular case of nanoBTS and HSL femto.
* the started boolean, which is used to know if we have already
started the BTS, ie. we have already invoked start().
Note that, I have splitted the bts_model_*_init() function into two
functions, the _init() functions that register the BTS driver
and the _start() functions that start BTS driver on-demand.
While I was at it, I added several changes/cleanups to this patch:
* Group all bts_model_*_init() calls into one function bts_init(),
which is called in the initialization path of osmo-nitb and
osmo-bsc.
* Add openbsc/bss.h that contains the declaration of
bsc_bootstrap_network, bsc_shutdown_net and bts_init.
* Add missing e1inp_init() in osmo-bsc.
* Fix missing declaration of hsl_setup in openbsc/e1_input.h
2011-05-14 09:32:48 +00:00
|
|
|
if (bts->model->start && !bts->model->started) {
|
|
|
|
int ret = bts->model->start(bts->network);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
bts->model->started = true;
|
|
|
|
}
|
|
|
|
|
2010-05-26 15:14:42 +00:00
|
|
|
/* FIXME: What about secondary TRX of a BTS? What about a BTS that has TRX
|
|
|
|
* in different bands? Why is 'band' a parameter of the BTS and not of the TRX? */
|
2009-10-02 11:19:34 +00:00
|
|
|
switch (bts->band) {
|
|
|
|
case GSM_BAND_1800:
|
2009-08-17 04:55:10 +00:00
|
|
|
if (bts->c0->arfcn < 512 || bts->c0->arfcn > 885) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DNM, LOGL_ERROR, "GSM1800 channel must be between 512-885.\n");
|
2009-08-17 04:55:10 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-02 11:19:34 +00:00
|
|
|
case GSM_BAND_1900:
|
|
|
|
if (bts->c0->arfcn < 512 || bts->c0->arfcn > 810) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DNM, LOGL_ERROR, "GSM1900 channel must be between 512-810.\n");
|
2009-10-02 11:19:34 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GSM_BAND_900:
|
2010-02-09 14:44:14 +00:00
|
|
|
if (bts->c0->arfcn < 1 ||
|
|
|
|
(bts->c0->arfcn > 124 && bts->c0->arfcn < 955) ||
|
|
|
|
bts->c0->arfcn > 1023) {
|
|
|
|
LOGP(DNM, LOGL_ERROR, "GSM900 channel must be between 1-124, 955-1023.\n");
|
2009-08-17 04:55:10 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
2010-05-26 15:14:42 +00:00
|
|
|
case GSM_BAND_850:
|
|
|
|
if (bts->c0->arfcn < 128 || bts->c0->arfcn > 251) {
|
|
|
|
LOGP(DNM, LOGL_ERROR, "GSM850 channel must be between 128-251.\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
2009-10-02 11:19:34 +00:00
|
|
|
default:
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DNM, LOGL_ERROR, "Unsupported frequency band.\n");
|
2009-08-17 04:55:10 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-12-12 12:44:19 +00:00
|
|
|
if (bts->network->auth_policy == GSM_AUTH_POLICY_ACCEPT_ALL &&
|
2009-12-21 22:08:18 +00:00
|
|
|
!bts->si_common.rach_control.cell_bar)
|
2009-12-21 22:36:45 +00:00
|
|
|
LOGP(DNM, LOGL_ERROR, "\nWARNING: You are running an 'accept-all' "
|
2009-12-12 12:44:19 +00:00
|
|
|
"network on a BTS that is not barred. This "
|
|
|
|
"configuration is likely to interfere with production "
|
|
|
|
"GSM networks and should only be used in a RF "
|
|
|
|
"shielded environment such as a faraday cage!\n\n");
|
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
/* Control Channel Description */
|
2009-12-01 12:34:30 +00:00
|
|
|
bts->si_common.chan_desc.att = 1;
|
|
|
|
bts->si_common.chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5;
|
2011-01-13 22:20:45 +00:00
|
|
|
bts->si_common.chan_desc.bs_ag_blks_res = 1;
|
|
|
|
|
2010-04-30 05:32:05 +00:00
|
|
|
/* T3212 is set from vty/config */
|
2010-04-28 19:31:29 +00:00
|
|
|
|
2010-04-30 05:32:05 +00:00
|
|
|
/* Set ccch config by looking at ts config */
|
2010-04-28 19:31:29 +00:00
|
|
|
for (n=0, i=0; i<8; i++)
|
|
|
|
n += bts->c0->ts[i].pchan == GSM_PCHAN_CCCH ? 1 : 0;
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
case 0:
|
|
|
|
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_C;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_1_NC;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_2_NC;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_3_NC;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
bts->si_common.chan_desc.ccch_conf = RSL_BCCH_CCCH_CONF_4_NC;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOGP(DNM, LOGL_ERROR, "Unsupported CCCH timeslot configuration\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-08-17 04:55:10 +00:00
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
/* some defaults for our system information */
|
2010-09-06 01:25:48 +00:00
|
|
|
bts->si_common.cell_options.radio_link_timeout = 7; /* 12 */
|
|
|
|
|
|
|
|
/* allow/disallow DTXu */
|
|
|
|
if (bts->network->dtx_enabled)
|
|
|
|
bts->si_common.cell_options.dtx = 0;
|
|
|
|
else
|
2011-01-15 17:06:34 +00:00
|
|
|
bts->si_common.cell_options.dtx = 2;
|
2010-09-06 01:25:48 +00:00
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
bts->si_common.cell_options.pwrc = 0; /* PWRC not set */
|
|
|
|
|
|
|
|
bts->si_common.cell_sel_par.acs = 0;
|
|
|
|
|
|
|
|
bts->si_common.ncc_permitted = 0xff;
|
|
|
|
|
2009-08-17 04:55:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-12-23 00:07:46 +00:00
|
|
|
int bsc_bootstrap_network(int (*mncc_recv)(struct gsm_network *, struct msgb *),
|
2009-08-17 04:55:10 +00:00
|
|
|
const char *config_file)
|
|
|
|
{
|
2010-05-16 18:52:23 +00:00
|
|
|
struct telnet_connection dummy_conn;
|
2009-08-17 04:55:10 +00:00
|
|
|
struct gsm_bts *bts;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* initialize our data structures */
|
|
|
|
bsc_gsmnet = gsm_network_init(1, 1, 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");
|
|
|
|
|
2010-05-16 18:52:23 +00:00
|
|
|
/* our vty command code expects vty->priv to point to a telnet_connection */
|
|
|
|
dummy_conn.priv = bsc_gsmnet;
|
|
|
|
rc = vty_read_config_file(config_file, &dummy_conn);
|
2009-08-17 04:55:10 +00:00
|
|
|
if (rc < 0) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DNM, LOGL_FATAL, "Failed to parse the config file: '%s'\n", config_file);
|
2009-08-17 04:55:10 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-05-16 18:52:23 +00:00
|
|
|
rc = telnet_init(tall_bsc_ctx, bsc_gsmnet, 4242);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL);
|
|
|
|
osmo_signal_register_handler(SS_INPUT, inp_sig_cb, NULL);
|
2009-08-17 04:55:10 +00:00
|
|
|
|
|
|
|
llist_for_each_entry(bts, &bsc_gsmnet->bts_list, list) {
|
2011-03-04 12:41:31 +00:00
|
|
|
rc = bootstrap_bts(bts);
|
2011-05-14 09:32:46 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DNM, LOGL_FATAL, "Error bootstrapping BTS\n");
|
|
|
|
return rc;
|
|
|
|
}
|
2011-03-04 12:41:31 +00:00
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_NANOBTS:
|
|
|
|
case GSM_BTS_TYPE_HSL_FEMTO:
|
|
|
|
break;
|
|
|
|
default:
|
2009-08-17 04:55:10 +00:00
|
|
|
rc = e1_reconfig_bts(bts);
|
2011-03-04 12:41:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-02-05 14:41:24 +00:00
|
|
|
if (rc < 0) {
|
2011-05-14 09:32:46 +00:00
|
|
|
LOGP(DNM, LOGL_FATAL, "Error enabling E1 input driver\n");
|
|
|
|
return rc;
|
2011-02-05 14:41:24 +00:00
|
|
|
}
|
2009-08-17 04:55:10 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|