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