2014-11-10 10:21:32 +00:00
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* 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
|
|
|
|
* (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
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/osmo_msc_data.h>
|
2014-12-03 08:28:24 +00:00
|
|
|
#include <openbsc/gsm_subscriber.h>
|
2014-11-10 10:21:32 +00:00
|
|
|
|
2016-06-30 08:25:49 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2016-05-09 17:12:44 +00:00
|
|
|
struct gsm_network *gsm_network_init(void *ctx,
|
|
|
|
uint16_t country_code,
|
|
|
|
uint16_t network_code,
|
2014-11-10 10:21:32 +00:00
|
|
|
int (*mncc_recv)(struct gsm_network *, struct msgb *))
|
|
|
|
{
|
|
|
|
struct gsm_network *net;
|
2016-07-27 10:06:36 +00:00
|
|
|
const char *default_regexp = ".*";
|
2014-11-10 10:21:32 +00:00
|
|
|
|
2016-05-09 17:12:44 +00:00
|
|
|
net = talloc_zero(ctx, struct gsm_network);
|
2014-11-10 10:21:32 +00:00
|
|
|
if (!net)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
net->bsc_data = talloc_zero(net, struct osmo_bsc_data);
|
|
|
|
if (!net->bsc_data) {
|
|
|
|
talloc_free(net);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-12-03 08:28:24 +00:00
|
|
|
net->subscr_group = talloc_zero(net, struct gsm_subscriber_group);
|
|
|
|
if (!net->subscr_group) {
|
|
|
|
talloc_free(net);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-30 08:25:49 +00:00
|
|
|
if (gsm_parse_reg(net, &net->authorized_regexp, &net->authorized_reg_str, 1,
|
|
|
|
&default_regexp) != 0)
|
|
|
|
return NULL;
|
|
|
|
|
2014-11-10 10:21:32 +00:00
|
|
|
/* Init back pointer */
|
|
|
|
net->bsc_data->auto_off_timeout = -1;
|
|
|
|
net->bsc_data->network = net;
|
|
|
|
INIT_LLIST_HEAD(&net->bsc_data->mscs);
|
2015-01-27 09:27:53 +00:00
|
|
|
|
2014-12-03 08:28:24 +00:00
|
|
|
net->subscr_group->net = net;
|
2016-06-30 08:25:49 +00:00
|
|
|
net->auto_create_subscr = true;
|
|
|
|
net->auto_assign_exten = true;
|
2014-11-10 10:21:32 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
net->T3105 = GSM_T3105_DEFAULT;
|
|
|
|
net->T3113 = GSM_T3113_DEFAULT;
|
|
|
|
net->T3122 = GSM_T3122_DEFAULT;
|
|
|
|
/* FIXME: initialize all other timers! */
|
|
|
|
|
|
|
|
/* default set of handover parameters */
|
|
|
|
net->handover.win_rxlev_avg = 10;
|
|
|
|
net->handover.win_rxqual_avg = 1;
|
|
|
|
net->handover.win_rxlev_avg_neigh = 10;
|
|
|
|
net->handover.pwr_interval = 6;
|
|
|
|
net->handover.pwr_hysteresis = 3;
|
|
|
|
net->handover.max_distance = 9999;
|
|
|
|
|
|
|
|
INIT_LLIST_HEAD(&net->trans_list);
|
|
|
|
INIT_LLIST_HEAD(&net->upqueue);
|
|
|
|
INIT_LLIST_HEAD(&net->bts_list);
|
2016-05-09 19:03:12 +00:00
|
|
|
INIT_LLIST_HEAD(&net->subscr_conns);
|
2014-11-10 10:21:32 +00:00
|
|
|
|
2016-07-12 13:42:02 +00:00
|
|
|
/* init statistics */
|
2016-08-02 09:34:11 +00:00
|
|
|
net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0);
|
2016-08-30 12:34:36 +00:00
|
|
|
net->msc_ctrs = rate_ctr_group_alloc(net, &msc_ctrg_desc, 0);
|
2016-08-23 05:32:27 +00:00
|
|
|
net->active_calls = osmo_counter_alloc("msc.active_calls");
|
2014-11-10 10:21:32 +00:00
|
|
|
|
|
|
|
net->mncc_recv = mncc_recv;
|
2016-06-07 13:32:16 +00:00
|
|
|
net->ext_min = GSM_MIN_EXTEN;
|
|
|
|
net->ext_max = GSM_MAX_EXTEN;
|
2014-11-10 10:21:32 +00:00
|
|
|
gsm_net_update_ctype(net);
|
|
|
|
|
dyn TS: OS#1778 workaround: disable TCH/F on dyn TS for nitb
To avoid two phones picking mismatching TCH pchans, never pick TCH/F on dynamic
TS in osmo-nitb.
Add gsm_network flag dyn_ts_allow_tch_f, set to true by default in
gsm_network_init().
Set this flag to false in osmo-nitb's main().
See http://osmocom.org/issues/1778
Reasoning about ways to solve this:
* a compile time switch doesn't work because libbsc is first compiled and then
linked to both osmo-nitb and osmo-bsc.
* we could test net->bsc_api == msc_bsc_api(), but I have the so-called MSC
split waiting on branch sysmocom/cscn, which will result in msc_bsc_api() not
being linked in the osmo-bsc binary.
* have a function am_i_nitb() with different implementations in osmo-nitb and
osmo-bsc, but then we'd need to add implementations to all tests and other
binaries linking lchan_alloc().
* have a flag in struct bsc_api, but so far there are only function pointers
there.
Having a "global" flag in gsm_network allows to add a VTY command in case we
decide to keep this feature (#1781), has no linking implications and is nicely
explicit.
Tested that osmo-bsc still picks TCH/F on dyn TS indirectly, since I have no
standalone MSC available: when compiling osmo-nitb with the line that sets
dyn_ts_allow_tch_f = false commented out, TCH/F is picked as described in
OS#1778; and by printf-verifying that dyn_ts_allow_tch_f == true in osmo-bsc
main(), only osmo-nitb should have TCH/F disabled.
Related: OS#1778, OS#1781
Change-Id: If7e4797a72815fc6e2bbef27756ea5df69f4bde7
2016-07-23 18:15:28 +00:00
|
|
|
net->dyn_ts_allow_tch_f = true;
|
|
|
|
|
2014-11-10 10:21:32 +00:00
|
|
|
return net;
|
|
|
|
}
|
|
|
|
|