blob: 1e93fffda8a655a2fba06d950f671d5a019d98da [file] [log] [blame]
Harald Welte9ee48252009-07-23 21:25:08 +02001#ifndef _TRANSACT_H
2#define _TRANSACT_H
3
4#include <openbsc/gsm_data.h>
5#include <openbsc/gsm_subscriber.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +01006#include <osmocom/core/linuxlist.h>
Harald Weltef142c972011-05-24 13:25:38 +02007#include <openbsc/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
Neels Hofmeyrc29505e2016-05-20 21:59:55 +020011enum bridge_state {
12 BRIDGE_STATE_NONE,
13 BRIDGE_STATE_LOOPBACK_PENDING,
14 BRIDGE_STATE_LOOPBACK_ESTABLISHED,
15 BRIDGE_STATE_BRIDGE_PENDING,
16 BRIDGE_STATE_BRIDGE_ESTABLISHED,
17};
18
Harald Welte0803b982009-07-26 14:24:11 +020019/* One transaction */
20struct gsm_trans {
21 /* Entry in list of all transactions */
22 struct llist_head entry;
23
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020024 /* Back pointer to the network struct */
Jacob Erlbeckf07c6052014-12-02 11:58:00 +010025 struct gsm_network *net;
26
Harald Welte0803b982009-07-26 14:24:11 +020027 /* The protocol within which we live */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020028 uint8_t protocol;
Harald Welte0803b982009-07-26 14:24:11 +020029
30 /* The current transaction ID */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020031 uint8_t transaction_id;
Neels Hofmeyr8ce66fd2016-08-29 17:52:39 +020032
Harald Welte0803b982009-07-26 14:24:11 +020033 /* To whom we belong, unique identifier of remote MM entity */
Harald Weltea43e0b42016-06-19 18:06:02 +020034 struct vlr_subscr *vsub;
Harald Welte0803b982009-07-26 14:24:11 +020035
Holger Hans Peter Freythere95d4822010-03-23 07:00:22 +010036 /* The associated connection we are using to transmit messages */
37 struct gsm_subscriber_connection *conn;
Harald Welte0803b982009-07-26 14:24:11 +020038
39 /* reference from MNCC or other application */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020040 uint32_t callref;
Harald Welte0803b982009-07-26 14:24:11 +020041
Harald Welteda7ab742009-12-19 22:23:05 +010042 /* if traffic channel receive was requested */
43 int tch_recv;
44
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010045 /* is thats one paging? */
Holger Hans Peter Freytherd6d7aff2015-04-06 12:03:45 +020046 struct subscr_request *paging_request;
Holger Hans Peter Freyther49b3ed22010-12-29 17:09:07 +010047
Philipp Maier39f62bb2017-04-09 12:32:51 +020048 /* bearer capabilities (rate and codec) */
49 struct gsm_mncc_bearer_cap bearer_cap;
50
51 /* status of the assignment, true when done */
52 bool assignment_done;
53
54 /* if true, TCH_RTP_CREATE is sent after the
55 * assignment is done */
56 bool tch_rtp_create;
57
Harald Welte0803b982009-07-26 14:24:11 +020058 union {
59 struct {
60
61 /* current call state */
62 int state;
63
64 /* current timer and message queue */
65 int Tcurrent; /* current CC timer */
66 int T308_second; /* used to send release again */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020067 struct osmo_timer_list timer;
Harald Welte0803b982009-07-26 14:24:11 +020068 struct gsm_mncc msg; /* stores setup/disconnect/release message */
69 } cc;
70 struct {
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020071 struct gsm411_smc_inst smc_inst;
Andreas Eversbergbc6c43f2011-10-28 11:11:13 +020072 struct gsm411_smr_inst smr_inst;
Andreas Eversbergf7396ea2011-10-28 04:07:07 +020073
Harald Welte76042182009-08-08 16:03:15 +020074 struct gsm_sms *sms;
Harald Welte0803b982009-07-26 14:24:11 +020075 } sms;
76 };
Neels Hofmeyrc29505e2016-05-20 21:59:55 +020077
78 struct {
79 struct gsm_trans *peer;
80 enum bridge_state state;
81 } bridge;
Harald Welte0803b982009-07-26 14:24:11 +020082};
83
84
Harald Welte9ee48252009-07-23 21:25:08 +020085
Jacob Erlbeckdae1f642014-12-02 14:22:53 +010086struct gsm_trans *trans_find_by_id(struct gsm_subscriber_connection *conn,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020087 uint8_t proto, uint8_t trans_id);
Harald Welte9ee48252009-07-23 21:25:08 +020088struct gsm_trans *trans_find_by_callref(struct gsm_network *net,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020089 uint32_t callref);
Harald Welte9ee48252009-07-23 21:25:08 +020090
Jacob Erlbeckaf792d62014-12-02 14:22:53 +010091struct gsm_trans *trans_alloc(struct gsm_network *net,
Harald Weltea43e0b42016-06-19 18:06:02 +020092 struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020093 uint8_t protocol, uint8_t trans_id,
94 uint32_t callref);
Harald Welte9ee48252009-07-23 21:25:08 +020095void trans_free(struct gsm_trans *trans);
96
Harald Weltea43e0b42016-06-19 18:06:02 +020097int trans_assign_trans_id(struct gsm_network *net, struct vlr_subscr *vsub,
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020098 uint8_t protocol, uint8_t ti_flag);
Neels Hofmeyrc29505e2016-05-20 21:59:55 +020099struct gsm_trans *trans_has_conn(const struct gsm_subscriber_connection *conn);
Harald Weltea43e0b42016-06-19 18:06:02 +0200100void trans_conn_closed(struct gsm_subscriber_connection *conn);
Harald Weltecc9beb52009-12-17 17:13:28 +0100101
Harald Welte9ee48252009-07-23 21:25:08 +0200102#endif