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 | |
Harald Welte | 0e2fa5d | 2018-04-09 16:35:01 +0200 | [diff] [blame] | 23 | /* TS 48.008 DLCI containing DCCH/ACCH + SAPI */ |
| 24 | #define OMSC_LINKID_CB(__msgb) (__msgb)->cb[3] |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 25 | |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 26 | #include "../../bscconfig.h" |
| 27 | #if BUILD_IU |
| 28 | #include <osmocom/ranap/iu_client.h> |
| 29 | #endif |
| 30 | |
Holger Hans Peter Freyther | d7b22c6 | 2013-04-29 09:11:02 +0200 | [diff] [blame] | 31 | /** annotations for msgb ownership */ |
| 32 | #define __uses |
| 33 | |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 34 | struct mncc_sock_state; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 35 | struct vlr_instance; |
| 36 | struct vlr_subscr; |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 37 | struct ranap_ue_conn_ctx; |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 38 | |
Neels Hofmeyr | 0e5d807 | 2017-01-10 00:49:56 +0100 | [diff] [blame] | 39 | #define tmsi_from_string(str) strtoul(str, NULL, 10) |
| 40 | |
Harald Welte | 8e1e3ee | 2009-02-01 13:32:45 +0000 | [diff] [blame] | 41 | struct msgb; |
| 42 | typedef int gsm_cbfn(unsigned int hooknum, |
| 43 | unsigned int event, |
| 44 | struct msgb *msg, |
| 45 | void *data, void *param); |
| 46 | |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 47 | struct gsm_auth_tuple { |
| 48 | int use_count; |
| 49 | int key_seq; |
Harald Welte | 121e9a4 | 2016-04-20 13:13:19 +0200 | [diff] [blame] | 50 | struct osmo_auth_vector vec; |
Sylvain Munaut | 4719307 | 2009-12-27 21:56:14 +0100 | [diff] [blame] | 51 | }; |
Sylvain Munaut | b48216f | 2010-06-09 12:45:37 +0200 | [diff] [blame] | 52 | #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] | 53 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 54 | enum ran_type { |
| 55 | RAN_UNKNOWN, |
| 56 | RAN_GERAN_A, /* 2G / A-interface */ |
| 57 | RAN_UTRAN_IU, /* 3G / Iu-interface (IuCS or IuPS) */ |
| 58 | }; |
| 59 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 60 | extern const struct value_string ran_type_names[]; |
| 61 | static inline const char *ran_type_name(enum ran_type val) |
| 62 | { return get_value_string(ran_type_names, val); } |
| 63 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 64 | struct gsm_classmark { |
| 65 | bool classmark1_set; |
| 66 | struct gsm48_classmark1 classmark1; |
| 67 | uint8_t classmark2_len; |
| 68 | uint8_t classmark2[3]; |
| 69 | uint8_t classmark3_len; |
| 70 | uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */ |
| 71 | }; |
| 72 | |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 73 | enum integrity_protection_state { |
| 74 | INTEGRITY_PROTECTION_NONE = 0, |
| 75 | INTEGRITY_PROTECTION_IK = 1, |
| 76 | INTEGRITY_PROTECTION_IK_CK = 2, |
| 77 | }; |
| 78 | |
Neels Hofmeyr | 16c42b5 | 2018-04-02 12:26:16 +0200 | [diff] [blame] | 79 | enum complete_layer3_type { |
| 80 | COMPLETE_LAYER3_NONE, |
| 81 | COMPLETE_LAYER3_LU, |
| 82 | COMPLETE_LAYER3_CM_SERVICE_REQ, |
| 83 | COMPLETE_LAYER3_PAGING_RESP, |
| 84 | }; |
| 85 | |
| 86 | extern const struct value_string complete_layer3_type_names[]; |
| 87 | static inline const char *complete_layer3_type_name(enum complete_layer3_type val) |
| 88 | { |
| 89 | return get_value_string(complete_layer3_type_names, val); |
| 90 | } |
| 91 | |
Neels Hofmeyr | 378a492 | 2016-05-09 21:07:43 +0200 | [diff] [blame] | 92 | /* active radio connection of a mobile subscriber */ |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 93 | struct gsm_subscriber_connection { |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 94 | /* global linked list of subscriber_connections */ |
Holger Hans Peter Freyther | 79f763f | 2010-09-16 00:53:37 +0800 | [diff] [blame] | 95 | struct llist_head entry; |
| 96 | |
Neels Hofmeyr | 4d3a66b | 2018-03-31 18:45:59 +0200 | [diff] [blame] | 97 | /* FSM instance to control the subscriber connection's permissions and lifetime. */ |
| 98 | struct osmo_fsm_inst *fi; |
Neels Hofmeyr | 16c42b5 | 2018-04-02 12:26:16 +0200 | [diff] [blame] | 99 | enum complete_layer3_type complete_layer3_type; |
Neels Hofmeyr | 4d3a66b | 2018-03-31 18:45:59 +0200 | [diff] [blame] | 100 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 101 | /* usage count. If this drops to zero, we start the release |
| 102 | * towards A/Iu */ |
| 103 | uint32_t use_count; |
Neels Hofmeyr | 6166f29 | 2017-11-22 14:33:12 +0100 | [diff] [blame] | 104 | uint32_t use_tokens; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 105 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 106 | /* The MS has opened the conn with a CM Service Request, and we shall |
| 107 | * keep it open for an actual request (or until timeout). */ |
| 108 | bool received_cm_service_request; |
| 109 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 110 | /* libmsc/libvlr subscriber information (if available) */ |
| 111 | struct vlr_subscr *vsub; |
| 112 | |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 113 | /* LU expiration handling */ |
| 114 | uint8_t expire_timer_stopped; |
Holger Hans Peter Freyther | ca11443 | 2014-02-08 15:20:48 +0100 | [diff] [blame] | 115 | /* SMS helpers for libmsc */ |
| 116 | uint8_t next_rp_ref; |
Holger Hans Peter Freyther | e7bd863 | 2013-06-30 15:30:47 +0200 | [diff] [blame] | 117 | |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 118 | /* Are we part of a special "silent" call */ |
| 119 | int silent_call; |
| 120 | |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 121 | /* MNCC rtp bridge markers */ |
| 122 | int mncc_rtp_bridge; |
Holger Hans Peter Freyther | c8a6c13 | 2015-08-04 13:32:09 +0200 | [diff] [blame] | 123 | |
Holger Hans Peter Freyther | 18b63f4 | 2010-03-23 07:52:17 +0100 | [diff] [blame] | 124 | /* back pointers */ |
Neels Hofmeyr | 5e0b0a6 | 2016-05-09 22:33:01 +0200 | [diff] [blame] | 125 | struct gsm_network *network; |
| 126 | |
Neels Hofmeyr | d3270a9 | 2017-02-02 01:07:28 +0100 | [diff] [blame] | 127 | /* connected via 2G or 3G? */ |
| 128 | enum ran_type via_ran; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 129 | |
| 130 | struct gsm_classmark classmark; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 131 | |
| 132 | uint16_t lac; |
| 133 | struct gsm_encr encr; |
| 134 | |
Harald Welte | c200785 | 2018-02-03 21:08:26 +0100 | [diff] [blame] | 135 | /* N(SD) expected in the received frame, per flow (TS 24.007 11.2.3.2.3.2.2) */ |
| 136 | uint8_t n_sd_next[4]; |
| 137 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 138 | struct { |
Philipp Maier | 621ba03 | 2017-11-07 17:19:25 +0100 | [diff] [blame] | 139 | struct mgcp_ctx *mgcp_ctx; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 140 | unsigned int mgcp_rtp_endpoint; |
Philipp Maier | 621ba03 | 2017-11-07 17:19:25 +0100 | [diff] [blame] | 141 | |
| 142 | uint16_t local_port_ran; |
| 143 | char local_addr_ran[INET_ADDRSTRLEN]; |
| 144 | uint16_t remote_port_ran; |
| 145 | char remote_addr_ran[INET_ADDRSTRLEN]; |
Philipp Maier | 8ad3dac | 2018-08-07 13:00:14 +0200 | [diff] [blame] | 146 | enum mgcp_codecs codec_ran; |
| 147 | |
Philipp Maier | 621ba03 | 2017-11-07 17:19:25 +0100 | [diff] [blame] | 148 | uint16_t local_port_cn; |
| 149 | char local_addr_cn[INET_ADDRSTRLEN]; |
| 150 | uint16_t remote_port_cn; |
| 151 | char remote_addr_cn[INET_ADDRSTRLEN]; |
Philipp Maier | 8ad3dac | 2018-08-07 13:00:14 +0200 | [diff] [blame] | 152 | enum mgcp_codecs codec_cn; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 153 | } rtp; |
| 154 | |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 155 | /* which Iu-CS connection, if any. */ |
| 156 | struct { |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 157 | struct ranap_ue_conn_ctx *ue_ctx; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 158 | uint8_t rab_id; |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 159 | bool waiting_for_release_complete; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 160 | } iu; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 161 | |
| 162 | struct { |
| 163 | /* A pointer to the SCCP user that handles |
| 164 | * the SCCP connections for this subscriber |
| 165 | * connection */ |
| 166 | struct osmo_sccp_user *scu; |
| 167 | |
| 168 | /* The address of the BSC that is associated |
| 169 | * with this subscriber connection */ |
| 170 | struct osmo_sccp_addr bsc_addr; |
| 171 | |
| 172 | /* The connection identifier that is used |
| 173 | * to reference the SCCP connection that is |
| 174 | * associated with this subscriber connection */ |
Philipp Maier | 64dbc54 | 2018-01-30 11:38:59 +0100 | [diff] [blame] | 175 | uint32_t conn_id; |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 176 | |
| 177 | bool waiting_for_clear_complete; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 178 | } a; |
Holger Hans Peter Freyther | 68884aa | 2010-03-23 06:41:45 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Harald Welte | f142c97 | 2011-05-24 13:25:38 +0200 | [diff] [blame] | 181 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 182 | enum { |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 183 | MSC_CTR_LOC_UPDATE_TYPE_ATTACH, |
| 184 | MSC_CTR_LOC_UPDATE_TYPE_NORMAL, |
| 185 | MSC_CTR_LOC_UPDATE_TYPE_PERIODIC, |
| 186 | MSC_CTR_LOC_UPDATE_TYPE_DETACH, |
Neels Hofmeyr | 36891a7 | 2016-05-09 13:18:03 +0200 | [diff] [blame] | 187 | MSC_CTR_LOC_UPDATE_FAILED, |
| 188 | MSC_CTR_LOC_UPDATE_COMPLETED, |
Neels Hofmeyr | e3d3dc6 | 2018-03-31 00:02:14 +0200 | [diff] [blame] | 189 | MSC_CTR_CM_SERVICE_REQUEST_REJECTED, |
| 190 | MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED, |
| 191 | MSC_CTR_PAGING_RESP_REJECTED, |
| 192 | MSC_CTR_PAGING_RESP_ACCEPTED, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 193 | MSC_CTR_SMS_SUBMITTED, |
| 194 | MSC_CTR_SMS_NO_RECEIVER, |
| 195 | MSC_CTR_SMS_DELIVERED, |
| 196 | MSC_CTR_SMS_RP_ERR_MEM, |
| 197 | MSC_CTR_SMS_RP_ERR_OTHER, |
Alexander Couzens | aa386d2 | 2016-08-21 20:16:33 +0200 | [diff] [blame] | 198 | MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 199 | MSC_CTR_CALL_MO_SETUP, |
| 200 | MSC_CTR_CALL_MO_CONNECT_ACK, |
| 201 | MSC_CTR_CALL_MT_SETUP, |
| 202 | MSC_CTR_CALL_MT_CONNECT, |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 203 | MSC_CTR_CALL_ACTIVE, |
| 204 | MSC_CTR_CALL_COMPLETE, |
| 205 | MSC_CTR_CALL_INCOMPLETE, |
Vadim Yanitskiy | 8e25cc5 | 2018-06-23 03:32:20 +0700 | [diff] [blame] | 206 | MSC_CTR_NC_SS_MO_REQUESTS, |
| 207 | MSC_CTR_NC_SS_MO_ESTABLISHED, |
| 208 | MSC_CTR_NC_SS_MT_REQUESTS, |
| 209 | MSC_CTR_NC_SS_MT_ESTABLISHED, |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 210 | }; |
| 211 | |
| 212 | static const struct rate_ctr_desc msc_ctr_description[] = { |
Neels Hofmeyr | c6bf274 | 2017-11-18 23:22:17 +0100 | [diff] [blame] | 213 | [MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received location update imsi attach requests."}, |
| 214 | [MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received location update normal requests."}, |
| 215 | [MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received location update periodic requests."}, |
| 216 | [MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received location update detach indication."}, |
| 217 | [MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected location updates."}, |
| 218 | [MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful location updates."}, |
Neels Hofmeyr | e3d3dc6 | 2018-03-31 00:02:14 +0200 | [diff] [blame] | 219 | [MSC_CTR_CM_SERVICE_REQUEST_REJECTED] = {"cm_service_request:rejected", "Rejected CM Service Request."}, |
| 220 | [MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED] = {"cm_service_request:accepted", "Accepted CM Service Request."}, |
| 221 | [MSC_CTR_PAGING_RESP_REJECTED] = {"paging_resp:rejected", "Rejected Paging Response."}, |
| 222 | [MSC_CTR_PAGING_RESP_ACCEPTED] = {"paging_resp:accepted", "Accepted Paging Response."}, |
Neels Hofmeyr | c6bf274 | 2017-11-18 23:22:17 +0100 | [diff] [blame] | 223 | [MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Received a RPDU from a MS (MO)."}, |
| 224 | [MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Counts SMS which couldn't routed because no receiver found."}, |
| 225 | [MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Global SMS Deliver attempts."}, |
| 226 | [MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."}, |
| 227 | [MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Other error of MS responses on a sms delive attempt."}, |
| 228 | [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] | 229 | /* FIXME: count also sms delivered */ |
Neels Hofmeyr | c6bf274 | 2017-11-18 23:22:17 +0100 | [diff] [blame] | 230 | [MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received setup requests from a MS to init a MO call."}, |
| 231 | [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."}, |
| 232 | [MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent setup requests to the MS (MT)."}, |
| 233 | [MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent a connect to the MS (MT)."}, |
| 234 | [MSC_CTR_CALL_ACTIVE] = {"call:active", "Count total amount of calls that ever reached active state."}, |
| 235 | [MSC_CTR_CALL_COMPLETE] = {"call:complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."}, |
| 236 | [MSC_CTR_CALL_INCOMPLETE] = {"call:incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."}, |
Vadim Yanitskiy | 8e25cc5 | 2018-06-23 03:32:20 +0700 | [diff] [blame] | 237 | [MSC_CTR_NC_SS_MO_REQUESTS] = {"nc_ss:mo_requests", "Received MS-initiated call independent SS/USSD requests."}, |
| 238 | [MSC_CTR_NC_SS_MO_ESTABLISHED] = {"nc_ss:mo_established", "Established MS-initiated call independent SS/USSD sessions."}, |
| 239 | [MSC_CTR_NC_SS_MT_REQUESTS] = {"nc_ss:mt_requests", "Received network-initiated call independent SS/USSD requests."}, |
| 240 | [MSC_CTR_NC_SS_MT_ESTABLISHED] = {"nc_ss:mt_established", "Established network-initiated call independent SS/USSD sessions."}, |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 241 | }; |
| 242 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 243 | static const struct rate_ctr_group_desc msc_ctrg_desc = { |
| 244 | "msc", |
| 245 | "mobile switching center", |
| 246 | OSMO_STATS_CLASS_GLOBAL, |
| 247 | ARRAY_SIZE(msc_ctr_description), |
| 248 | msc_ctr_description, |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 249 | }; |
| 250 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 251 | #define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10 |
Harald Welte | b84ddfc | 2009-12-01 17:36:54 +0530 | [diff] [blame] | 252 | |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 253 | struct gsm_tz { |
| 254 | int override; /* if 0, use system's time zone instead. */ |
| 255 | int hr; /* hour */ |
| 256 | int mn; /* minute */ |
| 257 | int dst; /* daylight savings */ |
| 258 | }; |
| 259 | |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 260 | struct gsm_network { |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 261 | /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for |
| 262 | * global settings and variables, "madly" mixing BSC and MSC stuff. Split |
| 263 | * this in e.g. struct osmo_bsc and struct osmo_msc, with the things |
| 264 | * these have in common, like country and network code, put in yet |
| 265 | * separate structs and placed as members in osmo_bsc and osmo_msc. */ |
| 266 | |
Neels Hofmeyr | 379d579 | 2018-02-22 04:04:54 +0100 | [diff] [blame] | 267 | struct osmo_plmn_id plmn; |
| 268 | |
Harald Welte | c6ba9c2 | 2008-12-30 18:01:02 +0000 | [diff] [blame] | 269 | char *name_long; |
| 270 | char *name_short; |
Neels Hofmeyr | 379d579 | 2018-02-22 04:04:54 +0100 | [diff] [blame] | 271 | |
Harald Welte | 7b222aa | 2017-12-23 19:30:32 +0100 | [diff] [blame] | 272 | /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */ |
| 273 | uint8_t a5_encryption_mask; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 274 | bool authentication_required; |
Harald Welte | 648b6ce | 2009-12-14 09:00:24 +0100 | [diff] [blame] | 275 | int send_mm_info; |
Harald Welte | bc81450 | 2009-12-19 21:41:52 +0100 | [diff] [blame] | 276 | struct { |
| 277 | int active; |
| 278 | } handover; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 279 | |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 280 | struct rate_ctr_group *msc_ctrs; |
Alexander Couzens | 92f552f | 2016-08-23 07:32:27 +0200 | [diff] [blame] | 281 | struct osmo_counter *active_calls; |
Vadim Yanitskiy | ad64e2a | 2018-06-26 18:27:25 +0700 | [diff] [blame] | 282 | struct osmo_counter *active_nc_ss; |
Harald Welte | 24ff6ee | 2009-12-22 00:41:05 +0100 | [diff] [blame] | 283 | |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 284 | /* layer 4 */ |
Holger Hans Peter Freyther | 694c82d | 2011-10-26 18:37:09 +0200 | [diff] [blame] | 285 | struct mncc_sock_state *mncc_state; |
Neels Hofmeyr | 402006d | 2016-05-11 14:28:25 +0200 | [diff] [blame] | 286 | mncc_recv_cb_t mncc_recv; |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 287 | struct llist_head upqueue; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 288 | /* |
| 289 | * TODO: Move the trans_list into the subscriber connection and |
| 290 | * create a pending list for MT transactions. These exist before |
| 291 | * we have a subscriber connection. |
| 292 | */ |
Harald Welte | 4bfdfe7 | 2009-06-10 23:11:52 +0800 | [diff] [blame] | 293 | struct llist_head trans_list; |
| 294 | |
Neels Hofmeyr | 2ff5bcd | 2017-12-15 03:02:27 +0100 | [diff] [blame] | 295 | unsigned int paging_response_timer; |
Harald Welte | eab84a1 | 2009-12-13 10:53:12 +0100 | [diff] [blame] | 296 | |
| 297 | /* Radio Resource Location Protocol (TS 04.31) */ |
| 298 | struct { |
| 299 | enum rrlp_mode mode; |
| 300 | } rrlp; |
Holger Hans Peter Freyther | 5a3a61d | 2010-09-06 09:25:48 +0800 | [diff] [blame] | 301 | |
Holger Hans Peter Freyther | 11b28f9 | 2010-12-24 13:48:27 +0100 | [diff] [blame] | 302 | struct gsm_sms_queue *sms_queue; |
Daniel Willmann | 6fc4a98 | 2011-07-22 17:55:42 +0200 | [diff] [blame] | 303 | |
| 304 | /* control interface */ |
| 305 | struct ctrl_handle *ctrl; |
Neels Hofmeyr | 5f0c71b | 2016-07-23 20:15:28 +0200 | [diff] [blame] | 306 | |
Neels Hofmeyr | d90fa42 | 2016-05-09 21:03:12 +0200 | [diff] [blame] | 307 | /* all active subscriber connections. */ |
| 308 | struct llist_head subscr_conns; |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 309 | |
| 310 | /* if override is nonzero, this timezone data is used for all MM |
| 311 | * contexts. */ |
| 312 | /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable |
| 313 | * BTS|RNC specific timezone overrides for multi-tz networks in |
Neels Hofmeyr | fe291de | 2017-02-23 21:06:12 +0100 | [diff] [blame] | 314 | * OsmoMSC, this should be tied to the location area code (LAC). */ |
Neels Hofmeyr | 7398395 | 2016-05-10 13:29:33 +0200 | [diff] [blame] | 315 | struct gsm_tz tz; |
Neels Hofmeyr | 6d804b1 | 2017-02-18 22:20:46 +0100 | [diff] [blame] | 316 | |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 317 | /* MSC: GSUP server address of the HLR */ |
| 318 | const char *gsup_server_addr_str; |
| 319 | uint16_t gsup_server_port; |
| 320 | |
| 321 | struct vlr_instance *vlr; |
Neels Hofmeyr | e2f24d5 | 2017-05-08 15:12:20 +0200 | [diff] [blame] | 322 | |
| 323 | /* Periodic location update default value */ |
| 324 | uint8_t t3212; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 325 | |
| 326 | struct { |
Neels Hofmeyr | 6c8afe1 | 2017-09-04 01:03:58 +0200 | [diff] [blame] | 327 | struct mgcp_client_conf conf; |
| 328 | struct mgcp_client *client; |
| 329 | } mgw; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 330 | |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 331 | #if BUILD_IU |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 332 | struct { |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 333 | /* CS7 instance id number (set via VTY) */ |
| 334 | uint32_t cs7_instance; |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 335 | enum ranap_nsap_addr_enc rab_assign_addr_enc; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 336 | struct osmo_sccp_instance *sccp; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 337 | } iu; |
Neels Hofmeyr | 21adb2b | 2018-03-15 12:55:46 +0100 | [diff] [blame] | 338 | #endif |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 339 | |
| 340 | struct { |
| 341 | /* CS7 instance id number (set via VTY) */ |
| 342 | uint32_t cs7_instance; |
| 343 | /* A list with the context information about |
| 344 | * all BSCs we have connections with */ |
| 345 | struct llist_head bscs; |
| 346 | struct osmo_sccp_instance *sccp; |
| 347 | } a; |
Harald Welte | 69c54a8 | 2018-02-09 20:41:14 +0100 | [diff] [blame] | 348 | |
| 349 | struct { |
| 350 | /* MSISDN to which to route MO emergency calls */ |
| 351 | char *route_to_msisdn; |
| 352 | } emergency; |
Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 355 | struct osmo_esme; |
| 356 | |
| 357 | enum gsm_sms_source_id { |
| 358 | SMS_SOURCE_UNKNOWN = 0, |
| 359 | SMS_SOURCE_MS, /* received from MS */ |
| 360 | SMS_SOURCE_VTY, /* received from VTY */ |
| 361 | SMS_SOURCE_SMPP, /* received via SMPP */ |
| 362 | }; |
| 363 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 364 | #define SMS_HDR_SIZE 128 |
| 365 | #define SMS_TEXT_SIZE 256 |
Harald Welte | e07b6a7 | 2012-11-23 19:02:37 +0100 | [diff] [blame] | 366 | |
| 367 | struct gsm_sms_addr { |
| 368 | uint8_t ton; |
| 369 | uint8_t npi; |
| 370 | char addr[21+1]; |
| 371 | }; |
| 372 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 373 | struct gsm_sms { |
Harald Welte | d409be7 | 2009-11-07 00:06:19 +0900 | [diff] [blame] | 374 | unsigned long long id; |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 375 | struct vlr_subscr *receiver; |
Harald Welte | c0de14d | 2012-11-23 23:35:01 +0100 | [diff] [blame] | 376 | struct gsm_sms_addr src, dst; |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 377 | enum gsm_sms_source_id source; |
| 378 | |
| 379 | struct { |
Pablo Neira Ayuso | 93ffbd0 | 2017-05-04 18:44:22 +0200 | [diff] [blame] | 380 | uint8_t transaction_id; |
| 381 | uint32_t msg_ref; |
| 382 | } gsm411; |
| 383 | |
| 384 | struct { |
Harald Welte | d4bdee7 | 2012-11-08 19:44:08 +0100 | [diff] [blame] | 385 | struct osmo_esme *esme; |
| 386 | uint32_t sequence_nr; |
| 387 | int transaction_mode; |
| 388 | char msg_id[16]; |
| 389 | } smpp; |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 390 | |
Harald Welte | b9c758b | 2009-07-05 14:02:46 +0200 | [diff] [blame] | 391 | unsigned long validity_minutes; |
Keith | c601adc | 2017-08-16 22:45:07 +0200 | [diff] [blame] | 392 | time_t created; |
Pablo Neira Ayuso | adae859 | 2017-08-07 14:01:30 +0100 | [diff] [blame] | 393 | bool is_report; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 394 | uint8_t reply_path_req; |
| 395 | uint8_t status_rep_req; |
| 396 | uint8_t ud_hdr_ind; |
| 397 | uint8_t protocol_id; |
| 398 | uint8_t data_coding_scheme; |
| 399 | uint8_t msg_ref; |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 400 | uint8_t user_data_len; |
| 401 | uint8_t user_data[SMS_TEXT_SIZE]; |
Harald Welte | f3efc59 | 2009-07-27 20:11:35 +0200 | [diff] [blame] | 402 | |
Harald Welte | 7e310b1 | 2009-03-30 20:56:32 +0000 | [diff] [blame] | 403 | char text[SMS_TEXT_SIZE]; |
| 404 | }; |
| 405 | |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 406 | /* control interface handling */ |
| 407 | int bsc_base_ctrl_cmds_install(void); |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 408 | int msc_ctrl_cmds_install(struct gsm_network *net); |
Holger Hans Peter Freyther | f8c4219 | 2013-01-09 17:03:27 +0100 | [diff] [blame] | 409 | |
Harald Welte | 6be350c | 2011-05-25 13:10:08 +0200 | [diff] [blame] | 410 | #endif /* _GSM_DATA_H */ |