blob: 5bb8ae2b6f53aa3cf12952b86d46b9489322d612 [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>
Jacob Erlbeck1e30a282014-12-03 09:28:24 +010022#include <openbsc/gsm_subscriber.h>
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010023
24struct 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 Erlbeck1e30a282014-12-03 09:28:24 +010039 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 Erlbeckcdd43022014-11-10 11:21:32 +010045 /* 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);
Jacob Erlbeck1e30a282014-12-03 09:28:24 +010049 net->subscr_group->net = net;
Jacob Erlbeckcdd43022014-11-10 11:21:32 +010050
51 net->country_code = country_code;
52 net->network_code = network_code;
53 net->num_bts = 0;
54 net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED;
55 net->T3101 = GSM_T3101_DEFAULT;
56 net->T3105 = GSM_T3105_DEFAULT;
57 net->T3113 = GSM_T3113_DEFAULT;
58 net->T3122 = GSM_T3122_DEFAULT;
59 /* FIXME: initialize all other timers! */
60
61 /* default set of handover parameters */
62 net->handover.win_rxlev_avg = 10;
63 net->handover.win_rxqual_avg = 1;
64 net->handover.win_rxlev_avg_neigh = 10;
65 net->handover.pwr_interval = 6;
66 net->handover.pwr_hysteresis = 3;
67 net->handover.max_distance = 9999;
68
69 INIT_LLIST_HEAD(&net->trans_list);
70 INIT_LLIST_HEAD(&net->upqueue);
71 INIT_LLIST_HEAD(&net->bts_list);
72
73 net->stats.chreq.total = osmo_counter_alloc("net.chreq.total");
74 net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel");
75 net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted");
76 net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel");
77 net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout");
78 net->stats.handover.completed = osmo_counter_alloc("net.handover.completed");
79 net->stats.handover.failed = osmo_counter_alloc("net.handover.failed");
80 net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach");
81 net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal");
82 net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic");
83 net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count");
84 net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject");
85 net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept");
86 net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted");
87 net->stats.paging.detached = osmo_counter_alloc("net.paging.detached");
88 net->stats.paging.completed = osmo_counter_alloc("net.paging.completed");
89 net->stats.paging.expired = osmo_counter_alloc("net.paging.expired");
90 net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted");
91 net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver");
92 net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered");
93 net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem");
94 net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other");
95 net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup");
96 net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack");
97 net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup");
98 net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect");
99 net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail");
100 net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err");
101 net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail");
102 net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail");
103
104 net->mncc_recv = mncc_recv;
105
106 gsm_net_update_ctype(net);
107
108 return net;
109}
110