Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | #ifndef _GSM_DATA_H |
| 2 | #define _GSM_DATA_H |
| 3 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 5 | #include <regex.h> |
| 6 | #include <sys/types.h> |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 7 | #include <stdbool.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 8 | |
| 9 | #include <osmocom/core/timer.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 10 | #include <osmocom/core/rate_ctr.h> |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 11 | #include <osmocom/core/select.h> |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 12 | #include <osmocom/core/stats.h> |
| 13 | |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 14 | #include <osmocom/crypt/auth.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 15 | |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 16 | #include <openbsc/rest_octets.h> |
Neels Hofmeyr | 402006d | 2016-05-11 14:28:25 +0200 | [diff] [blame] | 17 | #include <openbsc/common_cs.h> |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 18 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 19 | /** annotations for msgb ownership */ |
| 20 | #define __uses |
| 21 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 22 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 23 | |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 24 | struct mncc_sock_state; |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 25 | struct gsm_subscriber_group; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 26 | struct bsc_subscr; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 27 | struct vlr_instance; |
| 28 | struct vlr_subscr; |
Neels Hofmeyr | 0e5a7c4 | 2017-05-08 15:12:20 +0200 | [diff] [blame^] | 29 | struct ue_conn_ctx; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 30 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 31 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 32 | |
Neels Hofmeyr | 0e5d807 | 2017-01-10 00:49:56 +0100 | [diff] [blame] | 33 | #define tmsi_from_string(str) strtoul(str, NULL, 10) |
| 34 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 35 | /* 3-bit long values */ |
| 36 | #define EARFCN_PRIO_INVALID 8 |
| 37 | #define EARFCN_MEAS_BW_INVALID 8 |
| 38 | /* 5-bit long values */ |
| 39 | #define EARFCN_QRXLV_INVALID 32 |
| 40 | #define EARFCN_THRESH_LOW_INVALID 32 |
| 41 | |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 42 | enum gsm_security_event { |
| 43 | GSM_SECURITY_NOAVAIL, |
| 44 | GSM_SECURITY_AUTH_FAILED, |
| 45 | GSM_SECURITY_SUCCEEDED, |
Andreas Eversberg | 641475c | 2013-07-10 08:58:03 +0200 | [diff] [blame] | 46 | GSM_SECURITY_ALREADY, |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 47 | }; |
| 48 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 49 | struct msgb; |
| 50 | typedef int gsm_cbfn(unsigned int hooknum, |
| 51 | unsigned int event, |
| 52 | struct msgb *msg, |
| 53 | void *data, void *param); |
| 54 | |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 55 | /* Real authentication information containing Ki */ |
| 56 | enum gsm_auth_algo { |
| 57 | AUTH_ALGO_NONE, |
| 58 | AUTH_ALGO_XOR, |
| 59 | AUTH_ALGO_COMP128v1, |
| 60 | }; |
| 61 | |
| 62 | struct gsm_auth_info { |
| 63 | enum gsm_auth_algo auth_algo; |
| 64 | unsigned int a3a8_ki_len; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 65 | uint8_t a3a8_ki[16]; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct gsm_auth_tuple { |
| 69 | int use_count; |
| 70 | int key_seq; |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 71 | struct osmo_auth_vector vec; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 72 | }; |
Sylvain Munaut | b48216f | 2010-06-09 12:45:37 +0200 | [diff] [blame] | 73 | #define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */ |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 74 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 75 | /* |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 76 | * AUTHENTICATION/CIPHERING state |
| 77 | */ |
| 78 | struct gsm_security_operation { |
| 79 | struct gsm_auth_tuple atuple; |
| 80 | gsm_cbfn *cb; |
| 81 | void *cb_data; |
| 82 | }; |
| 83 | |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 84 | /* |
| 85 | * A dummy to keep a connection up for at least |
| 86 | * a couple of seconds to work around MSC issues. |
| 87 | */ |
| 88 | struct gsm_anchor_operation { |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 89 | struct osmo_timer_list timeout; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 90 | }; |
| 91 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 92 | /* Maximum number of neighbor cells whose average we track */ |
| 93 | #define MAX_NEIGH_MEAS 10 |
| 94 | /* Maximum size of the averaging window for neighbor cells */ |
| 95 | #define MAX_WIN_NEIGH_AVG 10 |
| 96 | |
| 97 | /* processed neighbor measurements for one cell */ |
| 98 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 99 | uint16_t arfcn; |
| 100 | uint8_t bsic; |
| 101 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 102 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 103 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 106 | enum ran_type { |
| 107 | RAN_UNKNOWN, |
| 108 | RAN_GERAN_A, /* 2G / A-interface */ |
| 109 | RAN_UTRAN_IU, /* 3G / Iu-interface (IuCS or IuPS) */ |
| 110 | }; |
| 111 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 112 | struct gsm_classmark { |
| 113 | bool classmark1_set; |
| 114 | struct gsm48_classmark1 classmark1; |
| 115 | uint8_t classmark2_len; |
| 116 | uint8_t classmark2[3]; |
| 117 | uint8_t classmark3_len; |
| 118 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 119 | }; |
| 120 | |
Neels Hofmeyr | 0e5a7c4 | 2017-05-08 15:12:20 +0200 | [diff] [blame^] | 121 | enum integrity_protection_state { |
| 122 | INTEGRITY_PROTECTION_NONE = 0, |
| 123 | INTEGRITY_PROTECTION_IK = 1, |
| 124 | INTEGRITY_PROTECTION_IK_CK = 2, |
| 125 | }; |
| 126 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 127 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 128 | struct gsm_subscriber_connection { |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 129 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 130 | struct llist_head entry; |
| 131 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 132 | /* usage count. If this drops to zero, we start the release |
| 133 | * towards A/Iu */ |
| 134 | uint32_t use_count; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 135 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 136 | /* The MS has opened the conn with a CM Service Request, and we shall |
| 137 | * keep it open for an actual request (or until timeout). */ |
| 138 | bool received_cm_service_request; |
| 139 | |
| 140 | /* libbsc subscriber information (if available) */ |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 141 | struct bsc_subscr *bsub; |
| 142 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 143 | /* libmsc/libvlr subscriber information (if available) */ |
| 144 | struct vlr_subscr *vsub; |
| 145 | |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 146 | /* LU expiration handling */ |
| 147 | uint8_t expire_timer_stopped; |
Holger Hans Peter Freyther | ca11443 | 2014-02-08 15:20:48 +0100 | [diff] [blame] | 148 | /* SMS helpers for libmsc */ |
| 149 | uint8_t next_rp_ref; |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 150 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 151 | /* |
| 152 | * Operations that have a state and might be pending |
| 153 | */ |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 154 | struct gsm_security_operation *sec_operation; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 155 | struct gsm_anchor_operation *anch_operation; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 156 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 157 | struct osmo_fsm_inst *conn_fsm; |
| 158 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 159 | /* Are we part of a special "silent" call */ |
| 160 | int silent_call; |
| 161 | |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 162 | /* MNCC rtp bridge markers */ |
| 163 | int mncc_rtp_bridge; |
| 164 | int mncc_rtp_create_pending; |
Holger Hans Peter Freyther | c21dcb2 | 2015-08-04 14:41:21 +0200 | [diff] [blame] | 165 | int mncc_rtp_connect_pending; |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 166 | |
Holger Hans Peter Freyther | 2f9d1ef | 2010-09-16 20:14:01 +0800 | [diff] [blame] | 167 | /* bsc structures */ |
Neels Hofmeyr | ce090f8 | 2016-05-30 15:00:23 +0200 | [diff] [blame] | 168 | struct osmo_bsc_sccp_con *sccp_con; /* BSC */ |
Holger Hans Peter Freyther | 2f9d1ef | 2010-09-16 20:14:01 +0800 | [diff] [blame] | 169 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 170 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 171 | struct gsm_network *network; |
| 172 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 173 | bool in_release; |
Neels Hofmeyr | ce090f8 | 2016-05-30 15:00:23 +0200 | [diff] [blame] | 174 | struct gsm_lchan *lchan; /* BSC */ |
| 175 | struct gsm_lchan *ho_lchan; /* BSC */ |
| 176 | struct gsm_bts *bts; /* BSC */ |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 177 | |
| 178 | /* for assignment handling */ |
Neels Hofmeyr | ce090f8 | 2016-05-30 15:00:23 +0200 | [diff] [blame] | 179 | struct osmo_timer_list T10; /* BSC */ |
| 180 | struct gsm_lchan *secondary_lchan; /* BSC */ |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 181 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 182 | /* connected via 2G or 3G? */ |
| 183 | enum ran_type via_ran; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 184 | |
| 185 | struct gsm_classmark classmark; |
Neels Hofmeyr | 0e5a7c4 | 2017-05-08 15:12:20 +0200 | [diff] [blame^] | 186 | |
| 187 | uint16_t lac; |
| 188 | struct gsm_encr encr; |
| 189 | |
| 190 | /* which Iu-CS connection, if any. */ |
| 191 | struct { |
| 192 | struct ue_conn_ctx *ue_ctx; |
| 193 | int integrity_protection; |
| 194 | } iu; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 195 | }; |
| 196 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 197 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 198 | #define ROLE_BSC |
| 199 | #include "gsm_data_shared.h" |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 200 | |
Holger Hans Peter Freyther | 5ba6f48 | 2009-10-28 14:23:39 +0100 | [diff] [blame] | 201 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 202 | enum { |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 203 | BSC_CTR_CHREQ_TOTAL, |
| 204 | BSC_CTR_CHREQ_NO_CHANNEL, |
| 205 | BSC_CTR_HANDOVER_ATTEMPTED, |
| 206 | BSC_CTR_HANDOVER_NO_CHANNEL, |
| 207 | BSC_CTR_HANDOVER_TIMEOUT, |
| 208 | BSC_CTR_HANDOVER_COMPLETED, |
| 209 | BSC_CTR_HANDOVER_FAILED, |
| 210 | BSC_CTR_PAGING_ATTEMPTED, |
| 211 | BSC_CTR_PAGING_DETACHED, |
| 212 | BSC_CTR_PAGING_COMPLETED, |
| 213 | BSC_CTR_PAGING_EXPIRED, |
| 214 | BSC_CTR_CHAN_RF_FAIL, |
| 215 | BSC_CTR_CHAN_RLL_ERR, |
| 216 | BSC_CTR_BTS_OML_FAIL, |
| 217 | BSC_CTR_BTS_RSL_FAIL, |
Alexander Couzens | 8c53c59 | 2016-08-23 06:27:19 +0200 | [diff] [blame] | 218 | BSC_CTR_CODEC_AMR_F, |
| 219 | BSC_CTR_CODEC_AMR_H, |
| 220 | BSC_CTR_CODEC_EFR, |
| 221 | BSC_CTR_CODEC_V1_FR, |
| 222 | BSC_CTR_CODEC_V1_HR, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | static const struct rate_ctr_desc bsc_ctr_description[] = { |
| 226 | [BSC_CTR_CHREQ_TOTAL] = {"chreq.total", "Received channel requests."}, |
| 227 | [BSC_CTR_CHREQ_NO_CHANNEL] = {"chreq.no_channel", "Sent to MS no channel available."}, |
| 228 | [BSC_CTR_HANDOVER_ATTEMPTED] = {"handover.attempted", "Received handover attempts."}, |
| 229 | [BSC_CTR_HANDOVER_NO_CHANNEL] = {"handover.no_channel", "Sent no channel available responses."}, |
| 230 | [BSC_CTR_HANDOVER_TIMEOUT] = {"handover.timeout", "Count the amount of timeouts of timer T3103."}, |
| 231 | [BSC_CTR_HANDOVER_COMPLETED] = {"handover.completed", "Received handover completed."}, |
| 232 | [BSC_CTR_HANDOVER_FAILED] = {"handover.failed", "Receive HO FAIL messages."}, |
| 233 | [BSC_CTR_PAGING_ATTEMPTED] = {"paging.attempted", "Paging attempts for a MS."}, |
| 234 | [BSC_CTR_PAGING_DETACHED] = {"paging.detached", "Counts the amount of paging attempts which couldn't sent out any paging request because no responsible bts found."}, |
| 235 | [BSC_CTR_PAGING_COMPLETED] = {"paging.completed", "Paging successful completed."}, |
| 236 | [BSC_CTR_PAGING_EXPIRED] = {"paging.expired", "Paging Request expired because of timeout T3113."}, |
| 237 | [BSC_CTR_CHAN_RF_FAIL] = {"chan.rf_fail", "Received a RF failure indication from BTS."}, |
| 238 | [BSC_CTR_CHAN_RLL_ERR] = {"chan.rll_err", "Received a RLL failure with T200 cause from BTS."}, |
| 239 | [BSC_CTR_BTS_OML_FAIL] = {"bts.oml_fail", "Received a TEI down on a OML link."}, |
| 240 | [BSC_CTR_BTS_RSL_FAIL] = {"bts.rsl_fail", "Received a TEI down on a OML link."}, |
Alexander Couzens | 8c53c59 | 2016-08-23 06:27:19 +0200 | [diff] [blame] | 241 | [BSC_CTR_CODEC_AMR_F] = {"bts.codec_amr_f", "Count the usage of AMR/F codec by channel mode requested."}, |
| 242 | [BSC_CTR_CODEC_AMR_H] = {"bts.codec_amr_h", "Count the usage of AMR/H codec by channel mode requested."}, |
| 243 | [BSC_CTR_CODEC_EFR] = {"bts.codec_efr", "Count the usage of EFR codec by channel mode requested."}, |
| 244 | [BSC_CTR_CODEC_V1_FR] = {"bts.codec_fr", "Count the usage of FR codec by channel mode requested."}, |
| 245 | [BSC_CTR_CODEC_V1_HR] = {"bts.codec_hr", "Count the usage of HR codec by channel mode requested."}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | enum { |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 249 | MSC_CTR_LOC_UPDATE_TYPE_ATTACH, |
| 250 | MSC_CTR_LOC_UPDATE_TYPE_NORMAL, |
| 251 | MSC_CTR_LOC_UPDATE_TYPE_PERIODIC, |
| 252 | MSC_CTR_LOC_UPDATE_TYPE_DETACH, |
Neels Hofmeyr | 36891a7 | 2016-05-09 13:18:03 +0200 | [diff] [blame] | 253 | MSC_CTR_LOC_UPDATE_FAILED, |
| 254 | MSC_CTR_LOC_UPDATE_COMPLETED, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 255 | MSC_CTR_SMS_SUBMITTED, |
| 256 | MSC_CTR_SMS_NO_RECEIVER, |
| 257 | MSC_CTR_SMS_DELIVERED, |
| 258 | MSC_CTR_SMS_RP_ERR_MEM, |
| 259 | MSC_CTR_SMS_RP_ERR_OTHER, |
Alexander Couzens | aa386d2 | 2016-08-21 20:16:33 +0200 | [diff] [blame] | 260 | MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 261 | MSC_CTR_CALL_MO_SETUP, |
| 262 | MSC_CTR_CALL_MO_CONNECT_ACK, |
| 263 | MSC_CTR_CALL_MT_SETUP, |
| 264 | MSC_CTR_CALL_MT_CONNECT, |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 265 | MSC_CTR_CALL_ACTIVE, |
| 266 | MSC_CTR_CALL_COMPLETE, |
| 267 | MSC_CTR_CALL_INCOMPLETE, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 268 | }; |
| 269 | |
| 270 | static const struct rate_ctr_desc msc_ctr_description[] = { |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 271 | [MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type.attach", "Received location update imsi attach requests."}, |
| 272 | [MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type.normal", "Received location update normal requests."}, |
| 273 | [MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type.periodic", "Received location update periodic requests."}, |
| 274 | [MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type.detach", "Received location update detach indication."}, |
Neels Hofmeyr | 36891a7 | 2016-05-09 13:18:03 +0200 | [diff] [blame] | 275 | [MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp.failed", "Rejected location updates."}, |
| 276 | [MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp.completed", "Successful location updates."}, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 277 | [MSC_CTR_SMS_SUBMITTED] = {"sms.submitted", "Received a RPDU from a MS (MO)."}, |
| 278 | [MSC_CTR_SMS_NO_RECEIVER] = {"sms.no_receiver", "Counts SMS which couldn't routed because no receiver found."}, |
| 279 | [MSC_CTR_SMS_DELIVERED] = {"sms.delivered", "Global SMS Deliver attempts."}, |
| 280 | [MSC_CTR_SMS_RP_ERR_MEM] = {"sms.rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."}, |
| 281 | [MSC_CTR_SMS_RP_ERR_OTHER] = {"sms.rp_err_other", "Other error of MS responses on a sms delive attempt."}, |
Alexander Couzens | aa386d2 | 2016-08-21 20:16:33 +0200 | [diff] [blame] | 282 | [MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR] = {"sms.deliver_unknown_error", "Unknown error occured during sms delivery."}, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 283 | /* FIXME: count also sms delivered */ |
| 284 | [MSC_CTR_CALL_MO_SETUP] = {"call.mo_setup", "Received setup requests from a MS to init a MO call."}, |
| 285 | [MSC_CTR_CALL_MO_CONNECT_ACK] = {"call.mo_connect_ack", "Received a connect ack from MS of a MO call. Call is now succesful connected up."}, |
| 286 | [MSC_CTR_CALL_MT_SETUP] = {"call.mt_setup", "Sent setup requests to the MS (MT)."}, |
| 287 | [MSC_CTR_CALL_MT_CONNECT] = {"call.mt_connect", "Sent a connect to the MS (MT)."}, |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 288 | [MSC_CTR_CALL_ACTIVE] = {"call.active", "Count total amount of calls that ever reached active state."}, |
| 289 | [MSC_CTR_CALL_COMPLETE] = {"call.complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."}, |
| 290 | [MSC_CTR_CALL_INCOMPLETE] = {"call.incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | |
| 294 | static const struct rate_ctr_group_desc bsc_ctrg_desc = { |
| 295 | "bsc", |
| 296 | "base station controller", |
| 297 | OSMO_STATS_CLASS_GLOBAL, |
| 298 | ARRAY_SIZE(bsc_ctr_description), |
| 299 | bsc_ctr_description, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | static const struct rate_ctr_group_desc msc_ctrg_desc = { |
| 303 | "msc", |
| 304 | "mobile switching center", |
| 305 | OSMO_STATS_CLASS_GLOBAL, |
| 306 | ARRAY_SIZE(msc_ctr_description), |
| 307 | msc_ctr_description, |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 308 | }; |
| 309 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 310 | enum gsm_auth_policy { |
| 311 | GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ |
| 312 | GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ |
| 313 | GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 314 | GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */ |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 315 | }; |
| 316 | |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 317 | #define GSM_T3101_DEFAULT 10 |
Harald Welte | 67161f2 | 2012-06-03 13:01:47 +0200 | [diff] [blame] | 318 | #define GSM_T3105_DEFAULT 40 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 319 | #define GSM_T3113_DEFAULT 60 |
Andreas Eversberg | 75e13a4 | 2013-02-07 11:51:16 +0100 | [diff] [blame] | 320 | #define GSM_T3122_DEFAULT 10 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 321 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 322 | struct gsm_tz { |
| 323 | int override; /* if 0, use system's time zone instead. */ |
| 324 | int hr; /* hour */ |
| 325 | int mn; /* minute */ |
| 326 | int dst; /* daylight savings */ |
| 327 | }; |
| 328 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 329 | struct gsm_network { |
Neels Hofmeyr | 0e5a7c4 | 2017-05-08 15:12:20 +0200 | [diff] [blame^] | 330 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 331 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 332 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 333 | * these have in common, like country and network code, put in yet |
| 334 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 335 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 336 | /* global parameters */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 337 | uint16_t country_code; |
| 338 | uint16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 339 | char *name_long; |
| 340 | char *name_short; |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 341 | enum gsm_auth_policy auth_policy; |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 342 | regex_t authorized_regexp; |
| 343 | char *authorized_reg_str; |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 344 | enum gsm48_reject_value reject_cause; |
Harald Welte | 4381cfe | 2009-08-30 15:47:06 +0900 | [diff] [blame] | 345 | int a5_encryption; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 346 | bool authentication_required; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 347 | int neci; |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 348 | int send_mm_info; |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 349 | struct { |
| 350 | int active; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 351 | /* Window RXLEV averaging */ |
| 352 | unsigned int win_rxlev_avg; /* number of SACCH frames */ |
| 353 | /* Window RXQUAL averaging */ |
| 354 | unsigned int win_rxqual_avg; /* number of SACCH frames */ |
| 355 | /* Window RXLEV neighbouring cells averaging */ |
| 356 | unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */ |
| 357 | |
| 358 | /* how often should we check for power budget HO */ |
| 359 | unsigned int pwr_interval; /* SACCH frames */ |
| 360 | /* how much better does a neighbor cell have to be ? */ |
| 361 | unsigned int pwr_hysteresis; /* dBm */ |
| 362 | /* maximum distacne before we try a handover */ |
| 363 | unsigned int max_distance; /* TA values */ |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 364 | } handover; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 365 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 366 | struct rate_ctr_group *bsc_ctrs; |
| 367 | struct rate_ctr_group *msc_ctrs; |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 368 | struct osmo_counter *active_calls; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 369 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 370 | /* layer 4 */ |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 371 | struct mncc_sock_state *mncc_state; |
Neels Hofmeyr | 402006d | 2016-05-11 14:28:25 +0200 | [diff] [blame] | 372 | mncc_recv_cb_t mncc_recv; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 373 | struct llist_head upqueue; |
| 374 | struct llist_head trans_list; |
Holger Hans Peter Freyther | abcddf1 | 2010-06-14 18:20:15 +0800 | [diff] [blame] | 375 | struct bsc_api *bsc_api; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 376 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 377 | unsigned int num_bts; |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 378 | struct llist_head bts_list; |
Holger Hans Peter Freyther | c4d88ad | 2009-11-21 21:18:38 +0100 | [diff] [blame] | 379 | |
| 380 | /* timer values */ |
| 381 | int T3101; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 382 | int T3103; |
| 383 | int T3105; |
| 384 | int T3107; |
| 385 | int T3109; |
| 386 | int T3111; |
| 387 | int T3113; |
| 388 | int T3115; |
| 389 | int T3117; |
| 390 | int T3119; |
Harald Welte | 2862dca | 2010-12-23 14:39:29 +0100 | [diff] [blame] | 391 | int T3122; |
Holger Hans Peter Freyther | 23975e7 | 2009-11-21 21:42:26 +0100 | [diff] [blame] | 392 | int T3141; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 393 | |
Jan Luebbe | bfbdeec | 2012-12-27 00:27:16 +0100 | [diff] [blame] | 394 | /* timer to expire old location updates */ |
| 395 | struct osmo_timer_list subscr_expire_timer; |
| 396 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 397 | /* Radio Resource Location Protocol (TS 04.31) */ |
| 398 | struct { |
| 399 | enum rrlp_mode mode; |
| 400 | } rrlp; |
Holger Hans Peter Freyther | 5a3a61d | 2010-09-06 09:25:48 +0800 | [diff] [blame] | 401 | |
Alexander Couzens | 1136811 | 2016-11-28 23:26:50 +0100 | [diff] [blame] | 402 | enum gsm_chan_t ctype_by_chreq[18]; |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 403 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 404 | /* Use a TCH for handling requests of type paging any */ |
| 405 | int pag_any_tch; |
| 406 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 407 | /* MSC data in case we are a true BSC */ |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 408 | struct osmo_bsc_data *bsc_data; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 409 | |
Holger Hans Peter Freyther | 11b28f9 | 2010-12-24 13:48:27 +0100 | [diff] [blame] | 410 | struct gsm_sms_queue *sms_queue; |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 411 | |
| 412 | /* control interface */ |
| 413 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 414 | |
| 415 | /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */ |
| 416 | bool dyn_ts_allow_tch_f; |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 417 | |
| 418 | /* all active subscriber connections. */ |
| 419 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 420 | |
| 421 | /* if override is nonzero, this timezone data is used for all MM |
| 422 | * contexts. */ |
| 423 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 424 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 425 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 426 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 427 | |
| 428 | /* List of all struct bsc_subscr used in libbsc. This llist_head is |
| 429 | * allocated so that the llist_head pointer itself can serve as a |
| 430 | * talloc context (useful to not have to pass the entire gsm_network |
| 431 | * struct to the bsc_subscr_* API, and for bsc_susbscr unit tests to |
| 432 | * not require gsm_data.h). In an MSC-without-BSC environment, this |
| 433 | * pointer is NULL to indicate absence of a bsc_subscribers list. */ |
| 434 | struct llist_head *bsc_subscribers; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 435 | |
| 436 | /* MSC: GSUP server address of the HLR */ |
| 437 | const char *gsup_server_addr_str; |
| 438 | uint16_t gsup_server_port; |
| 439 | |
| 440 | struct vlr_instance *vlr; |
Neels Hofmeyr | 0e5a7c4 | 2017-05-08 15:12:20 +0200 | [diff] [blame^] | 441 | |
| 442 | /* Periodic location update default value */ |
| 443 | uint8_t t3212; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 444 | }; |
| 445 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 446 | struct osmo_esme; |
| 447 | |
| 448 | enum gsm_sms_source_id { |
| 449 | SMS_SOURCE_UNKNOWN = 0, |
| 450 | SMS_SOURCE_MS, /* received from MS */ |
| 451 | SMS_SOURCE_VTY, /* received from VTY */ |
| 452 | SMS_SOURCE_SMPP, /* received via SMPP */ |
| 453 | }; |
| 454 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 455 | #define SMS_HDR_SIZE 128 |
| 456 | #define SMS_TEXT_SIZE 256 |
Harald Welte | e07b6a7 | 2012-11-23 19:02:37 +0100 | [diff] [blame] | 457 | |
| 458 | struct gsm_sms_addr { |
| 459 | uint8_t ton; |
| 460 | uint8_t npi; |
| 461 | char addr[21+1]; |
| 462 | }; |
| 463 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 464 | struct gsm_sms { |
Harald Welte | d409be7 | 2009-11-07 00:06:19 +0900 | [diff] [blame] | 465 | unsigned long long id; |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 466 | struct vlr_subscr *receiver; |
Harald Welte | c0de14d | 2012-11-23 23:35:01 +0100 | [diff] [blame] | 467 | struct gsm_sms_addr src, dst; |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 468 | enum gsm_sms_source_id source; |
| 469 | |
| 470 | struct { |
Pablo Neira Ayuso | 93ffbd0 | 2017-05-04 18:44:22 +0200 | [diff] [blame] | 471 | uint8_t transaction_id; |
| 472 | uint32_t msg_ref; |
| 473 | } gsm411; |
| 474 | |
| 475 | struct { |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 476 | struct osmo_esme *esme; |
| 477 | uint32_t sequence_nr; |
| 478 | int transaction_mode; |
| 479 | char msg_id[16]; |
| 480 | } smpp; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 481 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 482 | unsigned long validity_minutes; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 483 | uint8_t reply_path_req; |
| 484 | uint8_t status_rep_req; |
| 485 | uint8_t ud_hdr_ind; |
| 486 | uint8_t protocol_id; |
| 487 | uint8_t data_coding_scheme; |
| 488 | uint8_t msg_ref; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 489 | uint8_t user_data_len; |
| 490 | uint8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 491 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 492 | char text[SMS_TEXT_SIZE]; |
| 493 | }; |
| 494 | |
Neels Hofmeyr | c13e687 | 2016-05-11 13:53:47 +0200 | [diff] [blame] | 495 | extern void talloc_ctx_init(void *ctx_root); |
| 496 | |
Harald Welte | 39315c4 | 2010-01-10 18:01:52 +0100 | [diff] [blame] | 497 | int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type); |
Harald Welte | e441d9c | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 498 | |
Harald Welte | 1d014a5 | 2009-08-08 15:38:29 +0200 | [diff] [blame] | 499 | enum gsm_bts_type parse_btstype(const char *arg); |
Holger Hans Peter Freyther | 2dceae6 | 2009-06-12 17:39:38 +0200 | [diff] [blame] | 500 | const char *btstype2str(enum gsm_bts_type type); |
Harald Welte | be99149 | 2009-05-23 13:56:40 +0000 | [diff] [blame] | 501 | struct gsm_bts *gsm_bts_by_lac(struct gsm_network *net, unsigned int lac, |
| 502 | struct gsm_bts *start_bts); |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 503 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 504 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 505 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 506 | |
Harald Welte | f383aa1 | 2012-07-02 19:51:55 +0200 | [diff] [blame] | 507 | /* this actaully refers to the IPA transport, not the BTS model */ |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 508 | static inline int is_ipaccess_bts(struct gsm_bts *bts) |
| 509 | { |
| 510 | switch (bts->type) { |
Mike Haben | e2d8227 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 511 | case GSM_BTS_TYPE_NANOBTS: |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 512 | case GSM_BTS_TYPE_OSMOBTS: |
Harald Welte | 32201c1 | 2009-03-10 12:15:10 +0000 | [diff] [blame] | 513 | return 1; |
| 514 | default: |
| 515 | break; |
| 516 | } |
| 517 | return 0; |
| 518 | } |
| 519 | |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 520 | static inline int is_sysmobts_v2(struct gsm_bts *bts) |
| 521 | { |
| 522 | switch (bts->type) { |
Max | f9685c1 | 2017-03-23 12:01:07 +0100 | [diff] [blame] | 523 | case GSM_BTS_TYPE_OSMOBTS: |
Holger Hans Peter Freyther | 6f6cbf7 | 2015-04-04 19:35:22 +0200 | [diff] [blame] | 524 | return 1; |
| 525 | default: |
| 526 | break; |
| 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
Harald Welte | 5b57067 | 2009-08-10 10:08:01 +0200 | [diff] [blame] | 531 | static inline int is_siemens_bts(struct gsm_bts *bts) |
| 532 | { |
| 533 | switch (bts->type) { |
| 534 | case GSM_BTS_TYPE_BS11: |
| 535 | return 1; |
| 536 | default: |
| 537 | break; |
| 538 | } |
| 539 | |
| 540 | return 0; |
| 541 | } |
| 542 | |
Andreas Eversberg | 7d8fa34 | 2013-12-05 13:25:06 +0100 | [diff] [blame] | 543 | static inline int is_nokia_bts(struct gsm_bts *bts) |
| 544 | { |
| 545 | switch (bts->type) { |
| 546 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 547 | return 1; |
| 548 | default: |
| 549 | break; |
| 550 | } |
| 551 | |
| 552 | return 0; |
| 553 | } |
| 554 | |
Andreas Eversberg | dcf38e1 | 2013-12-05 14:37:11 +0100 | [diff] [blame] | 555 | static inline int is_e1_bts(struct gsm_bts *bts) |
| 556 | { |
| 557 | switch (bts->type) { |
| 558 | case GSM_BTS_TYPE_BS11: |
| 559 | case GSM_BTS_TYPE_RBS2000: |
| 560 | case GSM_BTS_TYPE_NOKIA_SITE: |
| 561 | return 1; |
| 562 | default: |
| 563 | break; |
| 564 | } |
| 565 | |
| 566 | return 0; |
| 567 | } |
| 568 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 569 | enum gsm_auth_policy gsm_auth_policy_parse(const char *arg); |
| 570 | const char *gsm_auth_policy_name(enum gsm_auth_policy policy); |
| 571 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 572 | enum rrlp_mode rrlp_mode_parse(const char *arg); |
| 573 | const char *rrlp_mode_name(enum rrlp_mode mode); |
| 574 | |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 575 | 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] | 576 | const char *bts_gprs_mode_name(enum bts_gprs_mode mode); |
Holger Hans Peter Freyther | 4e13a8f | 2015-01-31 22:16:00 +0100 | [diff] [blame] | 577 | int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode); |
Harald Welte | 4511d89 | 2010-04-18 15:51:20 +0200 | [diff] [blame] | 578 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 579 | int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts); |
Harald Welte | 97a282b | 2010-03-14 15:37:43 +0800 | [diff] [blame] | 580 | 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] | 581 | |
Harald Welte | f3d8e92 | 2010-06-14 22:44:42 +0200 | [diff] [blame] | 582 | int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum gsm_bts_features feat); |
Harald Welte | fbda4e1 | 2010-03-04 11:04:52 +0100 | [diff] [blame] | 583 | int gsm_bts_model_register(struct gsm_bts_model *model); |
| 584 | |
Neels Hofmeyr | 42eb014 | 2016-05-20 17:15:44 +0200 | [diff] [blame] | 585 | struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan *lchan); |
| 586 | void bsc_subscr_con_free(struct gsm_subscriber_connection *conn); |
| 587 | |
| 588 | struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network); |
| 589 | void msc_subscr_con_free(struct gsm_subscriber_connection *conn); |
Holger Hans Peter Freyther | 2412a07 | 2010-06-28 15:47:12 +0800 | [diff] [blame] | 590 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 591 | struct gsm_bts *gsm_bts_alloc_register(struct gsm_network *net, |
| 592 | enum gsm_bts_type type, |
Harald Welte | a2bbc5e | 2015-11-20 10:43:31 +0100 | [diff] [blame] | 593 | uint8_t bsic); |
Harald Welte | 142d12d | 2014-12-29 17:47:08 +0100 | [diff] [blame] | 594 | |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 595 | void set_ts_e1link(struct gsm_bts_trx_ts *ts, uint8_t e1_nr, |
| 596 | uint8_t e1_ts, uint8_t e1_ts_ss); |
| 597 | |
| 598 | void gsm_trx_lock_rf(struct gsm_bts_trx *trx, int locked); |
Max | 71d082b | 2017-05-30 15:03:38 +0200 | [diff] [blame] | 599 | bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum gsm_bts_features feat); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 600 | struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr); |
Holger Hans Peter Freyther | a49b2c0 | 2014-11-21 11:18:45 +0100 | [diff] [blame] | 601 | int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx); |
Alexander Chemeris | c36a13b | 2015-05-30 14:40:54 -0400 | [diff] [blame] | 602 | int gsm_bts_set_system_infos(struct gsm_bts *bts); |
Harald Welte | 3300c01 | 2011-06-05 13:31:33 +0200 | [diff] [blame] | 603 | |
Pablo Neira Ayuso | ed5cacb | 2011-08-17 22:44:07 +0200 | [diff] [blame] | 604 | /* generic E1 line operations for all ISDN-based BTS. */ |
| 605 | extern struct e1inp_line_ops bts_isdn_e1inp_line_ops; |
| 606 | |
Harald Welte | e555c2b | 2012-08-17 13:02:12 +0200 | [diff] [blame] | 607 | extern const struct value_string bts_type_names[_NUM_GSM_BTS_TYPE+1]; |
| 608 | extern const struct value_string bts_type_descs[_NUM_GSM_BTS_TYPE+1]; |
| 609 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 610 | /* control interface handling */ |
| 611 | int bsc_base_ctrl_cmds_install(void); |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 612 | int msc_ctrl_cmds_install(struct gsm_network *net); |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 613 | |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 614 | /* dependency handling */ |
| 615 | void bts_depend_mark(struct gsm_bts *bts, int dep); |
| 616 | void bts_depend_clear(struct gsm_bts *bts, int dep); |
| 617 | int bts_depend_check(struct gsm_bts *bts); |
Holger Hans Peter Freyther | f7e23c5 | 2014-12-17 15:44:32 +0100 | [diff] [blame] | 618 | int bts_depend_is_depedency(struct gsm_bts *base, struct gsm_bts *other); |
Holger Hans Peter Freyther | c22930e | 2014-12-17 14:46:17 +0100 | [diff] [blame] | 619 | |
Harald Welte | 2f8b9d2 | 2017-06-18 11:12:13 +0300 | [diff] [blame] | 620 | int gsm_bts_get_radio_link_timeout(const struct gsm_bts *bts); |
| 621 | void gsm_bts_set_radio_link_timeout(struct gsm_bts *bts, int value); |
| 622 | |
Harald Welte | 7b423ed | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 623 | bool classmark_is_r99(struct gsm_classmark *cm); |
| 624 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 625 | #endif /* _GSM_DATA_H */ |