blob: 085248cc77e97b9e74b4313d5e2135e8f9c94871 [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001#ifndef _GSM_DATA_H
2#define _GSM_DATA_H
3
Harald Weltef142c972011-05-24 13:25:38 +02004#include <stdint.h>
Maxddee01f2016-05-24 14:23:27 +02005#include <regex.h>
6#include <sys/types.h>
Maxe6052c42016-06-30 10:25:49 +02007#include <stdbool.h>
Harald Weltef142c972011-05-24 13:25:38 +02008
9#include <osmocom/core/timer.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020010#include <osmocom/core/rate_ctr.h>
Harald Welte6be350c2011-05-25 13:10:08 +020011#include <osmocom/core/select.h>
Alexander Couzens20423ea2016-07-12 15:42:02 +020012#include <osmocom/core/stats.h>
Max43b01b02017-09-15 11:22:30 +020013#include <osmocom/gsm/gsm48.h>
Harald Welte121e9a42016-04-20 13:13:19 +020014#include <osmocom/crypt/auth.h>
Philipp Maierfbf66102017-04-09 12:32:51 +020015#include <osmocom/sigtran/sccp_sap.h>
Harald Weltef142c972011-05-24 13:25:38 +020016
Neels Hofmeyr90843962017-09-04 15:04:35 +020017#include <osmocom/msc/common.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +020018#include <osmocom/msc/common_cs.h>
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +020019#include <osmocom/mgcp_client/mgcp_client.h>
Harald Welteb96be392011-05-25 12:33:33 +020020
Harald Welted35038d2018-01-25 00:07:33 +010021#include "gsm_data_shared.h"
22
Harald Welte0e2fa5d2018-04-09 16:35:01 +020023/* TS 48.008 DLCI containing DCCH/ACCH + SAPI */
24#define OMSC_LINKID_CB(__msgb) (__msgb)->cb[3]
Philipp Maierfbf66102017-04-09 12:32:51 +020025
Neels Hofmeyr21adb2b2018-03-15 12:55:46 +010026#include "../../bscconfig.h"
27#if BUILD_IU
28#include <osmocom/ranap/iu_client.h>
29#endif
30
Holger Hans Peter Freytherd7b22c62013-04-29 09:11:02 +020031/** annotations for msgb ownership */
32#define __uses
33
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020034struct mncc_sock_state;
Harald Welte2483f1b2016-06-19 18:06:02 +020035struct vlr_instance;
36struct vlr_subscr;
Neels Hofmeyr00e82d62017-07-05 15:19:52 +020037struct ranap_ue_conn_ctx;
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020038
Neels Hofmeyr0e5d8072017-01-10 00:49:56 +010039#define tmsi_from_string(str) strtoul(str, NULL, 10)
40
Harald Welte8e1e3ee2009-02-01 13:32:45 +000041struct msgb;
42typedef int gsm_cbfn(unsigned int hooknum,
43 unsigned int event,
44 struct msgb *msg,
45 void *data, void *param);
46
Sylvain Munaut47193072009-12-27 21:56:14 +010047struct gsm_auth_tuple {
48 int use_count;
49 int key_seq;
Harald Welte121e9a42016-04-20 13:13:19 +020050 struct osmo_auth_vector vec;
Sylvain Munaut47193072009-12-27 21:56:14 +010051};
Sylvain Munautb48216f2010-06-09 12:45:37 +020052#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
Sylvain Munaut47193072009-12-27 21:56:14 +010053
Neels Hofmeyrd3270a92017-02-02 01:07:28 +010054enum 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 Hofmeyr84da6b12016-05-20 21:59:55 +020060extern const struct value_string ran_type_names[];
61static inline const char *ran_type_name(enum ran_type val)
62{ return get_value_string(ran_type_names, val); }
63
Harald Welte2483f1b2016-06-19 18:06:02 +020064struct 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 Hofmeyre2f24d52017-05-08 15:12:20 +020073enum integrity_protection_state {
74 INTEGRITY_PROTECTION_NONE = 0,
75 INTEGRITY_PROTECTION_IK = 1,
76 INTEGRITY_PROTECTION_IK_CK = 2,
77};
78
Neels Hofmeyr16c42b52018-04-02 12:26:16 +020079enum complete_layer3_type {
80 COMPLETE_LAYER3_NONE,
81 COMPLETE_LAYER3_LU,
82 COMPLETE_LAYER3_CM_SERVICE_REQ,
83 COMPLETE_LAYER3_PAGING_RESP,
84};
85
86extern const struct value_string complete_layer3_type_names[];
87static 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 Hofmeyr378a4922016-05-09 21:07:43 +020092/* active radio connection of a mobile subscriber */
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +010093struct gsm_subscriber_connection {
Harald Welte2483f1b2016-06-19 18:06:02 +020094 /* global linked list of subscriber_connections */
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +080095 struct llist_head entry;
96
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +020097 /* FSM instance to control the subscriber connection's permissions and lifetime. */
98 struct osmo_fsm_inst *fi;
Neels Hofmeyr16c42b52018-04-02 12:26:16 +020099 enum complete_layer3_type complete_layer3_type;
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200100
Harald Welte2483f1b2016-06-19 18:06:02 +0200101 /* usage count. If this drops to zero, we start the release
102 * towards A/Iu */
103 uint32_t use_count;
Neels Hofmeyr6166f292017-11-22 14:33:12 +0100104 uint32_t use_tokens;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100105
Harald Welte2483f1b2016-06-19 18:06:02 +0200106 /* 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 Welte2483f1b2016-06-19 18:06:02 +0200110 /* libmsc/libvlr subscriber information (if available) */
111 struct vlr_subscr *vsub;
112
Holger Hans Peter Freythere7bd8632013-06-30 15:30:47 +0200113 /* LU expiration handling */
114 uint8_t expire_timer_stopped;
Holger Hans Peter Freytherca114432014-02-08 15:20:48 +0100115 /* SMS helpers for libmsc */
116 uint8_t next_rp_ref;
Holger Hans Peter Freythere7bd8632013-06-30 15:30:47 +0200117
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100118 /* Are we part of a special "silent" call */
119 int silent_call;
120
Holger Hans Peter Freytherc8a6c132015-08-04 13:32:09 +0200121 /* MNCC rtp bridge markers */
122 int mncc_rtp_bridge;
Holger Hans Peter Freytherc8a6c132015-08-04 13:32:09 +0200123
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100124 /* back pointers */
Neels Hofmeyr5e0b0a62016-05-09 22:33:01 +0200125 struct gsm_network *network;
126
Neels Hofmeyrd3270a92017-02-02 01:07:28 +0100127 /* connected via 2G or 3G? */
128 enum ran_type via_ran;
Harald Welte2483f1b2016-06-19 18:06:02 +0200129
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200130 uint16_t lac;
131 struct gsm_encr encr;
132
Neels Hofmeyr3117b702018-09-13 03:23:07 +0200133 /* "Temporary" storage for the case the VLR asked for Cipher Mode Command, but the MSC still
134 * wants to request a Classmark Update first. */
135 struct {
136 bool umts_aka;
137 bool retrieve_imeisv;
138 } geran_set_cipher_mode;
139
Harald Weltec2007852018-02-03 21:08:26 +0100140 /* N(SD) expected in the received frame, per flow (TS 24.007 11.2.3.2.3.2.2) */
141 uint8_t n_sd_next[4];
142
Philipp Maierfbf66102017-04-09 12:32:51 +0200143 struct {
Philipp Maier621ba032017-11-07 17:19:25 +0100144 struct mgcp_ctx *mgcp_ctx;
Philipp Maierfbf66102017-04-09 12:32:51 +0200145 unsigned int mgcp_rtp_endpoint;
Philipp Maier621ba032017-11-07 17:19:25 +0100146
147 uint16_t local_port_ran;
148 char local_addr_ran[INET_ADDRSTRLEN];
149 uint16_t remote_port_ran;
150 char remote_addr_ran[INET_ADDRSTRLEN];
Philipp Maier8ad3dac2018-08-07 13:00:14 +0200151 enum mgcp_codecs codec_ran;
152
Philipp Maier621ba032017-11-07 17:19:25 +0100153 uint16_t local_port_cn;
154 char local_addr_cn[INET_ADDRSTRLEN];
155 uint16_t remote_port_cn;
156 char remote_addr_cn[INET_ADDRSTRLEN];
Philipp Maier8ad3dac2018-08-07 13:00:14 +0200157 enum mgcp_codecs codec_cn;
Philipp Maierfbf66102017-04-09 12:32:51 +0200158 } rtp;
159
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200160 /* which Iu-CS connection, if any. */
161 struct {
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200162 struct ranap_ue_conn_ctx *ue_ctx;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200163 uint8_t rab_id;
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200164 bool waiting_for_release_complete;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200165 } iu;
Philipp Maierfbf66102017-04-09 12:32:51 +0200166
167 struct {
168 /* A pointer to the SCCP user that handles
169 * the SCCP connections for this subscriber
170 * connection */
171 struct osmo_sccp_user *scu;
172
173 /* The address of the BSC that is associated
174 * with this subscriber connection */
175 struct osmo_sccp_addr bsc_addr;
176
177 /* The connection identifier that is used
178 * to reference the SCCP connection that is
179 * associated with this subscriber connection */
Philipp Maier64dbc542018-01-30 11:38:59 +0100180 uint32_t conn_id;
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200181
182 bool waiting_for_clear_complete;
Philipp Maierfbf66102017-04-09 12:32:51 +0200183 } a;
Neels Hofmeyr68cf9572018-09-18 15:52:58 +0200184
185 /* Temporary storage for Classmark Information for times when a connection has no VLR subscriber
186 * associated yet. It will get copied to the VLR subscriber upon msc_vlr_subscr_assoc(). */
187 struct gsm_classmark temporary_classmark;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100188};
189
Harald Weltef142c972011-05-24 13:25:38 +0200190
Alexander Couzensb847a212016-08-02 11:34:11 +0200191enum {
Alexander Couzens20423ea2016-07-12 15:42:02 +0200192 MSC_CTR_LOC_UPDATE_TYPE_ATTACH,
193 MSC_CTR_LOC_UPDATE_TYPE_NORMAL,
194 MSC_CTR_LOC_UPDATE_TYPE_PERIODIC,
195 MSC_CTR_LOC_UPDATE_TYPE_DETACH,
Neels Hofmeyr36891a72016-05-09 13:18:03 +0200196 MSC_CTR_LOC_UPDATE_FAILED,
197 MSC_CTR_LOC_UPDATE_COMPLETED,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +0200198 MSC_CTR_CM_SERVICE_REQUEST_REJECTED,
199 MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED,
200 MSC_CTR_PAGING_RESP_REJECTED,
201 MSC_CTR_PAGING_RESP_ACCEPTED,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200202 MSC_CTR_SMS_SUBMITTED,
203 MSC_CTR_SMS_NO_RECEIVER,
204 MSC_CTR_SMS_DELIVERED,
205 MSC_CTR_SMS_RP_ERR_MEM,
206 MSC_CTR_SMS_RP_ERR_OTHER,
Alexander Couzensaa386d22016-08-21 20:16:33 +0200207 MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200208 MSC_CTR_CALL_MO_SETUP,
209 MSC_CTR_CALL_MO_CONNECT_ACK,
210 MSC_CTR_CALL_MT_SETUP,
211 MSC_CTR_CALL_MT_CONNECT,
Alexander Couzens92f552f2016-08-23 07:32:27 +0200212 MSC_CTR_CALL_ACTIVE,
213 MSC_CTR_CALL_COMPLETE,
214 MSC_CTR_CALL_INCOMPLETE,
Vadim Yanitskiy8e25cc52018-06-23 03:32:20 +0700215 MSC_CTR_NC_SS_MO_REQUESTS,
216 MSC_CTR_NC_SS_MO_ESTABLISHED,
217 MSC_CTR_NC_SS_MT_REQUESTS,
218 MSC_CTR_NC_SS_MT_ESTABLISHED,
Max366390d2018-11-02 16:01:03 +0100219 MSC_CTR_BSSMAP_CIPHER_MODE_REJECT,
220 MSC_CTR_BSSMAP_CIPHER_MODE_COMPLETE,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200221};
222
223static const struct rate_ctr_desc msc_ctr_description[] = {
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100224 [MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received location update imsi attach requests."},
225 [MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received location update normal requests."},
226 [MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received location update periodic requests."},
227 [MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received location update detach indication."},
228 [MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected location updates."},
229 [MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful location updates."},
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +0200230 [MSC_CTR_CM_SERVICE_REQUEST_REJECTED] = {"cm_service_request:rejected", "Rejected CM Service Request."},
231 [MSC_CTR_CM_SERVICE_REQUEST_ACCEPTED] = {"cm_service_request:accepted", "Accepted CM Service Request."},
232 [MSC_CTR_PAGING_RESP_REJECTED] = {"paging_resp:rejected", "Rejected Paging Response."},
233 [MSC_CTR_PAGING_RESP_ACCEPTED] = {"paging_resp:accepted", "Accepted Paging Response."},
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100234 [MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Received a RPDU from a MS (MO)."},
235 [MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Counts SMS which couldn't routed because no receiver found."},
236 [MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Global SMS Deliver attempts."},
237 [MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."},
238 [MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Other error of MS responses on a sms delive attempt."},
239 [MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR] = {"sms:deliver_unknown_error", "Unknown error occured during sms delivery."},
Alexander Couzens20423ea2016-07-12 15:42:02 +0200240 /* FIXME: count also sms delivered */
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100241 [MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received setup requests from a MS to init a MO call."},
242 [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."},
243 [MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent setup requests to the MS (MT)."},
244 [MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent a connect to the MS (MT)."},
245 [MSC_CTR_CALL_ACTIVE] = {"call:active", "Count total amount of calls that ever reached active state."},
246 [MSC_CTR_CALL_COMPLETE] = {"call:complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."},
247 [MSC_CTR_CALL_INCOMPLETE] = {"call:incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."},
Vadim Yanitskiy8e25cc52018-06-23 03:32:20 +0700248 [MSC_CTR_NC_SS_MO_REQUESTS] = {"nc_ss:mo_requests", "Received MS-initiated call independent SS/USSD requests."},
249 [MSC_CTR_NC_SS_MO_ESTABLISHED] = {"nc_ss:mo_established", "Established MS-initiated call independent SS/USSD sessions."},
250 [MSC_CTR_NC_SS_MT_REQUESTS] = {"nc_ss:mt_requests", "Received network-initiated call independent SS/USSD requests."},
251 [MSC_CTR_NC_SS_MT_ESTABLISHED] = {"nc_ss:mt_established", "Established network-initiated call independent SS/USSD sessions."},
Max366390d2018-11-02 16:01:03 +0100252 [MSC_CTR_BSSMAP_CIPHER_MODE_REJECT] = {"bssmap:cipher_mode_reject", "Number of CIPHER MODE REJECT messages processed by BSSMAP layer"},
253 [MSC_CTR_BSSMAP_CIPHER_MODE_COMPLETE] = {"bssmap:cipher_mode_complete", "Number of CIPHER MODE COMPLETE messages processed by BSSMAP layer"},
Alexander Couzensb847a212016-08-02 11:34:11 +0200254};
255
Alexander Couzens20423ea2016-07-12 15:42:02 +0200256static const struct rate_ctr_group_desc msc_ctrg_desc = {
257 "msc",
258 "mobile switching center",
259 OSMO_STATS_CLASS_GLOBAL,
260 ARRAY_SIZE(msc_ctr_description),
261 msc_ctr_description,
Harald Welte24ff6ee2009-12-22 00:41:05 +0100262};
263
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100264#define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
Harald Welteb84ddfc2009-12-01 17:36:54 +0530265
Neels Hofmeyr73983952016-05-10 13:29:33 +0200266struct gsm_tz {
267 int override; /* if 0, use system's time zone instead. */
268 int hr; /* hour */
269 int mn; /* minute */
270 int dst; /* daylight savings */
271};
272
Harald Welte52b1f982008-12-23 20:25:15 +0000273struct gsm_network {
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200274 /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for
275 * global settings and variables, "madly" mixing BSC and MSC stuff. Split
276 * this in e.g. struct osmo_bsc and struct osmo_msc, with the things
277 * these have in common, like country and network code, put in yet
278 * separate structs and placed as members in osmo_bsc and osmo_msc. */
279
Neels Hofmeyr379d5792018-02-22 04:04:54 +0100280 struct osmo_plmn_id plmn;
281
Harald Weltec6ba9c22008-12-30 18:01:02 +0000282 char *name_long;
283 char *name_short;
Neels Hofmeyr379d5792018-02-22 04:04:54 +0100284
Harald Welte7b222aa2017-12-23 19:30:32 +0100285 /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
286 uint8_t a5_encryption_mask;
Harald Welte2483f1b2016-06-19 18:06:02 +0200287 bool authentication_required;
Harald Welte648b6ce2009-12-14 09:00:24 +0100288 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100289 struct {
290 int active;
291 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000292
Alexander Couzensb847a212016-08-02 11:34:11 +0200293 struct rate_ctr_group *msc_ctrs;
Alexander Couzens92f552f2016-08-23 07:32:27 +0200294 struct osmo_counter *active_calls;
Vadim Yanitskiyad64e2a2018-06-26 18:27:25 +0700295 struct osmo_counter *active_nc_ss;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100296
Harald Welte4bfdfe72009-06-10 23:11:52 +0800297 /* layer 4 */
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +0200298 struct mncc_sock_state *mncc_state;
Neels Hofmeyr402006d2016-05-11 14:28:25 +0200299 mncc_recv_cb_t mncc_recv;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800300 struct llist_head upqueue;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200301 /*
302 * TODO: Move the trans_list into the subscriber connection and
303 * create a pending list for MT transactions. These exist before
304 * we have a subscriber connection.
305 */
Harald Welte4bfdfe72009-06-10 23:11:52 +0800306 struct llist_head trans_list;
307
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100308 unsigned int paging_response_timer;
Harald Welteeab84a12009-12-13 10:53:12 +0100309
310 /* Radio Resource Location Protocol (TS 04.31) */
311 struct {
312 enum rrlp_mode mode;
313 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800314
Holger Hans Peter Freyther11b28f92010-12-24 13:48:27 +0100315 struct gsm_sms_queue *sms_queue;
Daniel Willmann6fc4a982011-07-22 17:55:42 +0200316
317 /* control interface */
318 struct ctrl_handle *ctrl;
Neels Hofmeyr5f0c71b2016-07-23 20:15:28 +0200319
Neels Hofmeyrd90fa422016-05-09 21:03:12 +0200320 /* all active subscriber connections. */
321 struct llist_head subscr_conns;
Neels Hofmeyr73983952016-05-10 13:29:33 +0200322
323 /* if override is nonzero, this timezone data is used for all MM
324 * contexts. */
325 /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable
326 * BTS|RNC specific timezone overrides for multi-tz networks in
Neels Hofmeyrfe291de2017-02-23 21:06:12 +0100327 * OsmoMSC, this should be tied to the location area code (LAC). */
Neels Hofmeyr73983952016-05-10 13:29:33 +0200328 struct gsm_tz tz;
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100329
Harald Welte2483f1b2016-06-19 18:06:02 +0200330 /* MSC: GSUP server address of the HLR */
331 const char *gsup_server_addr_str;
332 uint16_t gsup_server_port;
333
334 struct vlr_instance *vlr;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200335
336 /* Periodic location update default value */
337 uint8_t t3212;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200338
Philipp Maier9ca7b312018-10-10 17:00:49 +0200339 /* Global MNCC guard timer value */
340 int mncc_guard_timeout;
341
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200342 struct {
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +0200343 struct mgcp_client_conf conf;
344 struct mgcp_client *client;
345 } mgw;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200346
Neels Hofmeyr21adb2b2018-03-15 12:55:46 +0100347#if BUILD_IU
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200348 struct {
Philipp Maierfbf66102017-04-09 12:32:51 +0200349 /* CS7 instance id number (set via VTY) */
350 uint32_t cs7_instance;
Neels Hofmeyr21adb2b2018-03-15 12:55:46 +0100351 enum ranap_nsap_addr_enc rab_assign_addr_enc;
Philipp Maierfbf66102017-04-09 12:32:51 +0200352 struct osmo_sccp_instance *sccp;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200353 } iu;
Neels Hofmeyr21adb2b2018-03-15 12:55:46 +0100354#endif
Philipp Maierfbf66102017-04-09 12:32:51 +0200355
356 struct {
357 /* CS7 instance id number (set via VTY) */
358 uint32_t cs7_instance;
359 /* A list with the context information about
360 * all BSCs we have connections with */
361 struct llist_head bscs;
362 struct osmo_sccp_instance *sccp;
363 } a;
Harald Welte69c54a82018-02-09 20:41:14 +0100364
365 struct {
366 /* MSISDN to which to route MO emergency calls */
367 char *route_to_msisdn;
368 } emergency;
Harald Welte52b1f982008-12-23 20:25:15 +0000369};
370
Harald Welted4bdee72012-11-08 19:44:08 +0100371struct osmo_esme;
372
373enum gsm_sms_source_id {
374 SMS_SOURCE_UNKNOWN = 0,
375 SMS_SOURCE_MS, /* received from MS */
376 SMS_SOURCE_VTY, /* received from VTY */
377 SMS_SOURCE_SMPP, /* received via SMPP */
378};
379
Harald Welte7e310b12009-03-30 20:56:32 +0000380#define SMS_HDR_SIZE 128
381#define SMS_TEXT_SIZE 256
Harald Weltee07b6a72012-11-23 19:02:37 +0100382
383struct gsm_sms_addr {
384 uint8_t ton;
385 uint8_t npi;
386 char addr[21+1];
387};
388
Harald Welte7e310b12009-03-30 20:56:32 +0000389struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900390 unsigned long long id;
Harald Welte2483f1b2016-06-19 18:06:02 +0200391 struct vlr_subscr *receiver;
Harald Weltec0de14d2012-11-23 23:35:01 +0100392 struct gsm_sms_addr src, dst;
Harald Welted4bdee72012-11-08 19:44:08 +0100393 enum gsm_sms_source_id source;
394
395 struct {
Pablo Neira Ayuso93ffbd02017-05-04 18:44:22 +0200396 uint8_t transaction_id;
397 uint32_t msg_ref;
398 } gsm411;
399
400 struct {
Harald Welted4bdee72012-11-08 19:44:08 +0100401 struct osmo_esme *esme;
402 uint32_t sequence_nr;
403 int transaction_mode;
404 char msg_id[16];
405 } smpp;
Harald Welte7e310b12009-03-30 20:56:32 +0000406
Harald Welteb9c758b2009-07-05 14:02:46 +0200407 unsigned long validity_minutes;
Keithc601adc2017-08-16 22:45:07 +0200408 time_t created;
Pablo Neira Ayusoadae8592017-08-07 14:01:30 +0100409 bool is_report;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200410 uint8_t reply_path_req;
411 uint8_t status_rep_req;
412 uint8_t ud_hdr_ind;
413 uint8_t protocol_id;
414 uint8_t data_coding_scheme;
415 uint8_t msg_ref;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200416 uint8_t user_data_len;
417 uint8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200418
Harald Welte7e310b12009-03-30 20:56:32 +0000419 char text[SMS_TEXT_SIZE];
420};
421
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100422/* control interface handling */
423int bsc_base_ctrl_cmds_install(void);
Harald Welte2483f1b2016-06-19 18:06:02 +0200424int msc_ctrl_cmds_install(struct gsm_network *net);
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100425
Harald Welte6be350c2011-05-25 13:10:08 +0200426#endif /* _GSM_DATA_H */