Harald Welte | 9ee4825 | 2009-07-23 21:25:08 +0200 | [diff] [blame] | 1 | #ifndef _TRANSACT_H |
| 2 | #define _TRANSACT_H |
| 3 | |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 4 | #include <osmocom/msc/gsm_data.h> |
| 5 | #include <osmocom/msc/gsm_subscriber.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 6 | #include <osmocom/core/linuxlist.h> |
Neels Hofmeyr | 9084396 | 2017-09-04 15:04:35 +0200 | [diff] [blame] | 7 | #include <osmocom/msc/gsm_04_11.h> |
| 8 | #include <osmocom/msc/mncc.h> |
Andreas Eversberg | f7396ea | 2011-10-28 04:07:07 +0200 | [diff] [blame] | 9 | #include <osmocom/gsm/gsm0411_smc.h> |
Andreas Eversberg | bc6c43f | 2011-10-28 11:11:13 +0200 | [diff] [blame] | 10 | #include <osmocom/gsm/gsm0411_smr.h> |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 11 | |
Max | d8daaae | 2019-02-14 16:54:10 +0700 | [diff] [blame] | 12 | /* Used for late TID assignment */ |
| 13 | #define TRANS_ID_UNASSIGNED 0xff |
| 14 | |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 15 | enum 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 Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 23 | /* One transaction */ |
| 24 | struct gsm_trans { |
| 25 | /* Entry in list of all transactions */ |
| 26 | struct llist_head entry; |
| 27 | |
Neels Hofmeyr | 8ce66fd | 2016-08-29 17:52:39 +0200 | [diff] [blame] | 28 | /* Back pointer to the network struct */ |
Jacob Erlbeck | f07c605 | 2014-12-02 11:58:00 +0100 | [diff] [blame] | 29 | struct gsm_network *net; |
| 30 | |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 31 | /* The protocol within which we live */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 32 | uint8_t protocol; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 33 | |
| 34 | /* The current transaction ID */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 35 | uint8_t transaction_id; |
Neels Hofmeyr | 8ce66fd | 2016-08-29 17:52:39 +0200 | [diff] [blame] | 36 | |
Harald Welte | 0e2fa5d | 2018-04-09 16:35:01 +0200 | [diff] [blame] | 37 | /* The DLCI (DCCH/ACCH + SAPI) of this transaction */ |
| 38 | uint8_t dlci; |
| 39 | |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 40 | /* To whom we belong, unique identifier of remote MM entity */ |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 41 | struct vlr_subscr *vsub; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 42 | |
Holger Hans Peter Freyther | e95d482 | 2010-03-23 07:00:22 +0100 | [diff] [blame] | 43 | /* The associated connection we are using to transmit messages */ |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 44 | struct ran_conn *conn; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 45 | |
| 46 | /* reference from MNCC or other application */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 47 | uint32_t callref; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 48 | |
Harald Welte | da7ab74 | 2009-12-19 22:23:05 +0100 | [diff] [blame] | 49 | /* if traffic channel receive was requested */ |
| 50 | int tch_recv; |
| 51 | |
Holger Hans Peter Freyther | 49b3ed2 | 2010-12-29 17:09:07 +0100 | [diff] [blame] | 52 | /* is thats one paging? */ |
Holger Hans Peter Freyther | d6d7aff | 2015-04-06 12:03:45 +0200 | [diff] [blame] | 53 | struct subscr_request *paging_request; |
Holger Hans Peter Freyther | 49b3ed2 | 2010-12-29 17:09:07 +0100 | [diff] [blame] | 54 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 55 | /* bearer capabilities (rate and codec) */ |
| 56 | struct gsm_mncc_bearer_cap bearer_cap; |
| 57 | |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 58 | /* if true, TCH_RTP_CREATE is sent after the |
| 59 | * assignment is done */ |
| 60 | bool tch_rtp_create; |
| 61 | |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 62 | 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 Ayuso | bf540cb | 2011-05-06 12:11:06 +0200 | [diff] [blame] | 71 | struct osmo_timer_list timer; |
Philipp Maier | 9ca7b31 | 2018-10-10 17:00:49 +0200 | [diff] [blame] | 72 | struct osmo_timer_list timer_guard; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 73 | struct gsm_mncc msg; /* stores setup/disconnect/release message */ |
Neels Hofmeyr | a35712d | 2018-12-20 03:03:44 +0100 | [diff] [blame] | 74 | bool assignment_started; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 75 | } cc; |
| 76 | struct { |
Andreas Eversberg | f7396ea | 2011-10-28 04:07:07 +0200 | [diff] [blame] | 77 | struct gsm411_smc_inst smc_inst; |
Andreas Eversberg | bc6c43f | 2011-10-28 11:11:13 +0200 | [diff] [blame] | 78 | struct gsm411_smr_inst smr_inst; |
Andreas Eversberg | f7396ea | 2011-10-28 04:07:07 +0200 | [diff] [blame] | 79 | |
Ivan Kluchnikov | 9bd4fd6 | 2015-12-21 12:05:56 +0300 | [diff] [blame] | 80 | /* SM-RP-MR, Message Reference (see GSM TS 04.11, section 8.2.3) */ |
| 81 | uint8_t sm_rp_mr; |
| 82 | |
Harald Welte | 7604218 | 2009-08-08 16:03:15 +0200 | [diff] [blame] | 83 | struct gsm_sms *sms; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 84 | } sms; |
Vadim Yanitskiy | f2f83b0 | 2018-06-17 21:09:28 +0700 | [diff] [blame] | 85 | 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 Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 92 | }; |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 93 | |
| 94 | struct { |
| 95 | struct gsm_trans *peer; |
| 96 | enum bridge_state state; |
| 97 | } bridge; |
Harald Welte | 0803b98 | 2009-07-26 14:24:11 +0200 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | |
Harald Welte | 9ee4825 | 2009-07-23 21:25:08 +0200 | [diff] [blame] | 101 | |
Max | 7916ca1 | 2019-01-02 11:48:14 +0100 | [diff] [blame] | 102 | struct gsm_trans *trans_find_by_id(const struct ran_conn *conn, |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 103 | uint8_t proto, uint8_t trans_id); |
Max | 7916ca1 | 2019-01-02 11:48:14 +0100 | [diff] [blame] | 104 | struct gsm_trans *trans_find_by_callref(const struct gsm_network *net, |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 105 | uint32_t callref); |
Vadim Yanitskiy | 36c44b2 | 2019-01-23 21:22:27 +0700 | [diff] [blame] | 106 | struct gsm_trans *trans_find_by_sm_rp_mr(const struct gsm_network *net, |
| 107 | const struct vlr_subscr *vsub, |
Ivan Kluchnikov | 9bd4fd6 | 2015-12-21 12:05:56 +0300 | [diff] [blame] | 108 | uint8_t sm_rp_mr); |
Harald Welte | 9ee4825 | 2009-07-23 21:25:08 +0200 | [diff] [blame] | 109 | |
Jacob Erlbeck | af792d6 | 2014-12-02 14:22:53 +0100 | [diff] [blame] | 110 | struct gsm_trans *trans_alloc(struct gsm_network *net, |
Harald Welte | 2483f1b | 2016-06-19 18:06:02 +0200 | [diff] [blame] | 111 | struct vlr_subscr *vsub, |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 112 | uint8_t protocol, uint8_t trans_id, |
| 113 | uint32_t callref); |
Harald Welte | 9ee4825 | 2009-07-23 21:25:08 +0200 | [diff] [blame] | 114 | void trans_free(struct gsm_trans *trans); |
| 115 | |
Max | 7916ca1 | 2019-01-02 11:48:14 +0100 | [diff] [blame] | 116 | int trans_assign_trans_id(const struct gsm_network *net, const struct vlr_subscr *vsub, |
Max | 30fb97a | 2019-01-10 17:25:33 +0100 | [diff] [blame] | 117 | uint8_t protocol); |
Neels Hofmeyr | c036b79 | 2018-11-29 22:37:51 +0100 | [diff] [blame] | 118 | struct gsm_trans *trans_has_conn(const struct ran_conn *conn); |
Max | 7916ca1 | 2019-01-02 11:48:14 +0100 | [diff] [blame] | 119 | void trans_conn_closed(const struct ran_conn *conn); |
Harald Welte | cc9beb5 | 2009-12-17 17:13:28 +0100 | [diff] [blame] | 120 | |
Harald Welte | 9ee4825 | 2009-07-23 21:25:08 +0200 | [diff] [blame] | 121 | #endif |