Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 1 | /* (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 Hofmeyr | e78ae21 | 2016-05-14 00:46:29 +0200 | [diff] [blame] | 20 | #include <openbsc/common_cs.h> |
Neels Hofmeyr | 27681a3 | 2016-05-14 00:45:26 +0200 | [diff] [blame] | 21 | #include <openbsc/osmo_bsc.h> |
Neels Hofmeyr | a42855f | 2017-02-23 21:49:55 +0100 | [diff] [blame] | 22 | #include <openbsc/bsc_msc_data.h> |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 23 | |
Neels Hofmeyr | 27681a3 | 2016-05-14 00:45:26 +0200 | [diff] [blame] | 24 | struct gsm_network *bsc_network_init(void *ctx, |
Neels Hofmeyr | 77c8d5f | 2016-05-09 19:12:44 +0200 | [diff] [blame] | 25 | uint16_t country_code, |
| 26 | uint16_t network_code, |
Neels Hofmeyr | 402006d | 2016-05-11 14:28:25 +0200 | [diff] [blame] | 27 | mncc_recv_cb_t mncc_recv) |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 28 | { |
| 29 | struct gsm_network *net; |
| 30 | |
Neels Hofmeyr | e78ae21 | 2016-05-14 00:46:29 +0200 | [diff] [blame] | 31 | net = gsm_network_init(ctx, country_code, network_code, mncc_recv); |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 32 | |
| 33 | net->bsc_data = talloc_zero(net, struct osmo_bsc_data); |
| 34 | if (!net->bsc_data) { |
| 35 | talloc_free(net); |
| 36 | return NULL; |
| 37 | } |
| 38 | |
| 39 | /* Init back pointer */ |
| 40 | net->bsc_data->auto_off_timeout = -1; |
| 41 | net->bsc_data->network = net; |
| 42 | INIT_LLIST_HEAD(&net->bsc_data->mscs); |
Holger Hans Peter Freyther | 1ba0730 | 2015-01-27 10:27:53 +0100 | [diff] [blame] | 43 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 44 | net->num_bts = 0; |
| 45 | net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED; |
| 46 | net->T3101 = GSM_T3101_DEFAULT; |
Harald Welte | 72aaf4c | 2017-07-20 01:47:39 +0200 | [diff] [blame^] | 47 | net->T3103 = GSM_T3103_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 48 | net->T3105 = GSM_T3105_DEFAULT; |
Harald Welte | 72aaf4c | 2017-07-20 01:47:39 +0200 | [diff] [blame^] | 49 | net->T3107 = GSM_T3107_DEFAULT; |
| 50 | net->T3109 = GSM_T3109_DEFAULT; |
| 51 | net->T3111 = GSM_T3111_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 52 | net->T3113 = GSM_T3113_DEFAULT; |
Harald Welte | 72aaf4c | 2017-07-20 01:47:39 +0200 | [diff] [blame^] | 53 | net->T3115 = GSM_T3115_DEFAULT; |
| 54 | net->T3117 = GSM_T3117_DEFAULT; |
| 55 | net->T3119 = GSM_T3119_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 56 | net->T3122 = GSM_T3122_DEFAULT; |
Harald Welte | 72aaf4c | 2017-07-20 01:47:39 +0200 | [diff] [blame^] | 57 | net->T3141 = GSM_T3141_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 58 | |
| 59 | /* default set of handover parameters */ |
| 60 | net->handover.win_rxlev_avg = 10; |
| 61 | net->handover.win_rxqual_avg = 1; |
| 62 | net->handover.win_rxlev_avg_neigh = 10; |
| 63 | net->handover.pwr_interval = 6; |
| 64 | net->handover.pwr_hysteresis = 3; |
| 65 | net->handover.max_distance = 9999; |
| 66 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 67 | INIT_LLIST_HEAD(&net->bts_list); |
| 68 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 69 | /* init statistics */ |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 70 | net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0); |
Harald Welte | 26c1465 | 2017-07-12 00:25:51 +0200 | [diff] [blame] | 71 | if (!net->bsc_ctrs) { |
| 72 | talloc_free(net); |
| 73 | return NULL; |
| 74 | } |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 75 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 76 | gsm_net_update_ctype(net); |
| 77 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 78 | return net; |
| 79 | } |
| 80 | |