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> |
Max | 43b01b0 | 2017-09-15 11:22:30 +0200 | [diff] [blame] | 13 | #include <osmocom/gsm/gsm48.h> |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 14 | #include <osmocom/crypt/auth.h> |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 15 | #include <osmocom/sigtran/sccp_sap.h> |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 16 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 17 | #include <osmocom/msc/common.h> |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 18 | #include <osmocom/msc/common_cs.h> |
Neels Hofmeyr | 6c8afe1 | 2017-09-04 01:03:58 +0200 | [diff] [blame] | 19 | #include <osmocom/mgcp_client/mgcp_client.h> |
Harald Welte | b96be39 | 2011-05-25 12:33:33 +0200 | [diff] [blame] | 20 | |
Harald Welte | d35038d | 2018-01-25 00:07:33 +0100 | [diff] [blame] | 21 | #include "gsm_data_shared.h" |
| 22 | |
| 23 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 24 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 25 | /** annotations for msgb ownership */ |
| 26 | #define __uses |
| 27 | |
Holger Hans Peter Freyther | 6f61555 | 2010-11-15 20:50:42 +0100 | [diff] [blame] | 28 | #define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3] |
| 29 | |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 30 | struct mncc_sock_state; |
Jacob Erlbeck | 1e30a28 | 2014-12-03 09:28:24 +0100 | [diff] [blame] | 31 | struct gsm_subscriber_group; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 32 | struct vlr_instance; |
| 33 | struct vlr_subscr; |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 34 | struct ranap_ue_conn_ctx; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 35 | |
Holger Hans Peter Freyther | 9c595b7 | 2010-06-15 11:20:52 +0800 | [diff] [blame] | 36 | #define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
| 37 | |
Neels Hofmeyr | 0e5d807 | 2017-01-10 00:49:56 +0100 | [diff] [blame] | 38 | #define tmsi_from_string(str) strtoul(str, NULL, 10) |
| 39 | |
Max | 70fdd24 | 2017-06-15 15:10:53 +0200 | [diff] [blame] | 40 | /* 3-bit long values */ |
| 41 | #define EARFCN_PRIO_INVALID 8 |
| 42 | #define EARFCN_MEAS_BW_INVALID 8 |
| 43 | /* 5-bit long values */ |
| 44 | #define EARFCN_QRXLV_INVALID 32 |
| 45 | #define EARFCN_THRESH_LOW_INVALID 32 |
| 46 | |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 47 | enum gsm_security_event { |
| 48 | GSM_SECURITY_NOAVAIL, |
| 49 | GSM_SECURITY_AUTH_FAILED, |
| 50 | GSM_SECURITY_SUCCEEDED, |
Andreas Eversberg | 641475c | 2013-07-10 08:58:03 +0200 | [diff] [blame] | 51 | GSM_SECURITY_ALREADY, |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 54 | struct msgb; |
| 55 | typedef int gsm_cbfn(unsigned int hooknum, |
| 56 | unsigned int event, |
| 57 | struct msgb *msg, |
| 58 | void *data, void *param); |
| 59 | |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 60 | /* Real authentication information containing Ki */ |
| 61 | enum gsm_auth_algo { |
| 62 | AUTH_ALGO_NONE, |
| 63 | AUTH_ALGO_XOR, |
| 64 | AUTH_ALGO_COMP128v1, |
| 65 | }; |
| 66 | |
| 67 | struct gsm_auth_info { |
| 68 | enum gsm_auth_algo auth_algo; |
| 69 | unsigned int a3a8_ki_len; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 70 | uint8_t a3a8_ki[16]; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | struct gsm_auth_tuple { |
| 74 | int use_count; |
| 75 | int key_seq; |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 76 | struct osmo_auth_vector vec; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 77 | }; |
Sylvain Munaut | b48216f | 2010-06-09 12:45:37 +0200 | [diff] [blame] | 78 | #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] | 79 | |
Holger Freyther | 73487a2 | 2008-12-31 18:53:57 +0000 | [diff] [blame] | 80 | /* |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 81 | * AUTHENTICATION/CIPHERING state |
| 82 | */ |
| 83 | struct gsm_security_operation { |
| 84 | struct gsm_auth_tuple atuple; |
| 85 | gsm_cbfn *cb; |
| 86 | void *cb_data; |
| 87 | }; |
| 88 | |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 89 | /* |
| 90 | * A dummy to keep a connection up for at least |
| 91 | * a couple of seconds to work around MSC issues. |
| 92 | */ |
| 93 | struct gsm_anchor_operation { |
Pablo Neira Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 94 | struct osmo_timer_list timeout; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 95 | }; |
| 96 | |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 97 | /* Maximum number of neighbor cells whose average we track */ |
| 98 | #define MAX_NEIGH_MEAS 10 |
| 99 | /* Maximum size of the averaging window for neighbor cells */ |
| 100 | #define MAX_WIN_NEIGH_AVG 10 |
| 101 | |
| 102 | /* processed neighbor measurements for one cell */ |
| 103 | struct neigh_meas_proc { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 104 | uint16_t arfcn; |
| 105 | uint8_t bsic; |
| 106 | uint8_t rxlev[MAX_WIN_NEIGH_AVG]; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 107 | unsigned int rxlev_cnt; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 108 | uint8_t last_seen_nr; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 109 | }; |
| 110 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 111 | enum ran_type { |
| 112 | RAN_UNKNOWN, |
| 113 | RAN_GERAN_A, /* 2G / A-interface */ |
| 114 | RAN_UTRAN_IU, /* 3G / Iu-interface (IuCS or IuPS) */ |
| 115 | }; |
| 116 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 117 | extern const struct value_string ran_type_names[]; |
| 118 | static inline const char *ran_type_name(enum ran_type val) |
| 119 | { return get_value_string(ran_type_names, val); } |
| 120 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 121 | struct gsm_classmark { |
| 122 | bool classmark1_set; |
| 123 | struct gsm48_classmark1 classmark1; |
| 124 | uint8_t classmark2_len; |
| 125 | uint8_t classmark2[3]; |
| 126 | uint8_t classmark3_len; |
| 127 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 128 | }; |
| 129 | |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 130 | enum integrity_protection_state { |
| 131 | INTEGRITY_PROTECTION_NONE = 0, |
| 132 | INTEGRITY_PROTECTION_IK = 1, |
| 133 | INTEGRITY_PROTECTION_IK_CK = 2, |
| 134 | }; |
| 135 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 136 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 137 | struct gsm_subscriber_connection { |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 138 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 139 | struct llist_head entry; |
| 140 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 141 | /* usage count. If this drops to zero, we start the release |
| 142 | * towards A/Iu */ |
| 143 | uint32_t use_count; |
Neels Hofmeyr | 6166f29 | 2017-11-22 14:33:12 +0100 | [diff] [blame] | 144 | uint32_t use_tokens; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 145 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 146 | /* The MS has opened the conn with a CM Service Request, and we shall |
| 147 | * keep it open for an actual request (or until timeout). */ |
| 148 | bool received_cm_service_request; |
| 149 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 150 | /* libmsc/libvlr subscriber information (if available) */ |
| 151 | struct vlr_subscr *vsub; |
| 152 | |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 153 | /* LU expiration handling */ |
| 154 | uint8_t expire_timer_stopped; |
Holger Hans Peter Freyther | ca11443 | 2014-02-08 15:20:48 +0100 | [diff] [blame] | 155 | /* SMS helpers for libmsc */ |
| 156 | uint8_t next_rp_ref; |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 157 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 158 | /* |
| 159 | * Operations that have a state and might be pending |
| 160 | */ |
Sylvain Munaut | 30a1538 | 2009-12-24 00:27:26 +0100 | [diff] [blame] | 161 | struct gsm_security_operation *sec_operation; |
Holger Hans Peter Freyther | 02d39b2 | 2010-07-05 15:34:16 +0800 | [diff] [blame] | 162 | struct gsm_anchor_operation *anch_operation; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 163 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 164 | struct osmo_fsm_inst *conn_fsm; |
| 165 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 166 | /* Are we part of a special "silent" call */ |
| 167 | int silent_call; |
| 168 | |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 169 | /* MNCC rtp bridge markers */ |
| 170 | int mncc_rtp_bridge; |
| 171 | int mncc_rtp_create_pending; |
Holger Hans Peter Freyther | c21dcb2 | 2015-08-04 14:41:21 +0200 | [diff] [blame] | 172 | int mncc_rtp_connect_pending; |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 173 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 174 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 175 | struct gsm_network *network; |
| 176 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 177 | bool in_release; |
Holger Hans Peter Freyther | 77cd95d | 2010-11-14 16:19:48 +0100 | [diff] [blame] | 178 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 179 | /* connected via 2G or 3G? */ |
| 180 | enum ran_type via_ran; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 181 | |
| 182 | struct gsm_classmark classmark; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 183 | |
| 184 | uint16_t lac; |
| 185 | struct gsm_encr encr; |
| 186 | |
Harald Welte | c200785 | 2018-02-03 21:08:26 +0100 | [diff] [blame] | 187 | /* N(SD) expected in the received frame, per flow (TS 24.007 11.2.3.2.3.2.2) */ |
| 188 | uint8_t n_sd_next[4]; |
| 189 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 190 | struct { |
Philipp Maier | 621ba03 | 2017-11-07 17:19:25 +0100 | [diff] [blame] | 191 | struct mgcp_ctx *mgcp_ctx; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 192 | unsigned int mgcp_rtp_endpoint; |
Philipp Maier | 621ba03 | 2017-11-07 17:19:25 +0100 | [diff] [blame] | 193 | |
| 194 | uint16_t local_port_ran; |
| 195 | char local_addr_ran[INET_ADDRSTRLEN]; |
| 196 | uint16_t remote_port_ran; |
| 197 | char remote_addr_ran[INET_ADDRSTRLEN]; |
| 198 | uint16_t local_port_cn; |
| 199 | char local_addr_cn[INET_ADDRSTRLEN]; |
| 200 | uint16_t remote_port_cn; |
| 201 | char remote_addr_cn[INET_ADDRSTRLEN]; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 202 | } rtp; |
| 203 | |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 204 | /* which Iu-CS connection, if any. */ |
| 205 | struct { |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 206 | struct ranap_ue_conn_ctx *ue_ctx; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 207 | uint8_t rab_id; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 208 | } iu; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 209 | |
| 210 | struct { |
| 211 | /* A pointer to the SCCP user that handles |
| 212 | * the SCCP connections for this subscriber |
| 213 | * connection */ |
| 214 | struct osmo_sccp_user *scu; |
| 215 | |
| 216 | /* The address of the BSC that is associated |
| 217 | * with this subscriber connection */ |
| 218 | struct osmo_sccp_addr bsc_addr; |
| 219 | |
| 220 | /* The connection identifier that is used |
| 221 | * to reference the SCCP connection that is |
| 222 | * associated with this subscriber connection */ |
Philipp Maier | 64dbc54 | 2018-01-30 11:38:59 +0100 | [diff] [blame] | 223 | uint32_t conn_id; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 224 | } a; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 225 | }; |
| 226 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 227 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 228 | enum { |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 229 | MSC_CTR_LOC_UPDATE_TYPE_ATTACH, |
| 230 | MSC_CTR_LOC_UPDATE_TYPE_NORMAL, |
| 231 | MSC_CTR_LOC_UPDATE_TYPE_PERIODIC, |
| 232 | MSC_CTR_LOC_UPDATE_TYPE_DETACH, |
Neels Hofmeyr | 36891a7 | 2016-05-09 13:18:03 +0200 | [diff] [blame] | 233 | MSC_CTR_LOC_UPDATE_FAILED, |
| 234 | MSC_CTR_LOC_UPDATE_COMPLETED, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 235 | MSC_CTR_SMS_SUBMITTED, |
| 236 | MSC_CTR_SMS_NO_RECEIVER, |
| 237 | MSC_CTR_SMS_DELIVERED, |
| 238 | MSC_CTR_SMS_RP_ERR_MEM, |
| 239 | MSC_CTR_SMS_RP_ERR_OTHER, |
Alexander Couzens | aa386d2 | 2016-08-21 20:16:33 +0200 | [diff] [blame] | 240 | MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 241 | MSC_CTR_CALL_MO_SETUP, |
| 242 | MSC_CTR_CALL_MO_CONNECT_ACK, |
| 243 | MSC_CTR_CALL_MT_SETUP, |
| 244 | MSC_CTR_CALL_MT_CONNECT, |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 245 | MSC_CTR_CALL_ACTIVE, |
| 246 | MSC_CTR_CALL_COMPLETE, |
| 247 | MSC_CTR_CALL_INCOMPLETE, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | static const struct rate_ctr_desc msc_ctr_description[] = { |
Neels Hofmeyr | c6bf274 | 2017-11-18 23:22:17 +0100 | [diff] [blame] | 251 | [MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received location update imsi attach requests."}, |
| 252 | [MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received location update normal requests."}, |
| 253 | [MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received location update periodic requests."}, |
| 254 | [MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received location update detach indication."}, |
| 255 | [MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected location updates."}, |
| 256 | [MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful location updates."}, |
| 257 | [MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Received a RPDU from a MS (MO)."}, |
| 258 | [MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Counts SMS which couldn't routed because no receiver found."}, |
| 259 | [MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Global SMS Deliver attempts."}, |
| 260 | [MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."}, |
| 261 | [MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Other error of MS responses on a sms delive attempt."}, |
| 262 | [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] | 263 | /* FIXME: count also sms delivered */ |
Neels Hofmeyr | c6bf274 | 2017-11-18 23:22:17 +0100 | [diff] [blame] | 264 | [MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received setup requests from a MS to init a MO call."}, |
| 265 | [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."}, |
| 266 | [MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent setup requests to the MS (MT)."}, |
| 267 | [MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent a connect to the MS (MT)."}, |
| 268 | [MSC_CTR_CALL_ACTIVE] = {"call:active", "Count total amount of calls that ever reached active state."}, |
| 269 | [MSC_CTR_CALL_COMPLETE] = {"call:complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."}, |
| 270 | [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] | 271 | }; |
| 272 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 273 | static const struct rate_ctr_group_desc msc_ctrg_desc = { |
| 274 | "msc", |
| 275 | "mobile switching center", |
| 276 | OSMO_STATS_CLASS_GLOBAL, |
| 277 | ARRAY_SIZE(msc_ctr_description), |
| 278 | msc_ctr_description, |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 279 | }; |
| 280 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 281 | enum gsm_auth_policy { |
| 282 | GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */ |
| 283 | GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */ |
| 284 | GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */ |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 285 | GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */ |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 286 | }; |
| 287 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 288 | #define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 289 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 290 | struct gsm_tz { |
| 291 | int override; /* if 0, use system's time zone instead. */ |
| 292 | int hr; /* hour */ |
| 293 | int mn; /* minute */ |
| 294 | int dst; /* daylight savings */ |
| 295 | }; |
| 296 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 297 | struct gsm_network { |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 298 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 299 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 300 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 301 | * these have in common, like country and network code, put in yet |
| 302 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 303 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 304 | /* global parameters */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 305 | uint16_t country_code; |
| 306 | uint16_t network_code; |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 307 | char *name_long; |
| 308 | char *name_short; |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 309 | enum gsm_auth_policy auth_policy; |
Max | ddee01f | 2016-05-24 14:23:27 +0200 | [diff] [blame] | 310 | regex_t authorized_regexp; |
| 311 | char *authorized_reg_str; |
Harald Welte | 1085c09 | 2009-11-18 20:33:19 +0100 | [diff] [blame] | 312 | enum gsm48_reject_value reject_cause; |
Harald Welte | 7b222aa | 2017-12-23 19:30:32 +0100 | [diff] [blame] | 313 | /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ |
| 314 | uint8_t a5_encryption_mask; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 315 | bool authentication_required; |
Holger Hans Peter Freyther | f7d752f | 2009-11-16 17:12:38 +0100 | [diff] [blame] | 316 | int neci; |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 317 | int send_mm_info; |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 318 | struct { |
| 319 | int active; |
Harald Welte | f7c28b0 | 2009-12-21 13:30:17 +0100 | [diff] [blame] | 320 | /* Window RXLEV averaging */ |
| 321 | unsigned int win_rxlev_avg; /* number of SACCH frames */ |
| 322 | /* Window RXQUAL averaging */ |
| 323 | unsigned int win_rxqual_avg; /* number of SACCH frames */ |
| 324 | /* Window RXLEV neighbouring cells averaging */ |
| 325 | unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */ |
| 326 | |
| 327 | /* how often should we check for power budget HO */ |
| 328 | unsigned int pwr_interval; /* SACCH frames */ |
| 329 | /* how much better does a neighbor cell have to be ? */ |
| 330 | unsigned int pwr_hysteresis; /* dBm */ |
| 331 | /* maximum distacne before we try a handover */ |
| 332 | unsigned int max_distance; /* TA values */ |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 333 | } handover; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 334 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 335 | struct rate_ctr_group *bsc_ctrs; |
| 336 | struct rate_ctr_group *msc_ctrs; |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 337 | struct osmo_counter *active_calls; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 338 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 339 | /* layer 4 */ |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 340 | struct mncc_sock_state *mncc_state; |
Neels Hofmeyr | 402006d | 2016-05-11 14:28:25 +0200 | [diff] [blame] | 341 | mncc_recv_cb_t mncc_recv; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 342 | struct llist_head upqueue; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 343 | /* |
| 344 | * TODO: Move the trans_list into the subscriber connection and |
| 345 | * create a pending list for MT transactions. These exist before |
| 346 | * we have a subscriber connection. |
| 347 | */ |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 348 | struct llist_head trans_list; |
Holger Hans Peter Freyther | abcddf1 | 2010-06-14 18:20:15 +0800 | [diff] [blame] | 349 | struct bsc_api *bsc_api; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 350 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 351 | unsigned int paging_response_timer; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 352 | |
Jan Luebbe | bfbdeec | 2012-12-27 00:27:16 +0100 | [diff] [blame] | 353 | /* timer to expire old location updates */ |
| 354 | struct osmo_timer_list subscr_expire_timer; |
| 355 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 356 | /* Radio Resource Location Protocol (TS 04.31) */ |
| 357 | struct { |
| 358 | enum rrlp_mode mode; |
| 359 | } rrlp; |
Holger Hans Peter Freyther | 5a3a61d | 2010-09-06 09:25:48 +0800 | [diff] [blame] | 360 | |
Alexander Couzens | 1136811 | 2016-11-28 23:26:50 +0100 | [diff] [blame] | 361 | enum gsm_chan_t ctype_by_chreq[18]; |
Holger Hans Peter Freyther | 7889107 | 2010-09-06 09:36:02 +0800 | [diff] [blame] | 362 | |
Holger Hans Peter Freyther | 76fc4a3 | 2010-09-06 09:41:50 +0800 | [diff] [blame] | 363 | /* Use a TCH for handling requests of type paging any */ |
| 364 | int pag_any_tch; |
| 365 | |
Holger Hans Peter Freyther | 3e8e046 | 2010-09-15 22:29:25 +0800 | [diff] [blame] | 366 | /* MSC data in case we are a true BSC */ |
Holger Hans Peter Freyther | 8ec4952 | 2011-08-15 15:53:00 +0200 | [diff] [blame] | 367 | struct osmo_bsc_data *bsc_data; |
Holger Hans Peter Freyther | daee5ca | 2010-12-22 12:34:39 +0100 | [diff] [blame] | 368 | |
Holger Hans Peter Freyther | 11b28f9 | 2010-12-24 13:48:27 +0100 | [diff] [blame] | 369 | struct gsm_sms_queue *sms_queue; |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 370 | |
| 371 | /* control interface */ |
| 372 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 373 | |
| 374 | /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */ |
| 375 | bool dyn_ts_allow_tch_f; |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 376 | |
| 377 | /* all active subscriber connections. */ |
| 378 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 379 | |
| 380 | /* if override is nonzero, this timezone data is used for all MM |
| 381 | * contexts. */ |
| 382 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 383 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 384 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 385 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 386 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 387 | /* MSC: GSUP server address of the HLR */ |
| 388 | const char *gsup_server_addr_str; |
| 389 | uint16_t gsup_server_port; |
| 390 | |
| 391 | struct vlr_instance *vlr; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 392 | |
| 393 | /* Periodic location update default value */ |
| 394 | uint8_t t3212; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 395 | |
| 396 | struct { |
Neels Hofmeyr | 6c8afe1 | 2017-09-04 01:03:58 +0200 | [diff] [blame] | 397 | struct mgcp_client_conf conf; |
| 398 | struct mgcp_client *client; |
| 399 | } mgw; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 400 | |
| 401 | struct { |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 402 | /* CS7 instance id number (set via VTY) */ |
| 403 | uint32_t cs7_instance; |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 404 | int rab_assign_addr_enc; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 405 | struct osmo_sccp_instance *sccp; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 406 | } iu; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 407 | |
| 408 | struct { |
| 409 | /* CS7 instance id number (set via VTY) */ |
| 410 | uint32_t cs7_instance; |
| 411 | /* A list with the context information about |
| 412 | * all BSCs we have connections with */ |
| 413 | struct llist_head bscs; |
| 414 | struct osmo_sccp_instance *sccp; |
| 415 | } a; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 416 | }; |
| 417 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 418 | struct osmo_esme; |
| 419 | |
| 420 | enum gsm_sms_source_id { |
| 421 | SMS_SOURCE_UNKNOWN = 0, |
| 422 | SMS_SOURCE_MS, /* received from MS */ |
| 423 | SMS_SOURCE_VTY, /* received from VTY */ |
| 424 | SMS_SOURCE_SMPP, /* received via SMPP */ |
| 425 | }; |
| 426 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 427 | #define SMS_HDR_SIZE 128 |
| 428 | #define SMS_TEXT_SIZE 256 |
Harald Welte | e07b6a7 | 2012-11-23 19:02:37 +0100 | [diff] [blame] | 429 | |
| 430 | struct gsm_sms_addr { |
| 431 | uint8_t ton; |
| 432 | uint8_t npi; |
| 433 | char addr[21+1]; |
| 434 | }; |
| 435 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 436 | struct gsm_sms { |
Harald Welte | d409be7 | 2009-11-07 00:06:19 +0900 | [diff] [blame] | 437 | unsigned long long id; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 438 | struct vlr_subscr *receiver; |
Harald Welte | c0de14d | 2012-11-23 23:35:01 +0100 | [diff] [blame] | 439 | struct gsm_sms_addr src, dst; |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 440 | enum gsm_sms_source_id source; |
| 441 | |
| 442 | struct { |
Pablo Neira Ayuso | 93ffbd0 | 2017-05-04 18:44:22 +0200 | [diff] [blame] | 443 | uint8_t transaction_id; |
| 444 | uint32_t msg_ref; |
| 445 | } gsm411; |
| 446 | |
| 447 | struct { |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 448 | struct osmo_esme *esme; |
| 449 | uint32_t sequence_nr; |
| 450 | int transaction_mode; |
| 451 | char msg_id[16]; |
| 452 | } smpp; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 453 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 454 | unsigned long validity_minutes; |
Keith | c601adc | 2017-08-16 22:45:07 +0200 | [diff] [blame] | 455 | time_t created; |
Pablo Neira Ayuso | adae859 | 2017-08-07 14:01:30 +0100 | [diff] [blame] | 456 | bool is_report; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 457 | uint8_t reply_path_req; |
| 458 | uint8_t status_rep_req; |
| 459 | uint8_t ud_hdr_ind; |
| 460 | uint8_t protocol_id; |
| 461 | uint8_t data_coding_scheme; |
| 462 | uint8_t msg_ref; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 463 | uint8_t user_data_len; |
| 464 | uint8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 465 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 466 | char text[SMS_TEXT_SIZE]; |
| 467 | }; |
| 468 | |
Neels Hofmeyr | c13e687 | 2016-05-11 13:53:47 +0200 | [diff] [blame] | 469 | extern void talloc_ctx_init(void *ctx_root); |
| 470 | |
Andreas Eversberg | 8226fa7 | 2009-06-29 15:19:38 +0200 | [diff] [blame] | 471 | extern void *tall_bsc_ctx; |
Harald Welte | f88c8a0 | 2009-12-20 13:48:15 +0100 | [diff] [blame] | 472 | extern int ipacc_rtp_direct; |
Harald Welte | 2cf161b | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 473 | |
Harald Welte (local) | 69de397 | 2009-08-12 14:42:23 +0200 | [diff] [blame] | 474 | enum gsm_auth_policy gsm_auth_policy_parse(const char *arg); |
| 475 | const char *gsm_auth_policy_name(enum gsm_auth_policy policy); |
| 476 | |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 477 | enum rrlp_mode rrlp_mode_parse(const char *arg); |
| 478 | const char *rrlp_mode_name(enum rrlp_mode mode); |
| 479 | |
Neels Hofmeyr | 42eb014 | 2016-05-20 17:15:44 +0200 | [diff] [blame] | 480 | struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network); |
| 481 | void msc_subscr_con_free(struct gsm_subscriber_connection *conn); |
Holger Hans Peter Freyther | 2412a07 | 2010-06-28 15:47:12 +0800 | [diff] [blame] | 482 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 483 | /* control interface handling */ |
| 484 | int bsc_base_ctrl_cmds_install(void); |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 485 | int msc_ctrl_cmds_install(struct gsm_network *net); |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 486 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 487 | bool classmark_is_r99(struct gsm_classmark *cm); |
| 488 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 489 | #endif /* _GSM_DATA_H */ |