blob: d5ea5b2753102ee3e6d8d5509e445bb50ec3b422 [file] [log] [blame]
Jacob Erlbeckcdd43022014-11-10 11:21:32 +01001/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
2 *
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
Neels Hofmeyrc0164792017-09-04 15:15:32 +020020#include <osmocom/bsc/osmo_bsc.h>
21#include <osmocom/bsc/bsc_msc_data.h>
22#include <osmocom/bsc/gsm_04_08_utils.h>
Neels Hofmeyre25018b2017-11-27 21:29:33 +010023#include <osmocom/bsc/handover_cfg.h>
Stefan Sperling6cee8932018-01-30 18:14:22 +010024#include <osmocom/bsc/chan_alloc.h>
Neels Hofmeyrf7a63292018-02-27 12:37:26 +010025#include <osmocom/bsc/common_bsc.h>
Stefan Sperling6cee8932018-01-30 18:14:22 +010026
27/* XXX hard-coded for now */
28#define T3122_CHAN_LOAD_SAMPLE_INTERVAL 1 /* in seconds */
29
30static void update_t3122_chan_load_timer(void *data)
31{
32 struct gsm_network *net = data;
33 struct gsm_bts *bts;
34
35 llist_for_each_entry(bts, &net->bts_list, list)
36 bts_update_t3122_chan_load(bts);
37
38 /* Keep this timer ticking. */
39 osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0);
40}
Maxe6052c42016-06-30 10:25:49 +020041
Neels Hofmeyrf7a63292018-02-27 12:37:26 +010042struct gsm_network *bsc_network_init(void *ctx)
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010043{
44 struct gsm_network *net;
45
Neels Hofmeyrab1b3812018-02-13 23:34:07 +010046 net = talloc_zero(ctx, struct gsm_network);
47 if (!net)
48 return NULL;
49
Neels Hofmeyrf93970b2018-03-05 02:09:40 +010050 net->plmn = (struct osmo_plmn_id){
51 .mcc = 1,
52 .mnc = 1,
53 };
Neels Hofmeyrf7a63292018-02-27 12:37:26 +010054
Harald Welte51e4bf32017-12-23 17:30:18 +010055 /* Permit a compile-time default of A5/3 and A5/1 */
56 net->a5_encryption_mask = (1 << 3) | (1 << 1);
Neels Hofmeyrab1b3812018-02-13 23:34:07 +010057
58 /* Use 30 min periodic update interval as sane default */
59 net->t3212 = 5;
60
Neels Hofmeyrab1b3812018-02-13 23:34:07 +010061 INIT_LLIST_HEAD(&net->subscr_conns);
62
63 net->bsc_subscribers = talloc_zero(net, struct llist_head);
64 INIT_LLIST_HEAD(net->bsc_subscribers);
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010065
66 net->bsc_data = talloc_zero(net, struct osmo_bsc_data);
67 if (!net->bsc_data) {
68 talloc_free(net);
69 return NULL;
70 }
71
72 /* Init back pointer */
73 net->bsc_data->auto_off_timeout = -1;
74 net->bsc_data->network = net;
75 INIT_LLIST_HEAD(&net->bsc_data->mscs);
Holger Hans Peter Freyther1ba07302015-01-27 10:27:53 +010076
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010077 net->num_bts = 0;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010078 net->T3101 = GSM_T3101_DEFAULT;
Harald Weltea0d324b2017-07-20 01:47:39 +020079 net->T3103 = GSM_T3103_DEFAULT;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010080 net->T3105 = GSM_T3105_DEFAULT;
Harald Weltea0d324b2017-07-20 01:47:39 +020081 net->T3107 = GSM_T3107_DEFAULT;
82 net->T3109 = GSM_T3109_DEFAULT;
83 net->T3111 = GSM_T3111_DEFAULT;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010084 net->T3113 = GSM_T3113_DEFAULT;
Harald Weltea0d324b2017-07-20 01:47:39 +020085 net->T3115 = GSM_T3115_DEFAULT;
86 net->T3117 = GSM_T3117_DEFAULT;
87 net->T3119 = GSM_T3119_DEFAULT;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010088 net->T3122 = GSM_T3122_DEFAULT;
Harald Weltea0d324b2017-07-20 01:47:39 +020089 net->T3141 = GSM_T3141_DEFAULT;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010090
Neels Hofmeyre25018b2017-11-27 21:29:33 +010091 net->ho = ho_cfg_init(net, NULL);
Neels Hofmeyr909e9722017-12-07 03:54:01 +010092 net->hodec2.congestion_check_interval_s = HO_CFG_CONGESTION_CHECK_DEFAULT;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010093
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010094 INIT_LLIST_HEAD(&net->bts_list);
95
Stefan Sperling6cee8932018-01-30 18:14:22 +010096 /*
97 * At present all BTS in the network share one channel load timeout.
98 * If this becomes a problem for networks with a lot of BTS, this
99 * code could be refactored to run the timeout individually per BTS.
100 */
101 osmo_timer_setup(&net->t3122_chan_load_timer, update_t3122_chan_load_timer, net);
102 osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0);
103
Alexander Couzens20423ea2016-07-12 15:42:02 +0200104 /* init statistics */
Alexander Couzensb847a212016-08-02 11:34:11 +0200105 net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0);
Harald Welteed208de2017-07-12 00:25:51 +0200106 if (!net->bsc_ctrs) {
107 talloc_free(net);
108 return NULL;
109 }
Jacob Erlbeckcdd43022014-11-10 11:21:32 +0100110
Jacob Erlbeckcdd43022014-11-10 11:21:32 +0100111 gsm_net_update_ctype(net);
112
Jacob Erlbeckcdd43022014-11-10 11:21:32 +0100113 return net;
114}
115