Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 1 | #pragma once |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 2 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
| 3 | #include <osmocom/gsm/protocol/gsm_04_08.h> |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 4 | #include <osmocom/core/fsm.h> |
| 5 | |
Neels Hofmeyr | 86a1dca | 2020-09-15 01:03:58 +0000 | [diff] [blame] | 6 | #define BSUB_USE_CONN "conn" |
| 7 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 8 | enum gscon_fsm_event { |
| 9 | /* local SCCP stack tells us incoming conn from MSC */ |
| 10 | GSCON_EV_A_CONN_IND, |
| 11 | /* RSL side requests CONNECT to MSC */ |
Neels Hofmeyr | d1e7d39 | 2020-09-27 23:34:57 +0200 | [diff] [blame] | 12 | GSCON_EV_MO_COMPL_L3, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 13 | /* MSC confirms the SCCP connection */ |
| 14 | GSCON_EV_A_CONN_CFM, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 15 | /* MSC has sent BSSMAP CLEAR CMD */ |
| 16 | GSCON_EV_A_CLEAR_CMD, |
| 17 | /* MSC SCCP disconnect indication */ |
| 18 | GSCON_EV_A_DISC_IND, |
Harald Welte | 210aa95 | 2020-06-21 18:00:23 +0200 | [diff] [blame] | 19 | /* MSC has sent a BSSMAP COMMON ID */ |
| 20 | GSCON_EV_A_COMMON_ID_IND, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 21 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 22 | GSCON_EV_ASSIGNMENT_START, |
| 23 | GSCON_EV_ASSIGNMENT_END, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 24 | |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 25 | GSCON_EV_HANDOVER_START, |
| 26 | GSCON_EV_HANDOVER_END, |
| 27 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 28 | /* RSL CONNection FAILure Indication */ |
| 29 | GSCON_EV_RSL_CONN_FAIL, |
| 30 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 31 | /* Mobile-originated DTAP (from MS) */ |
| 32 | GSCON_EV_MO_DTAP, |
| 33 | /* Mobile-terminated DTAP (from MSC) */ |
| 34 | GSCON_EV_MT_DTAP, |
| 35 | |
| 36 | /* Transmit custom SCCP message */ |
| 37 | GSCON_EV_TX_SCCP, |
| 38 | |
Harald Welte | c997ceb | 2018-05-30 01:39:43 +0200 | [diff] [blame] | 39 | /* MDCX response received (MSC) - triggered by LCLS */ |
| 40 | GSCON_EV_MGW_MDCX_RESP_MSC, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 41 | |
Harald Welte | c997ceb | 2018-05-30 01:39:43 +0200 | [diff] [blame] | 42 | /* LCLS child FSM has terminated due to hard failure */ |
| 43 | GSCON_EV_LCLS_FAIL, |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 44 | |
| 45 | GSCON_EV_FORGET_LCHAN, |
| 46 | GSCON_EV_FORGET_MGW_ENDPOINT, |
Neels Hofmeyr | 4ae338d | 2020-09-17 17:54:39 +0200 | [diff] [blame] | 47 | |
| 48 | GSCON_EV_LCS_LOC_REQ_END, |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 51 | struct gscon_clear_cmd_data { |
| 52 | enum gsm0808_cause cause_0808; |
| 53 | bool is_csfb; |
| 54 | }; |
| 55 | |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 56 | struct gsm_subscriber_connection; |
| 57 | struct gsm_network; |
Neels Hofmeyr | 149160f | 2018-06-16 17:20:13 +0200 | [diff] [blame] | 58 | struct msgb; |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 59 | struct osmo_mgcpc_ep_ci; |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 60 | struct assignment_request; |
| 61 | struct gsm_lchan; |
| 62 | |
| 63 | void bsc_subscr_conn_fsm_init(); |
Harald Welte | 3561bd4 | 2018-01-28 03:04:16 +0100 | [diff] [blame] | 64 | |
| 65 | /* Allocate a subscriber connection and its associated FSM */ |
| 66 | struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 67 | void gscon_update_id(struct gsm_subscriber_connection *conn); |
Neels Hofmeyr | 149160f | 2018-06-16 17:20:13 +0200 | [diff] [blame] | 68 | |
| 69 | void gscon_submit_rsl_dtap(struct gsm_subscriber_connection *conn, |
| 70 | struct msgb *msg, int link_id, int allow_sacch); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 71 | int gscon_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg); |
| 72 | |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 73 | struct osmo_mgcpc_ep *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn, |
Philipp Maier | 7a11fce | 2020-06-26 10:53:16 +0200 | [diff] [blame] | 74 | uint16_t msc_assigned_cic, struct gsm_lchan *for_lchan); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 75 | bool gscon_connect_mgw_to_msc(struct gsm_subscriber_connection *conn, |
| 76 | struct gsm_lchan *for_lchan, |
| 77 | const char *addr, uint16_t port, |
| 78 | struct osmo_fsm_inst *notify, |
| 79 | uint32_t event_success, uint32_t event_failure, |
| 80 | void *notify_data, |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 81 | struct osmo_mgcpc_ep_ci **created_ci); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 82 | |
| 83 | void gscon_start_assignment(struct gsm_subscriber_connection *conn, |
| 84 | struct assignment_request *req); |
| 85 | |
| 86 | void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan); |
Neels Hofmeyr | b523f54 | 2020-07-09 15:54:40 +0200 | [diff] [blame] | 87 | void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 88 | |
| 89 | void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan); |
| 90 | void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan); |
| 91 | |
Neels Hofmeyr | f14aaa4 | 2019-04-23 18:37:37 +0200 | [diff] [blame] | 92 | void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct osmo_mgcpc_ep_ci *ci); |
Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 93 | |
| 94 | bool gscon_is_aoip(struct gsm_subscriber_connection *conn); |
| 95 | bool gscon_is_sccplite(struct gsm_subscriber_connection *conn); |