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