blob: 39b09aeaa2d4b2f9f4e1efdb74700aa594bcec86 [file] [log] [blame]
Vadim Yanitskiy2eaee702019-02-14 16:44:45 +07001#pragma once
Harald Welte9ee48252009-07-23 21:25:08 +02002
Neels Hofmeyr90843962017-09-04 15:04:35 +02003#include <osmocom/msc/gsm_data.h>
4#include <osmocom/msc/gsm_subscriber.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +01005#include <osmocom/core/linuxlist.h>
Neels Hofmeyr90843962017-09-04 15:04:35 +02006#include <osmocom/msc/gsm_04_11.h>
7#include <osmocom/msc/mncc.h>
Andreas Eversbergf7396ea2011-10-28 04:07:07 +02008#include <osmocom/gsm/gsm0411_smc.h>
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +02009#include <osmocom/gsm/gsm0411_smr.h>
Harald Welte0803b982009-07-26 14:24:11 +020010
Maxd8daaae2019-02-14 16:54:10 +070011/* Used for late TID assignment */
12#define TRANS_ID_UNASSIGNED 0xff
13
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020014enum bridge_state {
15 BRIDGE_STATE_NONE,
16 BRIDGE_STATE_LOOPBACK_PENDING,
17 BRIDGE_STATE_LOOPBACK_ESTABLISHED,
18 BRIDGE_STATE_BRIDGE_PENDING,
19 BRIDGE_STATE_BRIDGE_ESTABLISHED,
20};
21
Harald Welte0803b982009-07-26 14:24:11 +020022/* One transaction */
23struct gsm_trans {
24 /* Entry in list of all transactions */
25 struct llist_head entry;
26
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020027 /* Back pointer to the network struct */
Jacob Erlbeckf07c6052014-12-02 11:58:00 +010028 struct gsm_network *net;
29
Harald Welte0803b982009-07-26 14:24:11 +020030 /* The protocol within which we live */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020031 uint8_t protocol;
Harald Welte0803b982009-07-26 14:24:11 +020032
33 /* The current transaction ID */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020034 uint8_t transaction_id;
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020035
Harald Welte0e2fa5d2018-04-09 16:35:01 +020036 /* The DLCI (DCCH/ACCH + SAPI) of this transaction */
37 uint8_t dlci;
38
Harald Welte0803b982009-07-26 14:24:11 +020039 /* To whom we belong, unique identifier of remote MM entity */
Harald Welte2483f1b2016-06-19 18:06:02 +020040 struct vlr_subscr *vsub;
Harald Welte0803b982009-07-26 14:24:11 +020041
Holger Hans Peter Freythere95d4822010-03-23 07:00:22 +010042 /* The associated connection we are using to transmit messages */
Neels Hofmeyrc036b792018-11-29 22:37:51 +010043 struct ran_conn *conn;
Harald Welte0803b982009-07-26 14:24:11 +020044
45 /* reference from MNCC or other application */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020046 uint32_t callref;
Harald Welte0803b982009-07-26 14:24:11 +020047
Harald Welteda7ab742009-12-19 22:23:05 +010048 /* if traffic channel receive was requested */
49 int tch_recv;
50
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010051 /* is thats one paging? */
Holger Hans Peter Freytherd6d7aff2015-04-06 12:03:45 +020052 struct subscr_request *paging_request;
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010053
Philipp Maierfbf66102017-04-09 12:32:51 +020054 /* bearer capabilities (rate and codec) */
55 struct gsm_mncc_bearer_cap bearer_cap;
56
Philipp Maierfbf66102017-04-09 12:32:51 +020057 /* if true, TCH_RTP_CREATE is sent after the
58 * assignment is done */
59 bool tch_rtp_create;
60
Harald Welte0803b982009-07-26 14:24:11 +020061 union {
62 struct {
63
64 /* current call state */
65 int state;
66
67 /* current timer and message queue */
68 int Tcurrent; /* current CC timer */
69 int T308_second; /* used to send release again */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020070 struct osmo_timer_list timer;
Philipp Maier9ca7b312018-10-10 17:00:49 +020071 struct osmo_timer_list timer_guard;
Harald Welte0803b982009-07-26 14:24:11 +020072 struct gsm_mncc msg; /* stores setup/disconnect/release message */
Neels Hofmeyra35712d2018-12-20 03:03:44 +010073 bool assignment_started;
Harald Welte0803b982009-07-26 14:24:11 +020074 } cc;
75 struct {
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020076 struct gsm411_smc_inst smc_inst;
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +020077 struct gsm411_smr_inst smr_inst;
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020078
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +030079 /* SM-RP-MR, Message Reference (see GSM TS 04.11, section 8.2.3) */
80 uint8_t sm_rp_mr;
81
Harald Welte76042182009-08-08 16:03:15 +020082 struct gsm_sms *sms;
Harald Welte0803b982009-07-26 14:24:11 +020083 } sms;
Vadim Yanitskiyf2f83b02018-06-17 21:09:28 +070084 struct {
85 /**
86 * Stores a GSM 04.80 message to be sent to
87 * a subscriber after successful Paging Response
88 */
89 struct msgb *msg;
90 } ss;
Harald Welte0803b982009-07-26 14:24:11 +020091 };
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020092
93 struct {
94 struct gsm_trans *peer;
95 enum bridge_state state;
96 } bridge;
Harald Welte0803b982009-07-26 14:24:11 +020097};
98
99
Harald Welte9ee48252009-07-23 21:25:08 +0200100
Max7916ca12019-01-02 11:48:14 +0100101struct gsm_trans *trans_find_by_id(const struct ran_conn *conn,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200102 uint8_t proto, uint8_t trans_id);
Max7916ca12019-01-02 11:48:14 +0100103struct gsm_trans *trans_find_by_callref(const struct gsm_network *net,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200104 uint32_t callref);
Vadim Yanitskiy36c44b22019-01-23 21:22:27 +0700105struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net,
106 const struct vlr_subscr *vsub,
Ivan Kluchnikov9bd4fd62015-12-21 12:05:56 +0300107 uint8_t sm_rp_mr);
Harald Welte9ee48252009-07-23 21:25:08 +0200108
Jacob Erlbeckaf792d62014-12-02 14:22:53 +0100109struct gsm_trans *trans_alloc(struct gsm_network *net,
Harald Welte2483f1b2016-06-19 18:06:02 +0200110 struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200111 uint8_t protocol, uint8_t trans_id,
112 uint32_t callref);
Harald Welte9ee48252009-07-23 21:25:08 +0200113void trans_free(struct gsm_trans *trans);
114
Max7916ca12019-01-02 11:48:14 +0100115int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub,
Max30fb97a2019-01-10 17:25:33 +0100116 uint8_t protocol);
Neels Hofmeyrc036b792018-11-29 22:37:51 +0100117struct gsm_trans *trans_has_conn(const struct ran_conn *conn);
Max7916ca12019-01-02 11:48:14 +0100118void trans_conn_closed(const struct ran_conn *conn);