blob: 3f322b3d8f6a6cfa37c18e08d50f21123c955508 [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
Harald Weltec2007852018-02-03 21:08:26 +0100187 /* 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 Maierfbf66102017-04-09 12:32:51 +0200190 struct {
Philipp Maier621ba032017-11-07 17:19:25 +0100191 struct mgcp_ctx *mgcp_ctx;
Philipp Maierfbf66102017-04-09 12:32:51 +0200192 unsigned int mgcp_rtp_endpoint;
Philipp Maier621ba032017-11-07 17:19:25 +0100193
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 Maierfbf66102017-04-09 12:32:51 +0200202 } rtp;
203
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200204 /* which Iu-CS connection, if any. */
205 struct {
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200206 struct ranap_ue_conn_ctx *ue_ctx;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200207 uint8_t rab_id;
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200208 } iu;
Philipp Maierfbf66102017-04-09 12:32:51 +0200209
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 Maier64dbc542018-01-30 11:38:59 +0100223 uint32_t conn_id;
Philipp Maierfbf66102017-04-09 12:32:51 +0200224 } a;
Holger Hans Peter Freyther68884aa2010-03-23 06:41:45 +0100225};
226
Harald Weltef142c972011-05-24 13:25:38 +0200227
Alexander Couzensb847a212016-08-02 11:34:11 +0200228enum {
Alexander Couzens20423ea2016-07-12 15:42:02 +0200229 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 Hofmeyr36891a72016-05-09 13:18:03 +0200233 MSC_CTR_LOC_UPDATE_FAILED,
234 MSC_CTR_LOC_UPDATE_COMPLETED,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200235 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 Couzensaa386d22016-08-21 20:16:33 +0200240 MSC_CTR_SMS_DELIVER_UNKNOWN_ERROR,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200241 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 Couzens92f552f2016-08-23 07:32:27 +0200245 MSC_CTR_CALL_ACTIVE,
246 MSC_CTR_CALL_COMPLETE,
247 MSC_CTR_CALL_INCOMPLETE,
Alexander Couzens20423ea2016-07-12 15:42:02 +0200248};
249
250static const struct rate_ctr_desc msc_ctr_description[] = {
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100251 [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 Couzens20423ea2016-07-12 15:42:02 +0200263 /* FIXME: count also sms delivered */
Neels Hofmeyrc6bf2742017-11-18 23:22:17 +0100264 [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 Couzensb847a212016-08-02 11:34:11 +0200271};
272
Alexander Couzens20423ea2016-07-12 15:42:02 +0200273static 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 Welte24ff6ee2009-12-22 00:41:05 +0100279};
280
Harald Welte (local)69de3972009-08-12 14:42:23 +0200281enum 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 */
Maxddee01f2016-05-24 14:23:27 +0200285 GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
Harald Welte (local)69de3972009-08-12 14:42:23 +0200286};
287
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100288#define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
Harald Welteb84ddfc2009-12-01 17:36:54 +0530289
Neels Hofmeyr73983952016-05-10 13:29:33 +0200290struct 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 Welte52b1f982008-12-23 20:25:15 +0000297struct gsm_network {
Neels Hofmeyre2f24d52017-05-08 15:12:20 +0200298 /* 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 Welte52b1f982008-12-23 20:25:15 +0000304 /* global parameters */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200305 uint16_t country_code;
306 uint16_t network_code;
Harald Weltec6ba9c22008-12-30 18:01:02 +0000307 char *name_long;
308 char *name_short;
Harald Welte (local)69de3972009-08-12 14:42:23 +0200309 enum gsm_auth_policy auth_policy;
Maxddee01f2016-05-24 14:23:27 +0200310 regex_t authorized_regexp;
311 char *authorized_reg_str;
Harald Welte1085c092009-11-18 20:33:19 +0100312 enum gsm48_reject_value reject_cause;
Harald Welte7b222aa2017-12-23 19:30:32 +0100313 /* bit-mask of permitted encryption algorithms. LSB=A5/0, MSB=A5/7 */
314 uint8_t a5_encryption_mask;
Harald Welte2483f1b2016-06-19 18:06:02 +0200315 bool authentication_required;
Holger Hans Peter Freytherf7d752f2009-11-16 17:12:38 +0100316 int neci;
Harald Welte648b6ce2009-12-14 09:00:24 +0100317 int send_mm_info;
Harald Weltebc814502009-12-19 21:41:52 +0100318 struct {
319 int active;
Harald Weltef7c28b02009-12-21 13:30:17 +0100320 /* 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 Weltebc814502009-12-19 21:41:52 +0100333 } handover;
Harald Welte52b1f982008-12-23 20:25:15 +0000334
Alexander Couzensb847a212016-08-02 11:34:11 +0200335 struct rate_ctr_group *bsc_ctrs;
336 struct rate_ctr_group *msc_ctrs;
Alexander Couzens92f552f2016-08-23 07:32:27 +0200337 struct osmo_counter *active_calls;
Harald Welte24ff6ee2009-12-22 00:41:05 +0100338
Harald Welte4bfdfe72009-06-10 23:11:52 +0800339 /* layer 4 */
Holger Hans Peter Freyther694c82d2011-10-26 18:37:09 +0200340 struct mncc_sock_state *mncc_state;
Neels Hofmeyr402006d2016-05-11 14:28:25 +0200341 mncc_recv_cb_t mncc_recv;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800342 struct llist_head upqueue;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200343 /*
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 Welte4bfdfe72009-06-10 23:11:52 +0800348 struct llist_head trans_list;
Holger Hans Peter Freytherabcddf12010-06-14 18:20:15 +0800349 struct bsc_api *bsc_api;
Harald Welte4bfdfe72009-06-10 23:11:52 +0800350
Neels Hofmeyr2ff5bcd2017-12-15 03:02:27 +0100351 unsigned int paging_response_timer;
Harald Welteeab84a12009-12-13 10:53:12 +0100352
Jan Luebbebfbdeec2012-12-27 00:27:16 +0100353 /* timer to expire old location updates */
354 struct osmo_timer_list subscr_expire_timer;
355
Harald Welteeab84a12009-12-13 10:53:12 +0100356 /* Radio Resource Location Protocol (TS 04.31) */
357 struct {
358 enum rrlp_mode mode;
359 } rrlp;
Holger Hans Peter Freyther5a3a61d2010-09-06 09:25:48 +0800360
Alexander Couzens11368112016-11-28 23:26:50 +0100361 enum gsm_chan_t ctype_by_chreq[18];
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +0800362
Holger Hans Peter Freyther76fc4a32010-09-06 09:41:50 +0800363 /* Use a TCH for handling requests of type paging any */
364 int pag_any_tch;
365
Holger Hans Peter Freyther3e8e0462010-09-15 22:29:25 +0800366 /* MSC data in case we are a true BSC */
Holger Hans Peter Freyther8ec49522011-08-15 15:53:00 +0200367 struct osmo_bsc_data *bsc_data;
Holger Hans Peter Freytherdaee5ca2010-12-22 12:34:39 +0100368
Holger Hans Peter Freyther11b28f92010-12-24 13:48:27 +0100369 struct gsm_sms_queue *sms_queue;
Daniel Willmann6fc4a982011-07-22 17:55:42 +0200370
371 /* control interface */
372 struct ctrl_handle *ctrl;
Neels Hofmeyr5f0c71b2016-07-23 20:15:28 +0200373
374 /* Allow or disallow TCH/F on dynamic TCH/F_TCH/H_PDCH; OS#1778 */
375 bool dyn_ts_allow_tch_f;
Neels Hofmeyrd90fa422016-05-09 21:03:12 +0200376
377 /* all active subscriber connections. */
378 struct llist_head subscr_conns;
Neels Hofmeyr73983952016-05-10 13:29:33 +0200379
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 Hofmeyrfe291de2017-02-23 21:06:12 +0100384 * OsmoMSC, this should be tied to the location area code (LAC). */
Neels Hofmeyr73983952016-05-10 13:29:33 +0200385 struct gsm_tz tz;
Neels Hofmeyr6d804b12017-02-18 22:20:46 +0100386
Harald Welte2483f1b2016-06-19 18:06:02 +0200387 /* 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 Hofmeyre2f24d52017-05-08 15:12:20 +0200392
393 /* Periodic location update default value */
394 uint8_t t3212;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200395
396 struct {
Neels Hofmeyr6c8afe12017-09-04 01:03:58 +0200397 struct mgcp_client_conf conf;
398 struct mgcp_client *client;
399 } mgw;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200400
401 struct {
Philipp Maierfbf66102017-04-09 12:32:51 +0200402 /* CS7 instance id number (set via VTY) */
403 uint32_t cs7_instance;
Neels Hofmeyr00e82d62017-07-05 15:19:52 +0200404 int rab_assign_addr_enc;
Philipp Maierfbf66102017-04-09 12:32:51 +0200405 struct osmo_sccp_instance *sccp;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200406 } iu;
Philipp Maierfbf66102017-04-09 12:32:51 +0200407
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 Welte52b1f982008-12-23 20:25:15 +0000416};
417
Harald Welted4bdee72012-11-08 19:44:08 +0100418struct osmo_esme;
419
420enum 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 Welte7e310b12009-03-30 20:56:32 +0000427#define SMS_HDR_SIZE 128
428#define SMS_TEXT_SIZE 256
Harald Weltee07b6a72012-11-23 19:02:37 +0100429
430struct gsm_sms_addr {
431 uint8_t ton;
432 uint8_t npi;
433 char addr[21+1];
434};
435
Harald Welte7e310b12009-03-30 20:56:32 +0000436struct gsm_sms {
Harald Welted409be72009-11-07 00:06:19 +0900437 unsigned long long id;
Harald Welte2483f1b2016-06-19 18:06:02 +0200438 struct vlr_subscr *receiver;
Harald Weltec0de14d2012-11-23 23:35:01 +0100439 struct gsm_sms_addr src, dst;
Harald Welted4bdee72012-11-08 19:44:08 +0100440 enum gsm_sms_source_id source;
441
442 struct {
Pablo Neira Ayuso93ffbd02017-05-04 18:44:22 +0200443 uint8_t transaction_id;
444 uint32_t msg_ref;
445 } gsm411;
446
447 struct {
Harald Welted4bdee72012-11-08 19:44:08 +0100448 struct osmo_esme *esme;
449 uint32_t sequence_nr;
450 int transaction_mode;
451 char msg_id[16];
452 } smpp;
Harald Welte7e310b12009-03-30 20:56:32 +0000453
Harald Welteb9c758b2009-07-05 14:02:46 +0200454 unsigned long validity_minutes;
Keithc601adc2017-08-16 22:45:07 +0200455 time_t created;
Pablo Neira Ayusoadae8592017-08-07 14:01:30 +0100456 bool is_report;
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200457 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 Freytherc42ad8b2011-04-18 17:04:00 +0200463 uint8_t user_data_len;
464 uint8_t user_data[SMS_TEXT_SIZE];
Harald Weltef3efc592009-07-27 20:11:35 +0200465
Harald Welte7e310b12009-03-30 20:56:32 +0000466 char text[SMS_TEXT_SIZE];
467};
468
Neels Hofmeyrc13e6872016-05-11 13:53:47 +0200469extern void talloc_ctx_init(void *ctx_root);
470
Andreas Eversberg8226fa72009-06-29 15:19:38 +0200471extern void *tall_bsc_ctx;
Harald Weltef88c8a02009-12-20 13:48:15 +0100472extern int ipacc_rtp_direct;
Harald Welte2cf161b2009-06-20 22:36:41 +0200473
Harald Welte (local)69de3972009-08-12 14:42:23 +0200474enum gsm_auth_policy gsm_auth_policy_parse(const char *arg);
475const char *gsm_auth_policy_name(enum gsm_auth_policy policy);
476
Harald Welteeab84a12009-12-13 10:53:12 +0100477enum rrlp_mode rrlp_mode_parse(const char *arg);
478const char *rrlp_mode_name(enum rrlp_mode mode);
479
Neels Hofmeyr42eb0142016-05-20 17:15:44 +0200480struct gsm_subscriber_connection *msc_subscr_con_allocate(struct gsm_network *network);
481void msc_subscr_con_free(struct gsm_subscriber_connection *conn);
Holger Hans Peter Freyther2412a072010-06-28 15:47:12 +0800482
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100483/* control interface handling */
484int bsc_base_ctrl_cmds_install(void);
Harald Welte2483f1b2016-06-19 18:06:02 +0200485int msc_ctrl_cmds_install(struct gsm_network *net);
Holger Hans Peter Freytherf8c42192013-01-09 17:03:27 +0100486
Harald Welte2483f1b2016-06-19 18:06:02 +0200487bool classmark_is_r99(struct gsm_classmark *cm);
488
Harald Welte6be350c2011-05-25 13:10:08 +0200489#endif /* _GSM_DATA_H */