blob: 142d535c21c947b7daf225df0e32d11642e7316f [file] [log] [blame]
Harald Welte3561bd42018-01-28 03:04:16 +01001#pragma once
Neels Hofmeyrb523f542020-07-09 15:54:40 +02002#include <osmocom/gsm/protocol/gsm_08_08.h>
3#include <osmocom/gsm/protocol/gsm_04_08.h>
Harald Welte3561bd42018-01-28 03:04:16 +01004#include <osmocom/core/fsm.h>
5
Neels Hofmeyr86a1dca2020-09-15 01:03:58 +00006#define BSUB_USE_CONN "conn"
7
Harald Welte3561bd42018-01-28 03:04:16 +01008enum 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 Hofmeyrd1e7d392020-09-27 23:34:57 +020012 GSCON_EV_MO_COMPL_L3,
Harald Welte3561bd42018-01-28 03:04:16 +010013 /* MSC confirms the SCCP connection */
14 GSCON_EV_A_CONN_CFM,
Harald Welte3561bd42018-01-28 03:04:16 +010015 /* MSC has sent BSSMAP CLEAR CMD */
16 GSCON_EV_A_CLEAR_CMD,
17 /* MSC SCCP disconnect indication */
18 GSCON_EV_A_DISC_IND,
Harald Welte210aa952020-06-21 18:00:23 +020019 /* MSC has sent a BSSMAP COMMON ID */
20 GSCON_EV_A_COMMON_ID_IND,
Harald Welte3561bd42018-01-28 03:04:16 +010021
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020022 GSCON_EV_ASSIGNMENT_START,
23 GSCON_EV_ASSIGNMENT_END,
Harald Welte3561bd42018-01-28 03:04:16 +010024
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020025 GSCON_EV_HANDOVER_START,
26 GSCON_EV_HANDOVER_END,
27
Harald Welte3561bd42018-01-28 03:04:16 +010028 /* RSL CONNection FAILure Indication */
29 GSCON_EV_RSL_CONN_FAIL,
30
Harald Welte3561bd42018-01-28 03:04:16 +010031 /* 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 Weltec997ceb2018-05-30 01:39:43 +020039 /* MDCX response received (MSC) - triggered by LCLS */
40 GSCON_EV_MGW_MDCX_RESP_MSC,
Harald Welte3561bd42018-01-28 03:04:16 +010041
Harald Weltec997ceb2018-05-30 01:39:43 +020042 /* LCLS child FSM has terminated due to hard failure */
43 GSCON_EV_LCLS_FAIL,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020044
45 GSCON_EV_FORGET_LCHAN,
46 GSCON_EV_FORGET_MGW_ENDPOINT,
Neels Hofmeyr4ae338d2020-09-17 17:54:39 +020047
48 GSCON_EV_LCS_LOC_REQ_END,
Harald Welte3561bd42018-01-28 03:04:16 +010049};
50
Neels Hofmeyrb523f542020-07-09 15:54:40 +020051struct gscon_clear_cmd_data {
52 enum gsm0808_cause cause_0808;
53 bool is_csfb;
54};
55
Harald Welte3561bd42018-01-28 03:04:16 +010056struct gsm_subscriber_connection;
57struct gsm_network;
Neels Hofmeyr149160f2018-06-16 17:20:13 +020058struct msgb;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020059struct osmo_mgcpc_ep_ci;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020060struct assignment_request;
61struct gsm_lchan;
62
63void bsc_subscr_conn_fsm_init();
Harald Welte3561bd42018-01-28 03:04:16 +010064
65/* Allocate a subscriber connection and its associated FSM */
66struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020067void gscon_update_id(struct gsm_subscriber_connection *conn);
Neels Hofmeyr149160f2018-06-16 17:20:13 +020068
69void gscon_submit_rsl_dtap(struct gsm_subscriber_connection *conn,
70 struct msgb *msg, int link_id, int allow_sacch);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020071int gscon_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg);
72
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020073struct osmo_mgcpc_ep *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn,
Philipp Maier7a11fce2020-06-26 10:53:16 +020074 uint16_t msc_assigned_cic, struct gsm_lchan *for_lchan);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020075bool 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 Hofmeyrf14aaa42019-04-23 18:37:37 +020081 struct osmo_mgcpc_ep_ci **created_ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020082
83void gscon_start_assignment(struct gsm_subscriber_connection *conn,
84 struct assignment_request *req);
85
86void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan);
Neels Hofmeyrb523f542020-07-09 15:54:40 +020087void gscon_release_lchans(struct gsm_subscriber_connection *conn, bool do_rr_release, enum gsm48_rr_cause cause_rr);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020088
89void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
90void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
91
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020092void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct osmo_mgcpc_ep_ci *ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020093
94bool gscon_is_aoip(struct gsm_subscriber_connection *conn);
95bool gscon_is_sccplite(struct gsm_subscriber_connection *conn);