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 <sys/types.h> |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 6 | #include <stdbool.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 7 | |
| 8 | #include <osmocom/core/timer.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 9 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 10 | #include <osmocom/core/select.h> |
Alexander Couzens | 2f9df96 | 2020-09-21 18:35:24 +0200 | [diff] [blame] | 11 | #include <osmocom/core/socket.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 12 | #include <osmocom/core/stats.h> |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 13 | #include <osmocom/core/stat_item.h> |
Philipp Maier | 8c498fc | 2018-02-21 13:24:36 +0100 | [diff] [blame] | 14 | #include <osmocom/gsm/bts_features.h> |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 15 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Harald Welte | d41b7c7 | 2019-06-13 09:41:58 +0200 | [diff] [blame] | 16 | #include <osmocom/gsm/protocol/gsm_48_049.h> |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 17 | #include <osmocom/gsm/gsm0808.h> |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 18 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 19 | #include <osmocom/core/fsm.h> |
Neels Hofmeyr | a6078fe | 2019-01-28 03:52:14 +0100 | [diff] [blame] | 20 | #include <osmocom/core/tdef.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 21 | |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 22 | #include <osmocom/crypt/auth.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 23 | |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame] | 24 | #include <osmocom/bsc/rest_octets.h> |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 25 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 26 | #include <osmocom/core/bitvec.h> |
| 27 | #include <osmocom/gsm/gsm_utils.h> |
| 28 | #include <osmocom/gsm/rxlev_stat.h> |
| 29 | #include <osmocom/gsm/protocol/gsm_08_58.h> |
| 30 | #include <osmocom/gsm/protocol/gsm_12_21.h> |
| 31 | #include <osmocom/abis/e1_input.h> |
| 32 | #include <osmocom/bsc/meas_rep.h> |
Pau Espin Pedrol | 02f2056 | 2020-07-20 16:21:54 +0200 | [diff] [blame] | 33 | #include <osmocom/bsc/acc.h> |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 34 | #include <osmocom/bsc/neighbor_ident.h> |
Pau Espin Pedrol | 83c0f76 | 2019-04-16 20:05:32 +0200 | [diff] [blame] | 35 | #include <osmocom/bsc/osmux.h> |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 36 | |
Neels Hofmeyr | 596c402 | 2018-06-16 19:29:50 +0200 | [diff] [blame] | 37 | #define GSM_T3122_DEFAULT 10 |
| 38 | |
Harald Welte | 74b8cdb | 2018-01-15 19:26:06 +0100 | [diff] [blame] | 39 | struct mgcp_client_conf; |
| 40 | struct mgcp_client; |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 41 | struct gsm0808_cell_id; |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 42 | struct osmo_mgcpc_ep; |
Pau Espin Pedrol | 388ed58 | 2020-07-15 20:53:16 +0200 | [diff] [blame] | 43 | struct gsm_bts; |
Pau Espin Pedrol | aca5320 | 2020-07-16 14:49:36 +0200 | [diff] [blame] | 44 | struct gsm_bts_trx; |
Philipp Maier | 39f62bb | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 45 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 46 | /** annotations for msgb ownership */ |
| 47 | #define __uses |
| 48 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 49 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 50 | |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 51 | struct bsc_subscr; |
Neels Hofmeyr | 7b65688 | 2017-07-09 22:09:18 +0200 | [diff] [blame] | 52 | struct gprs_ra_id; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 53 | struct handover; |
Neels Hofmeyr | a33ef3a | 2020-10-01 04:23:32 +0200 | [diff] [blame] | 54 | struct osmo_sccp_instance; |
Neels Hofmeyr | 4ae338d | 2020-09-17 17:54:39 +0200 | [diff] [blame] | 55 | struct smlc_config; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 56 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 57 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 58 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 59 | /* 3-bit long values */ |
| 60 | #define EARFCN_PRIO_INVALID 8 |
| 61 | #define EARFCN_MEAS_BW_INVALID 8 |
| 62 | /* 5-bit long values */ |
| 63 | #define EARFCN_QRXLV_INVALID 32 |
| 64 | #define EARFCN_THRESH_LOW_INVALID 32 |
| 65 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 66 | struct msgb; |
| 67 | typedef int gsm_cbfn(unsigned int hooknum, |
| 68 | unsigned int event, |
| 69 | struct msgb *msg, |
| 70 | void *data, void *param); |
| 71 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 72 | /* Maximum number of neighbor cells whose average we track */ |
| 73 | #define MAX_NEIGH_MEAS 10 |
| 74 | /* Maximum size of the averaging window for neighbor cells */ |
| 75 | #define MAX_WIN_NEIGH_AVG 10 |
Andreas Eversberg | 9869203 | 2013-06-23 10:44:34 +0200 | [diff] [blame] | 76 | /* Maximum number of report history we store */ |
| 77 | #define MAX_MEAS_REP 10 |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 78 | |
| 79 | /* processed neighbor measurements for one cell */ |
| 80 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 81 | uint16_t arfcn; |
| 82 | uint8_t bsic; |
| 83 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 84 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 85 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 86 | }; |
| 87 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 88 | struct gsm_classmark { |
| 89 | bool classmark1_set; |
| 90 | struct gsm48_classmark1 classmark1; |
| 91 | uint8_t classmark2_len; |
| 92 | uint8_t classmark2[3]; |
| 93 | uint8_t classmark3_len; |
| 94 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 95 | }; |
| 96 | |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 97 | enum subscr_sccp_state { |
| 98 | SUBSCR_SCCP_ST_NONE, |
| 99 | SUBSCR_SCCP_ST_WAIT_CONN_CONF, |
| 100 | SUBSCR_SCCP_ST_CONNECTED |
| 101 | }; |
| 102 | |
Sylvain Munaut | aa82492 | 2019-03-07 16:32:02 +0100 | [diff] [blame] | 103 | enum channel_rate { |
| 104 | CH_RATE_SDCCH, |
| 105 | CH_RATE_HALF, |
| 106 | CH_RATE_FULL, |
| 107 | }; |
| 108 | |
Philipp Maier | bb66d10 | 2019-01-22 11:29:06 +0100 | [diff] [blame] | 109 | struct channel_mode_and_rate { |
| 110 | enum gsm48_chan_mode chan_mode; |
Sylvain Munaut | aa82492 | 2019-03-07 16:32:02 +0100 | [diff] [blame] | 111 | enum channel_rate chan_rate; |
Philipp Maier | bb66d10 | 2019-01-22 11:29:06 +0100 | [diff] [blame] | 112 | uint16_t s15_s0; |
| 113 | }; |
| 114 | |
Neels Hofmeyr | 7cfdbe7 | 2019-02-06 01:30:19 +0100 | [diff] [blame] | 115 | /* Information retrieved during an Assignment Request from the MSC. This is storage of the Assignment instructions |
| 116 | * parsed from the Assignment Request message, to pass on until the gscon and assignment FSMs have decided whether an |
| 117 | * Assignment is actually going to be carried out. Should remain unchanged after initial decoding. */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 118 | struct assignment_request { |
| 119 | bool aoip; |
| 120 | |
| 121 | uint16_t msc_assigned_cic; |
| 122 | |
Pau Espin Pedrol | 657f310 | 2020-08-28 18:35:22 +0200 | [diff] [blame] | 123 | char msc_rtp_addr[INET6_ADDRSTRLEN]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 124 | uint16_t msc_rtp_port; |
Pau Espin Pedrol | 83c0f76 | 2019-04-16 20:05:32 +0200 | [diff] [blame] | 125 | bool use_osmux; |
| 126 | uint8_t osmux_cid; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 127 | |
Sylvain Munaut | aa82492 | 2019-03-07 16:32:02 +0100 | [diff] [blame] | 128 | /* Rate/codec setting in preference order (need at least 1 !) */ |
| 129 | int n_ch_mode_rate; |
| 130 | struct channel_mode_and_rate ch_mode_rate[3]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 131 | }; |
| 132 | |
Neels Hofmeyr | 7cfdbe7 | 2019-02-06 01:30:19 +0100 | [diff] [blame] | 133 | /* State of an ongoing Assignment, while the assignment_fsm is still busy. This serves as state separation to keep the |
| 134 | * currently used lchan and gscon unmodified until the outcome of an Assignment is known. If the Assignment fails, this |
| 135 | * state is simply discarded, and the gscon carries on with the original lchan remaining unchanged. */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 136 | struct assignment_fsm_data { |
| 137 | struct assignment_request req; |
| 138 | bool requires_voice_stream; |
| 139 | |
| 140 | struct osmo_fsm_inst *fi; |
| 141 | struct gsm_lchan *new_lchan; |
| 142 | |
| 143 | /* Whether this assignment triggered creation of the MGW endpoint: if the assignment |
| 144 | * fails, we will release that again as soon as possible. (If false, the endpoint already |
| 145 | * existed before or isn't needed at all.)*/ |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 146 | struct osmo_mgcpc_ep_ci *created_ci_for_msc; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 147 | |
| 148 | enum gsm0808_cause failure_cause; |
| 149 | enum gsm48_rr_cause rr_cause; |
| 150 | |
| 151 | bool result_rate_ctr_done; |
| 152 | }; |
| 153 | |
| 154 | enum hodec_id { |
| 155 | HODEC_NONE, |
| 156 | HODEC1 = 1, |
| 157 | HODEC2 = 2, |
| 158 | HODEC_USER, |
| 159 | HODEC_REMOTE, |
| 160 | }; |
| 161 | |
| 162 | /* For example, to count specific kinds of ongoing handovers, it is useful to be able to OR-combine |
| 163 | * scopes. */ |
| 164 | enum handover_scope { |
| 165 | HO_NO_HANDOVER = 0, |
| 166 | HO_INTRA_CELL = 0x1, |
| 167 | HO_INTRA_BSC = 0x2, |
| 168 | HO_INTER_BSC_OUT = 0x4, |
| 169 | HO_INTER_BSC_IN = 0x8, |
| 170 | HO_SCOPE_ALL = 0xffff, |
| 171 | }; |
| 172 | |
| 173 | extern const struct value_string handover_scope_names[]; |
| 174 | inline static const char *handover_scope_name(enum handover_scope val) |
| 175 | { return get_value_string(handover_scope_names, val); } |
| 176 | |
| 177 | struct handover_out_req { |
| 178 | enum hodec_id from_hodec_id; |
| 179 | struct gsm_lchan *old_lchan; |
| 180 | struct neighbor_ident_key target_nik; |
| 181 | enum gsm_chan_t new_lchan_type; /*< leave GSM_LCHAN_NONE to use same as old_lchan */ |
| 182 | }; |
| 183 | |
| 184 | struct handover_in_req { |
| 185 | struct gsm0808_channel_type ct; |
| 186 | struct gsm0808_speech_codec_list scl; |
| 187 | struct gsm0808_encrypt_info ei; |
| 188 | struct gsm_classmark classmark; |
Neels Hofmeyr | c15f6cd | 2019-03-15 02:48:39 +0100 | [diff] [blame] | 189 | /* chosen_encr_alg reflects the encoded value as in RSL_ENC_ALG_A5(a5_numer): |
| 190 | * chosen_encr_alg == 1 means A5/0 i.e. no encryption, chosen_encr_alg == 4 means A5/3. |
| 191 | * chosen_encr_alg == 0 means no such IE was present. */ |
| 192 | uint8_t chosen_encr_alg; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 193 | struct gsm0808_cell_id cell_id_serving; |
| 194 | char cell_id_serving_name[64]; |
| 195 | struct gsm0808_cell_id cell_id_target; |
| 196 | char cell_id_target_name[64]; |
| 197 | uint16_t msc_assigned_cic; |
Pau Espin Pedrol | 657f310 | 2020-08-28 18:35:22 +0200 | [diff] [blame] | 198 | char msc_assigned_rtp_addr[INET6_ADDRSTRLEN]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 199 | uint16_t msc_assigned_rtp_port; |
| 200 | }; |
| 201 | |
| 202 | struct handover { |
| 203 | struct osmo_fsm_inst *fi; |
| 204 | |
| 205 | enum hodec_id from_hodec_id; |
| 206 | enum handover_scope scope; |
| 207 | enum gsm_chan_t new_lchan_type; |
| 208 | struct neighbor_ident_key target_cell; |
| 209 | |
| 210 | uint8_t ho_ref; |
| 211 | struct gsm_bts *new_bts; |
| 212 | struct gsm_lchan *new_lchan; |
| 213 | bool async; |
| 214 | struct handover_in_req inter_bsc_in; |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 215 | struct osmo_mgcpc_ep_ci *created_ci_for_msc; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 216 | }; |
| 217 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 218 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 219 | struct gsm_subscriber_connection { |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 220 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 221 | struct llist_head entry; |
| 222 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 223 | /* FSM instance to control the subscriber connection state (RTP, A) */ |
| 224 | struct osmo_fsm_inst *fi; |
| 225 | |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 226 | /* libbsc subscriber information (if available) */ |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 227 | struct bsc_subscr *bsub; |
| 228 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 229 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 230 | struct gsm_network *network; |
| 231 | |
Neels Hofmeyr | 7cfdbe7 | 2019-02-06 01:30:19 +0100 | [diff] [blame] | 232 | /* the primary / currently active lchan to the BTS/subscriber. During Assignment and Handover, separate lchans |
| 233 | * are kept in the .assignment or .handover sub-structs, respectively, so that this lchan remains unaffected |
| 234 | * until Assignment or Handover have actually succeeded. */ |
Harald Welte | 4a8ebc8 | 2017-12-18 18:34:41 +0100 | [diff] [blame] | 235 | struct gsm_lchan *lchan; |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 236 | |
Neels Hofmeyr | 7cfdbe7 | 2019-02-06 01:30:19 +0100 | [diff] [blame] | 237 | /* Only valid during an ongoing Assignment; might be overwritten at any time by a failed Assignment attempt. |
| 238 | * Once an Assignment was successful, all relevant state must be copied out of this sub-struct. */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 239 | struct assignment_fsm_data assignment; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 240 | |
Neels Hofmeyr | 7cfdbe7 | 2019-02-06 01:30:19 +0100 | [diff] [blame] | 241 | /* handover information, if a handover is pending for this conn. Valid only during an ongoing Handover |
| 242 | * operation. If a Handover was successful, all relevant state must be copied out of this sub-struct. */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 243 | struct handover ho; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 244 | |
Neels Hofmeyr | 149160f | 2018-06-16 17:20:13 +0200 | [diff] [blame] | 245 | /* Queue DTAP messages during handover/assignment (msgb_enqueue()/msgb_dequeue())*/ |
| 246 | struct llist_head dtap_queue; |
| 247 | unsigned int dtap_queue_len; |
Andreas Eversberg | 084b421 | 2013-05-30 14:12:48 +0200 | [diff] [blame] | 248 | |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 249 | struct { |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 250 | int failures; |
Neels Hofmeyr | ec42264 | 2018-02-15 14:07:40 +0100 | [diff] [blame] | 251 | struct penalty_timers *penalty_timers; |
| 252 | } hodec2; |
Neels Hofmeyr | a60f344 | 2018-02-12 16:44:32 +0100 | [diff] [blame] | 253 | |
| 254 | /* "Codec List (MSC Preferred)" as received by the BSSAP Assignment Request. 3GPP 48.008 |
| 255 | * 3.2.2.103 says: |
| 256 | * The "Codec List (MSC Preferred)" shall not include codecs |
| 257 | * that are not supported by the MS. |
| 258 | * i.e. by heeding the "Codec list (MSC Preferred)", we inherently heed the MS bearer |
| 259 | * capabilities, which the MSC is required to translate into the codec list. */ |
| 260 | struct gsm0808_speech_codec_list codec_list; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 261 | |
| 262 | /* flag to prevent multiple simultaneous ciphering commands */ |
| 263 | int ciphering_handled; |
| 264 | |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 265 | /* SCCP connection associatd with this subscriber_connection */ |
| 266 | struct { |
Martin Hauke | a29affd | 2019-11-13 22:10:41 +0100 | [diff] [blame] | 267 | /* SCCP connection related */ |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 268 | struct bsc_msc_data *msc; |
| 269 | |
| 270 | /* Sigtran connection ID */ |
| 271 | int conn_id; |
| 272 | enum subscr_sccp_state state; |
| 273 | } sccp; |
| 274 | |
| 275 | /* for audio handling */ |
| 276 | struct { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 277 | uint16_t msc_assigned_cic; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 278 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 279 | /* RTP address where the MSC expects us to send the RTP stream coming from the BTS. */ |
Pau Espin Pedrol | 657f310 | 2020-08-28 18:35:22 +0200 | [diff] [blame] | 280 | char msc_assigned_rtp_addr[INET6_ADDRSTRLEN]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 281 | uint16_t msc_assigned_rtp_port; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 282 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 283 | /* The endpoint at the MGW used to join both BTS and MSC side connections, e.g. |
| 284 | * "rtpbridge/23@mgw". */ |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 285 | struct osmo_mgcpc_ep *mgw_endpoint; |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 286 | |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 287 | /* The connection identifier of the osmo_mgcpc_ep used to transceive RTP towards the MSC. |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 288 | * (The BTS side CI is handled by struct gsm_lchan and the lchan_fsm.) */ |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 289 | struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_msc; |
Harald Welte | 519c7e1 | 2018-01-28 02:45:46 +0100 | [diff] [blame] | 290 | } user_plane; |
Harald Welte | c997ceb | 2018-05-30 01:39:43 +0200 | [diff] [blame] | 291 | |
| 292 | /* LCLS (local call, local switch) related state */ |
| 293 | struct { |
| 294 | uint8_t global_call_ref[15]; |
| 295 | uint8_t global_call_ref_len; /* length of global_call_ref */ |
Max | fe65ece | 2018-11-09 13:36:11 +0100 | [diff] [blame] | 296 | enum gsm0808_lcls_config config; /* TS 48.008 3.2.2.116 */ |
| 297 | enum gsm0808_lcls_control control; /* TS 48.008 3.2.2.117 */ |
Harald Welte | c997ceb | 2018-05-30 01:39:43 +0200 | [diff] [blame] | 298 | /* LCLS FSM */ |
| 299 | struct osmo_fsm_inst *fi; |
| 300 | /* pointer to "other" connection, if Call Leg Relocation was successful */ |
| 301 | struct gsm_subscriber_connection *other; |
| 302 | } lcls; |
Pau Espin Pedrol | 7950e5d | 2019-10-31 15:59:49 +0100 | [diff] [blame] | 303 | |
| 304 | /* MS Power Class, TS 05.05 sec 4.1.1 "Mobile station". 0 means unset. */ |
| 305 | uint8_t ms_power_class:3; |
Neels Hofmeyr | 90f7c3c | 2020-08-29 23:01:44 +0000 | [diff] [blame] | 306 | |
| 307 | bool rx_clear_command; |
Neels Hofmeyr | 4ae338d | 2020-09-17 17:54:39 +0200 | [diff] [blame] | 308 | |
| 309 | /* Location Services handling for this subscriber */ |
| 310 | struct { |
| 311 | /* FSM to handle Perform Location Request coming in from the MSC via A interface, |
| 312 | * and receive BSSMAP-LE responses from the SMLC. */ |
| 313 | struct lcs_loc_req *loc_req; |
| 314 | |
| 315 | /* FSM to handle BSSLAP requests coming in from the SMLC via Lb interface. |
| 316 | * BSSLAP APDU are encapsulated in BSSMAP-LE Connection Oriented Information messages. */ |
| 317 | struct lcs_bsslap *bsslap; |
| 318 | |
| 319 | /* Lb interface to the SMLC: BSSMAP-LE/SCCP connection associated with this subscriber */ |
| 320 | struct { |
| 321 | int conn_id; |
| 322 | enum subscr_sccp_state state; |
| 323 | } lb; |
| 324 | } lcs; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 325 | }; |
| 326 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 327 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 328 | /* 16 is the max. number of SI2quater messages according to 3GPP TS 44.018 Table 10.5.2.33b.1: |
| 329 | 4-bit index is used (2#1111 = 10#15) */ |
| 330 | #define SI2Q_MAX_NUM 16 |
| 331 | /* length in bits (for single SI2quater message) */ |
| 332 | #define SI2Q_MAX_LEN 160 |
| 333 | #define SI2Q_MIN_LEN 18 |
| 334 | |
| 335 | struct osmo_bsc_data; |
| 336 | |
| 337 | struct osmo_bsc_sccp_con; |
| 338 | |
| 339 | /* Channel Request reason */ |
| 340 | enum gsm_chreq_reason_t { |
| 341 | GSM_CHREQ_REASON_EMERG, |
| 342 | GSM_CHREQ_REASON_PAG, |
| 343 | GSM_CHREQ_REASON_CALL, |
| 344 | GSM_CHREQ_REASON_LOCATION_UPD, |
| 345 | GSM_CHREQ_REASON_OTHER, |
| 346 | GSM_CHREQ_REASON_PDCH, |
| 347 | }; |
| 348 | |
| 349 | /* lchans 0..3 are SDCCH in combined channel configuration, |
| 350 | use 4 as magic number for BCCH hack - see osmo-bts-../oml.c:opstart_compl() */ |
| 351 | #define CCCH_LCHAN 4 |
| 352 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 353 | #define TS_MAX_LCHAN 8 |
| 354 | |
| 355 | #define HARDCODED_ARFCN 123 |
| 356 | #define HARDCODED_BSIC 0x3f /* NCC = 7 / BCC = 7 */ |
| 357 | |
| 358 | /* for multi-drop config */ |
| 359 | #define HARDCODED_BTS0_TS 1 |
| 360 | #define HARDCODED_BTS1_TS 6 |
| 361 | #define HARDCODED_BTS2_TS 11 |
| 362 | |
| 363 | #define MAX_VERSION_LENGTH 64 |
| 364 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 365 | enum gsm_hooks { |
| 366 | GSM_HOOK_NM_SWLOAD, |
| 367 | GSM_HOOK_RR_PAGING, |
| 368 | GSM_HOOK_RR_SECURITY, |
| 369 | }; |
| 370 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 371 | enum bts_gprs_mode { |
| 372 | BTS_GPRS_NONE = 0, |
| 373 | BTS_GPRS_GPRS = 1, |
| 374 | BTS_GPRS_EGPRS = 2, |
| 375 | }; |
| 376 | |
| 377 | struct gsm_lchan; |
| 378 | struct osmo_rtp_socket; |
| 379 | struct rtp_socket; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 380 | |
| 381 | /* Network Management State */ |
| 382 | struct gsm_nm_state { |
| 383 | uint8_t operational; |
| 384 | uint8_t administrative; |
| 385 | uint8_t availability; |
| 386 | }; |
| 387 | |
| 388 | struct gsm_abis_mo { |
| 389 | uint8_t obj_class; |
| 390 | uint8_t procedure_pending; |
| 391 | struct abis_om_obj_inst obj_inst; |
| 392 | const char *name; |
| 393 | struct gsm_nm_state nm_state; |
| 394 | struct tlv_parsed *nm_attr; |
| 395 | struct gsm_bts *bts; |
Pau Espin Pedrol | 4338de5 | 2020-09-30 12:52:04 +0200 | [diff] [blame] | 396 | struct osmo_fsm_inst *fi; |
| 397 | bool opstart_sent; |
Pau Espin Pedrol | 6adeb60 | 2020-09-30 12:52:53 +0200 | [diff] [blame^] | 398 | bool adm_unlock_sent; |
| 399 | bool set_attr_sent; |
| 400 | bool set_attr_ack_received; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | /* Ericsson OM2000 Managed Object */ |
| 404 | struct abis_om2k_mo { |
| 405 | uint8_t class; |
| 406 | uint8_t bts; |
| 407 | uint8_t assoc_so; |
| 408 | uint8_t inst; |
| 409 | } __attribute__ ((packed)); |
| 410 | |
| 411 | struct om2k_mo { |
| 412 | struct abis_om2k_mo addr; |
| 413 | struct osmo_fsm_inst *fsm; |
| 414 | }; |
| 415 | |
| 416 | #define A38_XOR_MIN_KEY_LEN 12 |
| 417 | #define A38_XOR_MAX_KEY_LEN 16 |
| 418 | #define A38_COMP128_KEY_LEN 16 |
| 419 | #define RSL_ENC_ALG_A5(x) (x+1) |
Neels Hofmeyr | 19ec374 | 2020-07-08 02:58:52 +0200 | [diff] [blame] | 420 | /* Up to 16 SI2quater are multiplexed; each fits 3 EARFCNS, so the practical maximum is 3*16. |
| 421 | * The real maximum that fits in a total of 16 SI2quater rest octets also depends on the bits left by other SI2quater |
| 422 | * rest octets elements, so to really fit 48 EARFCNs most other SI2quater elements need to be omitted. */ |
| 423 | #define MAX_EARFCN_LIST (3*16) |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 424 | |
| 425 | /* is the data link established? who established it? */ |
| 426 | #define LCHAN_SAPI_UNUSED 0 |
| 427 | #define LCHAN_SAPI_MS 1 |
| 428 | #define LCHAN_SAPI_NET 2 |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 429 | |
| 430 | /* BTS ONLY */ |
| 431 | #define MAX_NUM_UL_MEAS 104 |
| 432 | #define LC_UL_M_F_L1_VALID (1 << 0) |
| 433 | #define LC_UL_M_F_RES_VALID (1 << 1) |
| 434 | |
| 435 | struct bts_ul_meas { |
| 436 | /* BER in units of 0.01%: 10.000 == 100% ber, 0 == 0% ber */ |
| 437 | uint16_t ber10k; |
| 438 | /* timing advance offset (in quarter bits) */ |
| 439 | int16_t ta_offs_qbits; |
| 440 | /* C/I ratio in dB */ |
| 441 | float c_i; |
| 442 | /* flags */ |
| 443 | uint8_t is_sub:1; |
| 444 | /* RSSI in dBm * -1 */ |
| 445 | uint8_t inv_rssi; |
| 446 | }; |
| 447 | |
| 448 | struct bts_codec_conf { |
| 449 | uint8_t hr; |
| 450 | uint8_t efr; |
| 451 | uint8_t amr; |
| 452 | }; |
| 453 | |
| 454 | struct amr_mode { |
| 455 | uint8_t mode; |
| 456 | uint8_t threshold; |
| 457 | uint8_t hysteresis; |
| 458 | }; |
| 459 | |
| 460 | struct amr_multirate_conf { |
| 461 | uint8_t gsm48_ie[2]; |
| 462 | struct amr_mode ms_mode[4]; |
| 463 | struct amr_mode bts_mode[4]; |
| 464 | uint8_t num_modes; |
| 465 | }; |
| 466 | /* /BTS ONLY */ |
| 467 | |
| 468 | enum lchan_csd_mode { |
| 469 | LCHAN_CSD_M_NT, |
| 470 | LCHAN_CSD_M_T_1200_75, |
| 471 | LCHAN_CSD_M_T_600, |
| 472 | LCHAN_CSD_M_T_1200, |
| 473 | LCHAN_CSD_M_T_2400, |
| 474 | LCHAN_CSD_M_T_9600, |
| 475 | LCHAN_CSD_M_T_14400, |
| 476 | LCHAN_CSD_M_T_29000, |
| 477 | LCHAN_CSD_M_T_32000, |
| 478 | }; |
| 479 | |
| 480 | /* State of the SAPIs in the lchan */ |
| 481 | enum lchan_sapi_state { |
| 482 | LCHAN_SAPI_S_NONE, |
| 483 | LCHAN_SAPI_S_REQ, |
| 484 | LCHAN_SAPI_S_ASSIGNED, |
| 485 | LCHAN_SAPI_S_REL, |
| 486 | LCHAN_SAPI_S_ERROR, |
| 487 | }; |
| 488 | |
Neels Hofmeyr | 92b9f2e | 2018-02-14 00:19:11 +0100 | [diff] [blame] | 489 | #define MAX_A5_KEY_LEN (128/8) |
| 490 | |
| 491 | struct gsm_encr { |
| 492 | uint8_t alg_id; |
| 493 | uint8_t key_len; |
| 494 | uint8_t key[MAX_A5_KEY_LEN]; |
| 495 | }; |
| 496 | |
Neels Hofmeyr | 8da2233 | 2018-04-11 01:43:41 +0200 | [diff] [blame] | 497 | #define LOGPLCHAN(lchan, ss, level, fmt, args...) \ |
| 498 | LOGP(ss, level, "%s (ss=%d,%s) (%s) " fmt, \ |
| 499 | lchan ? gsm_ts_and_pchan_name(lchan->ts) : "-", \ |
| 500 | lchan ? lchan->nr : 0, \ |
| 501 | lchan ? gsm_lchant_name(lchan->type) : "-", \ |
| 502 | bsc_subscr_name(lchan && lchan->conn ? lchan->conn->bsub : NULL), \ |
| 503 | ## args) |
| 504 | |
Pau Espin Pedrol | d3e8e0c | 2018-11-28 16:35:10 +0100 | [diff] [blame] | 505 | /* Iterate lchans that have an FSM allocated based based on explicit pchan kind |
| 506 | * (GSM_PCHAN_* constant). |
| 507 | * Remark: PDCH related lchans are not handled in BSC but in PCU, so trying to |
| 508 | * iterate through GSM_PCHAN_PDCH is considered a void loop. |
| 509 | */ |
| 510 | #define ts_as_pchan_for_each_lchan(lchan, ts, as_pchan) \ |
| 511 | for (lchan = (ts)->lchan; \ |
| 512 | ((lchan - (ts)->lchan) < ARRAY_SIZE((ts)->lchan)) \ |
| 513 | && lchan->fi \ |
| 514 | && lchan->nr < pchan_subslots(as_pchan); \ |
| 515 | lchan++) |
| 516 | |
Pau Espin Pedrol | 7ae0f9c | 2018-11-28 16:37:37 +0100 | [diff] [blame] | 517 | /* Iterate lchans that have an FSM allocated based on current PCHAN |
| 518 | * mode set in \ref ts. |
| 519 | * usage: |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 520 | * struct gsm_lchan *lchan; |
| 521 | * struct gsm_bts_trx_ts *ts = get_some_timeslot(); |
| 522 | * ts_for_each_lchan(lchan, ts) { |
| 523 | * LOGPLCHAN(DMAIN, LOGL_DEBUG, "hello world\n"); |
| 524 | * } |
Pau Espin Pedrol | 7ae0f9c | 2018-11-28 16:37:37 +0100 | [diff] [blame] | 525 | */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 526 | #define ts_for_each_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_is) |
| 527 | |
Pau Espin Pedrol | 0ba20df | 2018-11-28 16:39:29 +0100 | [diff] [blame] | 528 | /* Iterate over all possible lchans available that have an FSM allocated based |
| 529 | * on PCHAN \ref ts (dynamic) configuration. |
| 530 | * Iterate all lchan instances set up by this \ref ts type, including those |
| 531 | * lchans currently disabled or in process of being enabled (e.g. due to dynamic |
| 532 | * timeslot in switchover). Compare ts_for_each_lchan(), which iterates only the |
| 533 | * enabled lchans. |
| 534 | * For example, it is useful in case dynamic timeslot \ref ts is in process of |
| 535 | * switching from configuration PDCH (no lchans) to TCH_F (1 lchan), where |
| 536 | * pchan_is is still set to PDCH but \ref ts may contain already an \ref lchan |
| 537 | * of type TCH_F which initiated the request to switch the \ts configuration. |
| 538 | */ |
| 539 | #define ts_for_each_potential_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_on_init) |
| 540 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 541 | enum lchan_activate_mode { |
| 542 | FOR_NONE, |
| 543 | FOR_MS_CHANNEL_REQUEST, |
| 544 | FOR_ASSIGNMENT, |
| 545 | FOR_HANDOVER, |
| 546 | FOR_VTY, |
| 547 | }; |
| 548 | |
| 549 | extern const struct value_string lchan_activate_mode_names[]; |
| 550 | static inline const char *lchan_activate_mode_name(enum lchan_activate_mode activ_for) |
| 551 | { return get_value_string(lchan_activate_mode_names, activ_for); } |
| 552 | |
Neels Hofmeyr | 700e518 | 2018-12-19 17:19:02 +0100 | [diff] [blame] | 553 | struct lchan_activate_info { |
| 554 | enum lchan_activate_mode activ_for; |
| 555 | struct gsm_subscriber_connection *for_conn; |
| 556 | /* This always is for a specific lchan, so its lchan->type indicates full or half rate. |
| 557 | * When a dyn TS was selected, the lchan->type has been set to the desired rate. */ |
| 558 | enum gsm48_chan_mode chan_mode; |
Neels Hofmeyr | 58cf1b1 | 2019-03-15 02:49:18 +0100 | [diff] [blame] | 559 | struct gsm_encr encr; |
Neels Hofmeyr | 38134ea | 2018-12-21 03:01:00 +0100 | [diff] [blame] | 560 | /* AMR config */ |
Neels Hofmeyr | 700e518 | 2018-12-19 17:19:02 +0100 | [diff] [blame] | 561 | uint16_t s15_s0; |
| 562 | bool requires_voice_stream; |
| 563 | bool wait_before_switching_rtp; /*< true = requires LCHAN_EV_READY_TO_SWITCH_RTP */ |
| 564 | uint16_t msc_assigned_cic; |
Neels Hofmeyr | 38134ea | 2018-12-21 03:01:00 +0100 | [diff] [blame] | 565 | /* During intra-BSC handover, we keep the MGW endpoint intact and just re-route to the new lchan. This |
| 566 | * activate_info is for the new lchan, the re_use_mgw_endpoint_from_lchan points at the old lchan. */ |
Neels Hofmeyr | 700e518 | 2018-12-19 17:19:02 +0100 | [diff] [blame] | 567 | struct gsm_lchan *re_use_mgw_endpoint_from_lchan; |
| 568 | }; |
| 569 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 570 | struct gsm_lchan { |
| 571 | /* The TS that we're part of */ |
| 572 | struct gsm_bts_trx_ts *ts; |
| 573 | /* The logical subslot number in the TS */ |
| 574 | uint8_t nr; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 575 | char *name; |
| 576 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 577 | char *last_error; |
| 578 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 579 | struct osmo_fsm_inst *fi; |
Neels Hofmeyr | ac85b34 | 2018-07-12 21:23:26 +0200 | [diff] [blame] | 580 | struct osmo_fsm_inst *fi_rtp; |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 581 | struct osmo_mgcpc_ep_ci *mgw_endpoint_ci_bts; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 582 | |
| 583 | struct { |
Neels Hofmeyr | 700e518 | 2018-12-19 17:19:02 +0100 | [diff] [blame] | 584 | struct lchan_activate_info info; |
Neels Hofmeyr | ac85b34 | 2018-07-12 21:23:26 +0200 | [diff] [blame] | 585 | bool activ_ack; /*< true as soon as RSL Chan Activ Ack is received */ |
Neels Hofmeyr | 369fba2 | 2018-11-27 01:30:50 +0100 | [diff] [blame] | 586 | bool immediate_assignment_sent; |
Neels Hofmeyr | 193c1e3 | 2018-08-27 22:06:24 +0200 | [diff] [blame] | 587 | /*! This flag ensures that when an lchan activation has succeeded, and we have already |
| 588 | * sent ACKs like Immediate Assignment or BSSMAP Assignment Complete, and if other errors |
| 589 | * occur later, e.g. during release, that we don't send a NACK out of context. */ |
| 590 | bool concluded; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 591 | enum gsm0808_cause gsm0808_error_cause; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 592 | } activate; |
| 593 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 594 | struct { |
| 595 | /* If an event to release the lchan comes in while still waiting for responses, just mark this |
| 596 | * flag, so that the lchan will gracefully release at the next sensible junction. */ |
| 597 | bool requested; |
| 598 | bool do_rr_release; |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 599 | enum gsm48_rr_cause rr_cause; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 600 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 601 | /* There is an RSL error cause of value 0, so we need a separate flag. */ |
| 602 | bool in_error; |
| 603 | /* RSL error code, RSL_ERR_* */ |
| 604 | uint8_t rsl_error_cause; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 605 | |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 606 | /* If a release event is being handled, ignore other ricocheting release events until that |
| 607 | * release handling has concluded. */ |
| 608 | bool in_release_handler; |
Harald Welte | 963763d | 2019-02-03 12:11:12 +0100 | [diff] [blame] | 609 | |
| 610 | /* is this release at the end of a CSFB call? */ |
| 611 | bool is_csfb; |
Neels Hofmeyr | eee24eb | 2018-11-06 21:39:15 +0100 | [diff] [blame] | 612 | } release; |
Neels Hofmeyr | d5df9a1 | 2018-07-20 05:35:47 +0200 | [diff] [blame] | 613 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 614 | /* The logical channel type */ |
| 615 | enum gsm_chan_t type; |
| 616 | /* RSL channel mode */ |
| 617 | enum rsl_cmod_spd rsl_cmode; |
| 618 | /* If TCH, traffic channel mode */ |
| 619 | enum gsm48_chan_mode tch_mode; |
| 620 | enum lchan_csd_mode csd_mode; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 621 | /* Power levels for MS and BTS */ |
| 622 | uint8_t bs_power; |
| 623 | uint8_t ms_power; |
| 624 | /* Encryption information */ |
| 625 | struct gsm_encr encr; |
| 626 | |
| 627 | /* AMR bits */ |
| 628 | uint8_t mr_ms_lv[7]; |
| 629 | uint8_t mr_bts_lv[7]; |
Neels Hofmeyr | 4daa210 | 2019-01-30 16:46:58 +0100 | [diff] [blame] | 630 | /* AMR bits were based on these rate bits: */ |
| 631 | uint16_t s15_s0; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 632 | |
| 633 | /* Established data link layer services */ |
| 634 | uint8_t sapis[8]; |
| 635 | |
| 636 | struct { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 637 | uint32_t bound_ip; /*< where the BTS receives RTP */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 638 | uint16_t bound_port; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 639 | uint32_t connect_ip; /*< where the BTS sends RTP to (MGW) */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 640 | uint16_t connect_port; |
| 641 | uint16_t conn_id; |
| 642 | uint8_t rtp_payload; |
| 643 | uint8_t rtp_payload2; |
| 644 | uint8_t speech_mode; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 645 | |
| 646 | /* info we need to postpone the AoIP |
| 647 | * assignment completed message */ |
| 648 | struct { |
| 649 | uint8_t rr_cause; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 650 | bool valid; |
| 651 | } ass_compl; |
| 652 | } abis_ip; |
| 653 | |
| 654 | uint8_t rqd_ta; |
| 655 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 656 | /* table of neighbor cell measurements */ |
| 657 | struct neigh_meas_proc neigh_meas[MAX_NEIGH_MEAS]; |
| 658 | |
| 659 | /* cache of last measurement reports on this lchan */ |
| 660 | struct gsm_meas_rep meas_rep[MAX_MEAS_REP]; |
| 661 | int meas_rep_idx; |
| 662 | int meas_rep_count; |
Neels Hofmeyr | 35ba85c | 2018-02-12 16:47:40 +0100 | [diff] [blame] | 663 | uint8_t meas_rep_last_seen_nr; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 664 | |
| 665 | /* GSM Random Access data */ |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 666 | /* TODO: don't allocate this, rather keep an "is_present" flag */ |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 667 | struct gsm48_req_ref *rqd_ref; |
| 668 | |
| 669 | struct gsm_subscriber_connection *conn; |
Philipp Maier | bb66d10 | 2019-01-22 11:29:06 +0100 | [diff] [blame] | 670 | |
| 671 | /* Depending on the preferences that where submitted together with |
| 672 | * the assignment and the current channel load, the BSC has to select |
| 673 | * one of the offered codec/rates. The final selection by the BSC is |
| 674 | * stored here and is used when sending the assignment complete or |
| 675 | * when performing a handover procedure. */ |
| 676 | struct channel_mode_and_rate ch_mode_rate; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 677 | }; |
| 678 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 679 | /* One Timeslot in a TRX */ |
| 680 | struct gsm_bts_trx_ts { |
| 681 | struct gsm_bts_trx *trx; |
| 682 | /* number of this timeslot at the TRX */ |
| 683 | uint8_t nr; |
| 684 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 685 | struct osmo_fsm_inst *fi; |
| 686 | char *last_errmsg; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 687 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 688 | /* vty phys_chan_config setting, not necessarily in effect in case it was changed in the telnet |
| 689 | * vty after OML activation. Gets written on vty 'write file'. */ |
| 690 | enum gsm_phys_chan_config pchan_from_config; |
| 691 | /* When the timeslot OML is established, pchan_from_config is copied here. This is the pchan |
| 692 | * currently in effect; for dynamic ts, this is the dyn kind (GSM_PCHAN_TCH_F_TCH_H_PDCH or |
| 693 | * GSM_PCHAN_TCH_F_PDCH) and does not show the pchan type currently active. */ |
| 694 | enum gsm_phys_chan_config pchan_on_init; |
| 695 | /* This is the *actual* pchan type currently active. For dynamic timeslots, this reflects either |
| 696 | * GSM_PCHAN_NONE or one of the standard GSM_PCHAN_TCH_F, GSM_PCHAN_TCH_H, GSM_PCHAN_PDCH. |
| 697 | * Callers can use this transparently without being aware of dyn ts. */ |
| 698 | enum gsm_phys_chan_config pchan_is; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 699 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 700 | /* After a PDCH ACT NACK, we shall not infinitely loop to try and ACT again. |
| 701 | * Also marks a timeslot where PDCH was deactivated by VTY. This is cleared whenever a timeslot |
| 702 | * enters IN_USE state, i.e. after each TCH use we try to PDCH ACT once again. */ |
| 703 | bool pdch_act_allowed; |
| 704 | |
Neels Hofmeyr | bcdbfb7 | 2018-07-26 20:33:15 +0200 | [diff] [blame] | 705 | /* Whether TS_EV_OML_READY was received */ |
| 706 | bool is_oml_ready; |
| 707 | /* Whether TS_EV_RSL_READY was received */ |
| 708 | bool is_rsl_ready; |
| 709 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 710 | struct gsm_abis_mo mo; |
| 711 | struct tlv_parsed nm_attr; |
| 712 | uint8_t nm_chan_comb; |
| 713 | int tsc; /* -1 == use BTS TSC */ |
| 714 | |
| 715 | struct { |
| 716 | /* Parameters below are configured by VTY */ |
| 717 | int enabled; |
| 718 | uint8_t maio; |
| 719 | uint8_t hsn; |
| 720 | struct bitvec arfcns; |
| 721 | uint8_t arfcns_data[1024/8]; |
| 722 | /* This is the pre-computed MA for channel assignments */ |
| 723 | struct bitvec ma; |
| 724 | uint8_t ma_len; /* part of ma_data that is used */ |
| 725 | uint8_t ma_data[8]; /* 10.5.2.21: max 8 bytes value part */ |
| 726 | } hopping; |
| 727 | |
| 728 | /* To which E1 subslot are we connected */ |
| 729 | struct gsm_e1_subslot e1_link; |
| 730 | |
| 731 | union { |
| 732 | struct { |
| 733 | struct om2k_mo om2k_mo; |
| 734 | } rbs2000; |
| 735 | }; |
| 736 | |
| 737 | struct gsm_lchan lchan[TS_MAX_LCHAN]; |
| 738 | }; |
| 739 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 740 | #define GSM_LCHAN_SI(lchan, i) (void *)((lchan)->si.buf[i][0]) |
| 741 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 742 | /* |
| 743 | * This keeps track of the paging status of one BTS. It |
| 744 | * includes a number of pending requests, a back pointer |
| 745 | * to the gsm_bts, a timer and some more state. |
| 746 | */ |
| 747 | struct gsm_bts_paging_state { |
| 748 | /* pending requests */ |
| 749 | struct llist_head pending_requests; |
| 750 | struct gsm_bts *bts; |
| 751 | |
| 752 | struct osmo_timer_list work_timer; |
| 753 | struct osmo_timer_list credit_timer; |
| 754 | |
| 755 | /* free chans needed */ |
| 756 | int free_chans_need; |
| 757 | |
| 758 | /* load */ |
| 759 | uint16_t available_slots; |
| 760 | }; |
| 761 | |
| 762 | struct gsm_envabtse { |
| 763 | struct gsm_abis_mo mo; |
| 764 | }; |
| 765 | |
| 766 | struct gsm_bts_gprs_nsvc { |
| 767 | struct gsm_bts *bts; |
| 768 | /* data read via VTY config file, to configure the BTS |
| 769 | * via OML from BSC */ |
| 770 | int id; |
| 771 | uint16_t nsvci; |
| 772 | uint16_t local_port; /* on the BTS */ |
Alexander Couzens | 2f9df96 | 2020-09-21 18:35:24 +0200 | [diff] [blame] | 773 | struct osmo_sockaddr remote; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 774 | struct gsm_abis_mo mo; |
| 775 | }; |
| 776 | |
| 777 | enum gprs_rlc_par { |
| 778 | RLC_T3142, |
| 779 | RLC_T3169, |
| 780 | RLC_T3191, |
| 781 | RLC_T3193, |
| 782 | RLC_T3195, |
| 783 | RLC_N3101, |
| 784 | RLC_N3103, |
| 785 | RLC_N3105, |
| 786 | CV_COUNTDOWN, |
| 787 | T_DL_TBF_EXT, /* ms */ |
| 788 | T_UL_TBF_EXT, /* ms */ |
| 789 | _NUM_RLC_PAR |
| 790 | }; |
| 791 | |
| 792 | enum gprs_cs { |
| 793 | GPRS_CS1, |
| 794 | GPRS_CS2, |
| 795 | GPRS_CS3, |
| 796 | GPRS_CS4, |
| 797 | GPRS_MCS1, |
| 798 | GPRS_MCS2, |
| 799 | GPRS_MCS3, |
| 800 | GPRS_MCS4, |
| 801 | GPRS_MCS5, |
| 802 | GPRS_MCS6, |
| 803 | GPRS_MCS7, |
| 804 | GPRS_MCS8, |
| 805 | GPRS_MCS9, |
| 806 | _NUM_GRPS_CS |
| 807 | }; |
| 808 | |
| 809 | struct gprs_rlc_cfg { |
| 810 | uint16_t parameter[_NUM_RLC_PAR]; |
| 811 | struct { |
| 812 | uint16_t repeat_time; /* ms */ |
| 813 | uint8_t repeat_count; |
| 814 | } paging; |
| 815 | uint32_t cs_mask; /* bitmask of gprs_cs */ |
| 816 | uint8_t initial_cs; |
| 817 | uint8_t initial_mcs; |
| 818 | }; |
| 819 | |
| 820 | |
| 821 | enum neigh_list_manual_mode { |
| 822 | NL_MODE_AUTOMATIC = 0, |
| 823 | NL_MODE_MANUAL = 1, |
| 824 | NL_MODE_MANUAL_SI5SEP = 2, /* SI2 and SI5 have separate neighbor lists */ |
| 825 | }; |
| 826 | |
| 827 | enum bts_loc_fix { |
| 828 | BTS_LOC_FIX_INVALID = 0, |
| 829 | BTS_LOC_FIX_2D = 1, |
| 830 | BTS_LOC_FIX_3D = 2, |
| 831 | }; |
| 832 | |
| 833 | extern const struct value_string bts_loc_fix_names[]; |
| 834 | |
| 835 | struct bts_location { |
| 836 | struct llist_head list; |
| 837 | time_t tstamp; |
| 838 | enum bts_loc_fix valid; |
| 839 | double lat; |
| 840 | double lon; |
| 841 | double height; |
| 842 | }; |
| 843 | |
| 844 | /* Channel load counter */ |
| 845 | struct load_counter { |
| 846 | unsigned int total; |
| 847 | unsigned int used; |
| 848 | }; |
| 849 | |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 850 | /* Useful to track N-N relations between BTS, for example neighbors. */ |
| 851 | struct gsm_bts_ref { |
| 852 | struct llist_head entry; |
| 853 | struct gsm_bts *bts; |
| 854 | }; |
| 855 | |
Harald Welte | d41b7c7 | 2019-06-13 09:41:58 +0200 | [diff] [blame] | 856 | /* A single Page of a SMSCB message */ |
| 857 | struct bts_smscb_page { |
| 858 | /* SMSCB message we're part of */ |
| 859 | struct bts_smscb_message *msg; |
| 860 | /* Page Number within message (1 to 15) */ |
| 861 | uint8_t nr; |
| 862 | /* number of valid blocks in data (up to 4) */ |
| 863 | uint8_t num_blocks; |
| 864 | /* up to four blocks of 22 bytes each */ |
| 865 | uint8_t data[88]; |
| 866 | }; |
| 867 | |
| 868 | /* A SMSCB message (received from CBSP) */ |
| 869 | struct bts_smscb_message { |
| 870 | /* entry in bts_smscb_chan_state.messages */ |
| 871 | struct llist_head list; |
| 872 | struct { |
| 873 | /* input data from CBSP (CBC) side */ |
| 874 | uint16_t msg_id; |
| 875 | uint16_t serial_nr; |
| 876 | enum cbsp_category category; |
| 877 | uint16_t rep_period; |
| 878 | uint16_t num_bcast_req; |
| 879 | uint8_t dcs; |
| 880 | } input; |
| 881 | /* how often have all pages of this message been broadcast? */ |
| 882 | uint32_t bcast_count; |
| 883 | /* actual page data of this message */ |
| 884 | uint8_t num_pages; /* up to 15 */ |
| 885 | struct bts_smscb_page page[15]; |
| 886 | }; |
| 887 | |
| 888 | /* per-channel (basic/extended) CBCH state for a single BTS */ |
| 889 | struct bts_smscb_chan_state { |
| 890 | /* back-pointer to BTS */ |
| 891 | struct gsm_bts *bts; |
| 892 | /* list of bts_smscb_message */ |
| 893 | struct llist_head messages; |
| 894 | /* scheduling array; pointer of SMSCB pages */ |
| 895 | struct bts_smscb_page **sched_arr; |
| 896 | size_t sched_arr_size; |
| 897 | /* index of the next to be transmitted page into the scheduler array */ |
| 898 | size_t next_idx; |
| 899 | /* number of messages we have to pause due to overflow */ |
| 900 | uint8_t overflow; |
| 901 | }; |
| 902 | |
Oliver Smith | ba0a122 | 2020-03-18 12:39:30 +0100 | [diff] [blame] | 903 | struct bts_oml_fail_rep { |
| 904 | struct llist_head list; |
| 905 | time_t time; |
| 906 | struct msgb *mb; |
| 907 | }; |
| 908 | |
Oliver Smith | 8d8d710 | 2018-10-23 15:35:43 +0200 | [diff] [blame] | 909 | /* One rejected BTS */ |
| 910 | struct gsm_bts_rejected { |
| 911 | /* list header in net->bts_rejected */ |
| 912 | struct llist_head list; |
| 913 | |
| 914 | uint16_t site_id; |
| 915 | uint16_t bts_id; |
| 916 | char ip[INET6_ADDRSTRLEN]; |
| 917 | time_t time; |
| 918 | }; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 919 | |
Neels Hofmeyr | 638eb99 | 2020-09-16 00:56:19 +0200 | [diff] [blame] | 920 | extern struct osmo_tdef_group bsc_tdef_group[]; |
| 921 | |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 922 | struct gsm_network *gsm_network_init(void *ctx); |
| 923 | |
Neels Hofmeyr | 6d568ed | 2018-07-09 16:49:18 +0200 | [diff] [blame] | 924 | struct gsm_bts *gsm_bts_num(const struct gsm_network *net, int num); |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 925 | struct gsm_bts *gsm_bts_by_cell_id(const struct gsm_network *net, |
| 926 | const struct gsm0808_cell_id *cell_id, |
| 927 | int match_idx); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 928 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 929 | extern const struct value_string gsm_chreq_descs[]; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 930 | extern const struct value_string gsm_pchant_names[]; |
| 931 | extern const struct value_string gsm_pchant_descs[]; |
| 932 | extern const struct value_string gsm_pchan_ids[]; |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 933 | const char *gsm_pchan_name(enum gsm_phys_chan_config c); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 934 | static inline const char *gsm_pchan_id(enum gsm_phys_chan_config c) |
| 935 | { return get_value_string(gsm_pchan_ids, c); } |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 936 | enum gsm_phys_chan_config gsm_pchan_parse(const char *name); |
| 937 | const char *gsm_lchant_name(enum gsm_chan_t c); |
| 938 | const char *gsm_chreq_name(enum gsm_chreq_reason_t c); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 939 | char *gsm_ts_name(const struct gsm_bts_trx_ts *ts); |
| 940 | char *gsm_ts_and_pchan_name(const struct gsm_bts_trx_ts *ts); |
| 941 | char *gsm_lchan_name_compute(const struct gsm_lchan *lchan); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 942 | |
| 943 | static inline char *gsm_lchan_name(const struct gsm_lchan *lchan) |
| 944 | { |
| 945 | return lchan->name; |
| 946 | } |
| 947 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 948 | void gsm_abis_mo_reset(struct gsm_abis_mo *mo); |
Pau Espin Pedrol | 388ed58 | 2020-07-15 20:53:16 +0200 | [diff] [blame] | 949 | void gsm_mo_init(struct gsm_abis_mo *mo, struct gsm_bts *bts, |
| 950 | uint8_t obj_class, uint8_t p1, uint8_t p2, uint8_t p3); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 951 | |
| 952 | struct gsm_nm_state * |
| 953 | gsm_objclass2nmstate(struct gsm_bts *bts, uint8_t obj_class, |
| 954 | const struct abis_om_obj_inst *obj_inst); |
| 955 | void * |
| 956 | gsm_objclass2obj(struct gsm_bts *bts, uint8_t obj_class, |
| 957 | const struct abis_om_obj_inst *obj_inst); |
| 958 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 959 | uint8_t gsm_pchan2chan_nr(enum gsm_phys_chan_config pchan, |
| 960 | uint8_t ts_nr, uint8_t lchan_nr); |
| 961 | uint8_t gsm_lchan2chan_nr(const struct gsm_lchan *lchan); |
| 962 | uint8_t gsm_lchan_as_pchan2chan_nr(const struct gsm_lchan *lchan, |
| 963 | enum gsm_phys_chan_config as_pchan); |
| 964 | |
Harald Welte | 251bec1 | 2018-09-09 17:14:09 +0200 | [diff] [blame] | 965 | void gsm48_lchan2chan_desc(struct gsm48_chan_desc *cd, |
| 966 | const struct gsm_lchan *lchan); |
Harald Welte | 24286f3 | 2018-09-09 17:17:44 +0200 | [diff] [blame] | 967 | void gsm48_lchan2chan_desc_as_configured(struct gsm48_chan_desc *cd, const struct gsm_lchan *lchan); |
Harald Welte | 251bec1 | 2018-09-09 17:14:09 +0200 | [diff] [blame] | 968 | |
Pau Espin Pedrol | 388ed58 | 2020-07-15 20:53:16 +0200 | [diff] [blame] | 969 | uint8_t gsm_ts_tsc(const struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 970 | |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 971 | enum gsm_phys_chan_config ts_pchan(struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 972 | uint8_t pchan_subslots(enum gsm_phys_chan_config pchan); |
Neels Hofmeyr | 1048516 | 2018-02-13 23:22:03 +0100 | [diff] [blame] | 973 | bool ts_is_tch(struct gsm_bts_trx_ts *ts); |
| 974 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 975 | |
Pau Espin Pedrol | 388ed58 | 2020-07-15 20:53:16 +0200 | [diff] [blame] | 976 | struct gsm_bts *conn_get_bts(struct gsm_subscriber_connection *conn); |
Harald Welte | b794887 | 2017-12-18 18:48:21 +0100 | [diff] [blame] | 977 | |
Pau Espin Pedrol | 7950e5d | 2019-10-31 15:59:49 +0100 | [diff] [blame] | 978 | void conn_update_ms_power_class(struct gsm_subscriber_connection *conn, uint8_t power_class); |
| 979 | void lchan_update_ms_power_ctrl_level(struct gsm_lchan *lchan, int ms_power_dbm); |
| 980 | |
Stefan Sperling | 81dc9e7 | 2018-02-05 17:34:36 +0100 | [diff] [blame] | 981 | enum { |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 982 | BSC_CTR_ASSIGNMENT_ATTEMPTED, |
| 983 | BSC_CTR_ASSIGNMENT_COMPLETED, |
| 984 | BSC_CTR_ASSIGNMENT_STOPPED, |
| 985 | BSC_CTR_ASSIGNMENT_NO_CHANNEL, |
| 986 | BSC_CTR_ASSIGNMENT_TIMEOUT, |
| 987 | BSC_CTR_ASSIGNMENT_FAILED, |
| 988 | BSC_CTR_ASSIGNMENT_ERROR, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 989 | BSC_CTR_HANDOVER_ATTEMPTED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 990 | BSC_CTR_HANDOVER_COMPLETED, |
| 991 | BSC_CTR_HANDOVER_STOPPED, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 992 | BSC_CTR_HANDOVER_NO_CHANNEL, |
| 993 | BSC_CTR_HANDOVER_TIMEOUT, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 994 | BSC_CTR_HANDOVER_FAILED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 995 | BSC_CTR_HANDOVER_ERROR, |
Daniel Willmann | bf2a4b6 | 2020-08-20 15:25:37 +0200 | [diff] [blame] | 996 | BSC_CTR_INTRA_CELL_HO_ATTEMPTED, |
| 997 | BSC_CTR_INTRA_CELL_HO_COMPLETED, |
| 998 | BSC_CTR_INTRA_CELL_HO_STOPPED, |
| 999 | BSC_CTR_INTRA_CELL_HO_NO_CHANNEL, |
| 1000 | BSC_CTR_INTRA_CELL_HO_TIMEOUT, |
| 1001 | BSC_CTR_INTRA_CELL_HO_FAILED, |
| 1002 | BSC_CTR_INTRA_CELL_HO_ERROR, |
| 1003 | BSC_CTR_INTRA_BSC_HO_ATTEMPTED, |
| 1004 | BSC_CTR_INTRA_BSC_HO_COMPLETED, |
| 1005 | BSC_CTR_INTRA_BSC_HO_STOPPED, |
| 1006 | BSC_CTR_INTRA_BSC_HO_NO_CHANNEL, |
| 1007 | BSC_CTR_INTRA_BSC_HO_TIMEOUT, |
| 1008 | BSC_CTR_INTRA_BSC_HO_FAILED, |
| 1009 | BSC_CTR_INTRA_BSC_HO_ERROR, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1010 | BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED, |
| 1011 | BSC_CTR_INTER_BSC_HO_OUT_COMPLETED, |
| 1012 | BSC_CTR_INTER_BSC_HO_OUT_STOPPED, |
| 1013 | BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT, |
Neels Hofmeyr | dbe59f6 | 2020-08-29 03:23:31 +0000 | [diff] [blame] | 1014 | BSC_CTR_INTER_BSC_HO_OUT_FAILED, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1015 | BSC_CTR_INTER_BSC_HO_OUT_ERROR, |
| 1016 | BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED, |
| 1017 | BSC_CTR_INTER_BSC_HO_IN_COMPLETED, |
| 1018 | BSC_CTR_INTER_BSC_HO_IN_STOPPED, |
| 1019 | BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL, |
| 1020 | BSC_CTR_INTER_BSC_HO_IN_FAILED, |
| 1021 | BSC_CTR_INTER_BSC_HO_IN_TIMEOUT, |
| 1022 | BSC_CTR_INTER_BSC_HO_IN_ERROR, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1023 | BSC_CTR_PAGING_ATTEMPTED, |
| 1024 | BSC_CTR_PAGING_DETACHED, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1025 | BSC_CTR_PAGING_RESPONDED, |
Alexander Chemeris | 43def74 | 2020-05-16 18:49:59 +0300 | [diff] [blame] | 1026 | BSC_CTR_PAGING_NO_ACTIVE_PAGING, |
Stefan Sperling | 7926d98 | 2018-05-17 14:52:02 +0200 | [diff] [blame] | 1027 | BSC_CTR_UNKNOWN_UNIT_ID, |
Neels Hofmeyr | 1c963eb | 2020-06-16 12:08:39 +0200 | [diff] [blame] | 1028 | BSC_CTR_MSCPOOL_SUBSCR_NO_MSC, |
| 1029 | BSC_CTR_MSCPOOL_EMERG_FORWARDED, |
| 1030 | BSC_CTR_MSCPOOL_EMERG_LOST, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1031 | }; |
| 1032 | |
| 1033 | static const struct rate_ctr_desc bsc_ctr_description[] = { |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1034 | [BSC_CTR_ASSIGNMENT_ATTEMPTED] = {"assignment:attempted", "Assignment attempts"}, |
| 1035 | [BSC_CTR_ASSIGNMENT_COMPLETED] = {"assignment:completed", "Assignment completed"}, |
| 1036 | [BSC_CTR_ASSIGNMENT_STOPPED] = {"assignment:stopped", "Connection ended during Assignment"}, |
| 1037 | [BSC_CTR_ASSIGNMENT_NO_CHANNEL] = {"assignment:no_channel", "Failure to allocate lchan for Assignment"}, |
| 1038 | [BSC_CTR_ASSIGNMENT_TIMEOUT] = {"assignment:timeout", "Assignment timed out"}, |
| 1039 | [BSC_CTR_ASSIGNMENT_FAILED] = {"assignment:failed", "Received Assignment Failure message"}, |
| 1040 | [BSC_CTR_ASSIGNMENT_ERROR] = {"assignment:error", "Assignment failed for other reason"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1041 | |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1042 | [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover:attempted", "Intra-BSC handover attempts"}, |
| 1043 | [BSC_CTR_HANDOVER_COMPLETED] = {"handover:completed", "Intra-BSC handover completed"}, |
| 1044 | [BSC_CTR_HANDOVER_STOPPED] = {"handover:stopped", "Connection ended during HO"}, |
| 1045 | [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover:no_channel", "Failure to allocate lchan for HO"}, |
| 1046 | [BSC_CTR_HANDOVER_TIMEOUT] = {"handover:timeout", "Handover timed out"}, |
| 1047 | [BSC_CTR_HANDOVER_FAILED] = {"handover:failed", "Received Handover Fail messages"}, |
| 1048 | [BSC_CTR_HANDOVER_ERROR] = {"handover:error", "Re-assignment failed for other reason"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1049 | |
Daniel Willmann | bf2a4b6 | 2020-08-20 15:25:37 +0200 | [diff] [blame] | 1050 | [BSC_CTR_INTRA_CELL_HO_ATTEMPTED] = {"intra_cell_ho:attempted", "Intra-Cell handover attempts"}, |
| 1051 | [BSC_CTR_INTRA_CELL_HO_COMPLETED] = {"intra_cell_ho:completed", "Intra-Cell handover completed"}, |
| 1052 | [BSC_CTR_INTRA_CELL_HO_STOPPED] = {"intra_cell_ho:stopped", "Connection ended during HO"}, |
| 1053 | [BSC_CTR_INTRA_CELL_HO_NO_CHANNEL] = {"intra_cell_ho:no_channel", "Failure to allocate lchan for HO"}, |
| 1054 | [BSC_CTR_INTRA_CELL_HO_TIMEOUT] = {"intra_cell_ho:timeout", "Handover timed out"}, |
| 1055 | [BSC_CTR_INTRA_CELL_HO_FAILED] = {"intra_cell_ho:failed", "Received Handover Fail messages"}, |
| 1056 | [BSC_CTR_INTRA_CELL_HO_ERROR] = {"intra_cell_ho:error", "Re-assignment failed for other reason"}, |
| 1057 | |
| 1058 | [BSC_CTR_INTRA_BSC_HO_ATTEMPTED] = {"intra_bsc_ho:attempted", "Intra-BSC handover attempts"}, |
| 1059 | [BSC_CTR_INTRA_BSC_HO_COMPLETED] = {"intra_bsc_ho:completed", "Intra-BSC handover completed"}, |
| 1060 | [BSC_CTR_INTRA_BSC_HO_STOPPED] = {"intra_bsc_ho:stopped", "Connection ended during HO"}, |
| 1061 | [BSC_CTR_INTRA_BSC_HO_NO_CHANNEL] = {"intra_bsc_ho:no_channel", "Failure to allocate lchan for HO"}, |
| 1062 | [BSC_CTR_INTRA_BSC_HO_TIMEOUT] = {"intra_bsc_ho:timeout", "Handover timed out"}, |
| 1063 | [BSC_CTR_INTRA_BSC_HO_FAILED] = {"intra_bsc_ho:failed", "Received Handover Fail messages"}, |
| 1064 | [BSC_CTR_INTRA_BSC_HO_ERROR] = {"intra_bsc_ho:error", "Re-assignment failed for other reason"}, |
| 1065 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1066 | [BSC_CTR_INTER_BSC_HO_OUT_ATTEMPTED] = {"interbsc_ho_out:attempted", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1067 | "Attempts to handover to remote BSS"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1068 | [BSC_CTR_INTER_BSC_HO_OUT_COMPLETED] = {"interbsc_ho_out:completed", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1069 | "Handover to remote BSS completed"}, |
| 1070 | [BSC_CTR_INTER_BSC_HO_OUT_STOPPED] = {"interbsc_ho_out:stopped", "Connection ended during HO"}, |
| 1071 | [BSC_CTR_INTER_BSC_HO_OUT_TIMEOUT] = {"interbsc_ho_out:timeout", "Handover timed out"}, |
Neels Hofmeyr | dbe59f6 | 2020-08-29 03:23:31 +0000 | [diff] [blame] | 1072 | [BSC_CTR_INTER_BSC_HO_OUT_FAILED] = {"interbsc_ho_out:failed", "Received Handover Fail message"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1073 | [BSC_CTR_INTER_BSC_HO_OUT_ERROR] = {"interbsc_ho_out:error", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1074 | "Handover to remote BSS failed for other reason"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1075 | |
| 1076 | [BSC_CTR_INTER_BSC_HO_IN_ATTEMPTED] = {"interbsc_ho_in:attempted", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1077 | "Attempts to handover from remote BSS"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1078 | [BSC_CTR_INTER_BSC_HO_IN_COMPLETED] = {"interbsc_ho_in:completed", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1079 | "Handover from remote BSS completed"}, |
| 1080 | [BSC_CTR_INTER_BSC_HO_IN_STOPPED] = {"interbsc_ho_in:stopped", "Connection ended during HO"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1081 | [BSC_CTR_INTER_BSC_HO_IN_NO_CHANNEL] = {"interbsc_ho_in:no_channel", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1082 | "Failure to allocate lchan for HO"}, |
| 1083 | [BSC_CTR_INTER_BSC_HO_IN_TIMEOUT] = {"interbsc_ho_in:timeout", "Handover from remote BSS timed out"}, |
| 1084 | [BSC_CTR_INTER_BSC_HO_IN_FAILED] = {"interbsc_ho_in:failed", "Received Handover Fail message"}, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1085 | [BSC_CTR_INTER_BSC_HO_IN_ERROR] = {"interbsc_ho_in:error", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1086 | "Handover from remote BSS failed for other reason"}, |
Harald Welte | cf9d431 | 2017-12-13 23:17:16 +0100 | [diff] [blame] | 1087 | |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1088 | [BSC_CTR_PAGING_ATTEMPTED] = {"paging:attempted", "Paging attempts for a subscriber"}, |
| 1089 | [BSC_CTR_PAGING_DETACHED] = {"paging:detached", "Paging request send failures because no responsible BTS was found"}, |
| 1090 | [BSC_CTR_PAGING_RESPONDED] = {"paging:responded", "Paging attempts with successful response"}, |
| 1091 | [BSC_CTR_PAGING_NO_ACTIVE_PAGING] = {"paging:no_active_paging", "Paging response without an active paging request (arrived after paging expiration?)"}, |
Stefan Sperling | 7926d98 | 2018-05-17 14:52:02 +0200 | [diff] [blame] | 1092 | |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1093 | [BSC_CTR_UNKNOWN_UNIT_ID] = {"abis:unknown_unit_id", "Connection attempts from unknown IPA CCM Unit ID"}, |
Neels Hofmeyr | 1c963eb | 2020-06-16 12:08:39 +0200 | [diff] [blame] | 1094 | |
| 1095 | [BSC_CTR_MSCPOOL_SUBSCR_NO_MSC] = {"mscpool:subscr:no_msc", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1096 | "Complete Layer 3 requests lost because no connected MSC is found available"}, |
Neels Hofmeyr | 1c963eb | 2020-06-16 12:08:39 +0200 | [diff] [blame] | 1097 | [BSC_CTR_MSCPOOL_EMERG_FORWARDED] = {"mscpool:emerg:forwarded", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1098 | "Emergency call requests forwarded to an MSC (see also per-MSC counters"}, |
Neels Hofmeyr | 1c963eb | 2020-06-16 12:08:39 +0200 | [diff] [blame] | 1099 | [BSC_CTR_MSCPOOL_EMERG_LOST] = {"mscpool:emerg:lost", |
Daniel Willmann | 45062b4 | 2020-08-20 18:37:51 +0200 | [diff] [blame] | 1100 | "Emergency call requests lost because no MSC was found available"}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1101 | }; |
| 1102 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1103 | |
| 1104 | |
| 1105 | static const struct rate_ctr_group_desc bsc_ctrg_desc = { |
| 1106 | "bsc", |
| 1107 | "base station controller", |
| 1108 | OSMO_STATS_CLASS_GLOBAL, |
| 1109 | ARRAY_SIZE(bsc_ctr_description), |
| 1110 | bsc_ctr_description, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 1111 | }; |
| 1112 | |
Alexander Chemeris | db54283 | 2020-05-08 01:49:12 +0300 | [diff] [blame] | 1113 | /* Constants for the BSC stats */ |
| 1114 | enum { |
| 1115 | BSC_STAT_NUM_BTS_TOTAL, |
| 1116 | }; |
| 1117 | |
Daniel Willmann | aa420ce | 2020-08-20 15:37:35 +0200 | [diff] [blame] | 1118 | /* BTS counter index if a BTS could not be found |
| 1119 | * Currently we are limited to bts 0 - 255 in the VTY, but that might change in |
| 1120 | * the future so use 2**16 */ |
| 1121 | #define BTS_STAT_IDX_UNKNOWN (UINT16_MAX + 1) |
| 1122 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1123 | struct gsm_tz { |
| 1124 | int override; /* if 0, use system's time zone instead. */ |
| 1125 | int hr; /* hour */ |
| 1126 | int mn; /* minute */ |
| 1127 | int dst; /* daylight savings */ |
| 1128 | }; |
| 1129 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1130 | struct gsm_network { |
Neels Hofmeyr | ce4d88b | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 1131 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 1132 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 1133 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 1134 | * these have in common, like country and network code, put in yet |
| 1135 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 1136 | |
Neels Hofmeyr | f93970b | 2018-03-05 02:09:40 +0100 | [diff] [blame] | 1137 | struct osmo_plmn_id plmn; |
| 1138 | |
Harald Welte | 51e4bf3 | 2017-12-23 17:30:18 +0100 | [diff] [blame] | 1139 | /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ |
| 1140 | uint8_t a5_encryption_mask; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 1141 | int neci; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1142 | |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 1143 | struct handover_cfg *ho; |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame] | 1144 | struct { |
| 1145 | unsigned int congestion_check_interval_s; |
| 1146 | struct osmo_timer_list congestion_check_timer; |
| 1147 | } hodec2; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1148 | |
Alexander Chemeris | db54283 | 2020-05-08 01:49:12 +0300 | [diff] [blame] | 1149 | /* structures for keeping rate counters and gauge stats */ |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 1150 | struct rate_ctr_group *bsc_ctrs; |
Alexander Chemeris | db54283 | 2020-05-08 01:49:12 +0300 | [diff] [blame] | 1151 | struct osmo_stat_item_group *bsc_statg; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 1152 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1153 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 1154 | struct llist_head bts_list; |
Oliver Smith | 8d8d710 | 2018-10-23 15:35:43 +0200 | [diff] [blame] | 1155 | struct llist_head bts_rejected; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 1156 | |
Daniel Willmann | aa420ce | 2020-08-20 15:37:35 +0200 | [diff] [blame] | 1157 | /* BTS-based counters when we can't find the actual BTS |
| 1158 | * e.g. when conn->lchan is NULL */ |
| 1159 | struct rate_ctr_group *bts_unknown_ctrs; |
| 1160 | struct osmo_stat_item_group *bts_unknown_statg; |
| 1161 | |
Neels Hofmeyr | 08822a3 | 2019-07-11 03:43:34 +0200 | [diff] [blame] | 1162 | /* see gsm_network_T_defs */ |
Neels Hofmeyr | a6078fe | 2019-01-28 03:52:14 +0100 | [diff] [blame] | 1163 | struct osmo_tdef *T_defs; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 1164 | |
Alexander Couzens | 547c207 | 2017-11-21 12:03:04 +0100 | [diff] [blame] | 1165 | enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T]; |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 1166 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 1167 | /* Use a TCH for handling requests of type paging any */ |
| 1168 | int pag_any_tch; |
| 1169 | |
Neels Hofmeyr | 06a14d2 | 2020-05-26 12:41:18 +0200 | [diff] [blame] | 1170 | /* msc configuration */ |
| 1171 | struct llist_head mscs; |
Neels Hofmeyr | eec776e | 2020-05-25 00:02:56 +0200 | [diff] [blame] | 1172 | uint8_t mscs_round_robin_next_nr; |
| 1173 | /* Emergency calls potentially select a different set of MSCs, so to not mess up the normal round-robin |
| 1174 | * behavior, emergency calls need a separate round-robin counter. */ |
| 1175 | uint8_t mscs_round_robin_next_emerg_nr; |
Neels Hofmeyr | 06a14d2 | 2020-05-26 12:41:18 +0200 | [diff] [blame] | 1176 | |
| 1177 | /* rf ctl related bits */ |
| 1178 | int mid_call_timeout; |
| 1179 | char *rf_ctrl_name; |
| 1180 | struct osmo_bsc_rf *rf_ctrl; |
| 1181 | int auto_off_timeout; |
| 1182 | |
| 1183 | struct bsc_cbc_link *cbc; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 1184 | |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 1185 | /* control interface */ |
| 1186 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 1187 | |
| 1188 | /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */ |
| 1189 | bool dyn_ts_allow_tch_f; |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 1190 | |
| 1191 | /* all active subscriber connections. */ |
| 1192 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1193 | |
| 1194 | /* if override is nonzero, this timezone data is used for all MM |
| 1195 | * contexts. */ |
| 1196 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 1197 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 1198 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 1199 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 1200 | |
| 1201 | /* List of all struct bsc_subscr used in libbsc. This llist_head is |
| 1202 | * allocated so that the llist_head pointer itself can serve as a |
| 1203 | * talloc context (useful to not have to pass the entire gsm_network |
| 1204 | * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to |
| 1205 | * not require gsm_data.h). In an MSC-without-BSC environment, this |
| 1206 | * pointer is NULL to indicate absence of a bsc_subscribers list. */ |
| 1207 | struct llist_head *bsc_subscribers; |
Harald Welte | a43e0b4 | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 1208 | |
Stefan Sperling | 6cee893 | 2018-01-30 18:14:22 +0100 | [diff] [blame] | 1209 | /* Timer for periodic channel load measurements to maintain each BTS's T3122. */ |
| 1210 | struct osmo_timer_list t3122_chan_load_timer; |
| 1211 | |
Neels Hofmeyr | c29505e | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1212 | struct { |
Philipp Maier | 39c609b | 2017-09-27 15:51:34 +0200 | [diff] [blame] | 1213 | struct mgcp_client_conf *conf; |
| 1214 | struct mgcp_client *client; |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 1215 | struct osmo_tdef *tdefs; |
Philipp Maier | 39c609b | 2017-09-27 15:51:34 +0200 | [diff] [blame] | 1216 | } mgw; |
Neels Hofmeyr | 19bed23 | 2018-03-22 04:54:57 +0100 | [diff] [blame] | 1217 | |
| 1218 | /* Remote BSS Cell Identifier Lists */ |
| 1219 | struct neighbor_ident_list *neighbor_bss_cells; |
Oliver Smith | a595db1 | 2020-03-17 12:21:00 +0100 | [diff] [blame] | 1220 | |
| 1221 | /* Don't refuse to start with mutually exclusive codec settings */ |
| 1222 | bool allow_unusable_timeslots; |
Neels Hofmeyr | 4099f1d | 2020-05-26 03:58:14 +0200 | [diff] [blame] | 1223 | |
| 1224 | uint8_t nri_bitlen; |
| 1225 | struct osmo_nri_ranges *null_nri_ranges; |
Neels Hofmeyr | 4ae338d | 2020-09-17 17:54:39 +0200 | [diff] [blame] | 1226 | |
| 1227 | struct smlc_config *smlc; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 1228 | }; |
| 1229 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1230 | struct gsm_audio_support { |
| 1231 | uint8_t hr : 1, |
| 1232 | ver : 7; |
| 1233 | }; |
| 1234 | |
Neels Hofmeyr | c13e687 | 2016-05-11 13:53:47 +0200 | [diff] [blame] | 1235 | extern void talloc_ctx_init(void *ctx_root); |
| 1236 | |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 1237 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 1238 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 1239 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 1240 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 1241 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 1242 | extern void *tall_bsc_ctx; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 1243 | |
Harald Welte | 1876c31 | 2018-05-27 11:53:43 +0200 | [diff] [blame] | 1244 | extern struct gsm_network *bsc_gsmnet; |
| 1245 | |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 1246 | 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] | 1247 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
| 1248 | |
Neels Hofmeyr | 4d358c0 | 2018-02-22 03:19:05 +0100 | [diff] [blame] | 1249 | 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] | 1250 | 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] | 1251 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 1252 | struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network); |
Neels Hofmeyr | 42eb014 | 2016-05-20 17:15:44 +0200 | [diff] [blame] | 1253 | |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1254 | struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic); |
| 1255 | struct gsm_bts *bsc_bts_alloc_register(struct gsm_network *net, enum gsm_bts_type type, uint8_t bsic); |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 1256 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 1257 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr, |
| 1258 | uint8_t e1_ts, uint8_t e1_ts_ss); |
| 1259 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 1260 | /* generic E1 line operations for all ISDN-based BTS. */ |
| 1261 | extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; |
| 1262 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 1263 | /* control interface handling */ |
| 1264 | int bsc_base_ctrl_cmds_install(void); |
| 1265 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1266 | bool ts_is_usable(const struct gsm_bts_trx_ts *ts); |
Neels Hofmeyr | 958f259 | 2018-05-27 01:26:31 +0200 | [diff] [blame] | 1267 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1268 | int gsm_lchan_type_by_pchan(enum gsm_phys_chan_config pchan); |
| 1269 | enum gsm_phys_chan_config gsm_pchan_by_lchan_type(enum gsm_chan_t type); |
| 1270 | |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 1271 | enum gsm48_rr_cause bsc_gsm48_rr_cause_from_gsm0808_cause(enum gsm0808_cause c); |
Neels Hofmeyr | 3405c77 | 2020-07-11 01:44:08 +0200 | [diff] [blame] | 1272 | enum gsm48_rr_cause bsc_gsm48_rr_cause_from_rsl_cause(uint8_t c); |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 1273 | |
Neels Hofmeyr | a33ef3a | 2020-10-01 04:23:32 +0200 | [diff] [blame] | 1274 | int bsc_sccp_inst_next_conn_id(struct osmo_sccp_instance *sccp); |
| 1275 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 1276 | #endif /* _GSM_DATA_H */ |