blob: 354c5ee9318c250b9c9a245e6af86ab0b013a5c6 [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
6enum 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 Welte3561bd42018-01-28 03:04:16 +010013 /* MSC has sent BSSMAP CLEAR CMD */
14 GSCON_EV_A_CLEAR_CMD,
15 /* MSC SCCP disconnect indication */
16 GSCON_EV_A_DISC_IND,
Harald Welte210aa952020-06-21 18:00:23 +020017 /* MSC has sent a BSSMAP COMMON ID */
18 GSCON_EV_A_COMMON_ID_IND,
Harald Welte3561bd42018-01-28 03:04:16 +010019
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020020 GSCON_EV_ASSIGNMENT_START,
21 GSCON_EV_ASSIGNMENT_END,
Harald Welte3561bd42018-01-28 03:04:16 +010022
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020023 GSCON_EV_HANDOVER_START,
24 GSCON_EV_HANDOVER_END,
25
Harald Welte3561bd42018-01-28 03:04:16 +010026 /* RSL CONNection FAILure Indication */
27 GSCON_EV_RSL_CONN_FAIL,
28
Harald Welte3561bd42018-01-28 03:04:16 +010029 /* 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 Weltec997ceb2018-05-30 01:39:43 +020037 /* MDCX response received (MSC) - triggered by LCLS */
38 GSCON_EV_MGW_MDCX_RESP_MSC,
Harald Welte3561bd42018-01-28 03:04:16 +010039
Harald Weltec997ceb2018-05-30 01:39:43 +020040 /* LCLS child FSM has terminated due to hard failure */
41 GSCON_EV_LCLS_FAIL,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020042
43 GSCON_EV_FORGET_LCHAN,
44 GSCON_EV_FORGET_MGW_ENDPOINT,
Harald Welte3561bd42018-01-28 03:04:16 +010045};
46
Neels Hofmeyrb523f542020-07-09 15:54:40 +020047struct gscon_clear_cmd_data {
48 enum gsm0808_cause cause_0808;
49 bool is_csfb;
50};
51
Harald Welte3561bd42018-01-28 03:04:16 +010052struct gsm_subscriber_connection;
53struct gsm_network;
Neels Hofmeyr149160f2018-06-16 17:20:13 +020054struct msgb;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020055struct osmo_mgcpc_ep_ci;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020056struct assignment_request;
57struct gsm_lchan;
58
59void bsc_subscr_conn_fsm_init();
Harald Welte3561bd42018-01-28 03:04:16 +010060
61/* Allocate a subscriber connection and its associated FSM */
62struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020063void gscon_update_id(struct gsm_subscriber_connection *conn);
Neels Hofmeyr149160f2018-06-16 17:20:13 +020064
65void gscon_submit_rsl_dtap(struct gsm_subscriber_connection *conn,
66 struct msgb *msg, int link_id, int allow_sacch);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020067int gscon_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg);
68
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020069struct osmo_mgcpc_ep *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn,
Philipp Maier7a11fce2020-06-26 10:53:16 +020070 uint16_t msc_assigned_cic, struct gsm_lchan *for_lchan);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020071bool 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 Hofmeyrf14aaa42019-04-23 18:37:37 +020077 struct osmo_mgcpc_ep_ci **created_ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020078
79void gscon_start_assignment(struct gsm_subscriber_connection *conn,
80 struct assignment_request *req);
81
82void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan);
Neels Hofmeyrb523f542020-07-09 15:54:40 +020083void 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 +020084
85void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
86void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
87
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020088void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct osmo_mgcpc_ep_ci *ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020089
90bool gscon_is_aoip(struct gsm_subscriber_connection *conn);
91bool gscon_is_sccplite(struct gsm_subscriber_connection *conn);