blob: 995b19592a913773d7667da500defa1638387f84 [file] [log] [blame]
Holger Hans Peter Freyther43b09092010-06-15 11:52:51 +08001/* Routines for the MSC handling */
2
3#ifndef OSMO_MSC_H
4#define OSMO_MSC_H
5
Harald Welte2483f1b2016-06-19 18:06:02 +02006#include <osmocom/core/fsm.h>
7#include <osmocom/gsm/gsup.h>
8
Neels Hofmeyr90843962017-09-04 15:04:35 +02009#include <osmocom/msc/gsm_data.h>
Harald Welte2483f1b2016-06-19 18:06:02 +020010
Harald Welte2483f1b2016-06-19 18:06:02 +020011#define MSC_HLR_REMOTE_IP_DEFAULT "127.0.0.1"
12#define MSC_HLR_REMOTE_PORT_DEFAULT OSMO_GSUP_PORT
13
14enum subscr_conn_fsm_event {
15 /* Mark 0 as invalid to catch uninitialized vars */
16 SUBSCR_CONN_E_INVALID = 0,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020017 /* Accepted the initial Complete Layer 3 (starting to evaluate Authentication and Ciphering) */
18 SUBSCR_CONN_E_COMPLETE_LAYER_3,
Harald Welte2483f1b2016-06-19 18:06:02 +020019 /* LU or Process Access FSM has determined that this conn is good */
20 SUBSCR_CONN_E_ACCEPTED,
21 /* received first reply from MS in "real" CC, SMS, USSD communication */
22 SUBSCR_CONN_E_COMMUNICATING,
23 /* Some async action has completed, check again whether all is done */
Neels Hofmeyre9e2f5c2018-03-15 13:26:43 +010024 SUBSCR_CONN_E_RELEASE_WHEN_UNUSED,
Harald Welte2483f1b2016-06-19 18:06:02 +020025 /* MS/BTS/BSC originated close request */
26 SUBSCR_CONN_E_MO_CLOSE,
27 /* MSC originated close request, e.g. failed authentication */
28 SUBSCR_CONN_E_CN_CLOSE,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020029 /* The usage count for the conn has reached zero */
30 SUBSCR_CONN_E_UNUSED,
Harald Welte2483f1b2016-06-19 18:06:02 +020031};
32
33enum subscr_conn_fsm_state {
Harald Welte2483f1b2016-06-19 18:06:02 +020034 SUBSCR_CONN_S_NEW,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020035 SUBSCR_CONN_S_AUTH_CIPH,
Harald Welte2483f1b2016-06-19 18:06:02 +020036 SUBSCR_CONN_S_ACCEPTED,
37 SUBSCR_CONN_S_COMMUNICATING,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020038 SUBSCR_CONN_S_RELEASING,
Harald Welte2483f1b2016-06-19 18:06:02 +020039 SUBSCR_CONN_S_RELEASED,
40};
41
Neels Hofmeyre2f24d52017-05-08 15:12:20 +020042enum msc_compl_l3_rc {
43 MSC_CONN_ACCEPT = 0,
44 MSC_CONN_REJECT = 1,
45};
46
Neels Hofmeyr93c74632018-04-02 23:10:28 +020047struct gsm_subscriber_connection *msc_subscr_conn_alloc(struct gsm_network *network,
48 enum ran_type via_ran, uint16_t lac);
49
Neels Hofmeyr16c42b52018-04-02 12:26:16 +020050void msc_subscr_conn_update_id(struct gsm_subscriber_connection *conn,
51 enum complete_layer3_type from, const char *id);
Daniel Willmann4e825b62018-02-15 10:33:26 +010052char *msc_subscr_conn_get_conn_id(struct gsm_subscriber_connection *conn);
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020053
54void msc_subscr_conn_complete_layer_3(struct gsm_subscriber_connection *conn);
Harald Welte2483f1b2016-06-19 18:06:02 +020055
56int msc_vlr_alloc(struct gsm_network *net);
57int msc_vlr_start(struct gsm_network *net);
58
Philipp Maierfbf66102017-04-09 12:32:51 +020059void msc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci);
60int msc_clear_request(struct gsm_subscriber_connection *conn, uint32_t cause);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020061int msc_compl_l3(struct gsm_subscriber_connection *conn,
62 struct msgb *msg, uint16_t chosen_channel);
63void msc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id,
64 struct msgb *msg);
65void msc_cipher_mode_compl(struct gsm_subscriber_connection *conn,
66 struct msgb *msg, uint8_t alg_id);
67void msc_rx_sec_mode_compl(struct gsm_subscriber_connection *conn);
Philipp Maierfbf66102017-04-09 12:32:51 +020068void msc_classmark_chg(struct gsm_subscriber_connection *conn,
69 const uint8_t *cm2, uint8_t cm2_len,
70 const uint8_t *cm3, uint8_t cm3_len);
71void msc_assign_fail(struct gsm_subscriber_connection *conn,
72 uint8_t cause, uint8_t *rr_cause);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020073
Harald Welte2483f1b2016-06-19 18:06:02 +020074void msc_subscr_conn_init(void);
Maxd83b17b2018-02-06 16:51:31 +010075bool msc_subscr_conn_is_accepted(const struct gsm_subscriber_connection *conn);
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020076bool msc_subscr_conn_is_establishing_auth_ciph(const struct gsm_subscriber_connection *conn);
Harald Welte2483f1b2016-06-19 18:06:02 +020077void msc_subscr_conn_communicating(struct gsm_subscriber_connection *conn);
78void msc_subscr_conn_close(struct gsm_subscriber_connection *conn,
79 uint32_t cause);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020080void msc_subscr_conn_mo_close(struct gsm_subscriber_connection *conn, uint32_t cause);
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020081bool msc_subscr_conn_in_release(struct gsm_subscriber_connection *conn);
Harald Welte2483f1b2016-06-19 18:06:02 +020082
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020083void msc_subscr_conn_rx_bssmap_clear_complete(struct gsm_subscriber_connection *conn);
84void msc_subscr_conn_rx_iu_release_complete(struct gsm_subscriber_connection *conn);
85
Neels Hofmeyr6166f292017-11-22 14:33:12 +010086enum msc_subscr_conn_use {
87 MSC_CONN_USE_UNTRACKED = -1,
88 MSC_CONN_USE_COMPL_L3,
89 MSC_CONN_USE_DTAP,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020090 MSC_CONN_USE_AUTH_CIPH,
91 MSC_CONN_USE_CM_SERVICE,
Neels Hofmeyr6166f292017-11-22 14:33:12 +010092 MSC_CONN_USE_TRANS_CC,
93 MSC_CONN_USE_TRANS_SMS,
Vadim Yanitskiy846efcb2018-06-10 22:22:49 +070094 MSC_CONN_USE_TRANS_NC_SS,
Neels Hofmeyr6166f292017-11-22 14:33:12 +010095 MSC_CONN_USE_SILENT_CALL,
Neels Hofmeyre3d3dc62018-03-31 00:02:14 +020096 MSC_CONN_USE_RELEASE,
Neels Hofmeyr6166f292017-11-22 14:33:12 +010097};
98
99extern const struct value_string msc_subscr_conn_use_names[];
100static inline const char *msc_subscr_conn_use_name(enum msc_subscr_conn_use val)
101{ return get_value_string(msc_subscr_conn_use_names, val); }
102
103#define msc_subscr_conn_get(conn, balance_token) \
104 _msc_subscr_conn_get(conn, balance_token, __BASE_FILE__, __LINE__)
105#define msc_subscr_conn_put(conn, balance_token) \
106 _msc_subscr_conn_put(conn, balance_token, __BASE_FILE__, __LINE__)
Harald Welte2483f1b2016-06-19 18:06:02 +0200107struct gsm_subscriber_connection *
108_msc_subscr_conn_get(struct gsm_subscriber_connection *conn,
Neels Hofmeyr6166f292017-11-22 14:33:12 +0100109 enum msc_subscr_conn_use balance_token,
Harald Welte2483f1b2016-06-19 18:06:02 +0200110 const char *file, int line);
111void _msc_subscr_conn_put(struct gsm_subscriber_connection *conn,
Neels Hofmeyr6166f292017-11-22 14:33:12 +0100112 enum msc_subscr_conn_use balance_token,
Harald Welte2483f1b2016-06-19 18:06:02 +0200113 const char *file, int line);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200114bool msc_subscr_conn_used_by(struct gsm_subscriber_connection *conn,
115 enum msc_subscr_conn_use token);
Holger Hans Peter Freyther43b09092010-06-15 11:52:51 +0800116
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200117void msc_stop_paging(struct vlr_subscr *vsub);
118
Holger Hans Peter Freyther43b09092010-06-15 11:52:51 +0800119#endif