Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_DATA_H |
| 2 | #define _GSM_DATA_H |
| 3 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 5 | #include <regex.h> |
| 6 | #include <sys/types.h> |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 7 | #include <stdbool.h> |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 8 | #include <stdint.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 9 | |
| 10 | #include <osmocom/core/timer.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 11 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 12 | #include <osmocom/core/select.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 13 | #include <osmocom/core/stats.h> |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 14 | #include <osmocom/core/stat_item.h> |
Philipp Maier | 8c498fc | 2018-02-21 13:24:36 +0100 | [diff] [blame] | 15 | #include <osmocom/gsm/bts_features.h> |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 16 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 17 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 18 | #include <osmocom/core/fsm.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 19 | |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 20 | #include <osmocom/crypt/auth.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 21 | |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame] | 22 | #include <osmocom/bsc/rest_octets.h> |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 23 | #include <osmocom/bsc/handover.h> |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 24 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 25 | #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> |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 32 | #include <osmocom/bsc/bsc_msg_filter.h> |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 33 | #include <osmocom/bsc/acc_ramp.h> |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 34 | |
Harald Welte | 74b8cdb | 2018-01-15 19:26:06 +0100 | [diff] [blame] | 35 | struct mgcp_client_conf; |
| 36 | struct mgcp_client; |
| 37 | struct mgcp_ctx; |
Philipp Maier | 39f62bb | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 38 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 39 | /** annotations for msgb ownership */ |
| 40 | #define __uses |
| 41 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 42 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 43 | |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 44 | struct bsc_subscr; |
Neels Hofmeyr | 7b65688 | 2017-07-09 22:09:18 +0200 | [diff] [blame] | 45 | struct gprs_ra_id; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 46 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 47 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 48 | |
Neels Hofmeyr | 0e5d807 | 2017-01-10 00:49:56 +0100 | [diff] [blame] | 49 | #define tmsi_from_string(str) strtoul(str, NULL, 10) |
| 50 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 51 | /* 3-bit long values */ |
| 52 | #define EARFCN_PRIO_INVALID 8 |
| 53 | #define EARFCN_MEAS_BW_INVALID 8 |
| 54 | /* 5-bit long values */ |
| 55 | #define EARFCN_QRXLV_INVALID 32 |
| 56 | #define EARFCN_THRESH_LOW_INVALID 32 |
| 57 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 58 | struct msgb; |
| 59 | typedef int gsm_cbfn(unsigned int hooknum, |
| 60 | unsigned int event, |
| 61 | struct msgb *msg, |
| 62 | void *data, void *param); |
| 63 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 64 | /* Maximum number of neighbor cells whose average we track */ |
| 65 | #define MAX_NEIGH_MEAS 10 |
| 66 | /* Maximum size of the averaging window for neighbor cells */ |
| 67 | #define MAX_WIN_NEIGH_AVG 10 |
Andreas Eversberg | 9869203 | 2013-06-23 10:44:34 +0200 | [diff] [blame] | 68 | /* Maximum number of report history we store */ |
| 69 | #define MAX_MEAS_REP 10 |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 70 | |
| 71 | /* processed neighbor measurements for one cell */ |
| 72 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 73 | uint16_t arfcn; |
| 74 | uint8_t bsic; |
| 75 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 76 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 77 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 78 | }; |
| 79 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 80 | struct gsm_classmark { |
| 81 | bool classmark1_set; |
| 82 | struct gsm48_classmark1 classmark1; |
| 83 | uint8_t classmark2_len; |
| 84 | uint8_t classmark2[3]; |
| 85 | uint8_t classmark3_len; |
| 86 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 87 | }; |
| 88 | |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 89 | enum subscr_sccp_state { |
| 90 | SUBSCR_SCCP_ST_NONE, |
| 91 | SUBSCR_SCCP_ST_WAIT_CONN_CONF, |
| 92 | SUBSCR_SCCP_ST_CONNECTED |
| 93 | }; |
| 94 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 95 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 96 | struct gsm_subscriber_connection { |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 97 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 98 | struct llist_head entry; |
| 99 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 100 | /* FSM instance to control the subscriber connection state (RTP, A) */ |
| 101 | struct osmo_fsm_inst *fi; |
| 102 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 103 | /* libbsc subscriber information (if available) */ |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 104 | struct bsc_subscr *bsub; |
| 105 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 106 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 107 | struct gsm_network *network; |
| 108 | |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 109 | /* the primary / currently active lchan to the BTS/subscriber */ |
| 110 | struct gsm_lchan *lchan; |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 111 | |
| 112 | /* handover information, if a handover is pending for this conn. */ |
| 113 | struct bsc_handover *ho; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 114 | |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 115 | /* timer for assignment handling */ |
| 116 | struct osmo_timer_list T10; |
| 117 | /* the future allocated but not yet used lchan during ASSIGNMENT */ |
| 118 | struct gsm_lchan *secondary_lchan; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 119 | |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 120 | /* buffer/cache for classmark of the ME of the subscriber */ |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 121 | struct gsm_classmark classmark; |
Andreas Eversberg | 935e5d7 | 2013-06-17 11:58:30 +0200 | [diff] [blame] | 122 | |
| 123 | /* Cache DTAP messages during handover/assignment (msgb_enqueue()/msgb_dequeue())*/ |
| 124 | struct llist_head ho_dtap_cache; |
| 125 | unsigned int ho_dtap_cache_len; |
Andreas Eversberg | 084b421 | 2013-05-30 14:12:48 +0200 | [diff] [blame] | 126 | |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 127 | struct { |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 128 | int failures; |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 129 | struct penalty_timers *penalty_timers; |
| 130 | } hodec2; |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 131 | |
| 132 | /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment Request. 3GPP 48.008 |
| 133 | * 3.2.2.103 says: |
| 134 | * The "Codec List (MSC Preferred)" shall not include codecs |
| 135 | * that are not supported by the MS. |
| 136 | * i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed the MS bearer |
| 137 | * capabilities, which the MSC is required to translate into the codec list. */ |
| 138 | struct gsm0808_speech_codec_list codec_list; |
| 139 | bool codec_list_present; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 140 | |
| 141 | /* flag to prevent multiple simultaneous ciphering commands */ |
| 142 | int ciphering_handled; |
| 143 | |
| 144 | /* state related to welcome USSD */ |
| 145 | uint8_t new_subscriber; |
| 146 | |
| 147 | /* state related to osmo_bsc_filter.c */ |
| 148 | struct bsc_filter_state filter_state; |
| 149 | |
| 150 | /* SCCP connection associatd with this subscriber_connection */ |
| 151 | struct { |
| 152 | /* for advanced ping/pong */ |
| 153 | int send_ping; |
| 154 | |
| 155 | /* SCCP connection realted */ |
| 156 | struct bsc_msc_data *msc; |
| 157 | |
| 158 | /* Sigtran connection ID */ |
| 159 | int conn_id; |
| 160 | enum subscr_sccp_state state; |
| 161 | } sccp; |
| 162 | |
| 163 | /* for audio handling */ |
| 164 | struct { |
| 165 | uint16_t cic; |
| 166 | uint32_t rtp_ip; |
| 167 | int rtp_port; |
| 168 | /* RTP address of the remote end (assigned by MSC through assignment request) */ |
| 169 | struct sockaddr_storage aoip_rtp_addr_remote; |
| 170 | |
| 171 | /* Local RTP address (reported back to the MSC by us with the |
| 172 | * assignment complete message) */ |
| 173 | struct sockaddr_storage aoip_rtp_addr_local; |
| 174 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 175 | /* FSM instance to control the BTS sided RTP connection */ |
| 176 | struct osmo_fsm_inst *fi_bts; |
| 177 | |
| 178 | /* FSM instance to control the MSC sided RTP connection */ |
| 179 | struct osmo_fsm_inst *fi_msc; |
| 180 | |
| 181 | /* Endpoint identifier of the MGCP endpoint the connection uses */ |
| 182 | char *mgw_endpoint; |
| 183 | |
| 184 | /* Channel rate flag, FR=1, HR=0, Invalid=-1 */ |
| 185 | int full_rate; |
| 186 | |
| 187 | /* Channel mode flage (signaling or voice channel) */ |
| 188 | enum gsm48_chan_mode chan_mode; |
| 189 | |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 190 | } user_plane; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 191 | }; |
| 192 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 193 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 194 | /* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1: |
| 195 | 4-bit index is used (2#1111 = 10#15) */ |
| 196 | #define SI2Q_MAX_NUM 16 |
| 197 | /* length in bits (for single SI2quater message) */ |
| 198 | #define SI2Q_MAX_LEN 160 |
| 199 | #define SI2Q_MIN_LEN 18 |
| 200 | |
| 201 | struct osmo_bsc_data; |
| 202 | |
| 203 | struct osmo_bsc_sccp_con; |
| 204 | |
| 205 | /* Channel Request reason */ |
| 206 | enum gsm_chreq_reason_t { |
| 207 | GSM_CHREQ_REASON_EMERG, |
| 208 | GSM_CHREQ_REASON_PAG, |
| 209 | GSM_CHREQ_REASON_CALL, |
| 210 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 211 | GSM_CHREQ_REASON_OTHER, |
| 212 | GSM_CHREQ_REASON_PDCH, |
| 213 | }; |
| 214 | |
| 215 | /* lchans 0..3 are SDCCH in combined channel configuration, |
| 216 | use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */ |
| 217 | #define CCCH_LCHAN 4 |
| 218 | |
| 219 | #define TRX_NR_TS 8 |
| 220 | #define TS_MAX_LCHAN 8 |
| 221 | |
| 222 | #define HARDCODED_ARFCN 123 |
| 223 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 224 | |
| 225 | /* for multi-drop config */ |
| 226 | #define HARDCODED_BTS0_TS 1 |
| 227 | #define HARDCODED_BTS1_TS 6 |
| 228 | #define HARDCODED_BTS2_TS 11 |
| 229 | |
| 230 | #define MAX_VERSION_LENGTH 64 |
| 231 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 232 | enum gsm_hooks { |
| 233 | GSM_HOOK_NM_SWLOAD, |
| 234 | GSM_HOOK_RR_PAGING, |
| 235 | GSM_HOOK_RR_SECURITY, |
| 236 | }; |
| 237 | |
| 238 | enum gsm_paging_event { |
| 239 | GSM_PAGING_SUCCEEDED, |
| 240 | GSM_PAGING_EXPIRED, |
| 241 | GSM_PAGING_OOM, |
| 242 | GSM_PAGING_BUSY, |
| 243 | }; |
| 244 | |
| 245 | enum bts_gprs_mode { |
| 246 | BTS_GPRS_NONE = 0, |
| 247 | BTS_GPRS_GPRS = 1, |
| 248 | BTS_GPRS_EGPRS = 2, |
| 249 | }; |
| 250 | |
| 251 | struct gsm_lchan; |
| 252 | struct osmo_rtp_socket; |
| 253 | struct rtp_socket; |
| 254 | struct bsc_api; |
| 255 | |
| 256 | /* Network Management State */ |
| 257 | struct gsm_nm_state { |
| 258 | uint8_t operational; |
| 259 | uint8_t administrative; |
| 260 | uint8_t availability; |
| 261 | }; |
| 262 | |
| 263 | struct gsm_abis_mo { |
| 264 | uint8_t obj_class; |
| 265 | uint8_t procedure_pending; |
| 266 | struct abis_om_obj_inst obj_inst; |
| 267 | const char *name; |
| 268 | struct gsm_nm_state nm_state; |
| 269 | struct tlv_parsed *nm_attr; |
| 270 | struct gsm_bts *bts; |
| 271 | }; |
| 272 | |
| 273 | /* Ericsson OM2000 Managed Object */ |
| 274 | struct abis_om2k_mo { |
| 275 | uint8_t class; |
| 276 | uint8_t bts; |
| 277 | uint8_t assoc_so; |
| 278 | uint8_t inst; |
| 279 | } __attribute__ ((packed)); |
| 280 | |
| 281 | struct om2k_mo { |
| 282 | struct abis_om2k_mo addr; |
| 283 | struct osmo_fsm_inst *fsm; |
| 284 | }; |
| 285 | |
| 286 | #define A38_XOR_MIN_KEY_LEN 12 |
| 287 | #define A38_XOR_MAX_KEY_LEN 16 |
| 288 | #define A38_COMP128_KEY_LEN 16 |
| 289 | #define RSL_ENC_ALG_A5(x) (x+1) |
| 290 | #define MAX_EARFCN_LIST 32 |
| 291 | |
| 292 | /* is the data link established? who established it? */ |
| 293 | #define LCHAN_SAPI_UNUSED 0 |
| 294 | #define LCHAN_SAPI_MS 1 |
| 295 | #define LCHAN_SAPI_NET 2 |
| 296 | #define LCHAN_SAPI_REL 3 |
| 297 | |
| 298 | /* state of a logical channel */ |
| 299 | enum gsm_lchan_state { |
| 300 | LCHAN_S_NONE, /* channel is not active */ |
| 301 | LCHAN_S_ACT_REQ, /* channel activation requested */ |
| 302 | LCHAN_S_ACTIVE, /* channel is active and operational */ |
| 303 | LCHAN_S_REL_REQ, /* channel release has been requested */ |
| 304 | LCHAN_S_REL_ERR, /* channel is in an error state */ |
| 305 | LCHAN_S_BROKEN, /* channel is somehow unusable */ |
| 306 | LCHAN_S_INACTIVE, /* channel is set inactive */ |
| 307 | }; |
| 308 | |
| 309 | /* BTS ONLY */ |
| 310 | #define MAX_NUM_UL_MEAS 104 |
| 311 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 312 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 313 | |
| 314 | struct bts_ul_meas { |
| 315 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 316 | uint16_t ber10k; |
| 317 | /* timing advance offset (in quarter bits) */ |
| 318 | int16_t ta_offs_qbits; |
| 319 | /* C/I ratio in dB */ |
| 320 | float c_i; |
| 321 | /* flags */ |
| 322 | uint8_t is_sub:1; |
| 323 | /* RSSI in dBm * -1 */ |
| 324 | uint8_t inv_rssi; |
| 325 | }; |
| 326 | |
| 327 | struct bts_codec_conf { |
| 328 | uint8_t hr; |
| 329 | uint8_t efr; |
| 330 | uint8_t amr; |
| 331 | }; |
| 332 | |
| 333 | struct amr_mode { |
| 334 | uint8_t mode; |
| 335 | uint8_t threshold; |
| 336 | uint8_t hysteresis; |
| 337 | }; |
| 338 | |
| 339 | struct amr_multirate_conf { |
| 340 | uint8_t gsm48_ie[2]; |
| 341 | struct amr_mode ms_mode[4]; |
| 342 | struct amr_mode bts_mode[4]; |
| 343 | uint8_t num_modes; |
| 344 | }; |
| 345 | /* /BTS ONLY */ |
| 346 | |
| 347 | enum lchan_csd_mode { |
| 348 | LCHAN_CSD_M_NT, |
| 349 | LCHAN_CSD_M_T_1200_75, |
| 350 | LCHAN_CSD_M_T_600, |
| 351 | LCHAN_CSD_M_T_1200, |
| 352 | LCHAN_CSD_M_T_2400, |
| 353 | LCHAN_CSD_M_T_9600, |
| 354 | LCHAN_CSD_M_T_14400, |
| 355 | LCHAN_CSD_M_T_29000, |
| 356 | LCHAN_CSD_M_T_32000, |
| 357 | }; |
| 358 | |
| 359 | /* State of the SAPIs in the lchan */ |
| 360 | enum lchan_sapi_state { |
| 361 | LCHAN_SAPI_S_NONE, |
| 362 | LCHAN_SAPI_S_REQ, |
| 363 | LCHAN_SAPI_S_ASSIGNED, |
| 364 | LCHAN_SAPI_S_REL, |
| 365 | LCHAN_SAPI_S_ERROR, |
| 366 | }; |
| 367 | |
Neels Hofmeyr | 92b9f2e | 2018-02-14 00:19:11 +0100 | [diff] [blame] | 368 | #define MAX_A5_KEY_LEN (128/8) |
| 369 | |
| 370 | struct gsm_encr { |
| 371 | uint8_t alg_id; |
| 372 | uint8_t key_len; |
| 373 | uint8_t key[MAX_A5_KEY_LEN]; |
| 374 | }; |
| 375 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 376 | struct gsm_lchan { |
| 377 | /* The TS that we're part of */ |
| 378 | struct gsm_bts_trx_ts *ts; |
| 379 | /* The logical subslot number in the TS */ |
| 380 | uint8_t nr; |
| 381 | /* The logical channel type */ |
| 382 | enum gsm_chan_t type; |
| 383 | /* RSL channel mode */ |
| 384 | enum rsl_cmod_spd rsl_cmode; |
| 385 | /* If TCH, traffic channel mode */ |
| 386 | enum gsm48_chan_mode tch_mode; |
| 387 | enum lchan_csd_mode csd_mode; |
| 388 | /* State */ |
| 389 | enum gsm_lchan_state state; |
| 390 | const char *broken_reason; |
| 391 | /* Power levels for MS and BTS */ |
| 392 | uint8_t bs_power; |
| 393 | uint8_t ms_power; |
| 394 | /* Encryption information */ |
| 395 | struct gsm_encr encr; |
| 396 | |
| 397 | /* AMR bits */ |
| 398 | uint8_t mr_ms_lv[7]; |
| 399 | uint8_t mr_bts_lv[7]; |
| 400 | |
| 401 | /* Established data link layer services */ |
| 402 | uint8_t sapis[8]; |
| 403 | |
| 404 | struct { |
| 405 | uint32_t bound_ip; |
| 406 | uint32_t connect_ip; |
| 407 | uint16_t bound_port; |
| 408 | uint16_t connect_port; |
| 409 | uint16_t conn_id; |
| 410 | uint8_t rtp_payload; |
| 411 | uint8_t rtp_payload2; |
| 412 | uint8_t speech_mode; |
| 413 | struct rtp_socket *rtp_socket; |
| 414 | |
| 415 | /* info we need to postpone the AoIP |
| 416 | * assignment completed message */ |
| 417 | struct { |
| 418 | uint8_t rr_cause; |
| 419 | uint8_t chosen_channel; |
| 420 | uint8_t encr_alg_id; |
| 421 | uint8_t speech_mode; |
| 422 | bool valid; |
| 423 | } ass_compl; |
| 424 | } abis_ip; |
| 425 | |
| 426 | uint8_t rqd_ta; |
| 427 | |
| 428 | char *name; |
| 429 | |
| 430 | struct osmo_timer_list T3101; |
| 431 | struct osmo_timer_list T3109; |
| 432 | struct osmo_timer_list T3111; |
| 433 | struct osmo_timer_list error_timer; |
| 434 | struct osmo_timer_list act_timer; |
| 435 | struct osmo_timer_list rel_work; |
| 436 | uint8_t error_cause; |
| 437 | |
| 438 | /* table of neighbor cell measurements */ |
| 439 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 440 | |
| 441 | /* cache of last measurement reports on this lchan */ |
| 442 | struct gsm_meas_rep meas_rep[MAX_MEAS_REP]; |
| 443 | int meas_rep_idx; |
| 444 | int meas_rep_count; |
Neels Hofmeyr | 35ba85c | 2018-02-12 16:47:40 +0100 | [diff] [blame] | 445 | uint8_t meas_rep_last_seen_nr; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 446 | |
| 447 | /* GSM Random Access data */ |
| 448 | struct gsm48_req_ref *rqd_ref; |
| 449 | |
| 450 | struct gsm_subscriber_connection *conn; |
| 451 | |
| 452 | struct { |
| 453 | /* channel activation type and handover ref */ |
| 454 | uint8_t act_type; |
| 455 | uint8_t ho_ref; |
| 456 | struct gsm48_req_ref *rqd_ref; |
| 457 | uint8_t rqd_ta; |
| 458 | } dyn; |
| 459 | }; |
| 460 | |
| 461 | enum { |
| 462 | TS_F_PDCH_ACTIVE = 0x1000, |
| 463 | TS_F_PDCH_ACT_PENDING = 0x2000, |
| 464 | TS_F_PDCH_DEACT_PENDING = 0x4000, |
| 465 | TS_F_PDCH_PENDING_MASK = 0x6000 /*< |
| 466 | TS_F_PDCH_ACT_PENDING | TS_F_PDCH_DEACT_PENDING */ |
| 467 | } gsm_bts_trx_ts_flags; |
| 468 | |
| 469 | /* One Timeslot in a TRX */ |
| 470 | struct gsm_bts_trx_ts { |
| 471 | struct gsm_bts_trx *trx; |
| 472 | /* number of this timeslot at the TRX */ |
| 473 | uint8_t nr; |
| 474 | |
| 475 | enum gsm_phys_chan_config pchan; |
| 476 | |
| 477 | struct { |
| 478 | enum gsm_phys_chan_config pchan_is; |
| 479 | enum gsm_phys_chan_config pchan_want; |
| 480 | struct msgb *pending_chan_activ; |
| 481 | } dyn; |
| 482 | |
| 483 | unsigned int flags; |
| 484 | struct gsm_abis_mo mo; |
| 485 | struct tlv_parsed nm_attr; |
| 486 | uint8_t nm_chan_comb; |
| 487 | int tsc; /* -1 == use BTS TSC */ |
| 488 | |
| 489 | struct { |
| 490 | /* Parameters below are configured by VTY */ |
| 491 | int enabled; |
| 492 | uint8_t maio; |
| 493 | uint8_t hsn; |
| 494 | struct bitvec arfcns; |
| 495 | uint8_t arfcns_data[1024/8]; |
| 496 | /* This is the pre-computed MA for channel assignments */ |
| 497 | struct bitvec ma; |
| 498 | uint8_t ma_len; /* part of ma_data that is used */ |
| 499 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 500 | } hopping; |
| 501 | |
| 502 | /* To which E1 subslot are we connected */ |
| 503 | struct gsm_e1_subslot e1_link; |
| 504 | |
| 505 | union { |
| 506 | struct { |
| 507 | struct om2k_mo om2k_mo; |
| 508 | } rbs2000; |
| 509 | }; |
| 510 | |
| 511 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 512 | }; |
| 513 | |
| 514 | /* One TRX in a BTS */ |
| 515 | struct gsm_bts_trx { |
| 516 | /* list header in bts->trx_list */ |
| 517 | struct llist_head list; |
| 518 | |
| 519 | struct gsm_bts *bts; |
| 520 | /* number of this TRX in the BTS */ |
| 521 | uint8_t nr; |
| 522 | /* human readable name / description */ |
| 523 | char *description; |
| 524 | /* how do we talk RSL with this TRX? */ |
| 525 | struct gsm_e1_subslot rsl_e1_link; |
| 526 | uint8_t rsl_tei; |
| 527 | struct e1inp_sign_link *rsl_link; |
| 528 | |
| 529 | /* Timeout for initiating the RSL connection. */ |
| 530 | struct osmo_timer_list rsl_connect_timeout; |
| 531 | |
| 532 | /* Some BTS (specifically Ericsson RBS) have a per-TRX OML Link */ |
| 533 | struct e1inp_sign_link *oml_link; |
| 534 | |
| 535 | struct gsm_abis_mo mo; |
| 536 | struct tlv_parsed nm_attr; |
| 537 | struct { |
| 538 | struct gsm_abis_mo mo; |
| 539 | } bb_transc; |
| 540 | |
| 541 | uint16_t arfcn; |
| 542 | int nominal_power; /* in dBm */ |
| 543 | unsigned int max_power_red; /* in actual dB */ |
| 544 | |
| 545 | union { |
| 546 | struct { |
| 547 | struct { |
| 548 | struct gsm_abis_mo mo; |
| 549 | } bbsig; |
| 550 | struct { |
| 551 | struct gsm_abis_mo mo; |
| 552 | } pa; |
| 553 | } bs11; |
| 554 | struct { |
| 555 | unsigned int test_state; |
| 556 | uint8_t test_nr; |
| 557 | struct rxlev_stats rxlev_stat; |
| 558 | } ipaccess; |
| 559 | struct { |
| 560 | struct { |
| 561 | struct om2k_mo om2k_mo; |
| 562 | } trxc; |
| 563 | struct { |
| 564 | struct om2k_mo om2k_mo; |
| 565 | } rx; |
| 566 | struct { |
| 567 | struct om2k_mo om2k_mo; |
| 568 | } tx; |
| 569 | } rbs2000; |
| 570 | }; |
| 571 | struct gsm_bts_trx_ts ts[TRX_NR_TS]; |
| 572 | }; |
| 573 | |
| 574 | #define GSM_BTS_SI2Q(bts, i) (struct gsm48_system_information_type_2quater *)((bts)->si_buf[SYSINFO_TYPE_2quater][i]) |
| 575 | #define GSM_BTS_HAS_SI(bts, i) ((bts)->si_valid & (1 << i)) |
| 576 | #define GSM_BTS_SI(bts, i) (void *)((bts)->si_buf[i][0]) |
| 577 | #define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0]) |
| 578 | |
| 579 | enum gsm_bts_type { |
| 580 | GSM_BTS_TYPE_UNKNOWN, |
| 581 | GSM_BTS_TYPE_BS11, |
| 582 | GSM_BTS_TYPE_NANOBTS, |
| 583 | GSM_BTS_TYPE_RBS2000, |
| 584 | GSM_BTS_TYPE_NOKIA_SITE, |
| 585 | GSM_BTS_TYPE_OSMOBTS, |
| 586 | _NUM_GSM_BTS_TYPE |
| 587 | }; |
| 588 | |
| 589 | enum gsm_bts_type_variant { |
| 590 | BTS_UNKNOWN, |
| 591 | BTS_OSMO_LITECELL15, |
| 592 | BTS_OSMO_OCTPHY, |
| 593 | BTS_OSMO_SYSMO, |
| 594 | BTS_OSMO_TRX, |
| 595 | _NUM_BTS_VARIANT |
| 596 | }; |
| 597 | |
| 598 | /* Used by OML layer for BTS Attribute reporting */ |
| 599 | enum bts_attribute { |
| 600 | BTS_TYPE_VARIANT, |
| 601 | BTS_SUB_MODEL, |
| 602 | TRX_PHY_VERSION, |
| 603 | }; |
| 604 | |
| 605 | struct vty; |
| 606 | |
| 607 | struct gsm_bts_model { |
| 608 | struct llist_head list; |
| 609 | |
| 610 | enum gsm_bts_type type; |
| 611 | enum gsm_bts_type_variant variant; |
| 612 | const char *name; |
| 613 | |
| 614 | bool started; |
| 615 | int (*start)(struct gsm_network *net); |
| 616 | int (*oml_rcvmsg)(struct msgb *msg); |
| 617 | char * (*oml_status)(const struct gsm_bts *bts); |
| 618 | |
| 619 | void (*e1line_bind_ops)(struct e1inp_line *line); |
| 620 | |
| 621 | void (*config_write_bts)(struct vty *vty, struct gsm_bts *bts); |
| 622 | void (*config_write_trx)(struct vty *vty, struct gsm_bts_trx *trx); |
| 623 | void (*config_write_ts)(struct vty *vty, struct gsm_bts_trx_ts *ts); |
| 624 | |
| 625 | struct tlv_definition nm_att_tlvdef; |
| 626 | |
| 627 | /* features of a given BTS model set via gsm_bts_model_register() locally */ |
| 628 | struct bitvec features; |
| 629 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
| 630 | }; |
| 631 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 632 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 633 | |
| 634 | /* |
| 635 | * This keeps track of the paging status of one BTS. It |
| 636 | * includes a number of pending requests, a back pointer |
| 637 | * to the gsm_bts, a timer and some more state. |
| 638 | */ |
| 639 | struct gsm_bts_paging_state { |
| 640 | /* pending requests */ |
| 641 | struct llist_head pending_requests; |
| 642 | struct gsm_bts *bts; |
| 643 | |
| 644 | struct osmo_timer_list work_timer; |
| 645 | struct osmo_timer_list credit_timer; |
| 646 | |
| 647 | /* free chans needed */ |
| 648 | int free_chans_need; |
| 649 | |
| 650 | /* load */ |
| 651 | uint16_t available_slots; |
| 652 | }; |
| 653 | |
| 654 | struct gsm_envabtse { |
| 655 | struct gsm_abis_mo mo; |
| 656 | }; |
| 657 | |
| 658 | struct gsm_bts_gprs_nsvc { |
| 659 | struct gsm_bts *bts; |
| 660 | /* data read via VTY config file, to configure the BTS |
| 661 | * via OML from BSC */ |
| 662 | int id; |
| 663 | uint16_t nsvci; |
| 664 | uint16_t local_port; /* on the BTS */ |
| 665 | uint16_t remote_port; /* on the SGSN */ |
| 666 | uint32_t remote_ip; /* on the SGSN */ |
| 667 | |
| 668 | struct gsm_abis_mo mo; |
| 669 | }; |
| 670 | |
| 671 | enum gprs_rlc_par { |
| 672 | RLC_T3142, |
| 673 | RLC_T3169, |
| 674 | RLC_T3191, |
| 675 | RLC_T3193, |
| 676 | RLC_T3195, |
| 677 | RLC_N3101, |
| 678 | RLC_N3103, |
| 679 | RLC_N3105, |
| 680 | CV_COUNTDOWN, |
| 681 | T_DL_TBF_EXT, /* ms */ |
| 682 | T_UL_TBF_EXT, /* ms */ |
| 683 | _NUM_RLC_PAR |
| 684 | }; |
| 685 | |
| 686 | enum gprs_cs { |
| 687 | GPRS_CS1, |
| 688 | GPRS_CS2, |
| 689 | GPRS_CS3, |
| 690 | GPRS_CS4, |
| 691 | GPRS_MCS1, |
| 692 | GPRS_MCS2, |
| 693 | GPRS_MCS3, |
| 694 | GPRS_MCS4, |
| 695 | GPRS_MCS5, |
| 696 | GPRS_MCS6, |
| 697 | GPRS_MCS7, |
| 698 | GPRS_MCS8, |
| 699 | GPRS_MCS9, |
| 700 | _NUM_GRPS_CS |
| 701 | }; |
| 702 | |
| 703 | struct gprs_rlc_cfg { |
| 704 | uint16_t parameter[_NUM_RLC_PAR]; |
| 705 | struct { |
| 706 | uint16_t repeat_time; /* ms */ |
| 707 | uint8_t repeat_count; |
| 708 | } paging; |
| 709 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 710 | uint8_t initial_cs; |
| 711 | uint8_t initial_mcs; |
| 712 | }; |
| 713 | |
| 714 | |
| 715 | enum neigh_list_manual_mode { |
| 716 | NL_MODE_AUTOMATIC = 0, |
| 717 | NL_MODE_MANUAL = 1, |
| 718 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 719 | }; |
| 720 | |
| 721 | enum bts_loc_fix { |
| 722 | BTS_LOC_FIX_INVALID = 0, |
| 723 | BTS_LOC_FIX_2D = 1, |
| 724 | BTS_LOC_FIX_3D = 2, |
| 725 | }; |
| 726 | |
| 727 | extern const struct value_string bts_loc_fix_names[]; |
| 728 | |
| 729 | struct bts_location { |
| 730 | struct llist_head list; |
| 731 | time_t tstamp; |
| 732 | enum bts_loc_fix valid; |
| 733 | double lat; |
| 734 | double lon; |
| 735 | double height; |
| 736 | }; |
| 737 | |
| 738 | /* Channel load counter */ |
| 739 | struct load_counter { |
| 740 | unsigned int total; |
| 741 | unsigned int used; |
| 742 | }; |
| 743 | |
| 744 | /* One BTS */ |
| 745 | struct gsm_bts { |
| 746 | /* list header in net->bts_list */ |
| 747 | struct llist_head list; |
| 748 | |
| 749 | /* Geographical location of the BTS */ |
| 750 | struct llist_head loc_list; |
| 751 | |
| 752 | /* number of ths BTS in network */ |
| 753 | uint8_t nr; |
| 754 | /* human readable name / description */ |
| 755 | char *description; |
| 756 | /* Cell Identity */ |
| 757 | uint16_t cell_identity; |
| 758 | /* location area code of this BTS */ |
| 759 | uint16_t location_area_code; |
| 760 | /* Base Station Identification Code (BSIC), lower 3 bits is BCC, |
| 761 | * which is used as TSC for the CCCH */ |
| 762 | uint8_t bsic; |
| 763 | /* type of BTS */ |
| 764 | enum gsm_bts_type type; |
| 765 | enum gsm_bts_type_variant variant; |
| 766 | struct gsm_bts_model *model; |
| 767 | enum gsm_band band; |
| 768 | char version[MAX_VERSION_LENGTH]; |
| 769 | char sub_model[MAX_VERSION_LENGTH]; |
| 770 | |
| 771 | /* features of a given BTS set/reported via OML */ |
| 772 | struct bitvec features; |
| 773 | uint8_t _features_data[MAX_BTS_FEATURES/8]; |
| 774 | |
| 775 | /* Connected PCU version (if any) */ |
| 776 | char pcu_version[MAX_VERSION_LENGTH]; |
| 777 | |
| 778 | /* maximum Tx power that the MS is permitted to use in this cell */ |
| 779 | int ms_max_power; |
| 780 | |
| 781 | /* how do we talk OML with this TRX? */ |
| 782 | struct gsm_e1_subslot oml_e1_link; |
| 783 | uint8_t oml_tei; |
| 784 | struct e1inp_sign_link *oml_link; |
| 785 | /* when OML link was established */ |
| 786 | time_t uptime; |
| 787 | |
| 788 | /* Abis network management O&M handle */ |
| 789 | struct abis_nm_h *nmh; |
| 790 | |
| 791 | struct gsm_abis_mo mo; |
| 792 | |
| 793 | /* number of this BTS on given E1 link */ |
| 794 | uint8_t bts_nr; |
| 795 | |
| 796 | /* DTX features of this BTS */ |
| 797 | enum gsm48_dtx_mode dtxu; |
| 798 | bool dtxd; |
| 799 | |
| 800 | /* paging state and control */ |
| 801 | struct gsm_bts_paging_state paging; |
| 802 | |
| 803 | /* CCCH is on C0 */ |
| 804 | struct gsm_bts_trx *c0; |
| 805 | |
| 806 | struct { |
| 807 | struct gsm_abis_mo mo; |
| 808 | } site_mgr; |
| 809 | |
| 810 | /* bitmask of all SI that are present/valid in si_buf */ |
| 811 | uint32_t si_valid; |
| 812 | /* 3GPP TS 44.018 Table 10.5.2.33b.1 INDEX and COUNT for SI2quater */ |
| 813 | uint8_t si2q_index; /* distinguish individual SI2quater messages */ |
| 814 | uint8_t si2q_count; /* si2q_index for the last (highest indexed) individual SI2quater message */ |
| 815 | /* buffers where we put the pre-computed SI */ |
| 816 | sysinfo_buf_t si_buf[_MAX_SYSINFO_TYPE][SI2Q_MAX_NUM]; |
| 817 | /* offsets used while generating SI2quater */ |
| 818 | size_t e_offset; |
| 819 | size_t u_offset; |
| 820 | |
| 821 | /* ip.accesss Unit ID's have Site/BTS/TRX layout */ |
| 822 | union { |
| 823 | struct { |
| 824 | uint16_t site_id; |
| 825 | uint16_t bts_id; |
| 826 | uint32_t flags; |
| 827 | uint32_t rsl_ip; |
| 828 | } ip_access; |
| 829 | struct { |
| 830 | struct { |
| 831 | struct gsm_abis_mo mo; |
| 832 | } cclk; |
| 833 | struct { |
| 834 | struct gsm_abis_mo mo; |
| 835 | } rack; |
| 836 | struct gsm_envabtse envabtse[4]; |
| 837 | } bs11; |
| 838 | struct { |
| 839 | struct { |
| 840 | struct om2k_mo om2k_mo; |
| 841 | struct gsm_abis_mo mo; |
| 842 | struct llist_head conn_groups; |
| 843 | } cf; |
| 844 | struct { |
| 845 | struct om2k_mo om2k_mo; |
| 846 | struct gsm_abis_mo mo; |
| 847 | struct llist_head conn_groups; |
| 848 | } is; |
| 849 | struct { |
| 850 | struct om2k_mo om2k_mo; |
| 851 | struct gsm_abis_mo mo; |
| 852 | struct llist_head conn_groups; |
| 853 | } con; |
| 854 | struct { |
| 855 | struct om2k_mo om2k_mo; |
| 856 | struct gsm_abis_mo mo; |
| 857 | } dp; |
| 858 | struct { |
| 859 | struct om2k_mo om2k_mo; |
| 860 | struct gsm_abis_mo mo; |
| 861 | } tf; |
| 862 | uint32_t use_superchannel:1; |
| 863 | } rbs2000; |
| 864 | struct { |
| 865 | uint8_t bts_type; |
| 866 | unsigned int configured:1, |
| 867 | skip_reset:1, |
| 868 | no_loc_rel_cnf:1, |
| 869 | bts_reset_timer_cnf, |
| 870 | did_reset:1, |
| 871 | wait_reset:1; |
| 872 | struct osmo_timer_list reset_timer; |
| 873 | } nokia; |
| 874 | }; |
| 875 | |
| 876 | /* Not entirely sure how ip.access specific this is */ |
| 877 | struct { |
| 878 | uint8_t supports_egprs_11bit_rach; |
| 879 | enum bts_gprs_mode mode; |
| 880 | struct { |
| 881 | struct gsm_abis_mo mo; |
| 882 | uint16_t nsei; |
| 883 | uint8_t timer[7]; |
| 884 | } nse; |
| 885 | struct { |
| 886 | struct gsm_abis_mo mo; |
| 887 | uint16_t bvci; |
| 888 | uint8_t timer[11]; |
| 889 | struct gprs_rlc_cfg rlc_cfg; |
| 890 | } cell; |
| 891 | struct gsm_bts_gprs_nsvc nsvc[2]; |
| 892 | uint8_t rac; |
| 893 | uint8_t net_ctrl_ord; |
| 894 | bool ctrl_ack_type_use_block; |
| 895 | } gprs; |
| 896 | |
| 897 | /* RACH NM values */ |
| 898 | int rach_b_thresh; |
| 899 | int rach_ldavg_slots; |
| 900 | |
| 901 | /* transceivers */ |
| 902 | int num_trx; |
| 903 | struct llist_head trx_list; |
| 904 | |
| 905 | /* SI related items */ |
| 906 | int force_combined_si; |
| 907 | int bcch_change_mark; |
| 908 | |
| 909 | /* Abis NM queue */ |
| 910 | struct llist_head abis_queue; |
| 911 | int abis_nm_pend; |
| 912 | |
| 913 | struct gsm_network *network; |
| 914 | |
| 915 | /* should the channel allocator allocate channels from high TRX to TRX0, |
| 916 | * rather than starting from TRX0 and go upwards? */ |
| 917 | int chan_alloc_reverse; |
| 918 | |
| 919 | enum neigh_list_manual_mode neigh_list_manual_mode; |
| 920 | /* parameters from which we build SYSTEM INFORMATION */ |
| 921 | struct { |
| 922 | struct gsm48_rach_control rach_control; |
| 923 | uint8_t ncc_permitted; |
| 924 | struct gsm48_cell_sel_par cell_sel_par; |
| 925 | struct gsm48_si_selection_params cell_ro_sel_par; /* rest octet */ |
| 926 | struct gsm48_cell_options cell_options; |
| 927 | struct gsm48_control_channel_descr chan_desc; |
| 928 | struct bitvec neigh_list; |
| 929 | struct bitvec cell_alloc; |
| 930 | struct bitvec si5_neigh_list; |
| 931 | struct osmo_earfcn_si2q si2quater_neigh_list; |
| 932 | size_t uarfcn_length; /* index for uarfcn and scramble lists */ |
| 933 | struct { |
| 934 | /* bitmask large enough for all possible ARFCN's */ |
| 935 | uint8_t neigh_list[1024/8]; |
| 936 | uint8_t cell_alloc[1024/8]; |
| 937 | /* If the user wants a different neighbor list in SI5 than in SI2 */ |
| 938 | uint8_t si5_neigh_list[1024/8]; |
| 939 | uint8_t meas_bw_list[MAX_EARFCN_LIST]; |
| 940 | uint16_t earfcn_list[MAX_EARFCN_LIST]; |
| 941 | uint16_t uarfcn_list[MAX_EARFCN_LIST]; |
| 942 | uint16_t scramble_list[MAX_EARFCN_LIST]; |
| 943 | } data; |
| 944 | } si_common; |
| 945 | bool early_classmark_allowed; |
| 946 | bool early_classmark_allowed_3g; |
| 947 | /* for testing only: Have an infinitely long radio link timeout */ |
| 948 | bool infinite_radio_link_timeout; |
| 949 | |
| 950 | /* do we use static (user-defined) system information messages? (bitmask) */ |
| 951 | uint32_t si_mode_static; |
| 952 | |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 953 | /* access control class ramping */ |
| 954 | struct acc_ramp acc_ramp; |
| 955 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 956 | /* exclude the BTS from the global RF Lock handling */ |
| 957 | int excl_from_rf_lock; |
| 958 | |
| 959 | /* supported codecs beside FR */ |
| 960 | struct bts_codec_conf codec; |
| 961 | |
| 962 | /* BTS dependencies bit field */ |
| 963 | uint32_t depends_on[256/(8*4)]; |
| 964 | |
| 965 | /* full and half rate multirate config */ |
| 966 | struct amr_multirate_conf mr_full; |
| 967 | struct amr_multirate_conf mr_half; |
| 968 | |
| 969 | /* PCU socket state */ |
| 970 | char *pcu_sock_path; |
| 971 | struct pcu_sock_state *pcu_state; |
| 972 | |
| 973 | struct rate_ctr_group *bts_ctrs; |
| 974 | struct osmo_stat_item_group *bts_statg; |
| 975 | |
| 976 | struct handover_cfg *ho; |
| 977 | |
| 978 | /* BTS-specific overrides for timer values from struct gsm_network. */ |
| 979 | uint8_t T3122; /* ASSIGMENT REJECT wait indication */ |
| 980 | |
| 981 | /* Periodic channel load measurements are used to maintain T3122. */ |
| 982 | struct load_counter chan_load_samples[7]; |
| 983 | int chan_load_samples_idx; |
Stefan Sperling | 6442e43 | 2018-02-06 14:44:54 +0100 | [diff] [blame] | 984 | uint8_t chan_load_avg; /* current channel load average in percent (0 - 100). */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 985 | }; |
| 986 | |
| 987 | |
| 988 | struct gsm_bts *gsm_bts_alloc(struct gsm_network *net, uint8_t bts_num); |
| 989 | struct gsm_bts *gsm_bts_num(struct gsm_network *net, int num); |
| 990 | |
| 991 | struct gsm_bts_trx *gsm_bts_trx_alloc(struct gsm_bts *bts); |
| 992 | struct gsm_bts_trx *gsm_bts_trx_num(const struct gsm_bts *bts, int num); |
| 993 | |
| 994 | enum gsm_bts_type str2btstype(const char *arg); |
| 995 | const char *btstype2str(enum gsm_bts_type type); |
| 996 | |
| 997 | enum bts_attribute str2btsattr(const char *s); |
| 998 | const char *btsatttr2str(enum bts_attribute v); |
| 999 | |
| 1000 | enum gsm_bts_type_variant str2btsvariant(const char *arg); |
| 1001 | const char *btsvariant2str(enum gsm_bts_type_variant v); |
| 1002 | |
| 1003 | extern const struct value_string gsm_chreq_descs[]; |
| 1004 | const struct value_string gsm_pchant_names[13]; |
| 1005 | const struct value_string gsm_pchant_descs[13]; |
| 1006 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
| 1007 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 1008 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 1009 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
| 1010 | char *gsm_trx_name(const struct gsm_bts_trx *trx); |
| 1011 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 1012 | char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts); |
| 1013 | char *gsm_lchan_name_compute(const struct gsm_lchan *lchan); |
| 1014 | const char *gsm_lchans_name(enum gsm_lchan_state s); |
| 1015 | |
| 1016 | static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) |
| 1017 | { |
| 1018 | return lchan->name; |
| 1019 | } |
| 1020 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 1021 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
| 1022 | |
| 1023 | struct gsm_nm_state * |
| 1024 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
| 1025 | const struct abis_om_obj_inst *obj_inst); |
| 1026 | void * |
| 1027 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
| 1028 | const struct abis_om_obj_inst *obj_inst); |
| 1029 | |
| 1030 | /* reset the state of all MO in the BTS */ |
| 1031 | void gsm_bts_mo_reset(struct gsm_bts *bts); |
| 1032 | |
| 1033 | uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan, |
| 1034 | uint8_t ts_nr, uint8_t lchan_nr); |
| 1035 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 1036 | uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, |
| 1037 | enum gsm_phys_chan_config as_pchan); |
| 1038 | |
| 1039 | /* return the gsm_lchan for the CBCH (if it exists at all) */ |
| 1040 | struct gsm_lchan *gsm_bts_get_cbch(struct gsm_bts *bts); |
| 1041 | |
| 1042 | /* |
| 1043 | * help with parsing regexps |
| 1044 | */ |
| 1045 | int gsm_parse_reg(void *ctx, regex_t *reg, char **str, |
| 1046 | int argc, const char **argv) __attribute__ ((warn_unused_result)); |
| 1047 | |
| 1048 | static inline uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts) |
| 1049 | { |
| 1050 | if (ts->tsc != -1) |
| 1051 | return ts->tsc; |
| 1052 | else |
| 1053 | return ts->trx->bts->bsic & 7; |
| 1054 | } |
| 1055 | |
| 1056 | struct gsm_lchan *rsl_lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr, |
| 1057 | int *rc); |
| 1058 | |
| 1059 | enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts); |
| 1060 | uint8_t ts_subslots(struct gsm_bts_trx_ts *ts); |
| 1061 | bool ts_is_tch(struct gsm_bts_trx_ts *ts); |
| 1062 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 1063 | |
Harald Welte | b794887 | 2017-12-18 18:48:21 +0100 | [diff] [blame] | 1064 | static inline struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection *conn) { |
| 1065 | OSMO_ASSERT(conn->lchan); |
| 1066 | return conn->lchan->ts->trx->bts; |
| 1067 | } |
| 1068 | |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1069 | enum { |
| 1070 | BTS_CTR_CHREQ_TOTAL, |
| 1071 | BTS_CTR_CHREQ_NO_CHANNEL, |
| 1072 | BTS_CTR_CHAN_RF_FAIL, |
| 1073 | BTS_CTR_CHAN_RLL_ERR, |
| 1074 | BTS_CTR_BTS_OML_FAIL, |
| 1075 | BTS_CTR_BTS_RSL_FAIL, |
| 1076 | BTS_CTR_CODEC_AMR_F, |
| 1077 | BTS_CTR_CODEC_AMR_H, |
| 1078 | BTS_CTR_CODEC_EFR, |
| 1079 | BTS_CTR_CODEC_V1_FR, |
| 1080 | BTS_CTR_CODEC_V1_HR, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1081 | BTS_CTR_PAGING_ATTEMPTED, |
| 1082 | BTS_CTR_PAGING_ALREADY, |
| 1083 | BTS_CTR_PAGING_RESPONDED, |
| 1084 | BTS_CTR_PAGING_EXPIRED, |
Harald Welte | 4f59892 | 2017-12-14 13:47:02 +0100 | [diff] [blame] | 1085 | BTS_CTR_CHAN_ACT_TOTAL, |
| 1086 | BTS_CTR_CHAN_ACT_NACK, |
Harald Welte | 62d9cb0 | 2017-12-14 14:00:26 +0100 | [diff] [blame] | 1087 | BTS_CTR_RSL_UNKNOWN, |
Harald Welte | 581398a | 2017-12-14 14:29:44 +0100 | [diff] [blame] | 1088 | BTS_CTR_RSL_IPA_NACK, |
Harald Welte | 00d64fd | 2017-12-14 14:34:16 +0100 | [diff] [blame] | 1089 | BTS_CTR_MODE_MODIFY_NACK, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1090 | }; |
| 1091 | |
| 1092 | static const struct rate_ctr_desc bts_ctr_description[] = { |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1093 | [BTS_CTR_CHREQ_TOTAL] = {"chreq:total", "Received channel requests."}, |
| 1094 | [BTS_CTR_CHREQ_NO_CHANNEL] = {"chreq:no_channel", "Sent to MS no channel available."}, |
| 1095 | [BTS_CTR_CHAN_RF_FAIL] = {"chan:rf_fail", "Received a RF failure indication from BTS."}, |
| 1096 | [BTS_CTR_CHAN_RLL_ERR] = {"chan:rll_err", "Received a RLL failure with T200 cause from BTS."}, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1097 | [BTS_CTR_BTS_OML_FAIL] = {"oml_fail", "Received a TEI down on a OML link."}, |
| 1098 | [BTS_CTR_BTS_RSL_FAIL] = {"rsl_fail", "Received a TEI down on a OML link."}, |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1099 | [BTS_CTR_CODEC_AMR_F] = {"codec:amr_f", "Count the usage of AMR/F codec by channel mode requested."}, |
| 1100 | [BTS_CTR_CODEC_AMR_H] = {"codec:amr_h", "Count the usage of AMR/H codec by channel mode requested."}, |
| 1101 | [BTS_CTR_CODEC_EFR] = {"codec:efr", "Count the usage of EFR codec by channel mode requested."}, |
| 1102 | [BTS_CTR_CODEC_V1_FR] = {"codec:fr", "Count the usage of FR codec by channel mode requested."}, |
| 1103 | [BTS_CTR_CODEC_V1_HR] = {"codec:hr", "Count the usage of HR codec by channel mode requested."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1104 | |
| 1105 | [BTS_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."}, |
| 1106 | [BTS_CTR_PAGING_ALREADY] = {"paging:already", "Paging attempts ignored as subsciber was already being paged."}, |
| 1107 | [BTS_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful paging response."}, |
| 1108 | [BTS_CTR_PAGING_EXPIRED] = {"paging:expired", "Paging Request expired because of timeout T3113."}, |
Harald Welte | 4f59892 | 2017-12-14 13:47:02 +0100 | [diff] [blame] | 1109 | [BTS_CTR_CHAN_ACT_TOTAL] = {"chan_act:total", "Total number of Channel Activations."}, |
| 1110 | [BTS_CTR_CHAN_ACT_NACK] = {"chan_act:nack", "Number of Channel Activations that the BTS NACKed"}, |
Harald Welte | 62d9cb0 | 2017-12-14 14:00:26 +0100 | [diff] [blame] | 1111 | [BTS_CTR_RSL_UNKNOWN] = {"rsl:unknown", "Number of unknown/unsupported RSL messages received from BTS"}, |
Harald Welte | 581398a | 2017-12-14 14:29:44 +0100 | [diff] [blame] | 1112 | [BTS_CTR_RSL_IPA_NACK] = {"rsl:ipa_nack", "Number of IPA (RTP/dyn-PDCH) related NACKs received from BTS"}, |
Harald Welte | 00d64fd | 2017-12-14 14:34:16 +0100 | [diff] [blame] | 1113 | [BTS_CTR_MODE_MODIFY_NACK] = {"chan:mode_modify_nack", "Number of Channel Mode Modify NACKs received from BTS"}, |
Harald Welte | d82101e | 2017-12-09 23:07:38 +0100 | [diff] [blame] | 1114 | }; |
| 1115 | |
| 1116 | static const struct rate_ctr_group_desc bts_ctrg_desc = { |
| 1117 | "bts", |
| 1118 | "base transceiver station", |
| 1119 | OSMO_STATS_CLASS_GLOBAL, |
| 1120 | ARRAY_SIZE(bts_ctr_description), |
| 1121 | bts_ctr_description, |
| 1122 | }; |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 1123 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 1124 | enum { |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 1125 | BTS_STAT_CHAN_LOAD_AVERAGE, |
| 1126 | BTS_STAT_T3122, |
| 1127 | }; |
| 1128 | |
| 1129 | enum { |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1130 | BSC_CTR_HANDOVER_ATTEMPTED, |
| 1131 | BSC_CTR_HANDOVER_NO_CHANNEL, |
| 1132 | BSC_CTR_HANDOVER_TIMEOUT, |
| 1133 | BSC_CTR_HANDOVER_COMPLETED, |
| 1134 | BSC_CTR_HANDOVER_FAILED, |
| 1135 | BSC_CTR_PAGING_ATTEMPTED, |
| 1136 | BSC_CTR_PAGING_DETACHED, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1137 | BSC_CTR_PAGING_RESPONDED, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1138 | }; |
| 1139 | |
| 1140 | static const struct rate_ctr_desc bsc_ctr_description[] = { |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1141 | [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover:attempted", "Received handover attempts."}, |
| 1142 | [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover:no_channel", "Sent no channel available responses."}, |
| 1143 | [BSC_CTR_HANDOVER_TIMEOUT] = {"handover:timeout", "Count the amount of timeouts of timer T3103."}, |
| 1144 | [BSC_CTR_HANDOVER_COMPLETED] = {"handover:completed", "Received handover completed."}, |
| 1145 | [BSC_CTR_HANDOVER_FAILED] = {"handover:failed", "Receive HO FAIL messages."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1146 | |
| 1147 | [BSC_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber."}, |
Harald Welte | 1ef46d9 | 2017-12-09 23:10:46 +0100 | [diff] [blame] | 1148 | [BSC_CTR_PAGING_DETACHED] = {"paging:detached", "Counts the amount of paging attempts which couldn't sent out any paging request because no responsible bts found."}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1149 | [BSC_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful response."}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1150 | }; |
| 1151 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1152 | |
| 1153 | |
| 1154 | static const struct rate_ctr_group_desc bsc_ctrg_desc = { |
| 1155 | "bsc", |
| 1156 | "base station controller", |
| 1157 | OSMO_STATS_CLASS_GLOBAL, |
| 1158 | ARRAY_SIZE(bsc_ctr_description), |
| 1159 | bsc_ctr_description, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 1160 | }; |
| 1161 | |
Harald Welte | dea252d | 2017-12-10 19:55:18 +0100 | [diff] [blame] | 1162 | #define GSM_T3101_DEFAULT 3 /* s */ |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 1163 | #define GSM_T3103_DEFAULT 5 /* s */ |
| 1164 | #define GSM_T3105_DEFAULT 100 /* ms */ |
| 1165 | #define GSM_T3107_DEFAULT 5 /* s */ |
Harald Welte | ed23c1d | 2017-12-10 19:58:16 +0100 | [diff] [blame] | 1166 | #define GSM_T3109_DEFAULT 5 /* s, must be 2s + radio_link_timeout*0.48 */ |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 1167 | #define GSM_T3111_DEFAULT 2 /* s */ |
Harald Welte | 6e59ced | 2017-12-14 12:49:43 +0100 | [diff] [blame] | 1168 | #define GSM_T3113_DEFAULT 10 /* s */ |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 1169 | #define GSM_T3115_DEFAULT 10 |
| 1170 | #define GSM_T3117_DEFAULT 10 |
| 1171 | #define GSM_T3119_DEFAULT 10 |
Andreas Eversberg | 75e13a4 | 2013-02-07 11:51:16 +0100 | [diff] [blame] | 1172 | #define GSM_T3122_DEFAULT 10 |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 1173 | #define GSM_T3141_DEFAULT 10 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 1174 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1175 | struct gsm_tz { |
| 1176 | int override; /* if 0, use system's time zone instead. */ |
| 1177 | int hr; /* hour */ |
| 1178 | int mn; /* minute */ |
| 1179 | int dst; /* daylight savings */ |
| 1180 | }; |
| 1181 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1182 | struct gsm_network { |
Neels Hofmeyr | ce4d88b | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 1183 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 1184 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 1185 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 1186 | * these have in common, like country and network code, put in yet |
| 1187 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 1188 | |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 1189 | struct osmo_plmn_id plmn; |
| 1190 | |
Harald Welte | 51e4bf3 | 2017-12-23 17:30:18 +0100 | [diff] [blame] | 1191 | /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ |
| 1192 | uint8_t a5_encryption_mask; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 1193 | int neci; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1194 | |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 1195 | struct handover_cfg *ho; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1196 | struct { |
| 1197 | unsigned int congestion_check_interval_s; |
| 1198 | struct osmo_timer_list congestion_check_timer; |
| 1199 | } hodec2; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1200 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1201 | struct rate_ctr_group *bsc_ctrs; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 1202 | |
Holger Hans Peter Freyther | abcddf1 | 2010-06-14 18:20:15 +0800 | [diff] [blame] | 1203 | struct bsc_api *bsc_api; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 1204 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1205 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1206 | struct llist_head bts_list; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1207 | |
| 1208 | /* timer values */ |
| 1209 | int T3101; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 1210 | int T3103; |
| 1211 | int T3105; |
| 1212 | int T3107; |
| 1213 | int T3109; |
| 1214 | int T3111; |
| 1215 | int T3113; |
| 1216 | int T3115; |
| 1217 | int T3117; |
| 1218 | int T3119; |
Harald Welte | 2862dca | 2010-12-23 14:39:29 +0100 | [diff] [blame] | 1219 | int T3122; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 1220 | int T3141; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1221 | |
Alexander Couzens | 547c207 | 2017-11-21 12:03:04 +0100 | [diff] [blame] | 1222 | enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T]; |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 1223 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 1224 | /* Use a TCH for handling requests of type paging any */ |
| 1225 | int pag_any_tch; |
| 1226 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 1227 | /* MSC data in case we are a true BSC */ |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 1228 | struct osmo_bsc_data *bsc_data; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 1229 | |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 1230 | /* control interface */ |
| 1231 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 1232 | |
| 1233 | /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */ |
| 1234 | bool dyn_ts_allow_tch_f; |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 1235 | |
| 1236 | /* all active subscriber connections. */ |
| 1237 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1238 | |
| 1239 | /* if override is nonzero, this timezone data is used for all MM |
| 1240 | * contexts. */ |
| 1241 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 1242 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 1243 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1244 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 1245 | |
| 1246 | /* List of all struct bsc_subscr used in libbsc. This llist_head is |
| 1247 | * allocated so that the llist_head pointer itself can serve as a |
| 1248 | * talloc context (useful to not have to pass the entire gsm_network |
| 1249 | * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to |
| 1250 | * not require gsm_data.h). In an MSC-without-BSC environment, this |
| 1251 | * pointer is NULL to indicate absence of a bsc_subscribers list. */ |
| 1252 | struct llist_head *bsc_subscribers; |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 1253 | |
Neels Hofmeyr | ce4d88b | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 1254 | /* Periodic location update default value */ |
| 1255 | uint8_t t3212; |
Neels Hofmeyr | c29505e | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1256 | |
Stefan Sperling | 6cee893 | 2018-01-30 18:14:22 +0100 | [diff] [blame] | 1257 | /* Timer for periodic channel load measurements to maintain each BTS's T3122. */ |
| 1258 | struct osmo_timer_list t3122_chan_load_timer; |
| 1259 | |
Neels Hofmeyr | c29505e | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1260 | struct { |
Philipp Maier | 39c609b | 2017-09-27 15:51:34 +0200 | [diff] [blame] | 1261 | struct mgcp_client_conf *conf; |
| 1262 | struct mgcp_client *client; |
| 1263 | } mgw; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 1264 | }; |
| 1265 | |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 1266 | static inline const struct osmo_location_area_id *bts_lai(struct gsm_bts *bts) |
| 1267 | { |
| 1268 | static struct osmo_location_area_id lai; |
| 1269 | lai = (struct osmo_location_area_id){ |
| 1270 | .plmn = bts->network->plmn, |
| 1271 | .lac = bts->location_area_code, |
| 1272 | }; |
| 1273 | return &lai; |
| 1274 | } |
| 1275 | |
Neels Hofmeyr | c13e687 | 2016-05-11 13:53:47 +0200 | [diff] [blame] | 1276 | extern void talloc_ctx_init(void *ctx_root); |
| 1277 | |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 1278 | int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1279 | |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 1280 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 1281 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 1282 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 1283 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1284 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 1285 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 1286 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1287 | |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 1288 | /* this actaully refers to the IPA transport, not the BTS model */ |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1289 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 1290 | { |
| 1291 | switch (bts->type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 1292 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 1293 | case GSM_BTS_TYPE_OSMOBTS: |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1294 | return 1; |
| 1295 | default: |
| 1296 | break; |
| 1297 | } |
| 1298 | return 0; |
| 1299 | } |
| 1300 | |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 1301 | static inline int is_sysmobts_v2(struct gsm_bts *bts) |
| 1302 | { |
| 1303 | switch (bts->type) { |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 1304 | case GSM_BTS_TYPE_OSMOBTS: |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 1305 | return 1; |
| 1306 | default: |
| 1307 | break; |
| 1308 | } |
| 1309 | return 0; |
| 1310 | } |
| 1311 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 1312 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 1313 | { |
| 1314 | switch (bts->type) { |
| 1315 | case GSM_BTS_TYPE_BS11: |
| 1316 | return 1; |
| 1317 | default: |
| 1318 | break; |
| 1319 | } |
| 1320 | |
| 1321 | return 0; |
| 1322 | } |
| 1323 | |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 1324 | static inline int is_nokia_bts(struct gsm_bts *bts) |
| 1325 | { |
| 1326 | switch (bts->type) { |
| 1327 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 1328 | return 1; |
| 1329 | default: |
| 1330 | break; |
| 1331 | } |
| 1332 | |
| 1333 | return 0; |
| 1334 | } |
| 1335 | |
Andreas Eversberg | dcf38e1 | 2013-12-05 14:37:11 +0100 | [diff] [blame] | 1336 | static inline int is_e1_bts(struct gsm_bts *bts) |
| 1337 | { |
| 1338 | switch (bts->type) { |
| 1339 | case GSM_BTS_TYPE_BS11: |
| 1340 | case GSM_BTS_TYPE_RBS2000: |
| 1341 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 1342 | return 1; |
| 1343 | default: |
| 1344 | break; |
| 1345 | } |
| 1346 | |
| 1347 | return 0; |
| 1348 | } |
| 1349 | |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 1350 | enum bts_gprs_mode bts_gprs_mode_parse(const char *arg, int *valid); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1351 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 1352 | int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 1353 | |
Neels Hofmeyr | 4d358c0 | 2018-02-22 03:19:05 +0100 | [diff] [blame] | 1354 | void gsm48_ra_id_by_bts(struct gsm48_ra_id *buf, struct gsm_bts *bts); |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 1355 | void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts); |
Harald Welte | d12b0fd | 2009-12-15 21:36:05 +0100 | [diff] [blame] | 1356 | |
Harald Welte | fbda4e1 | 2010-03-04 11:04:52 +0100 | [diff] [blame] | 1357 | int gsm_bts_model_register(struct gsm_bts_model *model); |
| 1358 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame^] | 1359 | struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network); |
Neels Hofmeyr | 42eb014 | 2016-05-20 17:15:44 +0200 | [diff] [blame] | 1360 | |
| 1361 | struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network); |
| 1362 | void msc_subscr_con_free(struct gsm_subscriber_connection *conn); |
Holger Hans Peter Freyther | 2412a07 | 2010-06-28 15:47:12 +0800 | [diff] [blame] | 1363 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1364 | struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, |
| 1365 | enum gsm_bts_type type, |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 1366 | uint8_t bsic); |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 1367 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1368 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr, |
| 1369 | uint8_t e1_ts, uint8_t e1_ts_ss); |
| 1370 | |
Max | be356ed | 2017-09-07 19:10:09 +0200 | [diff] [blame] | 1371 | void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1372 | struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); |
Holger Hans Peter Freyther | a49b2c0 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 1373 | int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx); |
Alexander Chemeris | c36a13b | 2015-05-30 14:40:54 -0400 | [diff] [blame] | 1374 | int gsm_bts_set_system_infos(struct gsm_bts *bts); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1375 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 1376 | /* generic E1 line operations for all ISDN-based BTS. */ |
| 1377 | extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; |
| 1378 | |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 1379 | extern const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1]; |
| 1380 | extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1]; |
| 1381 | |
Max | 3d049d2 | 2017-10-09 17:12:53 +0200 | [diff] [blame] | 1382 | char *get_model_oml_status(const struct gsm_bts *bts); |
| 1383 | |
Max | 25cc407 | 2017-10-10 14:50:35 +0200 | [diff] [blame] | 1384 | unsigned long long bts_uptime(const struct gsm_bts *bts); |
| 1385 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 1386 | /* control interface handling */ |
| 1387 | int bsc_base_ctrl_cmds_install(void); |
| 1388 | |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 1389 | /* dependency handling */ |
| 1390 | void bts_depend_mark(struct gsm_bts *bts, int dep); |
| 1391 | void bts_depend_clear(struct gsm_bts *bts, int dep); |
| 1392 | int bts_depend_check(struct gsm_bts *bts); |
Holger Hans Peter Freyther | f7e23c5 | 2014-12-17 15:44:32 +0100 | [diff] [blame] | 1393 | int bts_depend_is_depedency(struct gsm_bts *base, struct gsm_bts *other); |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 1394 | |
Harald Welte | 2f8b9d2 | 2017-06-18 11:12:13 +0300 | [diff] [blame] | 1395 | int gsm_bts_get_radio_link_timeout(const struct gsm_bts *bts); |
| 1396 | void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value); |
| 1397 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 1398 | bool classmark_is_r99(struct gsm_classmark *cm); |
| 1399 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1400 | #endif /* _GSM_DATA_H */ |