blob: 36e9bc1ed8afd8996b680b00255280ef4029fa56 [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
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020012enum bridge_state {
13 BRIDGE_STATE_NONE,
14 BRIDGE_STATE_LOOPBACK_PENDING,
15 BRIDGE_STATE_LOOPBACK_ESTABLISHED,
16 BRIDGE_STATE_BRIDGE_PENDING,
17 BRIDGE_STATE_BRIDGE_ESTABLISHED,
18};
19
Harald Welte0803b982009-07-26 14:24:11 +020020/* One transaction */
21struct gsm_trans {
22 /* Entry in list of all transactions */
23 struct llist_head entry;
24
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020025 /* Back pointer to the network struct */
Jacob Erlbeckf07c6052014-12-02 11:58:00 +010026 struct gsm_network *net;
27
Harald Welte0803b982009-07-26 14:24:11 +020028 /* The protocol within which we live */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020029 uint8_t protocol;
Harald Welte0803b982009-07-26 14:24:11 +020030
31 /* The current transaction ID */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020032 uint8_t transaction_id;
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020033
Harald Welte0e2fa5d2018-04-09 16:35:01 +020034 /* The DLCI (DCCH/ACCH + SAPI) of this transaction */
35 uint8_t dlci;
36
Harald Welte0803b982009-07-26 14:24:11 +020037 /* To whom we belong, unique identifier of remote MM entity */
Harald Welte2483f1b2016-06-19 18:06:02 +020038 struct vlr_subscr *vsub;
Harald Welte0803b982009-07-26 14:24:11 +020039
Holger Hans Peter Freythere95d4822010-03-23 07:00:22 +010040 /* The associated connection we are using to transmit messages */
Neels Hofmeyrc036b792018-11-29 22:37:51 +010041 struct ran_conn *conn;
Harald Welte0803b982009-07-26 14:24:11 +020042
43 /* reference from MNCC or other application */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020044 uint32_t callref;
Harald Welte0803b982009-07-26 14:24:11 +020045
Harald Welteda7ab742009-12-19 22:23:05 +010046 /* if traffic channel receive was requested */
47 int tch_recv;
48
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010049 /* is thats one paging? */
Holger Hans Peter Freytherd6d7aff2015-04-06 12:03:45 +020050 struct subscr_request *paging_request;
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010051
Philipp Maierfbf66102017-04-09 12:32:51 +020052 /* bearer capabilities (rate and codec) */
53 struct gsm_mncc_bearer_cap bearer_cap;
54
Philipp Maierfbf66102017-04-09 12:32:51 +020055 /* if true, TCH_RTP_CREATE is sent after the
56 * assignment is done */
57 bool tch_rtp_create;
58
Harald Welte0803b982009-07-26 14:24:11 +020059 union {
60 struct {
61
62 /* current call state */
63 int state;
64
65 /* current timer and message queue */
66 int Tcurrent; /* current CC timer */
67 int T308_second; /* used to send release again */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020068 struct osmo_timer_list timer;
Philipp Maier9ca7b312018-10-10 17:00:49 +020069 struct osmo_timer_list timer_guard;
Harald Welte0803b982009-07-26 14:24:11 +020070 struct gsm_mncc msg; /* stores setup/disconnect/release message */
Neels Hofmeyra35712d2018-12-20 03:03:44 +010071 bool assignment_started;
Harald Welte0803b982009-07-26 14:24:11 +020072 } cc;
73 struct {
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020074 struct gsm411_smc_inst smc_inst;
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +020075 struct gsm411_smr_inst smr_inst;
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020076
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +030077 /* SM-RP-MR, Message Reference (see GSM TS 04.11, section 8.2.3) */
78 uint8_t sm_rp_mr;
79
Harald Welte76042182009-08-08 16:03:15 +020080 struct gsm_sms *sms;
Harald Welte0803b982009-07-26 14:24:11 +020081 } sms;
Vadim Yanitskiyf2f83b02018-06-17 21:09:28 +070082 struct {
83 /**
84 * Stores a GSM 04.80 message to be sent to
85 * a subscriber after successful Paging Response
86 */
87 struct msgb *msg;
88 } ss;
Harald Welte0803b982009-07-26 14:24:11 +020089 };
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020090
91 struct {
92 struct gsm_trans *peer;
93 enum bridge_state state;
94 } bridge;
Harald Welte0803b982009-07-26 14:24:11 +020095};
96
97
Harald Welte9ee48252009-07-23 21:25:08 +020098
Max7916ca12019-01-02 11:48:14 +010099struct gsm_trans *trans_find_by_id(const struct ran_conn *conn,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200100 uint8_t proto, uint8_t trans_id);
Max7916ca12019-01-02 11:48:14 +0100101struct gsm_trans *trans_find_by_callref(const struct gsm_network *net,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200102 uint32_t callref);
Vadim Yanitskiy36c44b22019-01-23 21:22:27 +0700103struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net,
104 const struct vlr_subscr *vsub,
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +0300105 uint8_t sm_rp_mr);
Harald Welte9ee48252009-07-23 21:25:08 +0200106
Jacob Erlbeckaf792d62014-12-02 14:22:53 +0100107struct gsm_trans *trans_alloc(struct gsm_network *net,
Harald Welte2483f1b2016-06-19 18:06:02 +0200108 struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200109 uint8_t protocol, uint8_t trans_id,
110 uint32_t callref);
Harald Welte9ee48252009-07-23 21:25:08 +0200111void trans_free(struct gsm_trans *trans);
112
Max7916ca12019-01-02 11:48:14 +0100113int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200114 uint8_t protocol, uint8_t ti_flag);
Neels Hofmeyrc036b792018-11-29 22:37:51 +0100115struct gsm_trans *trans_has_conn(const struct ran_conn *conn);
Max7916ca12019-01-02 11:48:14 +0100116void trans_conn_closed(const struct ran_conn *conn);
Harald Weltecc9beb52009-12-17 17:13:28 +0100117
Harald Welte9ee48252009-07-23 21:25:08 +0200118#endif