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