blob: 1a827d95c0097a4d05a3fd9722418e3040667e00 [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 Welte3561bd42018-01-28 03:04:16 +010017
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020018 GSCON_EV_ASSIGNMENT_START,
19 GSCON_EV_ASSIGNMENT_END,
Harald Welte3561bd42018-01-28 03:04:16 +010020
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020021 GSCON_EV_HANDOVER_START,
22 GSCON_EV_HANDOVER_END,
23
Harald Welte3561bd42018-01-28 03:04:16 +010024 /* RSL CONNection FAILure Indication */
25 GSCON_EV_RSL_CONN_FAIL,
26
Harald Welte3561bd42018-01-28 03:04:16 +010027 /* Mobile-originated DTAP (from MS) */
28 GSCON_EV_MO_DTAP,
29 /* Mobile-terminated DTAP (from MSC) */
30 GSCON_EV_MT_DTAP,
31
32 /* Transmit custom SCCP message */
33 GSCON_EV_TX_SCCP,
34
Harald Weltec997ceb2018-05-30 01:39:43 +020035 /* MDCX response received (MSC) - triggered by LCLS */
36 GSCON_EV_MGW_MDCX_RESP_MSC,
Harald Welte3561bd42018-01-28 03:04:16 +010037
Harald Weltec997ceb2018-05-30 01:39:43 +020038 /* LCLS child FSM has terminated due to hard failure */
39 GSCON_EV_LCLS_FAIL,
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020040
41 GSCON_EV_FORGET_LCHAN,
42 GSCON_EV_FORGET_MGW_ENDPOINT,
Harald Welte3561bd42018-01-28 03:04:16 +010043};
44
Neels Hofmeyrb523f542020-07-09 15:54:40 +020045struct gscon_clear_cmd_data {
46 enum gsm0808_cause cause_0808;
47 bool is_csfb;
48};
49
Harald Welte3561bd42018-01-28 03:04:16 +010050struct gsm_subscriber_connection;
51struct gsm_network;
Neels Hofmeyr149160f2018-06-16 17:20:13 +020052struct msgb;
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020053struct osmo_mgcpc_ep_ci;
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020054struct assignment_request;
55struct gsm_lchan;
56
57void bsc_subscr_conn_fsm_init();
Harald Welte3561bd42018-01-28 03:04:16 +010058
59/* Allocate a subscriber connection and its associated FSM */
60struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020061void gscon_update_id(struct gsm_subscriber_connection *conn);
Neels Hofmeyr149160f2018-06-16 17:20:13 +020062
63void gscon_submit_rsl_dtap(struct gsm_subscriber_connection *conn,
64 struct msgb *msg, int link_id, int allow_sacch);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020065int gscon_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg);
66
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020067struct osmo_mgcpc_ep *gscon_ensure_mgw_endpoint(struct gsm_subscriber_connection *conn,
68 uint16_t msc_assigned_cic);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020069bool gscon_connect_mgw_to_msc(struct gsm_subscriber_connection *conn,
70 struct gsm_lchan *for_lchan,
71 const char *addr, uint16_t port,
72 struct osmo_fsm_inst *notify,
73 uint32_t event_success, uint32_t event_failure,
74 void *notify_data,
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020075 struct osmo_mgcpc_ep_ci **created_ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020076
77void gscon_start_assignment(struct gsm_subscriber_connection *conn,
78 struct assignment_request *req);
79
80void gscon_change_primary_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *new_lchan);
Neels Hofmeyrb523f542020-07-09 15:54:40 +020081void 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 +020082
83void gscon_lchan_releasing(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
84void gscon_forget_lchan(struct gsm_subscriber_connection *conn, struct gsm_lchan *lchan);
85
Neels Hofmeyrf14aaa42019-04-23 18:37:37 +020086void gscon_forget_mgw_endpoint_ci(struct gsm_subscriber_connection *conn, struct osmo_mgcpc_ep_ci *ci);
Neels Hofmeyr31f525e2018-05-14 18:14:15 +020087
88bool gscon_is_aoip(struct gsm_subscriber_connection *conn);
89bool gscon_is_sccplite(struct gsm_subscriber_connection *conn);