blob: 3ef1457650441391294584cb7a0d4a42626a0b44 [file] [log] [blame]
Harald Welte3da6b3f2011-05-25 13:10:08 +02001#ifndef _GSM_DATA_SHAREDH
2#define _GSM_DATA_SHAREDH
3
Holger Hans Peter Freyther1c14d962011-06-09 21:48:49 +02004#include <regex.h>
Harald Welte3da6b3f2011-05-25 13:10:08 +02005#include <stdbool.h>
6#include <stdint.h>
7
8#include <osmocom/core/timer.h>
9#include <osmocom/core/bitvec.h>
10#include <osmocom/core/statistics.h>
11#include <osmocom/core/utils.h>
12#include <osmocom/gsm/gsm_utils.h>
13#include <osmocom/gsm/tlv.h>
14#include <osmocom/gsm/rxlev_stat.h>
15#include <osmocom/gsm/sysinfo.h>
16
17#include <osmocom/gsm/protocol/gsm_08_58.h>
Harald Weltec7881282011-06-05 13:31:33 +020018#include <osmocom/gsm/protocol/gsm_12_21.h>
Harald Welte3da6b3f2011-05-25 13:10:08 +020019
Harald Welte924da552011-08-24 13:52:07 +020020#include <osmocom/abis/e1_input.h>
21
Holger Hans Peter Freyther2d75d3f2012-12-20 19:03:18 +010022#ifndef ROLE_BSC
23#include <osmocom/gsm/lapdm.h>
24#endif
25
Holger Hans Peter Freyther4d614172011-08-15 15:53:00 +020026struct osmo_bsc_data;
27
Harald Welte3da6b3f2011-05-25 13:10:08 +020028struct osmo_bsc_sccp_con;
29struct gsm_sms_queue;
30
31/* RRLP mode of operation */
32enum rrlp_mode {
33 RRLP_MODE_NONE,
34 RRLP_MODE_MS_BASED,
35 RRLP_MODE_MS_PREF,
36 RRLP_MODE_ASS_PREF,
37};
38
39/* Channel Request reason */
40enum gsm_chreq_reason_t {
41 GSM_CHREQ_REASON_EMERG,
42 GSM_CHREQ_REASON_PAG,
43 GSM_CHREQ_REASON_CALL,
44 GSM_CHREQ_REASON_LOCATION_UPD,
45 GSM_CHREQ_REASON_OTHER,
46};
47
48#define TRX_NR_TS 8
49#define TS_MAX_LCHAN 8
50
51#define HARDCODED_ARFCN 123
52#define HARDCODED_TSC 7
53#define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */
54
55/* for multi-drop config */
56#define HARDCODED_BTS0_TS 1
57#define HARDCODED_BTS1_TS 6
58#define HARDCODED_BTS2_TS 11
59
60/* reserved according to GSM 03.03 ยง 2.4 */
61#define GSM_RESERVED_TMSI 0xFFFFFFFF
62
63enum gsm_hooks {
64 GSM_HOOK_NM_SWLOAD,
65 GSM_HOOK_RR_PAGING,
66 GSM_HOOK_RR_SECURITY,
67};
68
69enum gsm_paging_event {
70 GSM_PAGING_SUCCEEDED,
71 GSM_PAGING_EXPIRED,
72 GSM_PAGING_OOM,
73 GSM_PAGING_BUSY,
74};
75
76enum bts_gprs_mode {
77 BTS_GPRS_NONE = 0,
78 BTS_GPRS_GPRS = 1,
79 BTS_GPRS_EGPRS = 2,
80};
81
82struct gsm_lchan;
83struct gsm_subscriber;
84struct gsm_mncc;
Harald Welte52bf91c2011-09-04 13:53:26 +020085struct osmo_rtp_socket;
Harald Welte3da6b3f2011-05-25 13:10:08 +020086struct rtp_socket;
87struct bsc_api;
88
89/* Network Management State */
90struct gsm_nm_state {
91 uint8_t operational;
92 uint8_t administrative;
93 uint8_t availability;
94};
95
Harald Welte69f6f812011-05-30 12:07:53 +020096struct gsm_abis_mo {
Harald Weltec7881282011-06-05 13:31:33 +020097 uint8_t obj_class;
98 struct abis_om_obj_inst obj_inst;
Harald Welte69f6f812011-05-30 12:07:53 +020099 const char *name;
100 struct gsm_nm_state nm_state;
101 struct tlv_parsed *nm_attr;
Harald Welte01f4d6b2011-06-06 18:58:48 +0200102 struct gsm_bts *bts;
Harald Welte69f6f812011-05-30 12:07:53 +0200103};
104
Harald Welte3da6b3f2011-05-25 13:10:08 +0200105#define MAX_A5_KEY_LEN (128/8)
106#define A38_XOR_MIN_KEY_LEN 12
107#define A38_XOR_MAX_KEY_LEN 16
108#define A38_COMP128_KEY_LEN 16
109#define RSL_ENC_ALG_A5(x) (x+1)
110
111/* is the data link established? who established it? */
112#define LCHAN_SAPI_UNUSED 0
113#define LCHAN_SAPI_MS 1
114#define LCHAN_SAPI_NET 2
115
116/* state of a logical channel */
117enum gsm_lchan_state {
118 LCHAN_S_NONE, /* channel is not active */
Holger Hans Peter Freyther5d880c62012-01-15 00:02:17 +0100119 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte3da6b3f2011-05-25 13:10:08 +0200120 LCHAN_S_ACTIVE, /* channel is active and operational */
121 LCHAN_S_REL_REQ, /* channel release has been requested */
122 LCHAN_S_REL_ERR, /* channel is in an error state */
Holger Hans Peter Freyther5149c172012-12-06 19:25:06 +0100123 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte3da6b3f2011-05-25 13:10:08 +0200124 LCHAN_S_INACTIVE, /* channel is set inactive */
125};
126
Harald Welte0e4f7dc2011-06-29 10:38:34 +0200127/* BTS ONLY */
128#define MAX_NUM_UL_MEAS 104
129#define LC_UL_M_F_L1_VALID (1 << 0)
130#define LC_UL_M_F_RES_VALID (1 << 1)
131
132struct bts_ul_meas {
133 /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */
134 uint16_t ber10k;
135 /* timing advance offset (in quarter bits) */
136 int16_t ta_offs_qbits;
137 /* C/I ratio in dB */
138 float c_i;
139 /* flags */
140 uint8_t is_sub:1;
141 /* RSSI in dBm * -1 */
142 uint8_t inv_rssi;
143};
Harald Welte886a5a52011-09-06 22:14:43 +0200144
145struct amr_mode {
146 uint8_t mode;
147 uint8_t threshold;
148 uint8_t hysteresis;
149};
150struct amr_multirate_conf {
151 uint8_t gsm48_ie[2];
152 struct amr_mode mode[4];
153 uint8_t num_modes;
154};
Harald Welte0e4f7dc2011-06-29 10:38:34 +0200155/* /BTS ONLY */
156
Harald Weltee75a47d2012-08-24 15:33:56 +0200157enum lchan_csd_mode {
158 LCHAN_CSD_M_NT,
159 LCHAN_CSD_M_T_1200_75,
160 LCHAN_CSD_M_T_600,
161 LCHAN_CSD_M_T_1200,
162 LCHAN_CSD_M_T_2400,
163 LCHAN_CSD_M_T_9600,
164 LCHAN_CSD_M_T_14400,
165 LCHAN_CSD_M_T_29000,
166 LCHAN_CSD_M_T_32000,
167};
168
Daniel Willmann4c2fac02012-12-29 12:32:30 +0100169/* State of the SAPIs in the lchan */
170enum lchan_sapi_state {
171 LCHAN_SAPI_S_NONE,
172 LCHAN_SAPI_S_REQ,
173 LCHAN_SAPI_S_ASSIGNED,
174 LCHAN_SAPI_S_REL,
175 LCHAN_SAPI_S_ERROR,
176};
177
Harald Welte3da6b3f2011-05-25 13:10:08 +0200178struct gsm_lchan {
179 /* The TS that we're part of */
180 struct gsm_bts_trx_ts *ts;
181 /* The logical subslot number in the TS */
182 uint8_t nr;
183 /* The logical channel type */
184 enum gsm_chan_t type;
185 /* RSL channel mode */
186 enum rsl_cmod_spd rsl_cmode;
187 /* If TCH, traffic channel mode */
188 enum gsm48_chan_mode tch_mode;
Harald Weltee75a47d2012-08-24 15:33:56 +0200189 enum lchan_csd_mode csd_mode;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200190 /* State */
191 enum gsm_lchan_state state;
192 /* Power levels for MS and BTS */
193 uint8_t bs_power;
194 uint8_t ms_power;
195 /* Encryption information */
196 struct {
197 uint8_t alg_id;
198 uint8_t key_len;
199 uint8_t key[MAX_A5_KEY_LEN];
200 } encr;
201
202 /* AMR bits */
203 struct gsm48_multi_rate_conf mr_conf;
204
205 /* Established data link layer services */
206 uint8_t sapis[8];
Holger Hans Peter Freyther3596bc72013-01-01 19:20:28 +0100207 int sacch_deact;
Holger Hans Peter Freythere3be5ca2011-12-27 20:49:53 +0100208
Harald Welte3da6b3f2011-05-25 13:10:08 +0200209 struct {
210 uint32_t bound_ip;
211 uint32_t connect_ip;
212 uint16_t bound_port;
213 uint16_t connect_port;
214 uint16_t conn_id;
215 uint8_t rtp_payload;
216 uint8_t rtp_payload2;
217 uint8_t speech_mode;
Harald Welte52bf91c2011-09-04 13:53:26 +0200218#ifdef ROLE_BSC
Harald Welte3da6b3f2011-05-25 13:10:08 +0200219 struct rtp_socket *rtp_socket;
Harald Welte52bf91c2011-09-04 13:53:26 +0200220#else
221 struct osmo_rtp_socket *rtp_socket;
222#endif
Harald Welte3da6b3f2011-05-25 13:10:08 +0200223 } abis_ip;
224
Harald Welte2fa27972011-06-26 14:13:37 +0200225 uint8_t rqd_ta;
226
Harald Welte3da6b3f2011-05-25 13:10:08 +0200227#ifdef ROLE_BSC
228 struct osmo_timer_list T3101;
Holger Hans Peter Freyther969a4052011-12-28 16:21:05 +0100229 struct osmo_timer_list T3109;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200230 struct osmo_timer_list T3111;
231 struct osmo_timer_list error_timer;
Harald Welte32951ea2011-08-10 23:26:33 +0200232 struct osmo_timer_list act_timer;
Holger Hans Peter Freyther5149c172012-12-06 19:25:06 +0100233 uint8_t error_cause;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200234
235 /* table of neighbor cell measurements */
236 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
237
238 /* cache of last measurement reports on this lchan */
239 struct gsm_meas_rep meas_rep[6];
240 int meas_rep_idx;
241
242 /* GSM Random Access data */
243 struct gsm48_req_ref *rqd_ref;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200244
245 struct gsm_subscriber_connection *conn;
Harald Weltee6d51f92011-06-25 10:02:33 +0200246#else
Daniel Willmann4c2fac02012-12-29 12:32:30 +0100247 /* Number of different GsmL1_Sapi_t used in osmo_bts_sysmo is 23.
248 * Currently we don't share these headers so this is a magic number. */
Holger Hans Peter Freytherca467982013-04-05 18:41:45 +0200249 struct llist_head sapi_cmds;
Daniel Willmann4c2fac02012-12-29 12:32:30 +0100250 uint8_t sapis_dl[23];
251 uint8_t sapis_ul[23];
Harald Weltee6d51f92011-06-25 10:02:33 +0200252 struct lapdm_channel lapdm_ch;
Harald Welte52bf91c2011-09-04 13:53:26 +0200253 struct llist_head dl_tch_queue;
Harald Welte2fa27972011-06-26 14:13:37 +0200254 struct {
255 /* bitmask of all SI that are present/valid in si_buf */
256 uint32_t valid;
257 uint32_t last;
258 /* buffers where we put the pre-computed SI */
259 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
260 } si;
Harald Welte0e4f7dc2011-06-29 10:38:34 +0200261 struct {
262 uint8_t flags;
263 /* RSL measurment result number, 0 at lchan_act */
264 uint8_t res_nr;
265 /* current Tx power level of the BTS */
266 uint8_t bts_tx_pwr;
267 /* number of measurements stored in array below */
268 uint8_t num_ul_meas;
269 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
270 /* last L1 header from the MS */
271 uint8_t l1_info[2];
272 struct {
273 uint8_t rxlev_full;
274 uint8_t rxlev_sub;
275 uint8_t rxqual_full;
276 uint8_t rxqual_sub;
277 } res;
278 } meas;
Harald Welte886a5a52011-09-06 22:14:43 +0200279 struct {
280 struct amr_multirate_conf amr_mr;
Harald Welte9e2b33b2011-09-07 12:41:38 +0200281 struct {
282 uint8_t buf[16];
283 uint8_t len;
284 } last_sid;
Harald Welte886a5a52011-09-06 22:14:43 +0200285 } tch;
Harald Welte3ac27c52012-04-08 20:23:28 +0200286 /* BTS-side ciphering state (rx only, bi-directional, ...) */
287 uint8_t ciph_state;
Harald Welte125c1b82012-04-19 23:13:35 +0200288 uint8_t loopback;
Harald Weltedddccd42012-06-16 14:57:08 +0800289 struct {
290 uint8_t active;
291 uint8_t ref;
292 /* T3105: PHYS INF retransmission */
293 struct osmo_timer_list t3105;
294 /* counts up to Ny1 */
295 unsigned int phys_info_count;
296 } ho;
Andreas Eversberg43924f52013-02-20 16:06:20 +0100297 /* S counter for link loss */
298 int s;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200299#endif
300};
301
Harald Welte3da6b3f2011-05-25 13:10:08 +0200302#define TS_F_PDCH_MODE 0x1000
303/* One Timeslot in a TRX */
304struct gsm_bts_trx_ts {
305 struct gsm_bts_trx *trx;
306 /* number of this timeslot at the TRX */
307 uint8_t nr;
308
309 enum gsm_phys_chan_config pchan;
310
311 unsigned int flags;
Harald Welte69f6f812011-05-30 12:07:53 +0200312 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200313 struct tlv_parsed nm_attr;
314 uint8_t nm_chan_comb;
Harald Welte85771a42011-05-30 12:09:13 +0200315 int tsc; /* -1 == use BTS TSC */
Harald Welte3da6b3f2011-05-25 13:10:08 +0200316
317 struct {
318 /* Parameters below are configured by VTY */
319 int enabled;
320 uint8_t maio;
321 uint8_t hsn;
322 struct bitvec arfcns;
323 uint8_t arfcns_data[1024/8];
324 /* This is the pre-computed MA for channel assignments */
325 struct bitvec ma;
326 uint8_t ma_len; /* part of ma_data that is used */
327 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
328 } hopping;
329
330 /* To which E1 subslot are we connected */
331 struct gsm_e1_subslot e1_link;
332
333 struct gsm_lchan lchan[TS_MAX_LCHAN];
334};
335
336/* One TRX in a BTS */
337struct gsm_bts_trx {
338 /* list header in bts->trx_list */
339 struct llist_head list;
340
341 struct gsm_bts *bts;
342 /* number of this TRX in the BTS */
343 uint8_t nr;
344 /* human readable name / description */
345 char *description;
346 /* how do we talk RSL with this TRX? */
347 struct gsm_e1_subslot rsl_e1_link;
348 uint8_t rsl_tei;
Holger Hans Peter Freyther1ad1aa82012-01-17 15:52:45 +0100349#ifdef ROLE_BSC
Harald Welte3da6b3f2011-05-25 13:10:08 +0200350 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freyther1ad1aa82012-01-17 15:52:45 +0100351#else
352 struct ipabis_link *rsl_link;
353#endif
Harald Welte3da6b3f2011-05-25 13:10:08 +0200354 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
355 struct e1inp_sign_link *oml_link;
356
Harald Welte69f6f812011-05-30 12:07:53 +0200357 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200358 struct tlv_parsed nm_attr;
359 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200360 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200361 } bb_transc;
362
363 uint16_t arfcn;
364 int nominal_power; /* in dBm */
365 unsigned int max_power_red; /* in actual dB */
366
Harald Welte4f215d02011-06-07 00:12:53 +0200367 struct {
368 void *l1h;
369 } role_bts;
370
Harald Welte3da6b3f2011-05-25 13:10:08 +0200371 union {
372 struct {
373 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200374 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200375 } bbsig;
376 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200377 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200378 } pa;
379 } bs11;
380 struct {
381 unsigned int test_state;
382 uint8_t test_nr;
383 struct rxlev_stats rxlev_stat;
384 } ipaccess;
385 };
386 struct gsm_bts_trx_ts ts[TRX_NR_TS];
387};
388
389#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
390
391enum gsm_bts_type {
392 GSM_BTS_TYPE_UNKNOWN,
393 GSM_BTS_TYPE_BS11,
394 GSM_BTS_TYPE_NANOBTS,
395 GSM_BTS_TYPE_RBS2000,
Dieter Spaar49c843e2011-07-28 00:01:50 +0200396 GSM_BTS_TYPE_NOKIA_SITE,
Harald Welte35ac0e42012-07-02 19:51:55 +0200397 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Welte85a77b12012-08-17 13:02:12 +0200398 _NUM_GSM_BTS_TYPE
Harald Welte3da6b3f2011-05-25 13:10:08 +0200399};
400
401struct vty;
402
403struct gsm_bts_model {
404 struct llist_head list;
405
406 enum gsm_bts_type type;
407 const char *name;
408
409 bool started;
410 int (*start)(struct gsm_network *net);
411 int (*oml_rcvmsg)(struct msgb *msg);
412
Pablo Neira Ayuso42e41df2011-08-17 22:44:07 +0200413 void (*e1line_bind_ops)(struct e1inp_line *line);
414
Harald Welte3da6b3f2011-05-25 13:10:08 +0200415 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
416 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
417 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
418
419 struct tlv_definition nm_att_tlvdef;
420
421 struct bitvec features;
422 uint8_t _features_data[128/8];
423};
424
425enum gsm_bts_features {
426 BTS_FEAT_HSCSD,
427 BTS_FEAT_GPRS,
428 BTS_FEAT_EGPRS,
429 BTS_FEAT_ECSD,
430 BTS_FEAT_HOPPING,
431};
432
433/*
434 * This keeps track of the paging status of one BTS. It
435 * includes a number of pending requests, a back pointer
436 * to the gsm_bts, a timer and some more state.
437 */
438struct gsm_bts_paging_state {
439 /* pending requests */
440 struct llist_head pending_requests;
441 struct gsm_bts *bts;
442
443 struct osmo_timer_list work_timer;
444 struct osmo_timer_list credit_timer;
445
446 /* free chans needed */
447 int free_chans_need;
448
449 /* load */
450 uint16_t available_slots;
451};
452
453struct gsm_envabtse {
Harald Welte69f6f812011-05-30 12:07:53 +0200454 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200455};
456
457struct gsm_bts_gprs_nsvc {
458 struct gsm_bts *bts;
459 /* data read via VTY config file, to configure the BTS
460 * via OML from BSC */
461 int id;
462 uint16_t nsvci;
463 uint16_t local_port; /* on the BTS */
464 uint16_t remote_port; /* on the SGSN */
465 uint32_t remote_ip; /* on the SGSN */
466
Harald Welte69f6f812011-05-30 12:07:53 +0200467 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200468};
469
Harald Welte1c6955a2012-06-28 08:43:14 +0200470enum gprs_rlc_par {
471 RLC_T3142,
472 RLC_T3169,
473 RLC_T3191,
474 RLC_T3193,
475 RLC_T3195,
476 RLC_N3101,
477 RLC_N3103,
478 RLC_N3105,
479 CV_COUNTDOWN,
480 T_DL_TBF_EXT, /* ms */
481 T_UL_TBF_EXT, /* ms */
482 _NUM_RLC_PAR
483};
484
485enum gprs_cs {
486 GPRS_CS1,
487 GPRS_CS2,
488 GPRS_CS3,
489 GPRS_CS4,
490 GPRS_MCS1,
491 GPRS_MCS2,
492 GPRS_MCS3,
493 GPRS_MCS4,
494 GPRS_MCS5,
495 GPRS_MCS6,
496 GPRS_MCS7,
497 GPRS_MCS8,
498 GPRS_MCS9,
499 _NUM_GRPS_CS
500};
501
502struct gprs_rlc_cfg {
503 uint16_t parameter[_NUM_RLC_PAR];
504 struct {
505 uint16_t repeat_time; /* ms */
506 uint8_t repeat_count;
507 } paging;
508 uint32_t cs_mask; /* bitmask of gprs_cs */
509 uint8_t initial_cs;
510 uint8_t initial_mcs;
511};
512
513
Harald Welte3da6b3f2011-05-25 13:10:08 +0200514enum neigh_list_manual_mode {
515 NL_MODE_AUTOMATIC = 0,
516 NL_MODE_MANUAL = 1,
517 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
518};
519
Daniel Willmann8c3483f2011-08-05 13:51:27 +0200520enum bts_loc_fix {
521 BTS_LOC_FIX_INVALID = 0,
522 BTS_LOC_FIX_2D = 1,
523 BTS_LOC_FIX_3D = 2,
524};
525
Daniel Willmann2c9540c2012-05-14 18:43:23 +0200526extern const struct value_string bts_loc_fix_names[];
527
Daniel Willmann8c3483f2011-08-05 13:51:27 +0200528struct bts_location {
529 struct llist_head list;
530 time_t tstamp;
531 enum bts_loc_fix valid;
532 double lat;
533 double lon;
534 double height;
535};
536
Harald Welte3da6b3f2011-05-25 13:10:08 +0200537/* One BTS */
538struct gsm_bts {
539 /* list header in net->bts_list */
540 struct llist_head list;
541
Daniel Willmann8c3483f2011-08-05 13:51:27 +0200542 /* Geographical location of the BTS */
543 struct llist_head loc_list;
544
Harald Welte3da6b3f2011-05-25 13:10:08 +0200545 /* number of ths BTS in network */
546 uint8_t nr;
547 /* human readable name / description */
548 char *description;
549 /* Cell Identity */
550 uint16_t cell_identity;
551 /* location area code of this BTS */
552 uint16_t location_area_code;
553 /* Training Sequence Code */
554 uint8_t tsc;
555 /* Base Station Identification Code (BSIC) */
556 uint8_t bsic;
557 /* type of BTS */
558 enum gsm_bts_type type;
559 struct gsm_bts_model *model;
560 enum gsm_band band;
561 /* maximum Tx power that the MS is permitted to use in this cell */
562 int ms_max_power;
563
564 /* how do we talk OML with this TRX? */
565 struct gsm_e1_subslot oml_e1_link;
566 uint8_t oml_tei;
567 struct e1inp_sign_link *oml_link;
568
569 /* Abis network management O&M handle */
570 struct abis_nm_h *nmh;
Harald Welte69f6f812011-05-30 12:07:53 +0200571
572 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200573
574 /* number of this BTS on given E1 link */
575 uint8_t bts_nr;
576
577 /* paging state and control */
578 struct gsm_bts_paging_state paging;
579
580 /* CCCH is on C0 */
581 struct gsm_bts_trx *c0;
582
583 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200584 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200585 } site_mgr;
586
587 /* bitmask of all SI that are present/valid in si_buf */
588 uint32_t si_valid;
589 /* buffers where we put the pre-computed SI */
590 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
591
Gus Bourgf9dc16b2011-12-02 10:18:17 +0100592 /* TimeZone hours, mins, and bts specific */
Harald Welte5c3abf92012-07-08 16:48:11 +0200593 struct {
594 int hr;
595 int mn;
596 int override;
597 } tz;
Gus Bourgf9dc16b2011-12-02 10:18:17 +0100598
Harald Welte3da6b3f2011-05-25 13:10:08 +0200599 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
600 union {
601 struct {
602 uint16_t site_id;
603 uint16_t bts_id;
604 uint32_t flags;
Harald Welte8b3c5952013-03-12 13:57:05 +0100605 uint32_t rsl_ip;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200606 } ip_access;
607 struct {
608 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200609 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200610 } cclk;
611 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200612 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200613 } rack;
614 struct gsm_envabtse envabtse[4];
615 } bs11;
616 struct {
617 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200618 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200619 struct llist_head conn_groups;
620 } is;
621 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200622 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200623 struct llist_head conn_groups;
624 } con;
625 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200626 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200627 } dp;
628 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200629 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200630 } tf;
631 } rbs2000;
632 struct {
Harald Welte3a070b92011-07-28 00:22:17 +0200633 uint8_t bts_type;
Holger Hans Peter Freythera6ca2372012-03-02 14:14:33 +0100634 unsigned int configured:1,
635 skip_reset:1,
636 did_reset:1,
637 wait_reset:1;
Harald Welte3a070b92011-07-28 00:22:17 +0200638 struct osmo_timer_list reset_timer;
639 } nokia;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200640 };
641
642 /* Not entirely sure how ip.access specific this is */
643 struct {
644 enum bts_gprs_mode mode;
645 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200646 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200647 uint16_t nsei;
648 uint8_t timer[7];
649 } nse;
650 struct {
Harald Welte69f6f812011-05-30 12:07:53 +0200651 struct gsm_abis_mo mo;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200652 uint16_t bvci;
653 uint8_t timer[11];
Harald Welte1c6955a2012-06-28 08:43:14 +0200654 struct gprs_rlc_cfg rlc_cfg;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200655 } cell;
656 struct gsm_bts_gprs_nsvc nsvc[2];
657 uint8_t rac;
Andreas Eversberga4fa21c2013-03-16 16:31:26 +0100658 uint8_t net_ctrl_ord;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200659 } gprs;
660
661 /* RACH NM values */
662 int rach_b_thresh;
663 int rach_ldavg_slots;
664
665 /* transceivers */
666 int num_trx;
667 struct llist_head trx_list;
668
669#ifdef ROLE_BSC
670 /* Abis NM queue */
671 struct llist_head abis_queue;
672 int abis_nm_pend;
673
674 struct gsm_network *network;
675
676 /* should the channel allocator allocate channels from high TRX to TRX0,
677 * rather than starting from TRX0 and go upwards? */
678 int chan_alloc_reverse;
679
680 enum neigh_list_manual_mode neigh_list_manual_mode;
681 /* parameters from which we build SYSTEM INFORMATION */
682 struct {
683 struct gsm48_rach_control rach_control;
684 uint8_t ncc_permitted;
685 struct gsm48_cell_sel_par cell_sel_par;
686 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
687 struct gsm48_cell_options cell_options;
688 struct gsm48_control_channel_descr chan_desc;
689 struct bitvec neigh_list;
690 struct bitvec cell_alloc;
691 struct bitvec si5_neigh_list;
692 struct {
693 /* bitmask large enough for all possible ARFCN's */
694 uint8_t neigh_list[1024/8];
695 uint8_t cell_alloc[1024/8];
696 /* If the user wants a different neighbor list in SI5 than in SI2 */
697 uint8_t si5_neigh_list[1024/8];
698 } data;
699 } si_common;
700
701 /* do we use static (user-defined) system information messages? (bitmask) */
702 uint32_t si_mode_static;
Holger Hans Peter Freyther10799162012-07-20 10:27:31 +0200703
704 /* exclude the BTS from the global RF Lock handling */
705 int excl_from_rf_lock;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200706#endif /* ROLE_BSC */
Harald Weltec6ed9282011-06-06 18:31:20 +0200707 void *role;
Harald Welte3da6b3f2011-05-25 13:10:08 +0200708};
709
710
Harald Weltec7881282011-06-05 13:31:33 +0200711struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte3da6b3f2011-05-25 13:10:08 +0200712struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
713
Harald Welte60732162011-09-19 14:21:51 +0200714struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte3da6b3f2011-05-25 13:10:08 +0200715
Harald Welte2addf852012-08-17 12:42:06 +0200716
717const struct value_string gsm_pchant_names[10];
718const struct value_string gsm_pchant_descs[10];
719const struct value_string gsm_lchant_names[6];
Harald Welte3da6b3f2011-05-25 13:10:08 +0200720const char *gsm_pchan_name(enum gsm_phys_chan_config c);
721enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
722const char *gsm_lchant_name(enum gsm_chan_t c);
723const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte60732162011-09-19 14:21:51 +0200724char *gsm_trx_name(const struct gsm_bts_trx *trx);
725char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
726char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte3da6b3f2011-05-25 13:10:08 +0200727const char *gsm_lchans_name(enum gsm_lchan_state s);
728
Harald Welte3da6b3f2011-05-25 13:10:08 +0200729
Harald Welte452119d2011-06-29 16:49:03 +0200730void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
731
Harald Weltec6ed9282011-06-06 18:31:20 +0200732struct gsm_abis_mo *
733gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte60732162011-09-19 14:21:51 +0200734 const struct abis_om_obj_inst *obj_inst);
Harald Weltec6ed9282011-06-06 18:31:20 +0200735
736struct gsm_nm_state *
737gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte60732162011-09-19 14:21:51 +0200738 const struct abis_om_obj_inst *obj_inst);
Harald Weltec6ed9282011-06-06 18:31:20 +0200739void *
740gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte60732162011-09-19 14:21:51 +0200741 const struct abis_om_obj_inst *obj_inst);
Harald Weltec6ed9282011-06-06 18:31:20 +0200742
Harald Welte452119d2011-06-29 16:49:03 +0200743/* reset the state of all MO in the BTS */
744void gsm_bts_mo_reset(struct gsm_bts *bts);
745
Harald Weltee6d51f92011-06-25 10:02:33 +0200746uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
747uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
748
Holger Hans Peter Freyther1c14d962011-06-09 21:48:49 +0200749/*
750 * help with parsing regexps
751 */
752int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
753 int argc, const char **argv) __attribute__ ((warn_unused_result));
754
755
756
Harald Welte3da6b3f2011-05-25 13:10:08 +0200757#endif