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 | |
| 20 | #include <openbsc/gsm_data.h> |
| 21 | #include <openbsc/osmo_msc_data.h> |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 22 | #include <openbsc/gsm_subscriber.h> |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 23 | |
| 24 | struct gsm_network *gsm_network_init(uint16_t country_code, uint16_t network_code, |
| 25 | int (*mncc_recv)(struct gsm_network *, struct msgb *)) |
| 26 | { |
| 27 | struct gsm_network *net; |
| 28 | |
| 29 | net = talloc_zero(tall_bsc_ctx, struct gsm_network); |
| 30 | if (!net) |
| 31 | return NULL; |
| 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 | |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 39 | net->subscr_group = talloc_zero(net, struct gsm_subscriber_group); |
| 40 | if (!net->subscr_group) { |
| 41 | talloc_free(net); |
| 42 | return NULL; |
| 43 | } |
| 44 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 45 | /* Init back pointer */ |
| 46 | net->bsc_data->auto_off_timeout = -1; |
| 47 | net->bsc_data->network = net; |
| 48 | INIT_LLIST_HEAD(&net->bsc_data->mscs); |
Holger Hans Peter Freyther | 1ba0730 | 2015-01-27 10:27:53 +0100 | [diff] [blame] | 49 | |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 50 | net->subscr_group->net = net; |
Holger Hans Peter Freyther | 1ba0730 | 2015-01-27 10:27:53 +0100 | [diff] [blame] | 51 | net->create_subscriber = 1; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 52 | |
| 53 | net->country_code = country_code; |
| 54 | net->network_code = network_code; |
| 55 | net->num_bts = 0; |
| 56 | net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED; |
| 57 | net->T3101 = GSM_T3101_DEFAULT; |
| 58 | net->T3105 = GSM_T3105_DEFAULT; |
| 59 | net->T3113 = GSM_T3113_DEFAULT; |
| 60 | net->T3122 = GSM_T3122_DEFAULT; |
| 61 | /* FIXME: initialize all other timers! */ |
| 62 | |
| 63 | /* default set of handover parameters */ |
| 64 | net->handover.win_rxlev_avg = 10; |
| 65 | net->handover.win_rxqual_avg = 1; |
| 66 | net->handover.win_rxlev_avg_neigh = 10; |
| 67 | net->handover.pwr_interval = 6; |
| 68 | net->handover.pwr_hysteresis = 3; |
| 69 | net->handover.max_distance = 9999; |
| 70 | |
| 71 | INIT_LLIST_HEAD(&net->trans_list); |
| 72 | INIT_LLIST_HEAD(&net->upqueue); |
| 73 | INIT_LLIST_HEAD(&net->bts_list); |
| 74 | |
| 75 | net->stats.chreq.total = osmo_counter_alloc("net.chreq.total"); |
| 76 | net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel"); |
| 77 | net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted"); |
| 78 | net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel"); |
| 79 | net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout"); |
| 80 | net->stats.handover.completed = osmo_counter_alloc("net.handover.completed"); |
| 81 | net->stats.handover.failed = osmo_counter_alloc("net.handover.failed"); |
| 82 | net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach"); |
| 83 | net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal"); |
| 84 | net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic"); |
| 85 | net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count"); |
| 86 | net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject"); |
| 87 | net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept"); |
| 88 | net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted"); |
| 89 | net->stats.paging.detached = osmo_counter_alloc("net.paging.detached"); |
| 90 | net->stats.paging.completed = osmo_counter_alloc("net.paging.completed"); |
| 91 | net->stats.paging.expired = osmo_counter_alloc("net.paging.expired"); |
| 92 | net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted"); |
| 93 | net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver"); |
| 94 | net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered"); |
| 95 | net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem"); |
| 96 | net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other"); |
| 97 | net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup"); |
| 98 | net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack"); |
| 99 | net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup"); |
| 100 | net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect"); |
| 101 | net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail"); |
| 102 | net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err"); |
| 103 | net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail"); |
| 104 | net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail"); |
| 105 | |
| 106 | net->mncc_recv = mncc_recv; |
| 107 | |
| 108 | gsm_net_update_ctype(net); |
| 109 | |
| 110 | return net; |
| 111 | } |
| 112 | |