blob: 27324d7b6c1cc81b9de0afa3edaf94faef183017 [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
23
Philipp Maierfbf66102017-04-09 12:32:51 +020024
Holger Hans Peter Freytherd7b22c62013-04-29 09:11:02 +020025/** annotations for msgb ownership */
26#define __uses
27
Holger Hans Peter Freyther6f615552010-11-15 20:50:42 +010028#define OBSC_NM_W_ACK_CB(__msgb) (__msgb)->cb[3]
29
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020030struct mncc_sock_state;
Jacob Erlbeck1e30a282014-12-03 09:28:24 +010031struct gsm_subscriber_group;
Harald Welte2483f1b2016-06-19 18:06:02 +020032struct vlr_instance;
33struct vlr_subscr;
Neels Hofmeyr00e82d62017-07-05 15:19:52 +020034struct ranap_ue_conn_ctx;
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +020035
Holger Hans Peter Freyther9c595b72010-06-15 11:20:52 +080036#define OBSC_LINKID_CB(__msgb) (__msgb)->cb[3]
37
Neels Hofmeyr0e5d8072017-01-10 00:49:56 +010038#define tmsi_from_string(str) strtoul(str, NULL, 10)
39
Max70fdd242017-06-15 15:10:53 +020040/* 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 Munaut30a15382009-12-24 00:27:26 +010047enum gsm_security_event {
48 GSM_SECURITY_NOAVAIL,
49 GSM_SECURITY_AUTH_FAILED,
50 GSM_SECURITY_SUCCEEDED,
Andreas Eversberg641475c2013-07-10 08:58:03 +020051 GSM_SECURITY_ALREADY,
Sylvain Munaut30a15382009-12-24 00:27:26 +010052};
53
Harald Welte8e1e3ee2009-02-01 13:32:45 +000054struct msgb;
55typedef int gsm_cbfn(unsigned int hooknum,
56 unsigned int event,
57 struct msgb *msg,
58 void *data, void *param);
59
Sylvain Munaut47193072009-12-27 21:56:14 +010060/* Real authentication information containing Ki */
61enum gsm_auth_algo {
62 AUTH_ALGO_NONE,
63 AUTH_ALGO_XOR,
64 AUTH_ALGO_COMP128v1,
65};
66
67struct gsm_auth_info {
68 enum gsm_auth_algo auth_algo;
69 unsigned int a3a8_ki_len;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020070 uint8_t a3a8_ki[16];
Sylvain Munaut47193072009-12-27 21:56:14 +010071};
72
73struct gsm_auth_tuple {
74 int use_count;
75 int key_seq;
Harald Welte121e9a42016-04-20 13:13:19 +020076 struct osmo_auth_vector vec;
Sylvain Munaut47193072009-12-27 21:56:14 +010077};
Sylvain Munautb48216f2010-06-09 12:45:37 +020078#define GSM_KEY_SEQ_INVAL 7 /* GSM 04.08 - 10.5.1.2 */
Sylvain Munaut47193072009-12-27 21:56:14 +010079
Holger Freyther73487a22008-12-31 18:53:57 +000080/*
Sylvain Munaut30a15382009-12-24 00:27:26 +010081 * AUTHENTICATION/CIPHERING state
82 */
83struct gsm_security_operation {
84 struct gsm_auth_tuple atuple;
85 gsm_cbfn *cb;
86 void *cb_data;
87};
88
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +080089/*
90 * A dummy to keep a connection up for at least
91 * a couple of seconds to work around MSC issues.
92 */
93struct gsm_anchor_operation {
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020094 struct osmo_timer_list timeout;
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +080095};
96
Harald Weltef7c28b02009-12-21 13:30:17 +010097/* 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 */
103struct neigh_meas_proc {
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200104 uint16_t arfcn;
105 uint8_t bsic;
106 uint8_t rxlev[MAX_WIN_NEIGH_AVG];
Harald Weltef7c28b02009-12-21 13:30:17 +0100107 unsigned int rxlev_cnt;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200108 uint8_t last_seen_nr;
Harald Weltef7c28b02009-12-21 13:30:17 +0100109};
110
Neels Hofmeyrd3270a92017-02-02 01:07:28 +0100111enum 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 Hofmeyr84da6b12016-05-20 21:59:55 +0200117extern const struct value_string ran_type_names[];
118static inline const char *ran_type_name(enum ran_type val)
119{ return get_value_string(ran_type_names, val); }
120
Harald Welte2483f1b2016-06-19 18:06:02 +0200121struct 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 Hofmeyre2f24d52017-05-08 15:12:20 +0200130enum integrity_protection_state {
131 INTEGRITY_PROTECTION_NONE = 0,
132 INTEGRITY_PROTECTION_IK = 1,
133 INTEGRITY_PROTECTION_IK_CK = 2,
134};
135
Neels Hofmeyr378a4922016-05-09 21:07:43 +0200136/* active radio connection of a mobile subscriber */
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100137struct gsm_subscriber_connection {
Harald Welte2483f1b2016-06-19 18:06:02 +0200138 /* global linked list of subscriber_connections */
Holger Hans Peter Freyther79f763f2010-09-16 00:53:37 +0800139 struct llist_head entry;
140
Harald Welte2483f1b2016-06-19 18:06:02 +0200141 /* usage count. If this drops to zero, we start the release
142 * towards A/Iu */
143 uint32_t use_count;
Neels Hofmeyr6166f292017-11-22 14:33:12 +0100144 uint32_t use_tokens;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100145
Harald Welte2483f1b2016-06-19 18:06:02 +0200146 /* 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 Welte2483f1b2016-06-19 18:06:02 +0200150 /* libmsc/libvlr subscriber information (if available) */
151 struct vlr_subscr *vsub;
152
Holger Hans Peter Freythere7bd8632013-06-30 15:30:47 +0200153 /* LU expiration handling */
154 uint8_t expire_timer_stopped;
Holger Hans Peter Freytherca114432014-02-08 15:20:48 +0100155 /* SMS helpers for libmsc */
156 uint8_t next_rp_ref;
Holger Hans Peter Freythere7bd8632013-06-30 15:30:47 +0200157
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100158 /*
159 * Operations that have a state and might be pending
160 */
Sylvain Munaut30a15382009-12-24 00:27:26 +0100161 struct gsm_security_operation *sec_operation;
Holger Hans Peter Freyther02d39b22010-07-05 15:34:16 +0800162 struct gsm_anchor_operation *anch_operation;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100163
Harald Welte2483f1b2016-06-19 18:06:02 +0200164 struct osmo_fsm_inst *conn_fsm;
165
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100166 /* Are we part of a special "silent" call */
167 int silent_call;
168
Holger Hans Peter Freytherc8a6c132015-08-04 13:32:09 +0200169 /* MNCC rtp bridge markers */
170 int mncc_rtp_bridge;
171 int mncc_rtp_create_pending;
Holger Hans Peter Freytherc21dcb22015-08-04 14:41:21 +0200172 int mncc_rtp_connect_pending;
Holger Hans Peter Freytherc8a6c132015-08-04 13:32:09 +0200173
Holger Hans Peter Freyther18b63f42010-03-23 07:52:17 +0100174 /* back pointers */
Neels Hofmeyr5e0b0a62016-05-09 22:33:01 +0200175 struct gsm_network *network;
176
Harald Welte2483f1b2016-06-19 18:06:02 +0200177 bool in_release;
Holger Hans Peter Freyther77cd95d2010-11-14 16:19:48 +0100178
Neels Hofmeyrd3270a92017-02-02 01:07:28 +0100179 /* connected via 2G or 3G? */
180 enum ran_type via_ran;
Harald Welte2483f1b2016-06-19 18:06:02 +0200181
182 struct gsm_classmark classmark;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200183
184 uint16_t lac;
185 struct gsm_encr encr;
186
Philipp Maierfbf66102017-04-09 12:32:51 +0200187 struct {
188 unsigned int mgcp_rtp_endpoint;
189 uint16_t port_subscr;
190 uint16_t port_cn;
191 } rtp;
192
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200193 /* which Iu-CS connection, if any. */
194 struct {
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200195 struct ranap_ue_conn_ctx *ue_ctx;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200196 uint8_t rab_id;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200197 } iu;
Philipp Maierfbf66102017-04-09 12:32:51 +0200198
199 struct {
200 /* A pointer to the SCCP user that handles
201 * the SCCP connections for this subscriber
202 * connection */
203 struct osmo_sccp_user *scu;
204
205 /* The address of the BSC that is associated
206 * with this subscriber connection */
207 struct osmo_sccp_addr bsc_addr;
208
209 /* The connection identifier that is used
210 * to reference the SCCP connection that is
211 * associated with this subscriber connection */
212 int conn_id;
213 } a;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100214};
215
Harald Weltef142c972011-05-24 13:25:38 +0200216
Alexander Couzensb847a212016-08-02 11:34:11 +0200217enum {
Alexander Couzens20423ea2016-07-12 15:42:02 +0200218 MSC_CTR_LOC_UPDATE_TYPE_ATTACH,
219 MSC_CTR_LOC_UPDATE_TYPE_NORMAL,
220 MSC_CTR_LOC_UPDATE_TYPE_PERIODIC,
221 MSC_CTR_LOC_UPDATE_TYPE_DETACH,
Neels Hofmeyr36891a72016-05-09 13:18:03 +0200222 MSC_CTR_LOC_UPDATE_FAILED,
223 MSC_CTR_LOC_UPDATE_COMPLETED,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200224 MSC_CTR_SMS_SUBMITTED,
225 MSC_CTR_SMS_NO_RECEIVER,
226 MSC_CTR_SMS_DELIVERED,
227 MSC_CTR_SMS_RP_ERR_MEM,
228 MSC_CTR_SMS_RP_ERR_OTHER,
Alexander Couzensaa386d22016-08-21 20:16:33 +0200229 MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200230 MSC_CTR_CALL_MO_SETUP,
231 MSC_CTR_CALL_MO_CONNECT_ACK,
232 MSC_CTR_CALL_MT_SETUP,
233 MSC_CTR_CALL_MT_CONNECT,
Alexander Couzens92f552f2016-08-23 07:32:27 +0200234 MSC_CTR_CALL_ACTIVE,
235 MSC_CTR_CALL_COMPLETE,
236 MSC_CTR_CALL_INCOMPLETE,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200237};
238
239static const struct rate_ctr_desc msc_ctr_description[] = {
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100240 [MSC_CTR_LOC_UPDATE_TYPE_ATTACH] = {"loc_update_type:attach", "Received location update imsi attach requests."},
241 [MSC_CTR_LOC_UPDATE_TYPE_NORMAL] = {"loc_update_type:normal", "Received location update normal requests."},
242 [MSC_CTR_LOC_UPDATE_TYPE_PERIODIC] = {"loc_update_type:periodic", "Received location update periodic requests."},
243 [MSC_CTR_LOC_UPDATE_TYPE_DETACH] = {"loc_update_type:detach", "Received location update detach indication."},
244 [MSC_CTR_LOC_UPDATE_FAILED] = {"loc_update_resp:failed", "Rejected location updates."},
245 [MSC_CTR_LOC_UPDATE_COMPLETED] = {"loc_update_resp:completed", "Successful location updates."},
246 [MSC_CTR_SMS_SUBMITTED] = {"sms:submitted", "Received a RPDU from a MS (MO)."},
247 [MSC_CTR_SMS_NO_RECEIVER] = {"sms:no_receiver", "Counts SMS which couldn't routed because no receiver found."},
248 [MSC_CTR_SMS_DELIVERED] = {"sms:delivered", "Global SMS Deliver attempts."},
249 [MSC_CTR_SMS_RP_ERR_MEM] = {"sms:rp_err_mem", "CAUSE_MT_MEM_EXCEEDED errors of MS responses on a sms deliver attempt."},
250 [MSC_CTR_SMS_RP_ERR_OTHER] = {"sms:rp_err_other", "Other error of MS responses on a sms delive attempt."},
251 [MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR] = {"sms:deliver_unknown_error", "Unknown error occured during sms delivery."},
Alexander Couzens20423ea2016-07-12 15:42:02 +0200252 /* FIXME: count also sms delivered */
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100253 [MSC_CTR_CALL_MO_SETUP] = {"call:mo_setup", "Received setup requests from a MS to init a MO call."},
254 [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."},
255 [MSC_CTR_CALL_MT_SETUP] = {"call:mt_setup", "Sent setup requests to the MS (MT)."},
256 [MSC_CTR_CALL_MT_CONNECT] = {"call:mt_connect", "Sent a connect to the MS (MT)."},
257 [MSC_CTR_CALL_ACTIVE] = {"call:active", "Count total amount of calls that ever reached active state."},
258 [MSC_CTR_CALL_COMPLETE] = {"call:complete", "Count total amount of calls which got terminated by disconnect req or ind after reaching active state."},
259 [MSC_CTR_CALL_INCOMPLETE] = {"call:incomplete", "Count total amount of call which got terminated by any other reason after reaching active state."},
Alexander Couzensb847a212016-08-02 11:34:11 +0200260};
261
Alexander Couzens20423ea2016-07-12 15:42:02 +0200262static const struct rate_ctr_group_desc msc_ctrg_desc = {
263 "msc",
264 "mobile switching center",
265 OSMO_STATS_CLASS_GLOBAL,
266 ARRAY_SIZE(msc_ctr_description),
267 msc_ctr_description,
Harald Welte24ff6ee2009-12-22 00:41:05 +0100268};
269
Harald Welte (local)69de3972009-08-12 14:42:23 +0200270enum gsm_auth_policy {
271 GSM_AUTH_POLICY_CLOSED, /* only subscribers authorized in DB */
272 GSM_AUTH_POLICY_ACCEPT_ALL, /* accept everyone, even if not authorized in DB */
273 GSM_AUTH_POLICY_TOKEN, /* accept first, send token per sms, then revoke authorization */
Maxddee01f2016-05-24 14:23:27 +0200274 GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
Harald Welte (local)69de3972009-08-12 14:42:23 +0200275};
276
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100277#define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
Harald Welteb84ddfc2009-12-01 17:36:54 +0530278
Neels Hofmeyr73983952016-05-10 13:29:33 +0200279struct gsm_tz {
280 int override; /* if 0, use system's time zone instead. */
281 int hr; /* hour */
282 int mn; /* minute */
283 int dst; /* daylight savings */
284};
285
Harald Welte52b1f982008-12-23 20:25:15 +0000286struct gsm_network {
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200287 /* TODO MSCSPLIT the gsm_network struct is basically a kitchen sink for
288 * global settings and variables, "madly" mixing BSC and MSC stuff. Split
289 * this in e.g. struct osmo_bsc and struct osmo_msc, with the things
290 * these have in common, like country and network code, put in yet
291 * separate structs and placed as members in osmo_bsc and osmo_msc. */
292
Harald Welte52b1f982008-12-23 20:25:15 +0000293 /* global parameters */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200294 uint16_t country_code;
295 uint16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000296 char *name_long;
297 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200298 enum gsm_auth_policy auth_policy;
Maxddee01f2016-05-24 14:23:27 +0200299 regex_t authorized_regexp;
300 char *authorized_reg_str;
Harald Welte1085c092009-11-18 20:33:19 +0100301 enum gsm48_reject_value reject_cause;
Harald Welte7b222aa2017-12-23 19:30:32 +0100302 /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
303 uint8_t a5_encryption_mask;
Harald Welte2483f1b2016-06-19 18:06:02 +0200304 bool authentication_required;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100305 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100306 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100307 struct {
308 int active;
Harald Weltef7c28b02009-12-21 13:30:17 +0100309 /* Window RXLEV averaging */
310 unsigned int win_rxlev_avg; /* number of SACCH frames */
311 /* Window RXQUAL averaging */
312 unsigned int win_rxqual_avg; /* number of SACCH frames */
313 /* Window RXLEV neighbouring cells averaging */
314 unsigned int win_rxlev_avg_neigh; /* number of SACCH frames */
315
316 /* how often should we check for power budget HO */
317 unsigned int pwr_interval; /* SACCH frames */
318 /* how much better does a neighbor cell have to be ? */
319 unsigned int pwr_hysteresis; /* dBm */
320 /* maximum distacne before we try a handover */
321 unsigned int max_distance; /* TA values */
Harald Weltebc814502009-12-19 21:41:52 +0100322 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000323
Alexander Couzensb847a212016-08-02 11:34:11 +0200324 struct rate_ctr_group *bsc_ctrs;
325 struct rate_ctr_group *msc_ctrs;
Alexander Couzens92f552f2016-08-23 07:32:27 +0200326 struct osmo_counter *active_calls;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100327
Harald Welte4bfdfe72009-06-10 23:11:52 +0800328 /* layer 4 */
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +0200329 struct mncc_sock_state *mncc_state;
Neels Hofmeyr402006d2016-05-11 14:28:25 +0200330 mncc_recv_cb_t mncc_recv;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800331 struct llist_head upqueue;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200332 /*
333 * TODO: Move the trans_list into the subscriber connection and
334 * create a pending list for MT transactions. These exist before
335 * we have a subscriber connection.
336 */
Harald Welte4bfdfe72009-06-10 23:11:52 +0800337 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800338 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800339
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100340 unsigned int paging_response_timer;
Harald Welteeab84a12009-12-13 10:53:12 +0100341
Jan Luebbebfbdeec2012-12-27 00:27:16 +0100342 /* timer to expire old location updates */
343 struct osmo_timer_list subscr_expire_timer;
344
Harald Welteeab84a12009-12-13 10:53:12 +0100345 /* Radio Resource Location Protocol (TS 04.31) */
346 struct {
347 enum rrlp_mode mode;
348 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800349
Alexander Couzens11368112016-11-28 23:26:50 +0100350 enum gsm_chan_t ctype_by_chreq[18];
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800351
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800352 /* Use a TCH for handling requests of type paging any */
353 int pag_any_tch;
354
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800355 /* MSC data in case we are a true BSC */
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200356 struct osmo_bsc_data *bsc_data;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +0100357
Holger Hans Peter Freyther11b28f92010-12-24 13:48:27 +0100358 struct gsm_sms_queue *sms_queue;
Daniel Willmann6fc4a982011-07-22 17:55:42 +0200359
360 /* control interface */
361 struct ctrl_handle *ctrl;
Neels Hofmeyr5f0c71b2016-07-23 20:15:28 +0200362
363 /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */
364 bool dyn_ts_allow_tch_f;
Neels Hofmeyrd90fa422016-05-09 21:03:12 +0200365
366 /* all active subscriber connections. */
367 struct llist_head subscr_conns;
Neels Hofmeyr73983952016-05-10 13:29:33 +0200368
369 /* if override is nonzero, this timezone data is used for all MM
370 * contexts. */
371 /* TODO: in OsmoNITB, tz-override used to be BTS-specific. To enable
372 * BTS|RNC specific timezone overrides for multi-tz networks in
Neels Hofmeyrfe291de2017-02-23 21:06:12 +0100373 * OsmoMSC, this should be tied to the location area code (LAC). */
Neels Hofmeyr73983952016-05-10 13:29:33 +0200374 struct gsm_tz tz;
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100375
Harald Welte2483f1b2016-06-19 18:06:02 +0200376 /* MSC: GSUP server address of the HLR */
377 const char *gsup_server_addr_str;
378 uint16_t gsup_server_port;
379
380 struct vlr_instance *vlr;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200381
382 /* Periodic location update default value */
383 uint8_t t3212;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200384
385 struct {
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +0200386 struct mgcp_client_conf conf;
387 struct mgcp_client *client;
388 } mgw;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200389
390 struct {
Philipp Maierfbf66102017-04-09 12:32:51 +0200391 /* CS7 instance id number (set via VTY) */
392 uint32_t cs7_instance;
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200393 int rab_assign_addr_enc;
Philipp Maierfbf66102017-04-09 12:32:51 +0200394 struct osmo_sccp_instance *sccp;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200395 } iu;
Philipp Maierfbf66102017-04-09 12:32:51 +0200396
397 struct {
398 /* CS7 instance id number (set via VTY) */
399 uint32_t cs7_instance;
400 /* A list with the context information about
401 * all BSCs we have connections with */
402 struct llist_head bscs;
403 struct osmo_sccp_instance *sccp;
404 } a;
Harald Welte52b1f982008-12-23 20:25:15 +0000405};
406
Harald Welted4bdee72012-11-08 19:44:08 +0100407struct osmo_esme;
408
409enum gsm_sms_source_id {
410 SMS_SOURCE_UNKNOWN = 0,
411 SMS_SOURCE_MS, /* received from MS */
412 SMS_SOURCE_VTY, /* received from VTY */
413 SMS_SOURCE_SMPP, /* received via SMPP */
414};
415
Harald Welte7e310b12009-03-30 20:56:32 +0000416#define SMS_HDR_SIZE 128
417#define SMS_TEXT_SIZE 256
Harald Weltee07b6a72012-11-23 19:02:37 +0100418
419struct gsm_sms_addr {
420 uint8_t ton;
421 uint8_t npi;
422 char addr[21+1];
423};
424
Harald Welte7e310b12009-03-30 20:56:32 +0000425struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900426 unsigned long long id;
Harald Welte2483f1b2016-06-19 18:06:02 +0200427 struct vlr_subscr *receiver;
Harald Weltec0de14d2012-11-23 23:35:01 +0100428 struct gsm_sms_addr src, dst;
Harald Welted4bdee72012-11-08 19:44:08 +0100429 enum gsm_sms_source_id source;
430
431 struct {
Pablo Neira Ayuso93ffbd02017-05-04 18:44:22 +0200432 uint8_t transaction_id;
433 uint32_t msg_ref;
434 } gsm411;
435
436 struct {
Harald Welted4bdee72012-11-08 19:44:08 +0100437 struct osmo_esme *esme;
438 uint32_t sequence_nr;
439 int transaction_mode;
440 char msg_id[16];
441 } smpp;
Harald Welte7e310b12009-03-30 20:56:32 +0000442
Harald Welteb9c758b2009-07-05 14:02:46 +0200443 unsigned long validity_minutes;
Keithc601adc2017-08-16 22:45:07 +0200444 time_t created;
Pablo Neira Ayusoadae8592017-08-07 14:01:30 +0100445 bool is_report;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200446 uint8_t reply_path_req;
447 uint8_t status_rep_req;
448 uint8_t ud_hdr_ind;
449 uint8_t protocol_id;
450 uint8_t data_coding_scheme;
451 uint8_t msg_ref;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200452 uint8_t user_data_len;
453 uint8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200454
Harald Welte7e310b12009-03-30 20:56:32 +0000455 char text[SMS_TEXT_SIZE];
456};
457
Neels Hofmeyrc13e6872016-05-11 13:53:47 +0200458extern void talloc_ctx_init(void *ctx_root);
459
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200460extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100461extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200462
Harald Welte (local)69de3972009-08-12 14:42:23 +0200463enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
464const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
465
Harald Welteeab84a12009-12-13 10:53:12 +0100466enum rrlp_mode rrlp_mode_parse(const char *arg);
467const char *rrlp_mode_name(enum rrlp_mode mode);
468
Neels Hofmeyr42eb0142016-05-20 17:15:44 +0200469struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network);
470void msc_subscr_con_free(struct gsm_subscriber_connection *conn);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800471
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100472/* control interface handling */
473int bsc_base_ctrl_cmds_install(void);
Harald Welte2483f1b2016-06-19 18:06:02 +0200474int msc_ctrl_cmds_install(struct gsm_network *net);
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100475
Harald Welte2483f1b2016-06-19 18:06:02 +0200476bool classmark_is_r99(struct gsm_classmark *cm);
477
Harald Welte6be350c2011-05-25 13:10:08 +0200478#endif /* _GSM_DATA_H */