blob: ba431da033efce7a12d374b5f2adec5483f90081 [file] [log] [blame]
Harald Welte6be350c2011-05-25 13:10:08 +02001#ifndef _GSM_DATA_SHAREDH
2#define _GSM_DATA_SHAREDH
3
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +02004#include <regex.h>
Harald Welte6be350c2011-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 Welte3300c012011-06-05 13:31:33 +020018#include <osmocom/gsm/protocol/gsm_12_21.h>
Harald Welte6be350c2011-05-25 13:10:08 +020019
Harald Welte0eae6132011-08-24 13:52:07 +020020#include <osmocom/abis/e1_input.h>
21
Holger Hans Peter Freyther0e0a09c2012-12-20 19:03:18 +010022#ifndef ROLE_BSC
23#include <osmocom/gsm/lapdm.h>
24#endif
25
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +020026struct osmo_bsc_data;
27
Harald Welte6be350c2011-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 Welte135a6bd2011-09-04 13:53:26 +020085struct osmo_rtp_socket;
Harald Welte6be350c2011-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 Welted64c0bc2011-05-30 12:07:53 +020096struct gsm_abis_mo {
Harald Welte3300c012011-06-05 13:31:33 +020097 uint8_t obj_class;
98 struct abis_om_obj_inst obj_inst;
Harald Welted64c0bc2011-05-30 12:07:53 +020099 const char *name;
100 struct gsm_nm_state nm_state;
101 struct tlv_parsed *nm_attr;
Harald Welte32bc1162011-06-06 18:58:48 +0200102 struct gsm_bts *bts;
Harald Welted64c0bc2011-05-30 12:07:53 +0200103};
104
Harald Welte6be350c2011-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 Freytherded02682012-01-15 00:02:17 +0100119 LCHAN_S_ACT_REQ, /* channel activation requested */
Harald Welte6be350c2011-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 Freyther638da512012-12-06 19:25:06 +0100123 LCHAN_S_BROKEN, /* channel is somehow unusable */
Harald Welte6be350c2011-05-25 13:10:08 +0200124 LCHAN_S_INACTIVE, /* channel is set inactive */
125};
126
Harald Weltec7921c92011-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 Weltef3b59322011-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 Weltec7921c92011-06-29 10:38:34 +0200155/* /BTS ONLY */
156
Harald Weltee4227982012-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
Harald Welte6be350c2011-05-25 13:10:08 +0200169struct gsm_lchan {
170 /* The TS that we're part of */
171 struct gsm_bts_trx_ts *ts;
172 /* The logical subslot number in the TS */
173 uint8_t nr;
174 /* The logical channel type */
175 enum gsm_chan_t type;
176 /* RSL channel mode */
177 enum rsl_cmod_spd rsl_cmode;
178 /* If TCH, traffic channel mode */
179 enum gsm48_chan_mode tch_mode;
Harald Weltee4227982012-08-24 15:33:56 +0200180 enum lchan_csd_mode csd_mode;
Harald Welte6be350c2011-05-25 13:10:08 +0200181 /* State */
182 enum gsm_lchan_state state;
183 /* Power levels for MS and BTS */
184 uint8_t bs_power;
185 uint8_t ms_power;
186 /* Encryption information */
187 struct {
188 uint8_t alg_id;
189 uint8_t key_len;
190 uint8_t key[MAX_A5_KEY_LEN];
191 } encr;
192
193 /* AMR bits */
194 struct gsm48_multi_rate_conf mr_conf;
195
196 /* Established data link layer services */
197 uint8_t sapis[8];
Holger Hans Peter Freytherafa0ad12012-04-18 18:58:36 +0200198 int sacch_deact;
Holger Hans Peter Freytherdfcfe652011-12-27 20:49:53 +0100199
Harald Welte6be350c2011-05-25 13:10:08 +0200200 struct {
201 uint32_t bound_ip;
202 uint32_t connect_ip;
203 uint16_t bound_port;
204 uint16_t connect_port;
205 uint16_t conn_id;
206 uint8_t rtp_payload;
207 uint8_t rtp_payload2;
208 uint8_t speech_mode;
Harald Welte135a6bd2011-09-04 13:53:26 +0200209#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200210 struct rtp_socket *rtp_socket;
Harald Welte135a6bd2011-09-04 13:53:26 +0200211#else
212 struct osmo_rtp_socket *rtp_socket;
213#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200214 } abis_ip;
215
Harald Welte2c1ae472011-06-26 14:13:37 +0200216 uint8_t rqd_ta;
217
Harald Welte6be350c2011-05-25 13:10:08 +0200218#ifdef ROLE_BSC
219 struct osmo_timer_list T3101;
Holger Hans Peter Freytherb3489392011-12-28 16:21:05 +0100220 struct osmo_timer_list T3109;
Harald Welte6be350c2011-05-25 13:10:08 +0200221 struct osmo_timer_list T3111;
222 struct osmo_timer_list error_timer;
Harald Weltee8bd9e82011-08-10 23:26:33 +0200223 struct osmo_timer_list act_timer;
Holger Hans Peter Freyther638da512012-12-06 19:25:06 +0100224 uint8_t error_cause;
Harald Welte6be350c2011-05-25 13:10:08 +0200225
226 /* table of neighbor cell measurements */
227 struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS];
228
229 /* cache of last measurement reports on this lchan */
230 struct gsm_meas_rep meas_rep[6];
231 int meas_rep_idx;
232
233 /* GSM Random Access data */
234 struct gsm48_req_ref *rqd_ref;
Harald Welte6be350c2011-05-25 13:10:08 +0200235
236 struct gsm_subscriber_connection *conn;
Harald Weltef6093a42011-06-25 10:02:33 +0200237#else
238 struct lapdm_channel lapdm_ch;
Harald Welte135a6bd2011-09-04 13:53:26 +0200239 struct llist_head dl_tch_queue;
Harald Welte2c1ae472011-06-26 14:13:37 +0200240 struct {
241 /* bitmask of all SI that are present/valid in si_buf */
242 uint32_t valid;
243 uint32_t last;
244 /* buffers where we put the pre-computed SI */
245 sysinfo_buf_t buf[_MAX_SYSINFO_TYPE];
246 } si;
Harald Weltec7921c92011-06-29 10:38:34 +0200247 struct {
248 uint8_t flags;
249 /* RSL measurment result number, 0 at lchan_act */
250 uint8_t res_nr;
251 /* current Tx power level of the BTS */
252 uint8_t bts_tx_pwr;
253 /* number of measurements stored in array below */
254 uint8_t num_ul_meas;
255 struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
256 /* last L1 header from the MS */
257 uint8_t l1_info[2];
258 struct {
259 uint8_t rxlev_full;
260 uint8_t rxlev_sub;
261 uint8_t rxqual_full;
262 uint8_t rxqual_sub;
263 } res;
264 } meas;
Harald Weltef3b59322011-09-06 22:14:43 +0200265 struct {
266 struct amr_multirate_conf amr_mr;
Harald Welte43290992011-09-07 12:41:38 +0200267 struct {
268 uint8_t buf[16];
269 uint8_t len;
270 } last_sid;
Harald Weltef3b59322011-09-06 22:14:43 +0200271 } tch;
Harald Welte5d52c972012-04-08 20:23:28 +0200272 /* BTS-side ciphering state (rx only, bi-directional, ...) */
273 uint8_t ciph_state;
Harald Welte46cb8512012-04-19 23:13:35 +0200274 uint8_t loopback;
Harald Welte704cb862012-06-16 14:57:08 +0800275 struct {
276 uint8_t active;
277 uint8_t ref;
278 /* T3105: PHYS INF retransmission */
279 struct osmo_timer_list t3105;
280 /* counts up to Ny1 */
281 unsigned int phys_info_count;
282 } ho;
Harald Welte6be350c2011-05-25 13:10:08 +0200283#endif
284};
285
Harald Welte6be350c2011-05-25 13:10:08 +0200286#define TS_F_PDCH_MODE 0x1000
287/* One Timeslot in a TRX */
288struct gsm_bts_trx_ts {
289 struct gsm_bts_trx *trx;
290 /* number of this timeslot at the TRX */
291 uint8_t nr;
292
293 enum gsm_phys_chan_config pchan;
294
295 unsigned int flags;
Harald Welted64c0bc2011-05-30 12:07:53 +0200296 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200297 struct tlv_parsed nm_attr;
298 uint8_t nm_chan_comb;
Harald Welte135a6482011-05-30 12:09:13 +0200299 int tsc; /* -1 == use BTS TSC */
Harald Welte6be350c2011-05-25 13:10:08 +0200300
301 struct {
302 /* Parameters below are configured by VTY */
303 int enabled;
304 uint8_t maio;
305 uint8_t hsn;
306 struct bitvec arfcns;
307 uint8_t arfcns_data[1024/8];
308 /* This is the pre-computed MA for channel assignments */
309 struct bitvec ma;
310 uint8_t ma_len; /* part of ma_data that is used */
311 uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */
312 } hopping;
313
314 /* To which E1 subslot are we connected */
315 struct gsm_e1_subslot e1_link;
316
317 struct gsm_lchan lchan[TS_MAX_LCHAN];
318};
319
320/* One TRX in a BTS */
321struct gsm_bts_trx {
322 /* list header in bts->trx_list */
323 struct llist_head list;
324
325 struct gsm_bts *bts;
326 /* number of this TRX in the BTS */
327 uint8_t nr;
328 /* human readable name / description */
329 char *description;
330 /* how do we talk RSL with this TRX? */
331 struct gsm_e1_subslot rsl_e1_link;
332 uint8_t rsl_tei;
Holger Hans Peter Freyther523a99d2012-01-17 15:52:45 +0100333#ifdef ROLE_BSC
Harald Welte6be350c2011-05-25 13:10:08 +0200334 struct e1inp_sign_link *rsl_link;
Holger Hans Peter Freyther523a99d2012-01-17 15:52:45 +0100335#else
336 struct ipabis_link *rsl_link;
337#endif
Harald Welte6be350c2011-05-25 13:10:08 +0200338 /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */
339 struct e1inp_sign_link *oml_link;
340
Harald Welted64c0bc2011-05-30 12:07:53 +0200341 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200342 struct tlv_parsed nm_attr;
343 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200344 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200345 } bb_transc;
346
347 uint16_t arfcn;
348 int nominal_power; /* in dBm */
349 unsigned int max_power_red; /* in actual dB */
350
Harald Welted134cc72011-06-07 00:12:53 +0200351 struct {
352 void *l1h;
353 } role_bts;
354
Harald Welte6be350c2011-05-25 13:10:08 +0200355 union {
356 struct {
357 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200358 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200359 } bbsig;
360 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200361 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200362 } pa;
363 } bs11;
364 struct {
365 unsigned int test_state;
366 uint8_t test_nr;
367 struct rxlev_stats rxlev_stat;
368 } ipaccess;
369 };
370 struct gsm_bts_trx_ts ts[TRX_NR_TS];
371};
372
373#define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i])
374
375enum gsm_bts_type {
376 GSM_BTS_TYPE_UNKNOWN,
377 GSM_BTS_TYPE_BS11,
378 GSM_BTS_TYPE_NANOBTS,
379 GSM_BTS_TYPE_RBS2000,
380 GSM_BTS_TYPE_HSL_FEMTO,
Dieter Spaar16646022011-07-28 00:01:50 +0200381 GSM_BTS_TYPE_NOKIA_SITE,
Harald Weltef383aa12012-07-02 19:51:55 +0200382 GSM_BTS_TYPE_OSMO_SYSMO,
Harald Weltee555c2b2012-08-17 13:02:12 +0200383 _NUM_GSM_BTS_TYPE
Harald Welte6be350c2011-05-25 13:10:08 +0200384};
385
386struct vty;
387
388struct gsm_bts_model {
389 struct llist_head list;
390
391 enum gsm_bts_type type;
392 const char *name;
393
394 bool started;
395 int (*start)(struct gsm_network *net);
396 int (*oml_rcvmsg)(struct msgb *msg);
397
Pablo Neira Ayusoed5cacb2011-08-17 22:44:07 +0200398 void (*e1line_bind_ops)(struct e1inp_line *line);
399
Harald Welte6be350c2011-05-25 13:10:08 +0200400 void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts);
401 void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx);
402 void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts);
403
404 struct tlv_definition nm_att_tlvdef;
405
406 struct bitvec features;
407 uint8_t _features_data[128/8];
408};
409
410enum gsm_bts_features {
411 BTS_FEAT_HSCSD,
412 BTS_FEAT_GPRS,
413 BTS_FEAT_EGPRS,
414 BTS_FEAT_ECSD,
415 BTS_FEAT_HOPPING,
416};
417
418/*
419 * This keeps track of the paging status of one BTS. It
420 * includes a number of pending requests, a back pointer
421 * to the gsm_bts, a timer and some more state.
422 */
423struct gsm_bts_paging_state {
424 /* pending requests */
425 struct llist_head pending_requests;
426 struct gsm_bts *bts;
427
428 struct osmo_timer_list work_timer;
429 struct osmo_timer_list credit_timer;
430
431 /* free chans needed */
432 int free_chans_need;
433
434 /* load */
435 uint16_t available_slots;
436};
437
438struct gsm_envabtse {
Harald Welted64c0bc2011-05-30 12:07:53 +0200439 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200440};
441
442struct gsm_bts_gprs_nsvc {
443 struct gsm_bts *bts;
444 /* data read via VTY config file, to configure the BTS
445 * via OML from BSC */
446 int id;
447 uint16_t nsvci;
448 uint16_t local_port; /* on the BTS */
449 uint16_t remote_port; /* on the SGSN */
450 uint32_t remote_ip; /* on the SGSN */
451
Harald Welted64c0bc2011-05-30 12:07:53 +0200452 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200453};
454
Harald Welte019f9132012-06-28 08:43:14 +0200455enum gprs_rlc_par {
456 RLC_T3142,
457 RLC_T3169,
458 RLC_T3191,
459 RLC_T3193,
460 RLC_T3195,
461 RLC_N3101,
462 RLC_N3103,
463 RLC_N3105,
464 CV_COUNTDOWN,
465 T_DL_TBF_EXT, /* ms */
466 T_UL_TBF_EXT, /* ms */
467 _NUM_RLC_PAR
468};
469
470enum gprs_cs {
471 GPRS_CS1,
472 GPRS_CS2,
473 GPRS_CS3,
474 GPRS_CS4,
475 GPRS_MCS1,
476 GPRS_MCS2,
477 GPRS_MCS3,
478 GPRS_MCS4,
479 GPRS_MCS5,
480 GPRS_MCS6,
481 GPRS_MCS7,
482 GPRS_MCS8,
483 GPRS_MCS9,
484 _NUM_GRPS_CS
485};
486
487struct gprs_rlc_cfg {
488 uint16_t parameter[_NUM_RLC_PAR];
489 struct {
490 uint16_t repeat_time; /* ms */
491 uint8_t repeat_count;
492 } paging;
493 uint32_t cs_mask; /* bitmask of gprs_cs */
494 uint8_t initial_cs;
495 uint8_t initial_mcs;
496};
497
498
Harald Welte6be350c2011-05-25 13:10:08 +0200499enum neigh_list_manual_mode {
500 NL_MODE_AUTOMATIC = 0,
501 NL_MODE_MANUAL = 1,
502 NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */
503};
504
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200505enum bts_loc_fix {
506 BTS_LOC_FIX_INVALID = 0,
507 BTS_LOC_FIX_2D = 1,
508 BTS_LOC_FIX_3D = 2,
509};
510
511struct bts_location {
512 struct llist_head list;
513 time_t tstamp;
514 enum bts_loc_fix valid;
515 double lat;
516 double lon;
517 double height;
518};
519
Harald Welte6be350c2011-05-25 13:10:08 +0200520/* One BTS */
521struct gsm_bts {
522 /* list header in net->bts_list */
523 struct llist_head list;
524
Daniel Willmann47b5b3e2011-08-05 13:51:27 +0200525 /* Geographical location of the BTS */
526 struct llist_head loc_list;
527
Harald Welte6be350c2011-05-25 13:10:08 +0200528 /* number of ths BTS in network */
529 uint8_t nr;
530 /* human readable name / description */
531 char *description;
532 /* Cell Identity */
533 uint16_t cell_identity;
534 /* location area code of this BTS */
535 uint16_t location_area_code;
536 /* Training Sequence Code */
537 uint8_t tsc;
538 /* Base Station Identification Code (BSIC) */
539 uint8_t bsic;
540 /* type of BTS */
541 enum gsm_bts_type type;
542 struct gsm_bts_model *model;
543 enum gsm_band band;
544 /* maximum Tx power that the MS is permitted to use in this cell */
545 int ms_max_power;
546
547 /* how do we talk OML with this TRX? */
548 struct gsm_e1_subslot oml_e1_link;
549 uint8_t oml_tei;
550 struct e1inp_sign_link *oml_link;
551
552 /* Abis network management O&M handle */
553 struct abis_nm_h *nmh;
Harald Welted64c0bc2011-05-30 12:07:53 +0200554
555 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200556
557 /* number of this BTS on given E1 link */
558 uint8_t bts_nr;
559
560 /* paging state and control */
561 struct gsm_bts_paging_state paging;
562
563 /* CCCH is on C0 */
564 struct gsm_bts_trx *c0;
565
566 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200567 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200568 } site_mgr;
569
570 /* bitmask of all SI that are present/valid in si_buf */
571 uint32_t si_valid;
572 /* buffers where we put the pre-computed SI */
573 sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE];
574
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100575 /* TimeZone hours, mins, and bts specific */
Harald Welte45f91712012-07-08 16:48:11 +0200576 struct {
577 int hr;
578 int mn;
579 int override;
580 } tz;
Gus Bourg1c5dd2c2011-12-02 10:18:17 +0100581
Harald Welte6be350c2011-05-25 13:10:08 +0200582 /* ip.accesss Unit ID's have Site/BTS/TRX layout */
583 union {
584 struct {
585 uint16_t site_id;
586 uint16_t bts_id;
587 uint32_t flags;
588 } ip_access;
589 struct {
590 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200591 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200592 } cclk;
593 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200594 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200595 } rack;
596 struct gsm_envabtse envabtse[4];
597 } bs11;
598 struct {
599 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200600 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200601 struct llist_head conn_groups;
602 } is;
603 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200604 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200605 struct llist_head conn_groups;
606 } con;
607 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200608 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200609 } dp;
610 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200611 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200612 } tf;
613 } rbs2000;
614 struct {
615 unsigned long serno;
616 } hsl;
Harald Weltec8755af2011-07-28 00:22:17 +0200617 struct {
618 uint8_t bts_type;
Holger Hans Peter Freyther3e603482012-03-02 14:14:33 +0100619 unsigned int configured:1,
620 skip_reset:1,
621 did_reset:1,
622 wait_reset:1;
Harald Weltec8755af2011-07-28 00:22:17 +0200623 struct osmo_timer_list reset_timer;
624 } nokia;
Harald Welte6be350c2011-05-25 13:10:08 +0200625 };
626
627 /* Not entirely sure how ip.access specific this is */
628 struct {
629 enum bts_gprs_mode mode;
630 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200631 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200632 uint16_t nsei;
633 uint8_t timer[7];
634 } nse;
635 struct {
Harald Welted64c0bc2011-05-30 12:07:53 +0200636 struct gsm_abis_mo mo;
Harald Welte6be350c2011-05-25 13:10:08 +0200637 uint16_t bvci;
638 uint8_t timer[11];
Harald Welte019f9132012-06-28 08:43:14 +0200639 struct gprs_rlc_cfg rlc_cfg;
Harald Welte6be350c2011-05-25 13:10:08 +0200640 } cell;
641 struct gsm_bts_gprs_nsvc nsvc[2];
642 uint8_t rac;
643 } gprs;
644
645 /* RACH NM values */
646 int rach_b_thresh;
647 int rach_ldavg_slots;
648
649 /* transceivers */
650 int num_trx;
651 struct llist_head trx_list;
652
653#ifdef ROLE_BSC
654 /* Abis NM queue */
655 struct llist_head abis_queue;
656 int abis_nm_pend;
657
658 struct gsm_network *network;
659
660 /* should the channel allocator allocate channels from high TRX to TRX0,
661 * rather than starting from TRX0 and go upwards? */
662 int chan_alloc_reverse;
663
664 enum neigh_list_manual_mode neigh_list_manual_mode;
665 /* parameters from which we build SYSTEM INFORMATION */
666 struct {
667 struct gsm48_rach_control rach_control;
668 uint8_t ncc_permitted;
669 struct gsm48_cell_sel_par cell_sel_par;
670 struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */
671 struct gsm48_cell_options cell_options;
672 struct gsm48_control_channel_descr chan_desc;
673 struct bitvec neigh_list;
674 struct bitvec cell_alloc;
675 struct bitvec si5_neigh_list;
676 struct {
677 /* bitmask large enough for all possible ARFCN's */
678 uint8_t neigh_list[1024/8];
679 uint8_t cell_alloc[1024/8];
680 /* If the user wants a different neighbor list in SI5 than in SI2 */
681 uint8_t si5_neigh_list[1024/8];
682 } data;
683 } si_common;
684
685 /* do we use static (user-defined) system information messages? (bitmask) */
686 uint32_t si_mode_static;
687#endif /* ROLE_BSC */
Harald Welte978714d2011-06-06 18:31:20 +0200688 void *role;
Harald Welte6be350c2011-05-25 13:10:08 +0200689};
690
691
Harald Welte3300c012011-06-05 13:31:33 +0200692struct gsm_bts *gsm_bts_alloc(void *talloc_ctx);
Harald Welte6be350c2011-05-25 13:10:08 +0200693struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts);
694
Harald Welte4f8ad532011-09-19 14:21:51 +0200695struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num);
Harald Welte6be350c2011-05-25 13:10:08 +0200696
Harald Welte4ab9d7c2012-08-17 12:42:06 +0200697
698const struct value_string gsm_pchant_names[10];
699const struct value_string gsm_pchant_descs[10];
700const struct value_string gsm_lchant_names[6];
Harald Welte6be350c2011-05-25 13:10:08 +0200701const char *gsm_pchan_name(enum gsm_phys_chan_config c);
702enum gsm_phys_chan_config gsm_pchan_parse(const char *name);
703const char *gsm_lchant_name(enum gsm_chan_t c);
704const char *gsm_chreq_name(enum gsm_chreq_reason_t c);
Harald Welte4f8ad532011-09-19 14:21:51 +0200705char *gsm_trx_name(const struct gsm_bts_trx *trx);
706char *gsm_ts_name(const struct gsm_bts_trx_ts *ts);
707char *gsm_lchan_name(const struct gsm_lchan *lchan);
Harald Welte6be350c2011-05-25 13:10:08 +0200708const char *gsm_lchans_name(enum gsm_lchan_state s);
709
Harald Welte6be350c2011-05-25 13:10:08 +0200710
Harald Welteb7849982011-06-29 16:49:03 +0200711void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
712
Harald Welte978714d2011-06-06 18:31:20 +0200713struct gsm_abis_mo *
714gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200715 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200716
717struct gsm_nm_state *
718gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200719 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200720void *
721gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class,
Harald Welte4f8ad532011-09-19 14:21:51 +0200722 const struct abis_om_obj_inst *obj_inst);
Harald Welte978714d2011-06-06 18:31:20 +0200723
Harald Welteb7849982011-06-29 16:49:03 +0200724/* reset the state of all MO in the BTS */
725void gsm_bts_mo_reset(struct gsm_bts *bts);
726
Harald Weltef6093a42011-06-25 10:02:33 +0200727uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr);
728uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan);
729
Holger Hans Peter Freyther06c9da62011-06-09 21:48:49 +0200730/*
731 * help with parsing regexps
732 */
733int gsm_parse_reg(void *ctx, regex_t *reg, char **str,
734 int argc, const char **argv) __attribute__ ((warn_unused_result));
735
736
737
Harald Welte6be350c2011-05-25 13:10:08 +0200738#endif