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