Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1 | #ifndef _GSM_DATA_SHAREDH |
| 2 | #define _GSM_DATA_SHAREDH |
| 3 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 4 | #include <regex.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 5 | #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 Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 18 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 19 | |
Harald Welte | 0eae613 | 2011-08-24 13:52:07 +0200 | [diff] [blame] | 20 | #include <osmocom/abis/e1_input.h> |
| 21 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 22 | struct osmo_msc_data; |
| 23 | struct osmo_bsc_sccp_con; |
| 24 | struct gsm_sms_queue; |
| 25 | |
| 26 | /* RRLP mode of operation */ |
| 27 | enum rrlp_mode { |
| 28 | RRLP_MODE_NONE, |
| 29 | RRLP_MODE_MS_BASED, |
| 30 | RRLP_MODE_MS_PREF, |
| 31 | RRLP_MODE_ASS_PREF, |
| 32 | }; |
| 33 | |
| 34 | /* Channel Request reason */ |
| 35 | enum gsm_chreq_reason_t { |
| 36 | GSM_CHREQ_REASON_EMERG, |
| 37 | GSM_CHREQ_REASON_PAG, |
| 38 | GSM_CHREQ_REASON_CALL, |
| 39 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 40 | GSM_CHREQ_REASON_OTHER, |
| 41 | }; |
| 42 | |
| 43 | #define TRX_NR_TS 8 |
| 44 | #define TS_MAX_LCHAN 8 |
| 45 | |
| 46 | #define HARDCODED_ARFCN 123 |
| 47 | #define HARDCODED_TSC 7 |
| 48 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 49 | |
| 50 | /* for multi-drop config */ |
| 51 | #define HARDCODED_BTS0_TS 1 |
| 52 | #define HARDCODED_BTS1_TS 6 |
| 53 | #define HARDCODED_BTS2_TS 11 |
| 54 | |
| 55 | /* reserved according to GSM 03.03 ยง 2.4 */ |
| 56 | #define GSM_RESERVED_TMSI 0xFFFFFFFF |
| 57 | |
| 58 | enum gsm_hooks { |
| 59 | GSM_HOOK_NM_SWLOAD, |
| 60 | GSM_HOOK_RR_PAGING, |
| 61 | GSM_HOOK_RR_SECURITY, |
| 62 | }; |
| 63 | |
| 64 | enum gsm_paging_event { |
| 65 | GSM_PAGING_SUCCEEDED, |
| 66 | GSM_PAGING_EXPIRED, |
| 67 | GSM_PAGING_OOM, |
| 68 | GSM_PAGING_BUSY, |
| 69 | }; |
| 70 | |
| 71 | enum bts_gprs_mode { |
| 72 | BTS_GPRS_NONE = 0, |
| 73 | BTS_GPRS_GPRS = 1, |
| 74 | BTS_GPRS_EGPRS = 2, |
| 75 | }; |
| 76 | |
| 77 | struct gsm_lchan; |
| 78 | struct gsm_subscriber; |
| 79 | struct gsm_mncc; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 80 | struct osmo_rtp_socket; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 81 | struct rtp_socket; |
| 82 | struct bsc_api; |
| 83 | |
| 84 | /* Network Management State */ |
| 85 | struct gsm_nm_state { |
| 86 | uint8_t operational; |
| 87 | uint8_t administrative; |
| 88 | uint8_t availability; |
| 89 | }; |
| 90 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 91 | struct gsm_abis_mo { |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 92 | uint8_t obj_class; |
| 93 | struct abis_om_obj_inst obj_inst; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 94 | const char *name; |
| 95 | struct gsm_nm_state nm_state; |
| 96 | struct tlv_parsed *nm_attr; |
Harald Welte | 32bc116 | 2011-06-06 18:58:48 +0200 | [diff] [blame] | 97 | struct gsm_bts *bts; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 98 | }; |
| 99 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 100 | #define MAX_A5_KEY_LEN (128/8) |
| 101 | #define A38_XOR_MIN_KEY_LEN 12 |
| 102 | #define A38_XOR_MAX_KEY_LEN 16 |
| 103 | #define A38_COMP128_KEY_LEN 16 |
| 104 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 105 | |
| 106 | /* is the data link established? who established it? */ |
| 107 | #define LCHAN_SAPI_UNUSED 0 |
| 108 | #define LCHAN_SAPI_MS 1 |
| 109 | #define LCHAN_SAPI_NET 2 |
| 110 | |
| 111 | /* state of a logical channel */ |
| 112 | enum gsm_lchan_state { |
| 113 | LCHAN_S_NONE, /* channel is not active */ |
| 114 | LCHAN_S_ACT_REQ, /* channel activatin requested */ |
| 115 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
| 116 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
| 117 | LCHAN_S_REL_ERR, /* channel is in an error state */ |
| 118 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 119 | }; |
| 120 | |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 121 | /* BTS ONLY */ |
| 122 | #define MAX_NUM_UL_MEAS 104 |
| 123 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 124 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 125 | |
| 126 | struct bts_ul_meas { |
| 127 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 128 | uint16_t ber10k; |
| 129 | /* timing advance offset (in quarter bits) */ |
| 130 | int16_t ta_offs_qbits; |
| 131 | /* C/I ratio in dB */ |
| 132 | float c_i; |
| 133 | /* flags */ |
| 134 | uint8_t is_sub:1; |
| 135 | /* RSSI in dBm * -1 */ |
| 136 | uint8_t inv_rssi; |
| 137 | }; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 138 | |
| 139 | struct amr_mode { |
| 140 | uint8_t mode; |
| 141 | uint8_t threshold; |
| 142 | uint8_t hysteresis; |
| 143 | }; |
| 144 | struct amr_multirate_conf { |
| 145 | uint8_t gsm48_ie[2]; |
| 146 | struct amr_mode mode[4]; |
| 147 | uint8_t num_modes; |
| 148 | }; |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 149 | /* /BTS ONLY */ |
| 150 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 151 | struct gsm_lchan { |
| 152 | /* The TS that we're part of */ |
| 153 | struct gsm_bts_trx_ts *ts; |
| 154 | /* The logical subslot number in the TS */ |
| 155 | uint8_t nr; |
| 156 | /* The logical channel type */ |
| 157 | enum gsm_chan_t type; |
| 158 | /* RSL channel mode */ |
| 159 | enum rsl_cmod_spd rsl_cmode; |
| 160 | /* If TCH, traffic channel mode */ |
| 161 | enum gsm48_chan_mode tch_mode; |
| 162 | /* State */ |
| 163 | enum gsm_lchan_state state; |
| 164 | /* Power levels for MS and BTS */ |
| 165 | uint8_t bs_power; |
| 166 | uint8_t ms_power; |
| 167 | /* Encryption information */ |
| 168 | struct { |
| 169 | uint8_t alg_id; |
| 170 | uint8_t key_len; |
| 171 | uint8_t key[MAX_A5_KEY_LEN]; |
| 172 | } encr; |
| 173 | |
| 174 | /* AMR bits */ |
| 175 | struct gsm48_multi_rate_conf mr_conf; |
| 176 | |
| 177 | /* Established data link layer services */ |
| 178 | uint8_t sapis[8]; |
| 179 | int sach_deact; |
| 180 | int release_reason; |
| 181 | |
| 182 | struct { |
| 183 | uint32_t bound_ip; |
| 184 | uint32_t connect_ip; |
| 185 | uint16_t bound_port; |
| 186 | uint16_t connect_port; |
| 187 | uint16_t conn_id; |
| 188 | uint8_t rtp_payload; |
| 189 | uint8_t rtp_payload2; |
| 190 | uint8_t speech_mode; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 191 | #ifdef ROLE_BSC |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 192 | struct rtp_socket *rtp_socket; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 193 | #else |
| 194 | struct osmo_rtp_socket *rtp_socket; |
| 195 | #endif |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 196 | } abis_ip; |
| 197 | |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 198 | uint8_t rqd_ta; |
| 199 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 200 | #ifdef ROLE_BSC |
| 201 | struct osmo_timer_list T3101; |
| 202 | struct osmo_timer_list T3111; |
| 203 | struct osmo_timer_list error_timer; |
Harald Welte | e8bd9e8 | 2011-08-10 23:26:33 +0200 | [diff] [blame] | 204 | struct osmo_timer_list act_timer; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 205 | |
| 206 | /* table of neighbor cell measurements */ |
| 207 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 208 | |
| 209 | /* cache of last measurement reports on this lchan */ |
| 210 | struct gsm_meas_rep meas_rep[6]; |
| 211 | int meas_rep_idx; |
| 212 | |
| 213 | /* GSM Random Access data */ |
| 214 | struct gsm48_req_ref *rqd_ref; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 215 | |
| 216 | struct gsm_subscriber_connection *conn; |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 217 | #else |
| 218 | struct lapdm_channel lapdm_ch; |
Harald Welte | 135a6bd | 2011-09-04 13:53:26 +0200 | [diff] [blame] | 219 | struct llist_head dl_tch_queue; |
Harald Welte | 2c1ae47 | 2011-06-26 14:13:37 +0200 | [diff] [blame] | 220 | struct { |
| 221 | /* bitmask of all SI that are present/valid in si_buf */ |
| 222 | uint32_t valid; |
| 223 | uint32_t last; |
| 224 | /* buffers where we put the pre-computed SI */ |
| 225 | sysinfo_buf_t buf[_MAX_SYSINFO_TYPE]; |
| 226 | } si; |
Harald Welte | c7921c9 | 2011-06-29 10:38:34 +0200 | [diff] [blame] | 227 | struct { |
| 228 | uint8_t flags; |
| 229 | /* RSL measurment result number, 0 at lchan_act */ |
| 230 | uint8_t res_nr; |
| 231 | /* current Tx power level of the BTS */ |
| 232 | uint8_t bts_tx_pwr; |
| 233 | /* number of measurements stored in array below */ |
| 234 | uint8_t num_ul_meas; |
| 235 | struct bts_ul_meas uplink[MAX_NUM_UL_MEAS]; |
| 236 | /* last L1 header from the MS */ |
| 237 | uint8_t l1_info[2]; |
| 238 | struct { |
| 239 | uint8_t rxlev_full; |
| 240 | uint8_t rxlev_sub; |
| 241 | uint8_t rxqual_full; |
| 242 | uint8_t rxqual_sub; |
| 243 | } res; |
| 244 | } meas; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 245 | struct { |
| 246 | struct amr_multirate_conf amr_mr; |
Harald Welte | 4329099 | 2011-09-07 12:41:38 +0200 | [diff] [blame] | 247 | struct { |
| 248 | uint8_t buf[16]; |
| 249 | uint8_t len; |
| 250 | } last_sid; |
Harald Welte | f3b5932 | 2011-09-06 22:14:43 +0200 | [diff] [blame] | 251 | } tch; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 252 | #endif |
| 253 | }; |
| 254 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 255 | #define TS_F_PDCH_MODE 0x1000 |
| 256 | /* One Timeslot in a TRX */ |
| 257 | struct gsm_bts_trx_ts { |
| 258 | struct gsm_bts_trx *trx; |
| 259 | /* number of this timeslot at the TRX */ |
| 260 | uint8_t nr; |
| 261 | |
| 262 | enum gsm_phys_chan_config pchan; |
| 263 | |
| 264 | unsigned int flags; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 265 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 266 | struct tlv_parsed nm_attr; |
| 267 | uint8_t nm_chan_comb; |
Harald Welte | 135a648 | 2011-05-30 12:09:13 +0200 | [diff] [blame] | 268 | int tsc; /* -1 == use BTS TSC */ |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 269 | |
| 270 | struct { |
| 271 | /* Parameters below are configured by VTY */ |
| 272 | int enabled; |
| 273 | uint8_t maio; |
| 274 | uint8_t hsn; |
| 275 | struct bitvec arfcns; |
| 276 | uint8_t arfcns_data[1024/8]; |
| 277 | /* This is the pre-computed MA for channel assignments */ |
| 278 | struct bitvec ma; |
| 279 | uint8_t ma_len; /* part of ma_data that is used */ |
| 280 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 281 | } hopping; |
| 282 | |
| 283 | /* To which E1 subslot are we connected */ |
| 284 | struct gsm_e1_subslot e1_link; |
| 285 | |
| 286 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 287 | }; |
| 288 | |
| 289 | /* One TRX in a BTS */ |
| 290 | struct gsm_bts_trx { |
| 291 | /* list header in bts->trx_list */ |
| 292 | struct llist_head list; |
| 293 | |
| 294 | struct gsm_bts *bts; |
| 295 | /* number of this TRX in the BTS */ |
| 296 | uint8_t nr; |
| 297 | /* human readable name / description */ |
| 298 | char *description; |
| 299 | /* how do we talk RSL with this TRX? */ |
| 300 | struct gsm_e1_subslot rsl_e1_link; |
| 301 | uint8_t rsl_tei; |
| 302 | struct e1inp_sign_link *rsl_link; |
| 303 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 304 | struct e1inp_sign_link *oml_link; |
| 305 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 306 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 307 | struct tlv_parsed nm_attr; |
| 308 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 309 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 310 | } bb_transc; |
| 311 | |
| 312 | uint16_t arfcn; |
| 313 | int nominal_power; /* in dBm */ |
| 314 | unsigned int max_power_red; /* in actual dB */ |
| 315 | |
Harald Welte | d134cc7 | 2011-06-07 00:12:53 +0200 | [diff] [blame] | 316 | struct { |
| 317 | void *l1h; |
| 318 | } role_bts; |
| 319 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 320 | union { |
| 321 | struct { |
| 322 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 323 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 324 | } bbsig; |
| 325 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 326 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 327 | } pa; |
| 328 | } bs11; |
| 329 | struct { |
| 330 | unsigned int test_state; |
| 331 | uint8_t test_nr; |
| 332 | struct rxlev_stats rxlev_stat; |
| 333 | } ipaccess; |
| 334 | }; |
| 335 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 336 | }; |
| 337 | |
| 338 | #define GSM_BTS_SI(bts, i) (void *)(bts->si_buf[i]) |
| 339 | |
| 340 | enum gsm_bts_type { |
| 341 | GSM_BTS_TYPE_UNKNOWN, |
| 342 | GSM_BTS_TYPE_BS11, |
| 343 | GSM_BTS_TYPE_NANOBTS, |
| 344 | GSM_BTS_TYPE_RBS2000, |
| 345 | GSM_BTS_TYPE_HSL_FEMTO, |
Dieter Spaar | 1664602 | 2011-07-28 00:01:50 +0200 | [diff] [blame] | 346 | GSM_BTS_TYPE_NOKIA_SITE, |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 347 | }; |
| 348 | |
| 349 | struct vty; |
| 350 | |
| 351 | struct gsm_bts_model { |
| 352 | struct llist_head list; |
| 353 | |
| 354 | enum gsm_bts_type type; |
| 355 | const char *name; |
| 356 | |
| 357 | bool started; |
| 358 | int (*start)(struct gsm_network *net); |
| 359 | int (*oml_rcvmsg)(struct msgb *msg); |
| 360 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 361 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 362 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 363 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 364 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 365 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 366 | |
| 367 | struct tlv_definition nm_att_tlvdef; |
| 368 | |
| 369 | struct bitvec features; |
| 370 | uint8_t _features_data[128/8]; |
| 371 | }; |
| 372 | |
| 373 | enum gsm_bts_features { |
| 374 | BTS_FEAT_HSCSD, |
| 375 | BTS_FEAT_GPRS, |
| 376 | BTS_FEAT_EGPRS, |
| 377 | BTS_FEAT_ECSD, |
| 378 | BTS_FEAT_HOPPING, |
| 379 | }; |
| 380 | |
| 381 | /* |
| 382 | * This keeps track of the paging status of one BTS. It |
| 383 | * includes a number of pending requests, a back pointer |
| 384 | * to the gsm_bts, a timer and some more state. |
| 385 | */ |
| 386 | struct gsm_bts_paging_state { |
| 387 | /* pending requests */ |
| 388 | struct llist_head pending_requests; |
| 389 | struct gsm_bts *bts; |
| 390 | |
| 391 | struct osmo_timer_list work_timer; |
| 392 | struct osmo_timer_list credit_timer; |
| 393 | |
| 394 | /* free chans needed */ |
| 395 | int free_chans_need; |
| 396 | |
| 397 | /* load */ |
| 398 | uint16_t available_slots; |
| 399 | }; |
| 400 | |
| 401 | struct gsm_envabtse { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 402 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 403 | }; |
| 404 | |
| 405 | struct gsm_bts_gprs_nsvc { |
| 406 | struct gsm_bts *bts; |
| 407 | /* data read via VTY config file, to configure the BTS |
| 408 | * via OML from BSC */ |
| 409 | int id; |
| 410 | uint16_t nsvci; |
| 411 | uint16_t local_port; /* on the BTS */ |
| 412 | uint16_t remote_port; /* on the SGSN */ |
| 413 | uint32_t remote_ip; /* on the SGSN */ |
| 414 | |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 415 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 416 | }; |
| 417 | |
| 418 | enum neigh_list_manual_mode { |
| 419 | NL_MODE_AUTOMATIC = 0, |
| 420 | NL_MODE_MANUAL = 1, |
| 421 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 422 | }; |
| 423 | |
| 424 | /* One BTS */ |
| 425 | struct gsm_bts { |
| 426 | /* list header in net->bts_list */ |
| 427 | struct llist_head list; |
| 428 | |
| 429 | /* number of ths BTS in network */ |
| 430 | uint8_t nr; |
| 431 | /* human readable name / description */ |
| 432 | char *description; |
| 433 | /* Cell Identity */ |
| 434 | uint16_t cell_identity; |
| 435 | /* location area code of this BTS */ |
| 436 | uint16_t location_area_code; |
| 437 | /* Training Sequence Code */ |
| 438 | uint8_t tsc; |
| 439 | /* Base Station Identification Code (BSIC) */ |
| 440 | uint8_t bsic; |
| 441 | /* type of BTS */ |
| 442 | enum gsm_bts_type type; |
| 443 | struct gsm_bts_model *model; |
| 444 | enum gsm_band band; |
| 445 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 446 | int ms_max_power; |
| 447 | |
| 448 | /* how do we talk OML with this TRX? */ |
| 449 | struct gsm_e1_subslot oml_e1_link; |
| 450 | uint8_t oml_tei; |
| 451 | struct e1inp_sign_link *oml_link; |
| 452 | |
| 453 | /* Abis network management O&M handle */ |
| 454 | struct abis_nm_h *nmh; |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 455 | |
| 456 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 457 | |
| 458 | /* number of this BTS on given E1 link */ |
| 459 | uint8_t bts_nr; |
| 460 | |
| 461 | /* paging state and control */ |
| 462 | struct gsm_bts_paging_state paging; |
| 463 | |
| 464 | /* CCCH is on C0 */ |
| 465 | struct gsm_bts_trx *c0; |
| 466 | |
| 467 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 468 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 469 | } site_mgr; |
| 470 | |
| 471 | /* bitmask of all SI that are present/valid in si_buf */ |
| 472 | uint32_t si_valid; |
| 473 | /* buffers where we put the pre-computed SI */ |
| 474 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE]; |
| 475 | |
Gus Bourg | 1c5dd2c | 2011-12-02 10:18:17 +0100 | [diff] [blame^] | 476 | /* TimeZone hours, mins, and bts specific */ |
| 477 | int tzhr; |
| 478 | int tzmn; |
| 479 | int tz_bts_specific; |
| 480 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 481 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 482 | union { |
| 483 | struct { |
| 484 | uint16_t site_id; |
| 485 | uint16_t bts_id; |
| 486 | uint32_t flags; |
| 487 | } ip_access; |
| 488 | struct { |
| 489 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 490 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 491 | } cclk; |
| 492 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 493 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 494 | } rack; |
| 495 | struct gsm_envabtse envabtse[4]; |
| 496 | } bs11; |
| 497 | struct { |
| 498 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 499 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 500 | struct llist_head conn_groups; |
| 501 | } is; |
| 502 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 503 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 504 | struct llist_head conn_groups; |
| 505 | } con; |
| 506 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 507 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 508 | } dp; |
| 509 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 510 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 511 | } tf; |
| 512 | } rbs2000; |
| 513 | struct { |
| 514 | unsigned long serno; |
| 515 | } hsl; |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 516 | struct { |
| 517 | uint8_t bts_type; |
| 518 | int configured:1, |
Sylvain Munaut | c951946 | 2011-10-17 14:04:55 +0200 | [diff] [blame] | 519 | skip_reset:1, |
| 520 | did_reset:1, |
Harald Welte | c8755af | 2011-07-28 00:22:17 +0200 | [diff] [blame] | 521 | wait_reset:1; |
| 522 | struct osmo_timer_list reset_timer; |
| 523 | } nokia; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | /* Not entirely sure how ip.access specific this is */ |
| 527 | struct { |
| 528 | enum bts_gprs_mode mode; |
| 529 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 530 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 531 | uint16_t nsei; |
| 532 | uint8_t timer[7]; |
| 533 | } nse; |
| 534 | struct { |
Harald Welte | d64c0bc | 2011-05-30 12:07:53 +0200 | [diff] [blame] | 535 | struct gsm_abis_mo mo; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 536 | uint16_t bvci; |
| 537 | uint8_t timer[11]; |
| 538 | } cell; |
| 539 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 540 | uint8_t rac; |
| 541 | } gprs; |
| 542 | |
| 543 | /* RACH NM values */ |
| 544 | int rach_b_thresh; |
| 545 | int rach_ldavg_slots; |
| 546 | |
| 547 | /* transceivers */ |
| 548 | int num_trx; |
| 549 | struct llist_head trx_list; |
| 550 | |
| 551 | #ifdef ROLE_BSC |
| 552 | /* Abis NM queue */ |
| 553 | struct llist_head abis_queue; |
| 554 | int abis_nm_pend; |
| 555 | |
| 556 | struct gsm_network *network; |
| 557 | |
| 558 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 559 | * rather than starting from TRX0 and go upwards? */ |
| 560 | int chan_alloc_reverse; |
| 561 | |
| 562 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 563 | /* parameters from which we build SYSTEM INFORMATION */ |
| 564 | struct { |
| 565 | struct gsm48_rach_control rach_control; |
| 566 | uint8_t ncc_permitted; |
| 567 | struct gsm48_cell_sel_par cell_sel_par; |
| 568 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 569 | struct gsm48_cell_options cell_options; |
| 570 | struct gsm48_control_channel_descr chan_desc; |
| 571 | struct bitvec neigh_list; |
| 572 | struct bitvec cell_alloc; |
| 573 | struct bitvec si5_neigh_list; |
| 574 | struct { |
| 575 | /* bitmask large enough for all possible ARFCN's */ |
| 576 | uint8_t neigh_list[1024/8]; |
| 577 | uint8_t cell_alloc[1024/8]; |
| 578 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 579 | uint8_t si5_neigh_list[1024/8]; |
| 580 | } data; |
| 581 | } si_common; |
| 582 | |
| 583 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 584 | uint32_t si_mode_static; |
| 585 | #endif /* ROLE_BSC */ |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 586 | void *role; |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 587 | }; |
| 588 | |
| 589 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 590 | struct gsm_bts *gsm_bts_alloc(void *talloc_ctx); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 591 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 592 | |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 593 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 594 | |
| 595 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 596 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 597 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 598 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 599 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 600 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 601 | char *gsm_lchan_name(const struct gsm_lchan *lchan); |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 602 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 603 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 604 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 605 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 606 | |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 607 | struct gsm_abis_mo * |
| 608 | gsm_objclass2mo(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 609 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 610 | |
| 611 | struct gsm_nm_state * |
| 612 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 613 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 614 | void * |
| 615 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
Harald Welte | 4f8ad53 | 2011-09-19 14:21:51 +0200 | [diff] [blame] | 616 | const struct abis_om_obj_inst *obj_inst); |
Harald Welte | 978714d | 2011-06-06 18:31:20 +0200 | [diff] [blame] | 617 | |
Harald Welte | b784998 | 2011-06-29 16:49:03 +0200 | [diff] [blame] | 618 | /* reset the state of all MO in the BTS */ |
| 619 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 620 | |
Harald Welte | f6093a4 | 2011-06-25 10:02:33 +0200 | [diff] [blame] | 621 | uint8_t gsm_ts2chan_nr(const struct gsm_bts_trx_ts *ts, uint8_t lchan_nr); |
| 622 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 623 | |
Holger Hans Peter Freyther | 06c9da6 | 2011-06-09 21:48:49 +0200 | [diff] [blame] | 624 | /* |
| 625 | * help with parsing regexps |
| 626 | */ |
| 627 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 628 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 629 | |
| 630 | |
| 631 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 632 | #endif |