blob: 09c02146fe67bb090db3aad3765a090724fb795c [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
Harald Weltef142c972011-05-24 13:25:38 +02004#include <stdint.h>
Maxddee01f2016-05-24 14:23:27 +02005#include <sys/types.h>
Maxe6052c42016-06-30 10:25:49 +02006#include <stdbool.h>
Harald Weltef142c972011-05-24 13:25:38 +02007
8#include <osmocom/core/timer.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +02009#include <osmocom/core/rate_ctr.h>
Harald Welte6be350c2011-05-25 13:10:08 +020010#include <osmocom/core/select.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020011#include <osmocom/core/stats.h>
Stefan Sperling81dc9e72018-02-05 17:34:36 +010012#include <osmocom/core/stat_item.h>
Philipp Maier8c498fc2018-02-21 13:24:36 +010013#include <osmocom/gsm/bts_features.h>
Neels Hofmeyra60f3442018-02-12 16:44:32 +010014#include <osmocom/gsm/protocol/gsm_08_08.h>
Harald Welted41b7c72019-06-13 09:41:58 +020015#include <osmocom/gsm/protocol/gsm_48_049.h>
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020016#include <osmocom/gsm/gsm0808.h>
Neels Hofmeyrf93970b2018-03-05 02:09:40 +010017#include <osmocom/gsm/gsm48.h>
Harald Welte3561bd42018-01-28 03:04:16 +010018#include <osmocom/core/fsm.h>
Neels Hofmeyra6078fe2019-01-28 03:52:14 +010019#include <osmocom/core/tdef.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020020
Harald Welte121e9a42016-04-20 13:13:19 +020021#include <osmocom/crypt/auth.h>
Harald Weltef142c972011-05-24 13:25:38 +020022
Neels Hofmeyrc0164792017-09-04 15:15:32 +020023#include <osmocom/bsc/rest_octets.h>
Harald Welteb96be392011-05-25 12:33:33 +020024
Neels Hofmeyr10485162018-02-13 23:22:03 +010025#include <osmocom/core/bitvec.h>
26#include <osmocom/gsm/gsm_utils.h>
27#include <osmocom/gsm/rxlev_stat.h>
28#include <osmocom/gsm/protocol/gsm_08_58.h>
29#include <osmocom/gsm/protocol/gsm_12_21.h>
30#include <osmocom/abis/e1_input.h>
31#include <osmocom/bsc/meas_rep.h>
Pau Espin Pedrol02f20562020-07-20 16:21:54 +020032#include <osmocom/bsc/acc.h>
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020033#include <osmocom/bsc/neighbor_ident.h>
Pau Espin Pedrol83c0f762019-04-16 20:05:32 +020034#include <osmocom/bsc/osmux.h>
Neels Hofmeyr10485162018-02-13 23:22:03 +010035
Neels Hofmeyr596c4022018-06-16 19:29:50 +020036#define GSM_T3122_DEFAULT 10
37
Harald Welte74b8cdb2018-01-15 19:26:06 +010038struct mgcp_client_conf;
39struct mgcp_client;
Neels Hofmeyr19bed232018-03-22 04:54:57 +010040struct gsm0808_cell_id;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020041struct osmo_mgcpc_ep;
Pau Espin Pedrol388ed582020-07-15 20:53:16 +020042struct gsm_bts;
Pau Espin Pedrolaca53202020-07-16 14:49:36 +020043struct gsm_bts_trx;
Philipp Maier39f62bb2017-04-09 12:32:51 +020044
Holger Hans Peter Freytherd7b22c62013-04-29 09:11:02 +020045/** annotations for msgb ownership */
46#define __uses
47
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +010048#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
49
Neels Hofmeyr6d804b12017-02-18 22:20:46 +010050struct bsc_subscr;
Neels Hofmeyr7b656882017-07-09 22:09:18 +020051struct gprs_ra_id;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020052struct handover;
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020053
Holger Hans Peter Freyther9c595b72010-06-15 11:20:52 +080054#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
55
Max70fdd242017-06-15 15:10:53 +020056/* 3-bit long values */
57#define EARFCN_PRIO_INVALID 8
58#define EARFCN_MEAS_BW_INVALID 8
59/* 5-bit long values */
60#define EARFCN_QRXLV_INVALID 32
61#define EARFCN_THRESH_LOW_INVALID 32
62
Harald Welte8e1e3ee2009-02-01 13:32:45 +000063struct msgb;
64typedef int gsm_cbfn(unsigned int hooknum,
65 unsigned int event,
66 struct msgb *msg,
67 void *data, void *param);
68
Harald Weltef7c28b02009-12-21 13:30:17 +010069/* Maximum number of neighbor cells whose average we track */
70#define MAX_NEIGH_MEAS 10
71/* Maximum size of the averaging window for neighbor cells */
72#define MAX_WIN_NEIGH_AVG 10
Andreas Eversberg98692032013-06-23 10:44:34 +020073/* Maximum number of report history we store */
74#define MAX_MEAS_REP 10
Harald Weltef7c28b02009-12-21 13:30:17 +010075
76/* processed neighbor measurements for one cell */
77struct neigh_meas_proc {
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020078 uint16_t arfcn;
79 uint8_t bsic;
80 uint8_t rxlev[MAX_WIN_NEIGH_AVG];
Harald Weltef7c28b02009-12-21 13:30:17 +010081 unsigned int rxlev_cnt;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020082 uint8_t last_seen_nr;
Harald Weltef7c28b02009-12-21 13:30:17 +010083};
84
Harald Weltea43e0b42016-06-19 18:06:02 +020085struct gsm_classmark {
86 bool classmark1_set;
87 struct gsm48_classmark1 classmark1;
88 uint8_t classmark2_len;
89 uint8_t classmark2[3];
90 uint8_t classmark3_len;
91 uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */
92};
93
Harald Welte519c7e12018-01-28 02:45:46 +010094enum subscr_sccp_state {
95 SUBSCR_SCCP_ST_NONE,
96 SUBSCR_SCCP_ST_WAIT_CONN_CONF,
97 SUBSCR_SCCP_ST_CONNECTED
98};
99
Sylvain Munautaa824922019-03-07 16:32:02 +0100100enum channel_rate {
101 CH_RATE_SDCCH,
102 CH_RATE_HALF,
103 CH_RATE_FULL,
104};
105
Philipp Maierbb66d102019-01-22 11:29:06 +0100106struct channel_mode_and_rate {
107 enum gsm48_chan_mode chan_mode;
Sylvain Munautaa824922019-03-07 16:32:02 +0100108 enum channel_rate chan_rate;
Philipp Maierbb66d102019-01-22 11:29:06 +0100109 uint16_t s15_s0;
110};
111
Neels Hofmeyr7cfdbe72019-02-06 01:30:19 +0100112/* Information retrieved during an Assignment Request from the MSC. This is storage of the Assignment instructions
113 * parsed from the Assignment Request message, to pass on until the gscon and assignment FSMs have decided whether an
114 * Assignment is actually going to be carried out. Should remain unchanged after initial decoding. */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200115struct assignment_request {
116 bool aoip;
117
118 uint16_t msc_assigned_cic;
119
Pau Espin Pedrol657f3102020-08-28 18:35:22 +0200120 char msc_rtp_addr[INET6_ADDRSTRLEN];
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200121 uint16_t msc_rtp_port;
Pau Espin Pedrol83c0f762019-04-16 20:05:32 +0200122 bool use_osmux;
123 uint8_t osmux_cid;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200124
Sylvain Munautaa824922019-03-07 16:32:02 +0100125 /* Rate/codec setting in preference order (need at least 1 !) */
126 int n_ch_mode_rate;
127 struct channel_mode_and_rate ch_mode_rate[3];
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200128};
129
Neels Hofmeyr7cfdbe72019-02-06 01:30:19 +0100130/* State of an ongoing Assignment, while the assignment_fsm is still busy. This serves as state separation to keep the
131 * currently used lchan and gscon unmodified until the outcome of an Assignment is known. If the Assignment fails, this
132 * state is simply discarded, and the gscon carries on with the original lchan remaining unchanged. */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200133struct assignment_fsm_data {
134 struct assignment_request req;
135 bool requires_voice_stream;
136
137 struct osmo_fsm_inst *fi;
138 struct gsm_lchan *new_lchan;
139
140 /* Whether this assignment triggered creation of the MGW endpoint: if the assignment
141 * fails, we will release that again as soon as possible. (If false, the endpoint already
142 * existed before or isn't needed at all.)*/
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200143 struct osmo_mgcpc_ep_ci *created_ci_for_msc;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200144
145 enum gsm0808_cause failure_cause;
146 enum gsm48_rr_cause rr_cause;
147
148 bool result_rate_ctr_done;
149};
150
151enum hodec_id {
152 HODEC_NONE,
153 HODEC1 = 1,
154 HODEC2 = 2,
155 HODEC_USER,
156 HODEC_REMOTE,
157};
158
159/* For example, to count specific kinds of ongoing handovers, it is useful to be able to OR-combine
160 * scopes. */
161enum handover_scope {
162 HO_NO_HANDOVER = 0,
163 HO_INTRA_CELL = 0x1,
164 HO_INTRA_BSC = 0x2,
165 HO_INTER_BSC_OUT = 0x4,
166 HO_INTER_BSC_IN = 0x8,
167 HO_SCOPE_ALL = 0xffff,
168};
169
170extern const struct value_string handover_scope_names[];
171inline static const char *handover_scope_name(enum handover_scope val)
172{ return get_value_string(handover_scope_names, val); }
173
174struct handover_out_req {
175 enum hodec_id from_hodec_id;
176 struct gsm_lchan *old_lchan;
177 struct neighbor_ident_key target_nik;
178 enum gsm_chan_t new_lchan_type; /*< leave GSM_LCHAN_NONE to use same as old_lchan */
179};
180
181struct handover_in_req {
182 struct gsm0808_channel_type ct;
183 struct gsm0808_speech_codec_list scl;
184 struct gsm0808_encrypt_info ei;
185 struct gsm_classmark classmark;
Neels Hofmeyrc15f6cd2019-03-15 02:48:39 +0100186 /* chosen_encr_alg reflects the encoded value as in RSL_ENC_ALG_A5(a5_numer):
187 * chosen_encr_alg == 1 means A5/0 i.e. no encryption, chosen_encr_alg == 4 means A5/3.
188 * chosen_encr_alg == 0 means no such IE was present. */
189 uint8_t chosen_encr_alg;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200190 struct gsm0808_cell_id cell_id_serving;
191 char cell_id_serving_name[64];
192 struct gsm0808_cell_id cell_id_target;
193 char cell_id_target_name[64];
194 uint16_t msc_assigned_cic;
Pau Espin Pedrol657f3102020-08-28 18:35:22 +0200195 char msc_assigned_rtp_addr[INET6_ADDRSTRLEN];
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200196 uint16_t msc_assigned_rtp_port;
197};
198
199struct handover {
200 struct osmo_fsm_inst *fi;
201
202 enum hodec_id from_hodec_id;
203 enum handover_scope scope;
204 enum gsm_chan_t new_lchan_type;
205 struct neighbor_ident_key target_cell;
206
207 uint8_t ho_ref;
208 struct gsm_bts *new_bts;
209 struct gsm_lchan *new_lchan;
210 bool async;
211 struct handover_in_req inter_bsc_in;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200212 struct osmo_mgcpc_ep_ci *created_ci_for_msc;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200213};
214
Neels Hofmeyr378a4922016-05-09 21:07:43 +0200215/* active radio connection of a mobile subscriber */
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100216struct gsm_subscriber_connection {
Harald Weltea43e0b42016-06-19 18:06:02 +0200217 /* global linked list of subscriber_connections */
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +0800218 struct llist_head entry;
219
Harald Welte3561bd42018-01-28 03:04:16 +0100220 /* FSM instance to control the subscriber connection state (RTP, A) */
221 struct osmo_fsm_inst *fi;
222
Harald Weltea43e0b42016-06-19 18:06:02 +0200223 /* libbsc subscriber information (if available) */
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100224 struct bsc_subscr *bsub;
225
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100226 /* back pointers */
Neels Hofmeyr5e0b0a62016-05-09 22:33:01 +0200227 struct gsm_network *network;
228
Neels Hofmeyr7cfdbe72019-02-06 01:30:19 +0100229 /* the primary / currently active lchan to the BTS/subscriber. During Assignment and Handover, separate lchans
230 * are kept in the .assignment or .handover sub-structs, respectively, so that this lchan remains unaffected
231 * until Assignment or Handover have actually succeeded. */
Harald Welte4a8ebc82017-12-18 18:34:41 +0100232 struct gsm_lchan *lchan;
Harald Welte3561bd42018-01-28 03:04:16 +0100233
Neels Hofmeyr7cfdbe72019-02-06 01:30:19 +0100234 /* Only valid during an ongoing Assignment; might be overwritten at any time by a failed Assignment attempt.
235 * Once an Assignment was successful, all relevant state must be copied out of this sub-struct. */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200236 struct assignment_fsm_data assignment;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100237
Neels Hofmeyr7cfdbe72019-02-06 01:30:19 +0100238 /* handover information, if a handover is pending for this conn. Valid only during an ongoing Handover
239 * operation. If a Handover was successful, all relevant state must be copied out of this sub-struct. */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200240 struct handover ho;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100241
Neels Hofmeyr149160f2018-06-16 17:20:13 +0200242 /* Queue DTAP messages during handover/assignment (msgb_enqueue()/msgb_dequeue())*/
243 struct llist_head dtap_queue;
244 unsigned int dtap_queue_len;
Andreas Eversberg084b4212013-05-30 14:12:48 +0200245
Neels Hofmeyrec422642018-02-15 14:07:40 +0100246 struct {
Neels Hofmeyr909e9722017-12-07 03:54:01 +0100247 int failures;
Neels Hofmeyrec422642018-02-15 14:07:40 +0100248 struct penalty_timers *penalty_timers;
249 } hodec2;
Neels Hofmeyra60f3442018-02-12 16:44:32 +0100250
251 /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment Request. 3GPP 48.008
252 * 3.2.2.103 says:
253 * The "Codec List (MSC Preferred)" shall not include codecs
254 * that are not supported by the MS.
255 * i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed the MS bearer
256 * capabilities, which the MSC is required to translate into the codec list. */
257 struct gsm0808_speech_codec_list codec_list;
Harald Welte519c7e12018-01-28 02:45:46 +0100258
259 /* flag to prevent multiple simultaneous ciphering commands */
260 int ciphering_handled;
261
Harald Welte519c7e12018-01-28 02:45:46 +0100262 /* SCCP connection associatd with this subscriber_connection */
263 struct {
264 /* for advanced ping/pong */
265 int send_ping;
266
Martin Haukea29affd2019-11-13 22:10:41 +0100267 /* SCCP connection related */
Harald Welte519c7e12018-01-28 02:45:46 +0100268 struct bsc_msc_data *msc;
269
270 /* Sigtran connection ID */
271 int conn_id;
272 enum subscr_sccp_state state;
273 } sccp;
274
275 /* for audio handling */
276 struct {
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200277 uint16_t msc_assigned_cic;
Harald Welte519c7e12018-01-28 02:45:46 +0100278
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200279 /* RTP address where the MSC expects us to send the RTP stream coming from the BTS. */
Pau Espin Pedrol657f3102020-08-28 18:35:22 +0200280 char msc_assigned_rtp_addr[INET6_ADDRSTRLEN];
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200281 uint16_t msc_assigned_rtp_port;
Harald Welte519c7e12018-01-28 02:45:46 +0100282
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200283 /* The endpoint at the MGW used to join both BTS and MSC side connections, e.g.
284 * "rtpbridge/23@mgw". */
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200285 struct osmo_mgcpc_ep *mgw_endpoint;
Harald Welte3561bd42018-01-28 03:04:16 +0100286
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200287 /* The connection identifier of the osmo_mgcpc_ep used to transceive RTP towards the MSC.
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200288 * (The BTS side CI is handled by struct gsm_lchan and the lchan_fsm.) */
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200289 struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_msc;
Harald Welte519c7e12018-01-28 02:45:46 +0100290 } user_plane;
Harald Weltec997ceb2018-05-30 01:39:43 +0200291
292 /* LCLS (local call, local switch) related state */
293 struct {
294 uint8_t global_call_ref[15];
295 uint8_t global_call_ref_len; /* length of global_call_ref */
Maxfe65ece2018-11-09 13:36:11 +0100296 enum gsm0808_lcls_config config; /* TS 48.008 3.2.2.116 */
297 enum gsm0808_lcls_control control; /* TS 48.008 3.2.2.117 */
Harald Weltec997ceb2018-05-30 01:39:43 +0200298 /* LCLS FSM */
299 struct osmo_fsm_inst *fi;
300 /* pointer to "other" connection, if Call Leg Relocation was successful */
301 struct gsm_subscriber_connection *other;
302 } lcls;
Pau Espin Pedrol7950e5d2019-10-31 15:59:49 +0100303
304 /* MS Power Class, TS 05.05 sec 4.1.1 "Mobile station". 0 means unset. */
305 uint8_t ms_power_class:3;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100306};
307
Harald Weltef142c972011-05-24 13:25:38 +0200308
Neels Hofmeyr10485162018-02-13 23:22:03 +0100309/* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1:
310 4-bit index is used (2#1111 = 10#15) */
311#define SI2Q_MAX_NUM 16
312/* length in bits (for single SI2quater message) */
313#define SI2Q_MAX_LEN 160
314#define SI2Q_MIN_LEN 18
315
316struct osmo_bsc_data;
317
318struct osmo_bsc_sccp_con;
319
320/* Channel Request reason */
321enum gsm_chreq_reason_t {
322 GSM_CHREQ_REASON_EMERG,
323 GSM_CHREQ_REASON_PAG,
324 GSM_CHREQ_REASON_CALL,
325 GSM_CHREQ_REASON_LOCATION_UPD,
326 GSM_CHREQ_REASON_OTHER,
327 GSM_CHREQ_REASON_PDCH,
328};
329
330/* lchans 0..3 are SDCCH in combined channel configuration,
331 use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */
332#define CCCH_LCHAN 4
333
Neels Hofmeyr10485162018-02-13 23:22:03 +0100334#define TS_MAX_LCHAN 8
335
336#define HARDCODED_ARFCN 123
337#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
338
339/* for multi-drop config */
340#define HARDCODED_BTS0_TS 1
341#define HARDCODED_BTS1_TS 6
342#define HARDCODED_BTS2_TS 11
343
344#define MAX_VERSION_LENGTH 64
345
Neels Hofmeyr10485162018-02-13 23:22:03 +0100346enum gsm_hooks {
347 GSM_HOOK_NM_SWLOAD,
348 GSM_HOOK_RR_PAGING,
349 GSM_HOOK_RR_SECURITY,
350};
351
Neels Hofmeyr10485162018-02-13 23:22:03 +0100352enum bts_gprs_mode {
353 BTS_GPRS_NONE = 0,
354 BTS_GPRS_GPRS = 1,
355 BTS_GPRS_EGPRS = 2,
356};
357
358struct gsm_lchan;
359struct osmo_rtp_socket;
360struct rtp_socket;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100361
362/* Network Management State */
363struct gsm_nm_state {
364 uint8_t operational;
365 uint8_t administrative;
366 uint8_t availability;
367};
368
369struct gsm_abis_mo {
370 uint8_t obj_class;
371 uint8_t procedure_pending;
372 struct abis_om_obj_inst obj_inst;
373 const char *name;
374 struct gsm_nm_state nm_state;
375 struct tlv_parsed *nm_attr;
376 struct gsm_bts *bts;
377};
378
379/* Ericsson OM2000 Managed Object */
380struct abis_om2k_mo {
381 uint8_t class;
382 uint8_t bts;
383 uint8_t assoc_so;
384 uint8_t inst;
385} __attribute__ ((packed));
386
387struct om2k_mo {
388 struct abis_om2k_mo addr;
389 struct osmo_fsm_inst *fsm;
390};
391
392#define A38_XOR_MIN_KEY_LEN 12
393#define A38_XOR_MAX_KEY_LEN 16
394#define A38_COMP128_KEY_LEN 16
395#define RSL_ENC_ALG_A5(x) (x+1)
Neels Hofmeyr19ec3742020-07-08 02:58:52 +0200396/* Up to 16 SI2quater are multiplexed; each fits 3 EARFCNS, so the practical maximum is 3*16.
397 * The real maximum that fits in a total of 16 SI2quater rest octets also depends on the bits left by other SI2quater
398 * rest octets elements, so to really fit 48 EARFCNs most other SI2quater elements need to be omitted. */
399#define MAX_EARFCN_LIST (3*16)
Neels Hofmeyr10485162018-02-13 23:22:03 +0100400
401/* is the data link established? who established it? */
402#define LCHAN_SAPI_UNUSED 0
403#define LCHAN_SAPI_MS 1
404#define LCHAN_SAPI_NET 2
Neels Hofmeyr10485162018-02-13 23:22:03 +0100405
406/* BTS ONLY */
407#define MAX_NUM_UL_MEAS 104
408#define LC_UL_M_F_L1_VALID (1 << 0)
409#define LC_UL_M_F_RES_VALID (1 << 1)
410
411struct bts_ul_meas {
412 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
413 uint16_t ber10k;
414 /* timing advance offset (in quarter bits) */
415 int16_t ta_offs_qbits;
416 /* C/I ratio in dB */
417 float c_i;
418 /* flags */
419 uint8_t is_sub:1;
420 /* RSSI in dBm * -1 */
421 uint8_t inv_rssi;
422};
423
424struct bts_codec_conf {
425 uint8_t hr;
426 uint8_t efr;
427 uint8_t amr;
428};
429
430struct amr_mode {
431 uint8_t mode;
432 uint8_t threshold;
433 uint8_t hysteresis;
434};
435
436struct amr_multirate_conf {
437 uint8_t gsm48_ie[2];
438 struct amr_mode ms_mode[4];
439 struct amr_mode bts_mode[4];
440 uint8_t num_modes;
441};
442/* /BTS ONLY */
443
444enum lchan_csd_mode {
445 LCHAN_CSD_M_NT,
446 LCHAN_CSD_M_T_1200_75,
447 LCHAN_CSD_M_T_600,
448 LCHAN_CSD_M_T_1200,
449 LCHAN_CSD_M_T_2400,
450 LCHAN_CSD_M_T_9600,
451 LCHAN_CSD_M_T_14400,
452 LCHAN_CSD_M_T_29000,
453 LCHAN_CSD_M_T_32000,
454};
455
456/* State of the SAPIs in the lchan */
457enum lchan_sapi_state {
458 LCHAN_SAPI_S_NONE,
459 LCHAN_SAPI_S_REQ,
460 LCHAN_SAPI_S_ASSIGNED,
461 LCHAN_SAPI_S_REL,
462 LCHAN_SAPI_S_ERROR,
463};
464
Neels Hofmeyr92b9f2e2018-02-14 00:19:11 +0100465#define MAX_A5_KEY_LEN (128/8)
466
467struct gsm_encr {
468 uint8_t alg_id;
469 uint8_t key_len;
470 uint8_t key[MAX_A5_KEY_LEN];
471};
472
Neels Hofmeyr8da22332018-04-11 01:43:41 +0200473#define LOGPLCHAN(lchan, ss, level, fmt, args...) \
474 LOGP(ss, level, "%s (ss=%d,%s) (%s) " fmt, \
475 lchan ? gsm_ts_and_pchan_name(lchan->ts) : "-", \
476 lchan ? lchan->nr : 0, \
477 lchan ? gsm_lchant_name(lchan->type) : "-", \
478 bsc_subscr_name(lchan && lchan->conn ? lchan->conn->bsub : NULL), \
479 ## args)
480
Pau Espin Pedrold3e8e0c2018-11-28 16:35:10 +0100481/* Iterate lchans that have an FSM allocated based based on explicit pchan kind
482 * (GSM_PCHAN_* constant).
483 * Remark: PDCH related lchans are not handled in BSC but in PCU, so trying to
484 * iterate through GSM_PCHAN_PDCH is considered a void loop.
485 */
486#define ts_as_pchan_for_each_lchan(lchan, ts, as_pchan) \
487 for (lchan = (ts)->lchan; \
488 ((lchan - (ts)->lchan) < ARRAY_SIZE((ts)->lchan)) \
489 && lchan->fi \
490 && lchan->nr < pchan_subslots(as_pchan); \
491 lchan++)
492
Pau Espin Pedrol7ae0f9c2018-11-28 16:37:37 +0100493/* Iterate lchans that have an FSM allocated based on current PCHAN
494 * mode set in \ref ts.
495 * usage:
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200496 * struct gsm_lchan *lchan;
497 * struct gsm_bts_trx_ts *ts = get_some_timeslot();
498 * ts_for_each_lchan(lchan, ts) {
499 * LOGPLCHAN(DMAIN, LOGL_DEBUG, "hello world\n");
500 * }
Pau Espin Pedrol7ae0f9c2018-11-28 16:37:37 +0100501 */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200502#define ts_for_each_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_is)
503
Pau Espin Pedrol0ba20df2018-11-28 16:39:29 +0100504/* Iterate over all possible lchans available that have an FSM allocated based
505 * on PCHAN \ref ts (dynamic) configuration.
506 * Iterate all lchan instances set up by this \ref ts type, including those
507 * lchans currently disabled or in process of being enabled (e.g. due to dynamic
508 * timeslot in switchover). Compare ts_for_each_lchan(), which iterates only the
509 * enabled lchans.
510 * For example, it is useful in case dynamic timeslot \ref ts is in process of
511 * switching from configuration PDCH (no lchans) to TCH_F (1 lchan), where
512 * pchan_is is still set to PDCH but \ref ts may contain already an \ref lchan
513 * of type TCH_F which initiated the request to switch the \ts configuration.
514 */
515#define ts_for_each_potential_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_on_init)
516
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200517enum lchan_activate_mode {
518 FOR_NONE,
519 FOR_MS_CHANNEL_REQUEST,
520 FOR_ASSIGNMENT,
521 FOR_HANDOVER,
522 FOR_VTY,
523};
524
525extern const struct value_string lchan_activate_mode_names[];
526static inline const char *lchan_activate_mode_name(enum lchan_activate_mode activ_for)
527{ return get_value_string(lchan_activate_mode_names, activ_for); }
528
Neels Hofmeyr700e5182018-12-19 17:19:02 +0100529struct lchan_activate_info {
530 enum lchan_activate_mode activ_for;
531 struct gsm_subscriber_connection *for_conn;
532 /* This always is for a specific lchan, so its lchan->type indicates full or half rate.
533 * When a dyn TS was selected, the lchan->type has been set to the desired rate. */
534 enum gsm48_chan_mode chan_mode;
Neels Hofmeyr58cf1b12019-03-15 02:49:18 +0100535 struct gsm_encr encr;
Neels Hofmeyr38134ea2018-12-21 03:01:00 +0100536 /* AMR config */
Neels Hofmeyr700e5182018-12-19 17:19:02 +0100537 uint16_t s15_s0;
538 bool requires_voice_stream;
539 bool wait_before_switching_rtp; /*< true = requires LCHAN_EV_READY_TO_SWITCH_RTP */
540 uint16_t msc_assigned_cic;
Neels Hofmeyr38134ea2018-12-21 03:01:00 +0100541 /* During intra-BSC handover, we keep the MGW endpoint intact and just re-route to the new lchan. This
542 * activate_info is for the new lchan, the re_use_mgw_endpoint_from_lchan points at the old lchan. */
Neels Hofmeyr700e5182018-12-19 17:19:02 +0100543 struct gsm_lchan *re_use_mgw_endpoint_from_lchan;
544};
545
Neels Hofmeyr10485162018-02-13 23:22:03 +0100546struct gsm_lchan {
547 /* The TS that we're part of */
548 struct gsm_bts_trx_ts *ts;
549 /* The logical subslot number in the TS */
550 uint8_t nr;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200551 char *name;
552
Neels Hofmeyreee24eb2018-11-06 21:39:15 +0100553 char *last_error;
554
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200555 struct osmo_fsm_inst *fi;
Neels Hofmeyrac85b342018-07-12 21:23:26 +0200556 struct osmo_fsm_inst *fi_rtp;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +0200557 struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_bts;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200558
559 struct {
Neels Hofmeyr700e5182018-12-19 17:19:02 +0100560 struct lchan_activate_info info;
Neels Hofmeyrac85b342018-07-12 21:23:26 +0200561 bool activ_ack; /*< true as soon as RSL Chan Activ Ack is received */
Neels Hofmeyr369fba22018-11-27 01:30:50 +0100562 bool immediate_assignment_sent;
Neels Hofmeyr193c1e32018-08-27 22:06:24 +0200563 /*! This flag ensures that when an lchan activation has succeeded, and we have already
564 * sent ACKs like Immediate Assignment or BSSMAP Assignment Complete, and if other errors
565 * occur later, e.g. during release, that we don't send a NACK out of context. */
566 bool concluded;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200567 enum gsm0808_cause gsm0808_error_cause;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200568 } activate;
569
Neels Hofmeyreee24eb2018-11-06 21:39:15 +0100570 struct {
571 /* If an event to release the lchan comes in while still waiting for responses, just mark this
572 * flag, so that the lchan will gracefully release at the next sensible junction. */
573 bool requested;
574 bool do_rr_release;
Neels Hofmeyrb523f542020-07-09 15:54:40 +0200575 enum gsm48_rr_cause rr_cause;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200576
Neels Hofmeyreee24eb2018-11-06 21:39:15 +0100577 /* There is an RSL error cause of value 0, so we need a separate flag. */
578 bool in_error;
579 /* RSL error code, RSL_ERR_* */
580 uint8_t rsl_error_cause;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200581
Neels Hofmeyreee24eb2018-11-06 21:39:15 +0100582 /* If a release event is being handled, ignore other ricocheting release events until that
583 * release handling has concluded. */
584 bool in_release_handler;
Harald Welte963763d2019-02-03 12:11:12 +0100585
586 /* is this release at the end of a CSFB call? */
587 bool is_csfb;
Neels Hofmeyreee24eb2018-11-06 21:39:15 +0100588 } release;
Neels Hofmeyrd5df9a12018-07-20 05:35:47 +0200589
Neels Hofmeyr10485162018-02-13 23:22:03 +0100590 /* The logical channel type */
591 enum gsm_chan_t type;
592 /* RSL channel mode */
593 enum rsl_cmod_spd rsl_cmode;
594 /* If TCH, traffic channel mode */
595 enum gsm48_chan_mode tch_mode;
596 enum lchan_csd_mode csd_mode;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100597 /* Power levels for MS and BTS */
598 uint8_t bs_power;
599 uint8_t ms_power;
600 /* Encryption information */
601 struct gsm_encr encr;
602
603 /* AMR bits */
604 uint8_t mr_ms_lv[7];
605 uint8_t mr_bts_lv[7];
Neels Hofmeyr4daa2102019-01-30 16:46:58 +0100606 /* AMR bits were based on these rate bits: */
607 uint16_t s15_s0;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100608
609 /* Established data link layer services */
610 uint8_t sapis[8];
611
612 struct {
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200613 uint32_t bound_ip; /*< where the BTS receives RTP */
Neels Hofmeyr10485162018-02-13 23:22:03 +0100614 uint16_t bound_port;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200615 uint32_t connect_ip; /*< where the BTS sends RTP to (MGW) */
Neels Hofmeyr10485162018-02-13 23:22:03 +0100616 uint16_t connect_port;
617 uint16_t conn_id;
618 uint8_t rtp_payload;
619 uint8_t rtp_payload2;
620 uint8_t speech_mode;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100621
622 /* info we need to postpone the AoIP
623 * assignment completed message */
624 struct {
625 uint8_t rr_cause;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100626 bool valid;
627 } ass_compl;
628 } abis_ip;
629
630 uint8_t rqd_ta;
631
Neels Hofmeyr10485162018-02-13 23:22:03 +0100632 /* table of neighbor cell measurements */
633 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
634
635 /* cache of last measurement reports on this lchan */
636 struct gsm_meas_rep meas_rep[MAX_MEAS_REP];
637 int meas_rep_idx;
638 int meas_rep_count;
Neels Hofmeyr35ba85c2018-02-12 16:47:40 +0100639 uint8_t meas_rep_last_seen_nr;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100640
641 /* GSM Random Access data */
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200642 /* TODO: don't allocate this, rather keep an "is_present" flag */
Neels Hofmeyr10485162018-02-13 23:22:03 +0100643 struct gsm48_req_ref *rqd_ref;
644
645 struct gsm_subscriber_connection *conn;
Philipp Maierbb66d102019-01-22 11:29:06 +0100646
647 /* Depending on the preferences that where submitted together with
648 * the assignment and the current channel load, the BSC has to select
649 * one of the offered codec/rates. The final selection by the BSC is
650 * stored here and is used when sending the assignment complete or
651 * when performing a handover procedure. */
652 struct channel_mode_and_rate ch_mode_rate;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100653};
654
Neels Hofmeyr10485162018-02-13 23:22:03 +0100655/* One Timeslot in a TRX */
656struct gsm_bts_trx_ts {
657 struct gsm_bts_trx *trx;
658 /* number of this timeslot at the TRX */
659 uint8_t nr;
660
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200661 struct osmo_fsm_inst *fi;
662 char *last_errmsg;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100663
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200664 /* vty phys_chan_config setting, not necessarily in effect in case it was changed in the telnet
665 * vty after OML activation. Gets written on vty 'write file'. */
666 enum gsm_phys_chan_config pchan_from_config;
667 /* When the timeslot OML is established, pchan_from_config is copied here. This is the pchan
668 * currently in effect; for dynamic ts, this is the dyn kind (GSM_PCHAN_TCH_F_TCH_H_PDCH or
669 * GSM_PCHAN_TCH_F_PDCH) and does not show the pchan type currently active. */
670 enum gsm_phys_chan_config pchan_on_init;
671 /* This is the *actual* pchan type currently active. For dynamic timeslots, this reflects either
672 * GSM_PCHAN_NONE or one of the standard GSM_PCHAN_TCH_F, GSM_PCHAN_TCH_H, GSM_PCHAN_PDCH.
673 * Callers can use this transparently without being aware of dyn ts. */
674 enum gsm_phys_chan_config pchan_is;
Neels Hofmeyr10485162018-02-13 23:22:03 +0100675
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200676 /* After a PDCH ACT NACK, we shall not infinitely loop to try and ACT again.
677 * Also marks a timeslot where PDCH was deactivated by VTY. This is cleared whenever a timeslot
678 * enters IN_USE state, i.e. after each TCH use we try to PDCH ACT once again. */
679 bool pdch_act_allowed;
680
Neels Hofmeyrbcdbfb72018-07-26 20:33:15 +0200681 /* Whether TS_EV_OML_READY was received */
682 bool is_oml_ready;
683 /* Whether TS_EV_RSL_READY was received */
684 bool is_rsl_ready;
685
Neels Hofmeyr10485162018-02-13 23:22:03 +0100686 struct gsm_abis_mo mo;
687 struct tlv_parsed nm_attr;
688 uint8_t nm_chan_comb;
689 int tsc; /* -1 == use BTS TSC */
690
691 struct {
692 /* Parameters below are configured by VTY */
693 int enabled;
694 uint8_t maio;
695 uint8_t hsn;
696 struct bitvec arfcns;
697 uint8_t arfcns_data[1024/8];
698 /* This is the pre-computed MA for channel assignments */
699 struct bitvec ma;
700 uint8_t ma_len; /* part of ma_data that is used */
701 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
702 } hopping;
703
704 /* To which E1 subslot are we connected */
705 struct gsm_e1_subslot e1_link;
706
707 union {
708 struct {
709 struct om2k_mo om2k_mo;
710 } rbs2000;
711 };
712
713 struct gsm_lchan lchan[TS_MAX_LCHAN];
714};
715
Neels Hofmeyr10485162018-02-13 23:22:03 +0100716#define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0])
717
Neels Hofmeyr10485162018-02-13 23:22:03 +0100718/*
719 * This keeps track of the paging status of one BTS. It
720 * includes a number of pending requests, a back pointer
721 * to the gsm_bts, a timer and some more state.
722 */
723struct gsm_bts_paging_state {
724 /* pending requests */
725 struct llist_head pending_requests;
726 struct gsm_bts *bts;
727
728 struct osmo_timer_list work_timer;
729 struct osmo_timer_list credit_timer;
730
731 /* free chans needed */
732 int free_chans_need;
733
734 /* load */
735 uint16_t available_slots;
736};
737
738struct gsm_envabtse {
739 struct gsm_abis_mo mo;
740};
741
742struct gsm_bts_gprs_nsvc {
743 struct gsm_bts *bts;
744 /* data read via VTY config file, to configure the BTS
745 * via OML from BSC */
746 int id;
747 uint16_t nsvci;
748 uint16_t local_port; /* on the BTS */
749 uint16_t remote_port; /* on the SGSN */
750 uint32_t remote_ip; /* on the SGSN */
751
752 struct gsm_abis_mo mo;
753};
754
755enum gprs_rlc_par {
756 RLC_T3142,
757 RLC_T3169,
758 RLC_T3191,
759 RLC_T3193,
760 RLC_T3195,
761 RLC_N3101,
762 RLC_N3103,
763 RLC_N3105,
764 CV_COUNTDOWN,
765 T_DL_TBF_EXT, /* ms */
766 T_UL_TBF_EXT, /* ms */
767 _NUM_RLC_PAR
768};
769
770enum gprs_cs {
771 GPRS_CS1,
772 GPRS_CS2,
773 GPRS_CS3,
774 GPRS_CS4,
775 GPRS_MCS1,
776 GPRS_MCS2,
777 GPRS_MCS3,
778 GPRS_MCS4,
779 GPRS_MCS5,
780 GPRS_MCS6,
781 GPRS_MCS7,
782 GPRS_MCS8,
783 GPRS_MCS9,
784 _NUM_GRPS_CS
785};
786
787struct gprs_rlc_cfg {
788 uint16_t parameter[_NUM_RLC_PAR];
789 struct {
790 uint16_t repeat_time; /* ms */
791 uint8_t repeat_count;
792 } paging;
793 uint32_t cs_mask; /* bitmask of gprs_cs */
794 uint8_t initial_cs;
795 uint8_t initial_mcs;
796};
797
798
799enum neigh_list_manual_mode {
800 NL_MODE_AUTOMATIC = 0,
801 NL_MODE_MANUAL = 1,
802 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
803};
804
805enum bts_loc_fix {
806 BTS_LOC_FIX_INVALID = 0,
807 BTS_LOC_FIX_2D = 1,
808 BTS_LOC_FIX_3D = 2,
809};
810
811extern const struct value_string bts_loc_fix_names[];
812
813struct bts_location {
814 struct llist_head list;
815 time_t tstamp;
816 enum bts_loc_fix valid;
817 double lat;
818 double lon;
819 double height;
820};
821
822/* Channel load counter */
823struct load_counter {
824 unsigned int total;
825 unsigned int used;
826};
827
Neels Hofmeyr19bed232018-03-22 04:54:57 +0100828/* Useful to track N-N relations between BTS, for example neighbors. */
829struct gsm_bts_ref {
830 struct llist_head entry;
831 struct gsm_bts *bts;
832};
833
Harald Welted41b7c72019-06-13 09:41:58 +0200834/* A single Page of a SMSCB message */
835struct bts_smscb_page {
836 /* SMSCB message we're part of */
837 struct bts_smscb_message *msg;
838 /* Page Number within message (1 to 15) */
839 uint8_t nr;
840 /* number of valid blocks in data (up to 4) */
841 uint8_t num_blocks;
842 /* up to four blocks of 22 bytes each */
843 uint8_t data[88];
844};
845
846/* A SMSCB message (received from CBSP) */
847struct bts_smscb_message {
848 /* entry in bts_smscb_chan_state.messages */
849 struct llist_head list;
850 struct {
851 /* input data from CBSP (CBC) side */
852 uint16_t msg_id;
853 uint16_t serial_nr;
854 enum cbsp_category category;
855 uint16_t rep_period;
856 uint16_t num_bcast_req;
857 uint8_t dcs;
858 } input;
859 /* how often have all pages of this message been broadcast? */
860 uint32_t bcast_count;
861 /* actual page data of this message */
862 uint8_t num_pages; /* up to 15 */
863 struct bts_smscb_page page[15];
864};
865
866/* per-channel (basic/extended) CBCH state for a single BTS */
867struct bts_smscb_chan_state {
868 /* back-pointer to BTS */
869 struct gsm_bts *bts;
870 /* list of bts_smscb_message */
871 struct llist_head messages;
872 /* scheduling array; pointer of SMSCB pages */
873 struct bts_smscb_page **sched_arr;
874 size_t sched_arr_size;
875 /* index of the next to be transmitted page into the scheduler array */
876 size_t next_idx;
877 /* number of messages we have to pause due to overflow */
878 uint8_t overflow;
879};
880
Oliver Smithba0a1222020-03-18 12:39:30 +0100881struct bts_oml_fail_rep {
882 struct llist_head list;
883 time_t time;
884 struct msgb *mb;
885};
886
Oliver Smith8d8d7102018-10-23 15:35:43 +0200887/* One rejected BTS */
888struct gsm_bts_rejected {
889 /* list header in net->bts_rejected */
890 struct llist_head list;
891
892 uint16_t site_id;
893 uint16_t bts_id;
894 char ip[INET6_ADDRSTRLEN];
895 time_t time;
896};
Neels Hofmeyr10485162018-02-13 23:22:03 +0100897
Neels Hofmeyr958f2592018-05-27 01:26:31 +0200898struct gsm_network *gsm_network_init(void *ctx);
899
Neels Hofmeyr6d568ed2018-07-09 16:49:18 +0200900struct gsm_bts *gsm_bts_num(const struct gsm_network *net, int num);
Neels Hofmeyr19bed232018-03-22 04:54:57 +0100901struct gsm_bts *gsm_bts_by_cell_id(const struct gsm_network *net,
902 const struct gsm0808_cell_id *cell_id,
903 int match_idx);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100904
Neels Hofmeyr10485162018-02-13 23:22:03 +0100905extern const struct value_string gsm_chreq_descs[];
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200906extern const struct value_string gsm_pchant_names[];
907extern const struct value_string gsm_pchant_descs[];
908extern const struct value_string gsm_pchan_ids[];
Neels Hofmeyr10485162018-02-13 23:22:03 +0100909const char *gsm_pchan_name(enum gsm_phys_chan_config c);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200910static inline const char *gsm_pchan_id(enum gsm_phys_chan_config c)
911{ return get_value_string(gsm_pchan_ids, c); }
Neels Hofmeyr10485162018-02-13 23:22:03 +0100912enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
913const char *gsm_lchant_name(enum gsm_chan_t c);
914const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100915char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
916char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts);
917char *gsm_lchan_name_compute(const struct gsm_lchan *lchan);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100918
919static inline char *gsm_lchan_name(const struct gsm_lchan *lchan)
920{
921 return lchan->name;
922}
923
Neels Hofmeyr10485162018-02-13 23:22:03 +0100924void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
Pau Espin Pedrol388ed582020-07-15 20:53:16 +0200925void gsm_mo_init(struct gsm_abis_mo *mo, struct gsm_bts *bts,
926 uint8_t obj_class, uint8_t p1, uint8_t p2, uint8_t p3);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100927
928struct gsm_nm_state *
929gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
930 const struct abis_om_obj_inst *obj_inst);
931void *
932gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
933 const struct abis_om_obj_inst *obj_inst);
934
Neels Hofmeyr10485162018-02-13 23:22:03 +0100935uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan,
936 uint8_t ts_nr, uint8_t lchan_nr);
937uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
938uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan,
939 enum gsm_phys_chan_config as_pchan);
940
Harald Welte251bec12018-09-09 17:14:09 +0200941void gsm48_lchan2chan_desc(struct gsm48_chan_desc *cd,
942 const struct gsm_lchan *lchan);
Harald Welte24286f32018-09-09 17:17:44 +0200943void gsm48_lchan2chan_desc_as_configured(struct gsm48_chan_desc *cd, const struct gsm_lchan *lchan);
Harald Welte251bec12018-09-09 17:14:09 +0200944
Pau Espin Pedrol388ed582020-07-15 20:53:16 +0200945uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100946
Neels Hofmeyr10485162018-02-13 23:22:03 +0100947enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200948uint8_t pchan_subslots(enum gsm_phys_chan_config pchan);
Neels Hofmeyr10485162018-02-13 23:22:03 +0100949bool ts_is_tch(struct gsm_bts_trx_ts *ts);
950
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100951
Pau Espin Pedrol388ed582020-07-15 20:53:16 +0200952struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection *conn);
Harald Welteb7948872017-12-18 18:48:21 +0100953
Pau Espin Pedrol7950e5d2019-10-31 15:59:49 +0100954void conn_update_ms_power_class(struct gsm_subscriber_connection *conn, uint8_t power_class);
955void lchan_update_ms_power_ctrl_level(struct gsm_lchan *lchan, int ms_power_dbm);
956
Stefan Sperling81dc9e72018-02-05 17:34:36 +0100957enum {
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200958 BSC_CTR_ASSIGNMENT_ATTEMPTED,
959 BSC_CTR_ASSIGNMENT_COMPLETED,
960 BSC_CTR_ASSIGNMENT_STOPPED,
961 BSC_CTR_ASSIGNMENT_NO_CHANNEL,
962 BSC_CTR_ASSIGNMENT_TIMEOUT,
963 BSC_CTR_ASSIGNMENT_FAILED,
964 BSC_CTR_ASSIGNMENT_ERROR,
Alexander Couzensb847a212016-08-02 11:34:11 +0200965 BSC_CTR_HANDOVER_ATTEMPTED,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200966 BSC_CTR_HANDOVER_COMPLETED,
967 BSC_CTR_HANDOVER_STOPPED,
Alexander Couzensb847a212016-08-02 11:34:11 +0200968 BSC_CTR_HANDOVER_NO_CHANNEL,
969 BSC_CTR_HANDOVER_TIMEOUT,
Alexander Couzensb847a212016-08-02 11:34:11 +0200970 BSC_CTR_HANDOVER_FAILED,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200971 BSC_CTR_HANDOVER_ERROR,
Daniel Willmannbf2a4b62020-08-20 15:25:37 +0200972 BSC_CTR_INTRA_CELL_HO_ATTEMPTED,
973 BSC_CTR_INTRA_CELL_HO_COMPLETED,
974 BSC_CTR_INTRA_CELL_HO_STOPPED,
975 BSC_CTR_INTRA_CELL_HO_NO_CHANNEL,
976 BSC_CTR_INTRA_CELL_HO_TIMEOUT,
977 BSC_CTR_INTRA_CELL_HO_FAILED,
978 BSC_CTR_INTRA_CELL_HO_ERROR,
979 BSC_CTR_INTRA_BSC_HO_ATTEMPTED,
980 BSC_CTR_INTRA_BSC_HO_COMPLETED,
981 BSC_CTR_INTRA_BSC_HO_STOPPED,
982 BSC_CTR_INTRA_BSC_HO_NO_CHANNEL,
983 BSC_CTR_INTRA_BSC_HO_TIMEOUT,
984 BSC_CTR_INTRA_BSC_HO_FAILED,
985 BSC_CTR_INTRA_BSC_HO_ERROR,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200986 BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED,
987 BSC_CTR_INTER_BSC_HO_OUT_COMPLETED,
988 BSC_CTR_INTER_BSC_HO_OUT_STOPPED,
989 BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT,
Neels Hofmeyrdbe59f62020-08-29 03:23:31 +0000990 BSC_CTR_INTER_BSC_HO_OUT_FAILED,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +0200991 BSC_CTR_INTER_BSC_HO_OUT_ERROR,
992 BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED,
993 BSC_CTR_INTER_BSC_HO_IN_COMPLETED,
994 BSC_CTR_INTER_BSC_HO_IN_STOPPED,
995 BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL,
996 BSC_CTR_INTER_BSC_HO_IN_FAILED,
997 BSC_CTR_INTER_BSC_HO_IN_TIMEOUT,
998 BSC_CTR_INTER_BSC_HO_IN_ERROR,
Alexander Couzensb847a212016-08-02 11:34:11 +0200999 BSC_CTR_PAGING_ATTEMPTED,
1000 BSC_CTR_PAGING_DETACHED,
Harald Weltecf9d4312017-12-13 23:17:16 +01001001 BSC_CTR_PAGING_RESPONDED,
Alexander Chemeris43def742020-05-16 18:49:59 +03001002 BSC_CTR_PAGING_NO_ACTIVE_PAGING,
Stefan Sperling7926d982018-05-17 14:52:02 +02001003 BSC_CTR_UNKNOWN_UNIT_ID,
Neels Hofmeyr1c963eb2020-06-16 12:08:39 +02001004 BSC_CTR_MSCPOOL_SUBSCR_NO_MSC,
1005 BSC_CTR_MSCPOOL_EMERG_FORWARDED,
1006 BSC_CTR_MSCPOOL_EMERG_LOST,
Alexander Couzensb847a212016-08-02 11:34:11 +02001007};
1008
1009static const struct rate_ctr_desc bsc_ctr_description[] = {
Daniel Willmann45062b42020-08-20 18:37:51 +02001010 [BSC_CTR_ASSIGNMENT_ATTEMPTED] = {"assignment:attempted", "Assignment attempts"},
1011 [BSC_CTR_ASSIGNMENT_COMPLETED] = {"assignment:completed", "Assignment completed"},
1012 [BSC_CTR_ASSIGNMENT_STOPPED] = {"assignment:stopped", "Connection ended during Assignment"},
1013 [BSC_CTR_ASSIGNMENT_NO_CHANNEL] = {"assignment:no_channel", "Failure to allocate lchan for Assignment"},
1014 [BSC_CTR_ASSIGNMENT_TIMEOUT] = {"assignment:timeout", "Assignment timed out"},
1015 [BSC_CTR_ASSIGNMENT_FAILED] = {"assignment:failed", "Received Assignment Failure message"},
1016 [BSC_CTR_ASSIGNMENT_ERROR] = {"assignment:error", "Assignment failed for other reason"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001017
Daniel Willmann45062b42020-08-20 18:37:51 +02001018 [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover:attempted", "Intra-BSC handover attempts"},
1019 [BSC_CTR_HANDOVER_COMPLETED] = {"handover:completed", "Intra-BSC handover completed"},
1020 [BSC_CTR_HANDOVER_STOPPED] = {"handover:stopped", "Connection ended during HO"},
1021 [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover:no_channel", "Failure to allocate lchan for HO"},
1022 [BSC_CTR_HANDOVER_TIMEOUT] = {"handover:timeout", "Handover timed out"},
1023 [BSC_CTR_HANDOVER_FAILED] = {"handover:failed", "Received Handover Fail messages"},
1024 [BSC_CTR_HANDOVER_ERROR] = {"handover:error", "Re-assignment failed for other reason"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001025
Daniel Willmannbf2a4b62020-08-20 15:25:37 +02001026 [BSC_CTR_INTRA_CELL_HO_ATTEMPTED] = {"intra_cell_ho:attempted", "Intra-Cell handover attempts"},
1027 [BSC_CTR_INTRA_CELL_HO_COMPLETED] = {"intra_cell_ho:completed", "Intra-Cell handover completed"},
1028 [BSC_CTR_INTRA_CELL_HO_STOPPED] = {"intra_cell_ho:stopped", "Connection ended during HO"},
1029 [BSC_CTR_INTRA_CELL_HO_NO_CHANNEL] = {"intra_cell_ho:no_channel", "Failure to allocate lchan for HO"},
1030 [BSC_CTR_INTRA_CELL_HO_TIMEOUT] = {"intra_cell_ho:timeout", "Handover timed out"},
1031 [BSC_CTR_INTRA_CELL_HO_FAILED] = {"intra_cell_ho:failed", "Received Handover Fail messages"},
1032 [BSC_CTR_INTRA_CELL_HO_ERROR] = {"intra_cell_ho:error", "Re-assignment failed for other reason"},
1033
1034 [BSC_CTR_INTRA_BSC_HO_ATTEMPTED] = {"intra_bsc_ho:attempted", "Intra-BSC handover attempts"},
1035 [BSC_CTR_INTRA_BSC_HO_COMPLETED] = {"intra_bsc_ho:completed", "Intra-BSC handover completed"},
1036 [BSC_CTR_INTRA_BSC_HO_STOPPED] = {"intra_bsc_ho:stopped", "Connection ended during HO"},
1037 [BSC_CTR_INTRA_BSC_HO_NO_CHANNEL] = {"intra_bsc_ho:no_channel", "Failure to allocate lchan for HO"},
1038 [BSC_CTR_INTRA_BSC_HO_TIMEOUT] = {"intra_bsc_ho:timeout", "Handover timed out"},
1039 [BSC_CTR_INTRA_BSC_HO_FAILED] = {"intra_bsc_ho:failed", "Received Handover Fail messages"},
1040 [BSC_CTR_INTRA_BSC_HO_ERROR] = {"intra_bsc_ho:error", "Re-assignment failed for other reason"},
1041
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001042 [BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED] = {"interbsc_ho_out:attempted",
Daniel Willmann45062b42020-08-20 18:37:51 +02001043 "Attempts to handover to remote BSS"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001044 [BSC_CTR_INTER_BSC_HO_OUT_COMPLETED] = {"interbsc_ho_out:completed",
Daniel Willmann45062b42020-08-20 18:37:51 +02001045 "Handover to remote BSS completed"},
1046 [BSC_CTR_INTER_BSC_HO_OUT_STOPPED] = {"interbsc_ho_out:stopped", "Connection ended during HO"},
1047 [BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT] = {"interbsc_ho_out:timeout", "Handover timed out"},
Neels Hofmeyrdbe59f62020-08-29 03:23:31 +00001048 [BSC_CTR_INTER_BSC_HO_OUT_FAILED] = {"interbsc_ho_out:failed", "Received Handover Fail message"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001049 [BSC_CTR_INTER_BSC_HO_OUT_ERROR] = {"interbsc_ho_out:error",
Daniel Willmann45062b42020-08-20 18:37:51 +02001050 "Handover to remote BSS failed for other reason"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001051
1052 [BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED] = {"interbsc_ho_in:attempted",
Daniel Willmann45062b42020-08-20 18:37:51 +02001053 "Attempts to handover from remote BSS"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001054 [BSC_CTR_INTER_BSC_HO_IN_COMPLETED] = {"interbsc_ho_in:completed",
Daniel Willmann45062b42020-08-20 18:37:51 +02001055 "Handover from remote BSS completed"},
1056 [BSC_CTR_INTER_BSC_HO_IN_STOPPED] = {"interbsc_ho_in:stopped", "Connection ended during HO"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001057 [BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL] = {"interbsc_ho_in:no_channel",
Daniel Willmann45062b42020-08-20 18:37:51 +02001058 "Failure to allocate lchan for HO"},
1059 [BSC_CTR_INTER_BSC_HO_IN_TIMEOUT] = {"interbsc_ho_in:timeout", "Handover from remote BSS timed out"},
1060 [BSC_CTR_INTER_BSC_HO_IN_FAILED] = {"interbsc_ho_in:failed", "Received Handover Fail message"},
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001061 [BSC_CTR_INTER_BSC_HO_IN_ERROR] = {"interbsc_ho_in:error",
Daniel Willmann45062b42020-08-20 18:37:51 +02001062 "Handover from remote BSS failed for other reason"},
Harald Weltecf9d4312017-12-13 23:17:16 +01001063
Daniel Willmann45062b42020-08-20 18:37:51 +02001064 [BSC_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber"},
1065 [BSC_CTR_PAGING_DETACHED] = {"paging:detached", "Paging request send failures because no responsible BTS was found"},
1066 [BSC_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful response"},
1067 [BSC_CTR_PAGING_NO_ACTIVE_PAGING] = {"paging:no_active_paging", "Paging response without an active paging request (arrived after paging expiration?)"},
Stefan Sperling7926d982018-05-17 14:52:02 +02001068
Daniel Willmann45062b42020-08-20 18:37:51 +02001069 [BSC_CTR_UNKNOWN_UNIT_ID] = {"abis:unknown_unit_id", "Connection attempts from unknown IPA CCM Unit ID"},
Neels Hofmeyr1c963eb2020-06-16 12:08:39 +02001070
1071 [BSC_CTR_MSCPOOL_SUBSCR_NO_MSC] = {"mscpool:subscr:no_msc",
Daniel Willmann45062b42020-08-20 18:37:51 +02001072 "Complete Layer 3 requests lost because no connected MSC is found available"},
Neels Hofmeyr1c963eb2020-06-16 12:08:39 +02001073 [BSC_CTR_MSCPOOL_EMERG_FORWARDED] = {"mscpool:emerg:forwarded",
Daniel Willmann45062b42020-08-20 18:37:51 +02001074 "Emergency call requests forwarded to an MSC (see also per-MSC counters"},
Neels Hofmeyr1c963eb2020-06-16 12:08:39 +02001075 [BSC_CTR_MSCPOOL_EMERG_LOST] = {"mscpool:emerg:lost",
Daniel Willmann45062b42020-08-20 18:37:51 +02001076 "Emergency call requests lost because no MSC was found available"},
Alexander Couzensb847a212016-08-02 11:34:11 +02001077};
1078
Alexander Couzensb847a212016-08-02 11:34:11 +02001079
1080
1081static const struct rate_ctr_group_desc bsc_ctrg_desc = {
1082 "bsc",
1083 "base station controller",
1084 OSMO_STATS_CLASS_GLOBAL,
1085 ARRAY_SIZE(bsc_ctr_description),
1086 bsc_ctr_description,
Alexander Couzens20423ea2016-07-12 15:42:02 +02001087};
1088
Alexander Chemerisdb542832020-05-08 01:49:12 +03001089/* Constants for the BSC stats */
1090enum {
1091 BSC_STAT_NUM_BTS_TOTAL,
1092};
1093
Daniel Willmannaa420ce2020-08-20 15:37:35 +02001094/* BTS counter index if a BTS could not be found
1095 * Currently we are limited to bts 0 - 255 in the VTY, but that might change in
1096 * the future so use 2**16 */
1097#define BTS_STAT_IDX_UNKNOWN (UINT16_MAX + 1)
1098
Neels Hofmeyr73983952016-05-10 13:29:33 +02001099struct gsm_tz {
1100 int override; /* if 0, use system's time zone instead. */
1101 int hr; /* hour */
1102 int mn; /* minute */
1103 int dst; /* daylight savings */
1104};
1105
Harald Welte52b1f982008-12-23 20:25:15 +00001106struct gsm_network {
Neels Hofmeyrce4d88b2017-05-08 15:12:20 +02001107 /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for
1108 * global settings and variables, "madly" mixing BSC and MSC stuff. Split
1109 * this in e.g. struct osmo_bsc and struct osmo_msc, with the things
1110 * these have in common, like country and network code, put in yet
1111 * separate structs and placed as members in osmo_bsc and osmo_msc. */
1112
Neels Hofmeyrf93970b2018-03-05 02:09:40 +01001113 struct osmo_plmn_id plmn;
1114
Harald Welte51e4bf32017-12-23 17:30:18 +01001115 /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
1116 uint8_t a5_encryption_mask;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +01001117 int neci;
Neels Hofmeyr909e9722017-12-07 03:54:01 +01001118
Neels Hofmeyre25018b2017-11-27 21:29:33 +01001119 struct handover_cfg *ho;
Neels Hofmeyr909e9722017-12-07 03:54:01 +01001120 struct {
1121 unsigned int congestion_check_interval_s;
1122 struct osmo_timer_list congestion_check_timer;
1123 } hodec2;
Harald Welte52b1f982008-12-23 20:25:15 +00001124
Alexander Chemerisdb542832020-05-08 01:49:12 +03001125 /* structures for keeping rate counters and gauge stats */
Alexander Couzensb847a212016-08-02 11:34:11 +02001126 struct rate_ctr_group *bsc_ctrs;
Alexander Chemerisdb542832020-05-08 01:49:12 +03001127 struct osmo_stat_item_group *bsc_statg;
Harald Welte24ff6ee2009-12-22 00:41:05 +01001128
Harald Welte52b1f982008-12-23 20:25:15 +00001129 unsigned int num_bts;
Harald Weltee441d9c2009-06-21 16:17:15 +02001130 struct llist_head bts_list;
Oliver Smith8d8d7102018-10-23 15:35:43 +02001131 struct llist_head bts_rejected;
Holger Hans Peter Freytherc4d88ad2009-11-21 21:18:38 +01001132
Daniel Willmannaa420ce2020-08-20 15:37:35 +02001133 /* BTS-based counters when we can't find the actual BTS
1134 * e.g. when conn->lchan is NULL */
1135 struct rate_ctr_group *bts_unknown_ctrs;
1136 struct osmo_stat_item_group *bts_unknown_statg;
1137
Neels Hofmeyr08822a32019-07-11 03:43:34 +02001138 /* see gsm_network_T_defs */
Neels Hofmeyra6078fe2019-01-28 03:52:14 +01001139 struct osmo_tdef *T_defs;
Harald Welteeab84a12009-12-13 10:53:12 +01001140
Alexander Couzens547c2072017-11-21 12:03:04 +01001141 enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T];
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +08001142
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +08001143 /* Use a TCH for handling requests of type paging any */
1144 int pag_any_tch;
1145
Neels Hofmeyr06a14d22020-05-26 12:41:18 +02001146 /* msc configuration */
1147 struct llist_head mscs;
Neels Hofmeyreec776e2020-05-25 00:02:56 +02001148 uint8_t mscs_round_robin_next_nr;
1149 /* Emergency calls potentially select a different set of MSCs, so to not mess up the normal round-robin
1150 * behavior, emergency calls need a separate round-robin counter. */
1151 uint8_t mscs_round_robin_next_emerg_nr;
Neels Hofmeyr06a14d22020-05-26 12:41:18 +02001152
1153 /* rf ctl related bits */
1154 int mid_call_timeout;
1155 char *rf_ctrl_name;
1156 struct osmo_bsc_rf *rf_ctrl;
1157 int auto_off_timeout;
1158
1159 struct bsc_cbc_link *cbc;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +01001160
Daniel Willmann6fc4a982011-07-22 17:55:42 +02001161 /* control interface */
1162 struct ctrl_handle *ctrl;
Neels Hofmeyr5f0c71b2016-07-23 20:15:28 +02001163
1164 /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */
1165 bool dyn_ts_allow_tch_f;
Neels Hofmeyrd90fa422016-05-09 21:03:12 +02001166
1167 /* all active subscriber connections. */
1168 struct llist_head subscr_conns;
Neels Hofmeyr73983952016-05-10 13:29:33 +02001169
1170 /* if override is nonzero, this timezone data is used for all MM
1171 * contexts. */
1172 /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable
1173 * BTS|RNC specific timezone overrides for multi-tz networks in
Neels Hofmeyrfe291de2017-02-23 21:06:12 +01001174 * OsmoMSC, this should be tied to the location area code (LAC). */
Neels Hofmeyr73983952016-05-10 13:29:33 +02001175 struct gsm_tz tz;
Neels Hofmeyr6d804b12017-02-18 22:20:46 +01001176
1177 /* List of all struct bsc_subscr used in libbsc. This llist_head is
1178 * allocated so that the llist_head pointer itself can serve as a
1179 * talloc context (useful to not have to pass the entire gsm_network
1180 * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to
1181 * not require gsm_data.h). In an MSC-without-BSC environment, this
1182 * pointer is NULL to indicate absence of a bsc_subscribers list. */
1183 struct llist_head *bsc_subscribers;
Harald Weltea43e0b42016-06-19 18:06:02 +02001184
Stefan Sperling6cee8932018-01-30 18:14:22 +01001185 /* Timer for periodic channel load measurements to maintain each BTS's T3122. */
1186 struct osmo_timer_list t3122_chan_load_timer;
1187
Neels Hofmeyrc29505e2016-05-20 21:59:55 +02001188 struct {
Philipp Maier39c609b2017-09-27 15:51:34 +02001189 struct mgcp_client_conf *conf;
1190 struct mgcp_client *client;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +02001191 struct osmo_tdef *tdefs;
Philipp Maier39c609b2017-09-27 15:51:34 +02001192 } mgw;
Neels Hofmeyr19bed232018-03-22 04:54:57 +01001193
1194 /* Remote BSS Cell Identifier Lists */
1195 struct neighbor_ident_list *neighbor_bss_cells;
Oliver Smitha595db12020-03-17 12:21:00 +01001196
1197 /* Don't refuse to start with mutually exclusive codec settings */
1198 bool allow_unusable_timeslots;
Neels Hofmeyr4099f1d2020-05-26 03:58:14 +02001199
1200 uint8_t nri_bitlen;
1201 struct osmo_nri_ranges *null_nri_ranges;
Harald Welte7e310b12009-03-30 20:56:32 +00001202};
1203
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001204struct gsm_audio_support {
1205 uint8_t hr : 1,
1206 ver : 7;
1207};
1208
Neels Hofmeyrc13e6872016-05-11 13:53:47 +02001209extern void talloc_ctx_init(void *ctx_root);
1210
Harald Welte1d014a52009-08-08 15:38:29 +02001211enum gsm_bts_type parse_btstype(const char *arg);
Holger Hans Peter Freyther2dceae62009-06-12 17:39:38 +02001212const char *btstype2str(enum gsm_bts_type type);
Harald Weltebe991492009-05-23 13:56:40 +00001213struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac,
1214 struct gsm_bts *start_bts);
Harald Welte32201c12009-03-10 12:15:10 +00001215
Andreas Eversberg8226fa72009-06-29 15:19:38 +02001216extern void *tall_bsc_ctx;
Harald Welte2cf161b2009-06-20 22:36:41 +02001217
Harald Welte1876c312018-05-27 11:53:43 +02001218extern struct gsm_network *bsc_gsmnet;
1219
Holger Hans Peter Freyther4e13a8f2015-01-31 22:16:00 +01001220enum bts_gprs_mode bts_gprs_mode_parse(const char *arg, int *valid);
Harald Welte4511d892010-04-18 15:51:20 +02001221const char *bts_gprs_mode_name(enum bts_gprs_mode mode);
1222
Neels Hofmeyr4d358c02018-02-22 03:19:05 +01001223void gsm48_ra_id_by_bts(struct gsm48_ra_id *buf, struct gsm_bts *bts);
Harald Welte97a282b2010-03-14 15:37:43 +08001224void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
Harald Welted12b0fd2009-12-15 21:36:05 +01001225
Harald Welte3561bd42018-01-28 03:04:16 +01001226struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network);
Neels Hofmeyr42eb0142016-05-20 17:15:44 +02001227
Neels Hofmeyr958f2592018-05-27 01:26:31 +02001228struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic);
1229struct gsm_bts *bsc_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic);
Harald Welte142d12d2014-12-29 17:47:08 +01001230
Harald Welte3300c012011-06-05 13:31:33 +02001231void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr,
1232 uint8_t e1_ts, uint8_t e1_ts_ss);
1233
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +02001234/* generic E1 line operations for all ISDN-based BTS. */
1235extern struct e1inp_line_ops bts_isdn_e1inp_line_ops;
1236
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +01001237/* control interface handling */
1238int bsc_base_ctrl_cmds_install(void);
1239
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001240bool ts_is_usable(const struct gsm_bts_trx_ts *ts);
Neels Hofmeyr958f2592018-05-27 01:26:31 +02001241
Neels Hofmeyr31f525e2018-05-14 18:14:15 +02001242int gsm_lchan_type_by_pchan(enum gsm_phys_chan_config pchan);
1243enum gsm_phys_chan_config gsm_pchan_by_lchan_type(enum gsm_chan_t type);
1244
Neels Hofmeyrb523f542020-07-09 15:54:40 +02001245enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c);
Neels Hofmeyr3405c772020-07-11 01:44:08 +02001246enum gsm48_rr_cause bsc_gsm48_rr_cause_from_rsl_cause(uint8_t c);
Neels Hofmeyrb523f542020-07-09 15:54:40 +02001247
Harald Welte6be350c2011-05-25 13:10:08 +02001248#endif /* _GSM_DATA_H */