blob: 5e8d637e5053419c6597a31052bd02ad2430d642 [file] [log] [blame]
Harald Welte9ee48252009-07-23 21:25:08 +02001#ifndef _TRANSACT_H
2#define _TRANSACT_H
3
Neels Hofmeyr90843962017-09-04 15:04:35 +02004#include <osmocom/msc/gsm_data.h>
5#include <osmocom/msc/gsm_subscriber.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +01006#include <osmocom/core/linuxlist.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +02007#include <osmocom/msc/gsm_04_11.h>
8#include <osmocom/msc/mncc.h>
Andreas Eversbergf7396ea2011-10-28 04:07:07 +02009#include <osmocom/gsm/gsm0411_smc.h>
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +020010#include <osmocom/gsm/gsm0411_smr.h>
Harald Welte0803b982009-07-26 14:24:11 +020011
Maxd8daaae2019-02-14 16:54:10 +070012/* Used for late TID assignment */
13#define TRANS_ID_UNASSIGNED 0xff
14
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020015enum bridge_state {
16 BRIDGE_STATE_NONE,
17 BRIDGE_STATE_LOOPBACK_PENDING,
18 BRIDGE_STATE_LOOPBACK_ESTABLISHED,
19 BRIDGE_STATE_BRIDGE_PENDING,
20 BRIDGE_STATE_BRIDGE_ESTABLISHED,
21};
22
Harald Welte0803b982009-07-26 14:24:11 +020023/* One transaction */
24struct gsm_trans {
25 /* Entry in list of all transactions */
26 struct llist_head entry;
27
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020028 /* Back pointer to the network struct */
Jacob Erlbeckf07c6052014-12-02 11:58:00 +010029 struct gsm_network *net;
30
Harald Welte0803b982009-07-26 14:24:11 +020031 /* The protocol within which we live */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020032 uint8_t protocol;
Harald Welte0803b982009-07-26 14:24:11 +020033
34 /* The current transaction ID */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020035 uint8_t transaction_id;
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020036
Harald Welte0e2fa5d2018-04-09 16:35:01 +020037 /* The DLCI (DCCH/ACCH + SAPI) of this transaction */
38 uint8_t dlci;
39
Harald Welte0803b982009-07-26 14:24:11 +020040 /* To whom we belong, unique identifier of remote MM entity */
Harald Welte2483f1b2016-06-19 18:06:02 +020041 struct vlr_subscr *vsub;
Harald Welte0803b982009-07-26 14:24:11 +020042
Holger Hans Peter Freythere95d4822010-03-23 07:00:22 +010043 /* The associated connection we are using to transmit messages */
Neels Hofmeyrc036b792018-11-29 22:37:51 +010044 struct ran_conn *conn;
Harald Welte0803b982009-07-26 14:24:11 +020045
46 /* reference from MNCC or other application */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020047 uint32_t callref;
Harald Welte0803b982009-07-26 14:24:11 +020048
Harald Welteda7ab742009-12-19 22:23:05 +010049 /* if traffic channel receive was requested */
50 int tch_recv;
51
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010052 /* is thats one paging? */
Holger Hans Peter Freytherd6d7aff2015-04-06 12:03:45 +020053 struct subscr_request *paging_request;
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010054
Philipp Maierfbf66102017-04-09 12:32:51 +020055 /* bearer capabilities (rate and codec) */
56 struct gsm_mncc_bearer_cap bearer_cap;
57
Philipp Maierfbf66102017-04-09 12:32:51 +020058 /* if true, TCH_RTP_CREATE is sent after the
59 * assignment is done */
60 bool tch_rtp_create;
61
Harald Welte0803b982009-07-26 14:24:11 +020062 union {
63 struct {
64
65 /* current call state */
66 int state;
67
68 /* current timer and message queue */
69 int Tcurrent; /* current CC timer */
70 int T308_second; /* used to send release again */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020071 struct osmo_timer_list timer;
Philipp Maier9ca7b312018-10-10 17:00:49 +020072 struct osmo_timer_list timer_guard;
Harald Welte0803b982009-07-26 14:24:11 +020073 struct gsm_mncc msg; /* stores setup/disconnect/release message */
Neels Hofmeyra35712d2018-12-20 03:03:44 +010074 bool assignment_started;
Harald Welte0803b982009-07-26 14:24:11 +020075 } cc;
76 struct {
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020077 struct gsm411_smc_inst smc_inst;
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +020078 struct gsm411_smr_inst smr_inst;
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020079
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +030080 /* SM-RP-MR, Message Reference (see GSM TS 04.11, section 8.2.3) */
81 uint8_t sm_rp_mr;
82
Harald Welte76042182009-08-08 16:03:15 +020083 struct gsm_sms *sms;
Harald Welte0803b982009-07-26 14:24:11 +020084 } sms;
Vadim Yanitskiyf2f83b02018-06-17 21:09:28 +070085 struct {
86 /**
87 * Stores a GSM 04.80 message to be sent to
88 * a subscriber after successful Paging Response
89 */
90 struct msgb *msg;
91 } ss;
Harald Welte0803b982009-07-26 14:24:11 +020092 };
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020093
94 struct {
95 struct gsm_trans *peer;
96 enum bridge_state state;
97 } bridge;
Harald Welte0803b982009-07-26 14:24:11 +020098};
99
100
Harald Welte9ee48252009-07-23 21:25:08 +0200101
Max7916ca12019-01-02 11:48:14 +0100102struct gsm_trans *trans_find_by_id(const struct ran_conn *conn,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200103 uint8_t proto, uint8_t trans_id);
Max7916ca12019-01-02 11:48:14 +0100104struct gsm_trans *trans_find_by_callref(const struct gsm_network *net,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200105 uint32_t callref);
Vadim Yanitskiy36c44b22019-01-23 21:22:27 +0700106struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net,
107 const struct vlr_subscr *vsub,
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +0300108 uint8_t sm_rp_mr);
Harald Welte9ee48252009-07-23 21:25:08 +0200109
Jacob Erlbeckaf792d62014-12-02 14:22:53 +0100110struct gsm_trans *trans_alloc(struct gsm_network *net,
Harald Welte2483f1b2016-06-19 18:06:02 +0200111 struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200112 uint8_t protocol, uint8_t trans_id,
113 uint32_t callref);
Harald Welte9ee48252009-07-23 21:25:08 +0200114void trans_free(struct gsm_trans *trans);
115
Max7916ca12019-01-02 11:48:14 +0100116int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub,
Max30fb97a2019-01-10 17:25:33 +0100117 uint8_t protocol);
Neels Hofmeyrc036b792018-11-29 22:37:51 +0100118struct gsm_trans *trans_has_conn(const struct ran_conn *conn);
Max7916ca12019-01-02 11:48:14 +0100119void trans_conn_closed(const struct ran_conn *conn);
Harald Weltecc9beb52009-12-17 17:13:28 +0100120
Harald Welte9ee48252009-07-23 21:25:08 +0200121#endif