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