2009-10-16 06:32:58 +00:00
|
|
|
/* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
* (C) 2008, 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* (C) 2009 by Mike Haben <michael.haben@btinternet.com>
|
2018-06-12 01:21:20 +00:00
|
|
|
* (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
|
2009-10-16 06:32:58 +00:00
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2009-10-16 06:32:58 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2009-10-16 06:32:58 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-10-16 06:32:58 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-11 22:24:52 +00:00
|
|
|
/**
|
|
|
|
* MSC-specific handling of call independent Supplementary
|
|
|
|
* Services messages (NC_SS) according to GSM TS 09.11
|
|
|
|
* "Signalling interworking for supplementary services".
|
|
|
|
*/
|
2009-10-16 06:32:58 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2018-06-12 01:21:20 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
#include <osmocom/core/linuxlist.h>
|
2018-06-22 20:32:20 +00:00
|
|
|
#include <osmocom/core/rate_ctr.h>
|
2018-06-12 01:21:20 +00:00
|
|
|
#include <osmocom/core/utils.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
2018-08-02 21:39:04 +00:00
|
|
|
|
|
|
|
#include <osmocom/gsm/protocol/gsm_04_80.h>
|
|
|
|
#include <osmocom/gsm/gsm0480.h>
|
2018-06-12 01:21:20 +00:00
|
|
|
#include <osmocom/gsm/tlv.h>
|
2009-10-16 06:32:58 +00:00
|
|
|
|
2017-09-04 13:04:35 +00:00
|
|
|
#include <osmocom/msc/gsm_04_80.h>
|
|
|
|
#include <osmocom/msc/gsm_subscriber.h>
|
|
|
|
#include <osmocom/msc/debug.h>
|
|
|
|
#include <osmocom/msc/vlr.h>
|
2017-09-15 09:22:30 +00:00
|
|
|
#include <osmocom/msc/gsm_04_08.h>
|
2018-04-17 12:17:11 +00:00
|
|
|
#include <osmocom/msc/transaction.h>
|
2018-07-31 17:40:52 +00:00
|
|
|
#include <osmocom/gsupclient/gsup_client.h>
|
2018-06-12 01:21:20 +00:00
|
|
|
#include <osmocom/msc/msc_ifaces.h>
|
2018-04-17 12:17:11 +00:00
|
|
|
|
|
|
|
/* FIXME: choose a proper range */
|
|
|
|
static uint32_t new_callref = 0x20000001;
|
2009-10-16 06:32:58 +00:00
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
static void ncss_session_timeout_handler(void *_trans)
|
|
|
|
{
|
|
|
|
struct gsm_trans *trans = (struct gsm_trans *) _trans;
|
|
|
|
struct osmo_gsup_message gsup_msg = { 0 };
|
|
|
|
|
|
|
|
/* The timeout might be disabled from the VTY */
|
|
|
|
if (trans->net->ncss_guard_timeout == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LOGP(DMM, LOGL_NOTICE, "SS/USSD session timeout, releasing "
|
|
|
|
"transaction (trans=%p, callref=%x)\n", trans, trans->callref);
|
|
|
|
|
|
|
|
/* Indicate connection release to subscriber (if active) */
|
|
|
|
if (trans->conn != NULL) {
|
|
|
|
/* This pair of cause location and value is used by commercial networks */
|
|
|
|
msc_send_ussd_release_complete_cause(trans->conn, trans->transaction_id,
|
|
|
|
GSM48_CAUSE_LOC_PUN_S_LU, GSM48_CC_CAUSE_NORMAL_UNSPEC);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate GSUP session with EUSE */
|
|
|
|
gsup_msg.message_type = OSMO_GSUP_MSGT_PROC_SS_ERROR;
|
|
|
|
OSMO_STRLCPY_ARRAY(gsup_msg.imsi, trans->vsub->imsi);
|
|
|
|
|
|
|
|
gsup_msg.session_state = OSMO_GSUP_SESSION_STATE_END;
|
|
|
|
gsup_msg.session_id = trans->callref;
|
|
|
|
gsup_msg.cause = GMM_CAUSE_NET_FAIL;
|
|
|
|
|
|
|
|
osmo_gsup_client_enc_send(trans->net->vlr->gsup_client, &gsup_msg);
|
|
|
|
|
|
|
|
/* Finally, release this transaction */
|
|
|
|
trans_free(trans);
|
|
|
|
}
|
|
|
|
|
2018-06-11 22:24:52 +00:00
|
|
|
/* Entry point for call independent MO SS messages */
|
rename gsm_subscriber_connection to ran_conn
In preparation for inter-BSC and inter-MSC handover, we need to separate the
subscriber management logic from the actual RAN connections. What better time
to finally rename gsm_subscriber_connection.
* Name choice:
In 2G, this is a connection to the BSS, but even though 3GPP TS commonly talk
of "BSS-A" and "BSS-B" when explaining handover, it's not good to call it
"bss_conn": in 3G a BSS is called RNS, IIUC.
The overall term for 2G (GERAN) and 3G (UTRAN) is RAN: Radio Access Network.
* Rationale:
A subscriber in the MSC so far has only one RAN connection, but e.g. for
inter-BSC handover, a second one needs to be created to handover to. Most of
the items in the former gsm_subscriber_connection are actually related to the
RAN, with only a few MM and RTP related items. So, as a first step, just rename
it to ran_conn, to cosmetically prepare for moving the not strictly RAN related
items away later.
Also:
- Rename some functions from msc_subscr_conn_* to ran_conn_*
- Rename "Subscr_Conn" FSM instance name to "RAN_conn"
- Rename SUBSCR_CONN_* to RAN_CONN_*
Change-Id: Ic595f7a558d3553c067f77dc67543ab59659707a
2018-11-29 21:37:51 +00:00
|
|
|
int gsm0911_rcv_nc_ss(struct ran_conn *conn, struct msgb *msg)
|
2009-10-16 06:32:58 +00:00
|
|
|
{
|
2018-04-17 12:17:11 +00:00
|
|
|
struct gsm48_hdr *gh = msgb_l3(msg);
|
2018-06-12 01:21:20 +00:00
|
|
|
struct osmo_gsup_message gsup_msg;
|
2018-04-17 12:17:11 +00:00
|
|
|
struct gsm_trans *trans;
|
2018-06-12 01:21:20 +00:00
|
|
|
struct msgb *gsup_msgb;
|
|
|
|
uint16_t facility_ie_len;
|
|
|
|
uint8_t *facility_ie;
|
2019-01-10 16:41:05 +00:00
|
|
|
uint8_t tid;
|
2018-04-17 12:17:11 +00:00
|
|
|
uint8_t msg_type;
|
|
|
|
int rc;
|
2009-10-16 06:32:58 +00:00
|
|
|
|
2018-04-17 12:17:11 +00:00
|
|
|
msg_type = gsm48_hdr_msg_type(gh);
|
|
|
|
tid = gsm48_hdr_trans_id_flip_ti(gh);
|
2016-06-19 16:06:02 +00:00
|
|
|
|
2018-04-17 12:17:11 +00:00
|
|
|
/* Associate logging messages with this subscriber */
|
|
|
|
log_set_context(LOG_CTX_VLR_SUBSCR, conn->vsub);
|
|
|
|
|
|
|
|
DEBUGP(DMM, "Received SS/USSD data (trans_id=%x, msg_type=%s)\n",
|
2019-01-10 16:41:05 +00:00
|
|
|
tid, gsm48_pdisc_msgtype_name(GSM48_PDISC_NC_SS, msg_type));
|
2018-04-17 12:17:11 +00:00
|
|
|
|
|
|
|
/* Reuse existing transaction, or create a new one */
|
2019-01-10 16:41:05 +00:00
|
|
|
trans = trans_find_by_id(conn, GSM48_PDISC_NC_SS, tid);
|
2018-04-17 12:17:11 +00:00
|
|
|
if (!trans) {
|
2018-06-22 20:32:20 +00:00
|
|
|
/* Count MS-initiated attempts to establish a NC SS/USSD session */
|
|
|
|
rate_ctr_inc(&conn->network->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_REQUESTS]);
|
|
|
|
|
2018-04-17 12:17:11 +00:00
|
|
|
/**
|
|
|
|
* According to GSM TS 04.80, section 2.4.2 "Register
|
|
|
|
* (mobile station to network direction)", the REGISTER
|
|
|
|
* message is sent by the mobile station to the network
|
|
|
|
* to assign a new transaction identifier for call independent
|
|
|
|
* supplementary service control and to request or acknowledge
|
|
|
|
* a supplementary service.
|
|
|
|
*/
|
|
|
|
if (msg_type != GSM0480_MTYPE_REGISTER) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Unexpected message (msg_type=%s), "
|
|
|
|
"transaction is not allocated yet\n",
|
2019-01-10 16:41:05 +00:00
|
|
|
gsm48_pdisc_msgtype_name(GSM48_PDISC_NC_SS, msg_type));
|
2018-06-11 23:26:28 +00:00
|
|
|
gsm48_tx_simple(conn,
|
|
|
|
GSM48_PDISC_NC_SS | (tid << 4),
|
|
|
|
GSM0480_MTYPE_RELEASE_COMPLETE);
|
2018-04-17 12:17:11 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUGP(DMM, " -> (new transaction)\n");
|
|
|
|
trans = trans_alloc(conn->network, conn->vsub,
|
2019-01-10 16:41:05 +00:00
|
|
|
GSM48_PDISC_NC_SS, tid, new_callref++);
|
2018-04-17 12:17:11 +00:00
|
|
|
if (!trans) {
|
2019-01-17 12:38:10 +00:00
|
|
|
LOGP(DMM, LOGL_ERROR, " -> No memory for trans\n");
|
2018-06-11 23:26:28 +00:00
|
|
|
gsm48_tx_simple(conn,
|
|
|
|
GSM48_PDISC_NC_SS | (tid << 4),
|
|
|
|
GSM0480_MTYPE_RELEASE_COMPLETE);
|
2018-04-17 12:17:11 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* Init inactivity timer */
|
|
|
|
osmo_timer_setup(&trans->ss.timer_guard,
|
|
|
|
ncss_session_timeout_handler, trans);
|
|
|
|
|
2018-06-26 11:27:25 +00:00
|
|
|
/* Count active NC SS/USSD sessions */
|
|
|
|
osmo_counter_inc(conn->network->active_nc_ss);
|
|
|
|
|
2018-11-30 00:08:36 +00:00
|
|
|
trans->conn = ran_conn_get(conn, RAN_CONN_USE_TRANS_NC_SS);
|
2018-04-17 12:17:11 +00:00
|
|
|
trans->dlci = OMSC_LINKID_CB(msg);
|
|
|
|
cm_service_request_concludes(conn, msg);
|
|
|
|
}
|
2016-06-19 16:06:02 +00:00
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* (Re)schedule the inactivity timer */
|
|
|
|
if (conn->network->ncss_guard_timeout > 0) {
|
|
|
|
osmo_timer_schedule(&trans->ss.timer_guard,
|
|
|
|
conn->network->ncss_guard_timeout, 0);
|
|
|
|
}
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
/* Attempt to extract Facility IE */
|
|
|
|
rc = gsm0480_extract_ie_by_tag(gh, msgb_l3len(msg),
|
|
|
|
&facility_ie, &facility_ie_len, GSM0480_IE_FACILITY);
|
|
|
|
if (rc) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "GSM 04.80 message parsing error, "
|
|
|
|
"couldn't extract Facility IE\n");
|
|
|
|
goto error;
|
2013-12-28 16:03:14 +00:00
|
|
|
}
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
/* Facility IE is optional for RELEASE COMPLETE */
|
|
|
|
if (msg_type != GSM0480_MTYPE_RELEASE_COMPLETE) {
|
|
|
|
if (!facility_ie || facility_ie_len < 2) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "GSM 04.80 message parsing error, "
|
|
|
|
"missing mandatory Facility IE\n");
|
|
|
|
rc = -EINVAL;
|
|
|
|
goto error;
|
2016-07-12 15:53:26 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-16 06:32:58 +00:00
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
/* Compose a mew GSUP message */
|
|
|
|
memset(&gsup_msg, 0x00, sizeof(gsup_msg));
|
|
|
|
gsup_msg.message_type = OSMO_GSUP_MSGT_PROC_SS_REQUEST;
|
|
|
|
gsup_msg.session_id = trans->callref;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform A-interface to GSUP-interface mapping,
|
|
|
|
* according to GSM TS 09.11, table 4.2.
|
|
|
|
*/
|
|
|
|
switch (msg_type) {
|
|
|
|
case GSM0480_MTYPE_REGISTER:
|
|
|
|
gsup_msg.session_state = OSMO_GSUP_SESSION_STATE_BEGIN;
|
|
|
|
break;
|
|
|
|
case GSM0480_MTYPE_FACILITY:
|
|
|
|
gsup_msg.session_state = OSMO_GSUP_SESSION_STATE_CONTINUE;
|
|
|
|
break;
|
|
|
|
case GSM0480_MTYPE_RELEASE_COMPLETE:
|
|
|
|
gsup_msg.session_state = OSMO_GSUP_SESSION_STATE_END;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the (optional) message payload */
|
|
|
|
if (facility_ie) {
|
|
|
|
gsup_msg.ss_info_len = facility_ie_len;
|
|
|
|
gsup_msg.ss_info = facility_ie;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in subscriber's IMSI */
|
|
|
|
OSMO_STRLCPY_ARRAY(gsup_msg.imsi, conn->vsub->imsi);
|
|
|
|
|
|
|
|
/* Allocate GSUP message buffer */
|
2018-07-31 17:40:52 +00:00
|
|
|
gsup_msgb = osmo_gsup_client_msgb_alloc();
|
2018-06-12 01:21:20 +00:00
|
|
|
if (!gsup_msgb) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Couldn't allocate GSUP message\n");
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode GSUP message */
|
|
|
|
rc = osmo_gsup_encode(gsup_msgb, &gsup_msg);
|
|
|
|
if (rc) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Couldn't encode GSUP message\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally send */
|
2018-07-31 17:40:52 +00:00
|
|
|
rc = osmo_gsup_client_send(conn->network->vlr->gsup_client, gsup_msgb);
|
2018-06-12 01:21:20 +00:00
|
|
|
if (rc) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Couldn't send GSUP message\n");
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2018-06-21 10:55:56 +00:00
|
|
|
/* Should we release connection? Or wait for response? */
|
|
|
|
if (msg_type == GSM0480_MTYPE_RELEASE_COMPLETE)
|
|
|
|
trans_free(trans);
|
|
|
|
else
|
rename gsm_subscriber_connection to ran_conn
In preparation for inter-BSC and inter-MSC handover, we need to separate the
subscriber management logic from the actual RAN connections. What better time
to finally rename gsm_subscriber_connection.
* Name choice:
In 2G, this is a connection to the BSS, but even though 3GPP TS commonly talk
of "BSS-A" and "BSS-B" when explaining handover, it's not good to call it
"bss_conn": in 3G a BSS is called RNS, IIUC.
The overall term for 2G (GERAN) and 3G (UTRAN) is RAN: Radio Access Network.
* Rationale:
A subscriber in the MSC so far has only one RAN connection, but e.g. for
inter-BSC handover, a second one needs to be created to handover to. Most of
the items in the former gsm_subscriber_connection are actually related to the
RAN, with only a few MM and RTP related items. So, as a first step, just rename
it to ran_conn, to cosmetically prepare for moving the not strictly RAN related
items away later.
Also:
- Rename some functions from msc_subscr_conn_* to ran_conn_*
- Rename "Subscr_Conn" FSM instance name to "RAN_conn"
- Rename SUBSCR_CONN_* to RAN_CONN_*
Change-Id: Ic595f7a558d3553c067f77dc67543ab59659707a
2018-11-29 21:37:51 +00:00
|
|
|
ran_conn_communicating(conn);
|
2018-06-12 01:21:20 +00:00
|
|
|
|
2018-06-22 20:32:20 +00:00
|
|
|
/* Count established MS-initiated NC SS/USSD sessions */
|
|
|
|
if (msg_type == GSM0480_MTYPE_REGISTER)
|
|
|
|
rate_ctr_inc(&conn->network->msc_ctrs->ctr[MSC_CTR_NC_SS_MO_ESTABLISHED]);
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
/* Abort transaction on DTAP-interface */
|
2018-08-02 21:39:04 +00:00
|
|
|
msc_send_ussd_reject(conn, tid, -1,
|
2018-06-12 01:21:20 +00:00
|
|
|
GSM_0480_PROBLEM_CODE_TAG_GENERAL,
|
|
|
|
GSM_0480_GEN_PROB_CODE_UNRECOGNISED);
|
|
|
|
if (trans)
|
|
|
|
trans_free(trans);
|
|
|
|
|
|
|
|
/* TODO: abort transaction on GSUP interface if any */
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
/* Call-back from paging the B-end of the connection */
|
|
|
|
static int handle_paging_event(unsigned int hooknum, unsigned int event,
|
|
|
|
struct msgb *msg, void *_conn, void *_transt)
|
|
|
|
{
|
rename gsm_subscriber_connection to ran_conn
In preparation for inter-BSC and inter-MSC handover, we need to separate the
subscriber management logic from the actual RAN connections. What better time
to finally rename gsm_subscriber_connection.
* Name choice:
In 2G, this is a connection to the BSS, but even though 3GPP TS commonly talk
of "BSS-A" and "BSS-B" when explaining handover, it's not good to call it
"bss_conn": in 3G a BSS is called RNS, IIUC.
The overall term for 2G (GERAN) and 3G (UTRAN) is RAN: Radio Access Network.
* Rationale:
A subscriber in the MSC so far has only one RAN connection, but e.g. for
inter-BSC handover, a second one needs to be created to handover to. Most of
the items in the former gsm_subscriber_connection are actually related to the
RAN, with only a few MM and RTP related items. So, as a first step, just rename
it to ran_conn, to cosmetically prepare for moving the not strictly RAN related
items away later.
Also:
- Rename some functions from msc_subscr_conn_* to ran_conn_*
- Rename "Subscr_Conn" FSM instance name to "RAN_conn"
- Rename SUBSCR_CONN_* to RAN_CONN_*
Change-Id: Ic595f7a558d3553c067f77dc67543ab59659707a
2018-11-29 21:37:51 +00:00
|
|
|
struct ran_conn *conn = _conn;
|
2018-06-17 14:09:28 +00:00
|
|
|
enum gsm_paging_event paging_event = event;
|
|
|
|
struct gsm_trans *transt = _transt;
|
|
|
|
struct gsm48_hdr *gh;
|
|
|
|
struct msgb *ss_msg;
|
|
|
|
|
|
|
|
OSMO_ASSERT(!transt->conn);
|
|
|
|
OSMO_ASSERT(transt->ss.msg);
|
|
|
|
|
|
|
|
switch (paging_event) {
|
|
|
|
case GSM_PAGING_SUCCEEDED:
|
|
|
|
DEBUGP(DMM, "Paging subscr %s succeeded!\n",
|
|
|
|
vlr_subscr_msisdn_or_name(transt->vsub));
|
|
|
|
|
|
|
|
/* Assign connection */
|
2018-11-30 00:08:36 +00:00
|
|
|
transt->conn = ran_conn_get(conn, RAN_CONN_USE_TRANS_NC_SS);
|
2018-06-17 14:09:28 +00:00
|
|
|
transt->paging_request = NULL;
|
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* (Re)schedule the inactivity timer */
|
|
|
|
if (conn->network->ncss_guard_timeout > 0) {
|
|
|
|
osmo_timer_schedule(&transt->ss.timer_guard,
|
|
|
|
conn->network->ncss_guard_timeout, 0);
|
|
|
|
}
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
/* Send stored message */
|
|
|
|
ss_msg = transt->ss.msg;
|
|
|
|
gh = (struct gsm48_hdr *) msgb_push(ss_msg, sizeof(*gh));
|
|
|
|
gh->proto_discr = GSM48_PDISC_NC_SS;
|
|
|
|
gh->proto_discr |= transt->transaction_id << 4;
|
|
|
|
gh->msg_type = GSM0480_MTYPE_REGISTER;
|
|
|
|
|
|
|
|
/* Sent to the MS, give ownership of ss_msg */
|
|
|
|
msc_tx_dtap(transt->conn, ss_msg);
|
|
|
|
transt->ss.msg = NULL;
|
2018-06-22 20:32:20 +00:00
|
|
|
|
|
|
|
/* Count established network-initiated NC SS/USSD sessions */
|
|
|
|
rate_ctr_inc(&conn->network->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_ESTABLISHED]);
|
2018-06-17 14:09:28 +00:00
|
|
|
break;
|
|
|
|
case GSM_PAGING_EXPIRED:
|
|
|
|
case GSM_PAGING_BUSY:
|
|
|
|
DEBUGP(DMM, "Paging subscr %s %s!\n",
|
|
|
|
vlr_subscr_msisdn_or_name(transt->vsub),
|
|
|
|
paging_event == GSM_PAGING_EXPIRED ? "expired" : "busy");
|
|
|
|
|
|
|
|
/* TODO: inform HLR about this failure */
|
|
|
|
|
|
|
|
msgb_free(transt->ss.msg);
|
|
|
|
transt->ss.msg = NULL;
|
|
|
|
|
|
|
|
transt->callref = 0;
|
|
|
|
transt->paging_request = NULL;
|
|
|
|
trans_free(transt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gsm_trans *establish_nc_ss_trans(struct gsm_network *net,
|
|
|
|
struct vlr_subscr *vsub, struct osmo_gsup_message *gsup_msg)
|
|
|
|
{
|
rename gsm_subscriber_connection to ran_conn
In preparation for inter-BSC and inter-MSC handover, we need to separate the
subscriber management logic from the actual RAN connections. What better time
to finally rename gsm_subscriber_connection.
* Name choice:
In 2G, this is a connection to the BSS, but even though 3GPP TS commonly talk
of "BSS-A" and "BSS-B" when explaining handover, it's not good to call it
"bss_conn": in 3G a BSS is called RNS, IIUC.
The overall term for 2G (GERAN) and 3G (UTRAN) is RAN: Radio Access Network.
* Rationale:
A subscriber in the MSC so far has only one RAN connection, but e.g. for
inter-BSC handover, a second one needs to be created to handover to. Most of
the items in the former gsm_subscriber_connection are actually related to the
RAN, with only a few MM and RTP related items. So, as a first step, just rename
it to ran_conn, to cosmetically prepare for moving the not strictly RAN related
items away later.
Also:
- Rename some functions from msc_subscr_conn_* to ran_conn_*
- Rename "Subscr_Conn" FSM instance name to "RAN_conn"
- Rename SUBSCR_CONN_* to RAN_CONN_*
Change-Id: Ic595f7a558d3553c067f77dc67543ab59659707a
2018-11-29 21:37:51 +00:00
|
|
|
struct ran_conn *conn;
|
2018-06-17 14:09:28 +00:00
|
|
|
struct gsm_trans *trans, *transt;
|
|
|
|
int tid;
|
|
|
|
|
|
|
|
if (gsup_msg->session_state != OSMO_GSUP_SESSION_STATE_BEGIN) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Received non-BEGIN message "
|
|
|
|
"for non-existing transaction\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gsup_msg->ss_info || gsup_msg->ss_info_len < 2) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Missing mandatory Facility IE\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If subscriber is not "attached" */
|
2018-12-19 10:48:33 +00:00
|
|
|
if (!vsub->cgi.lai.lac) {
|
2018-06-17 14:09:28 +00:00
|
|
|
LOGP(DMM, LOGL_ERROR, "Network-originated session "
|
|
|
|
"rejected - subscriber is not attached\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUGP(DMM, "Establishing network-originated session\n");
|
|
|
|
|
|
|
|
/* Allocate a new transaction */
|
|
|
|
trans = trans_alloc(net, vsub, GSM48_PDISC_NC_SS,
|
2019-02-14 09:54:10 +00:00
|
|
|
TRANS_ID_UNASSIGNED, gsup_msg->session_id);
|
2018-06-17 14:09:28 +00:00
|
|
|
if (!trans) {
|
2019-01-17 12:38:10 +00:00
|
|
|
LOGP(DMM, LOGL_ERROR, " -> No memory for trans\n");
|
2018-06-17 14:09:28 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-26 11:27:25 +00:00
|
|
|
/* Count active NC SS/USSD sessions */
|
|
|
|
osmo_counter_inc(net->active_nc_ss);
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
/* Assign transaction ID */
|
2019-01-10 16:25:33 +00:00
|
|
|
tid = trans_assign_trans_id(trans->net, trans->vsub, GSM48_PDISC_NC_SS);
|
2018-06-17 14:09:28 +00:00
|
|
|
if (tid < 0) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "No free transaction ID\n");
|
|
|
|
/* TODO: inform HLR about this */
|
|
|
|
/* TODO: release connection with subscriber */
|
|
|
|
trans->callref = 0;
|
|
|
|
trans_free(trans);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
trans->transaction_id = tid;
|
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* Init inactivity timer */
|
|
|
|
osmo_timer_setup(&trans->ss.timer_guard,
|
|
|
|
ncss_session_timeout_handler, trans);
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
/* Attempt to find connection */
|
|
|
|
conn = connection_for_subscr(vsub);
|
|
|
|
if (conn) {
|
|
|
|
/* Assign connection */
|
2018-11-30 00:08:36 +00:00
|
|
|
trans->conn = ran_conn_get(conn, RAN_CONN_USE_TRANS_NC_SS);
|
2018-06-17 14:09:28 +00:00
|
|
|
trans->dlci = 0x00; /* SAPI=0, not SACCH */
|
|
|
|
return trans;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUGP(DMM, "Triggering Paging Request\n");
|
|
|
|
|
|
|
|
/* Find transaction with this subscriber already paging */
|
|
|
|
llist_for_each_entry(transt, &net->trans_list, entry) {
|
|
|
|
/* Transaction of our conn? */
|
|
|
|
if (transt == trans || transt->vsub != vsub)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Paging already started, "
|
|
|
|
"rejecting message...\n");
|
|
|
|
trans_free(trans);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Trigger Paging Request */
|
|
|
|
trans->paging_request = subscr_request_conn(vsub,
|
2018-12-03 10:00:04 +00:00
|
|
|
&handle_paging_event, trans, "GSM 09.11 SS/USSD",
|
|
|
|
SGSAP_SERV_IND_CS_CALL);
|
2018-06-17 14:09:28 +00:00
|
|
|
if (!trans->paging_request) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Failed to allocate paging token\n");
|
|
|
|
trans_free(trans);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the Facility IE to be sent */
|
|
|
|
OSMO_ASSERT(trans->ss.msg == NULL);
|
|
|
|
trans->ss.msg = gsm48_msgb_alloc_name("GSM 04.08 SS/USSD");
|
|
|
|
msgb_tlv_put(trans->ss.msg, GSM0480_IE_FACILITY,
|
|
|
|
gsup_msg->ss_info_len, gsup_msg->ss_info);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* NC SS specific transaction release.
|
|
|
|
* Gets called by trans_free, DO NOT CALL YOURSELF! */
|
|
|
|
void _gsm911_nc_ss_trans_free(struct gsm_trans *trans)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* TODO: if transaction wasn't properly terminated,
|
|
|
|
* we need to do it here by releasing the subscriber
|
|
|
|
* connection and sending notification via GSUP...
|
|
|
|
*/
|
|
|
|
if (trans->ss.msg != NULL)
|
|
|
|
msgb_free(trans->ss.msg);
|
2018-06-26 11:27:25 +00:00
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* Stop inactivity timer */
|
|
|
|
osmo_timer_del(&trans->ss.timer_guard);
|
|
|
|
|
2018-06-26 11:27:25 +00:00
|
|
|
/* One session less */
|
|
|
|
osmo_counter_dec(trans->net->active_nc_ss);
|
2018-06-17 14:09:28 +00:00
|
|
|
}
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
int gsm0911_gsup_handler(struct vlr_subscr *vsub,
|
|
|
|
struct osmo_gsup_message *gsup_msg)
|
|
|
|
{
|
|
|
|
struct vlr_instance *vlr;
|
|
|
|
struct gsm_network *net;
|
|
|
|
struct gsm_trans *trans;
|
|
|
|
struct gsm48_hdr *gh;
|
|
|
|
struct msgb *ss_msg;
|
|
|
|
bool trans_end;
|
|
|
|
|
|
|
|
/* Associate logging messages with this subscriber */
|
|
|
|
log_set_context(LOG_CTX_VLR_SUBSCR, vsub);
|
|
|
|
|
|
|
|
/* Obtain pointer to vlr_instance */
|
|
|
|
vlr = vsub->vlr;
|
|
|
|
OSMO_ASSERT(vlr);
|
|
|
|
|
|
|
|
/* Obtain pointer to gsm_network */
|
|
|
|
net = (struct gsm_network *) vlr->user_ctx;
|
|
|
|
OSMO_ASSERT(net);
|
|
|
|
|
|
|
|
/* Handle errors */
|
|
|
|
if (OSMO_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
|
|
|
|
/* FIXME: handle this error somehow! */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to find DTAP-transaction */
|
|
|
|
trans = trans_find_by_callref(net, gsup_msg->session_id);
|
|
|
|
if (!trans) {
|
2018-06-22 20:32:20 +00:00
|
|
|
/* Count network-initiated attempts to establish a NC SS/USSD session */
|
|
|
|
rate_ctr_inc(&net->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_REQUESTS]);
|
|
|
|
|
2018-06-17 14:09:28 +00:00
|
|
|
/* Attempt to establish a new transaction */
|
|
|
|
trans = establish_nc_ss_trans(net, vsub, gsup_msg);
|
|
|
|
if (!trans) {
|
|
|
|
/* FIXME: send ERROR back to the HLR */
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for Paging Response */
|
|
|
|
if (trans->paging_request)
|
|
|
|
return 0;
|
2009-10-16 06:32:58 +00:00
|
|
|
}
|
2010-06-30 04:15:19 +00:00
|
|
|
|
libmsc/gsm_09_11.c: implement guard timer for NCSS sessions
It may happen that either the MS or an EUSE would become
unresponsive during a call independent SS session, e.g.
due to a bug, or a dropped message. In such cases, the
corresponding transaction would remain unfreed forever.
This change introduces a guard timer, that prevents keeping
'stalled' NCSS sessions forever. As soon as it expires, both
sides (i.e. MS and EUSE) are getting notified, and the
transaction is being released.
By default, the timer expires after 30 seconds. As soon as
either the MS, or an EUSE initiates any activity,
the watchdog timer is rescheduled.
The timeout value can be configured from the VTY:
msc
...
! Use 0 to disable this timer
ncss guard-timeout 30
Please note that changing the timeout value at run-time
doesn't affect the existing NCSS sessions, excepting the
case when the timer is disabled at run-time.
This change makes TC_lu_and_ss_session_timeout pass.
Change-Id: Icf4d87c45e90324764073e8230e0fb9cb96dd9cb
Related Change-Id: (TTCN) I3e1791773d56617172ae27a46889a1ae4d400e2f
Related: OS#3655
2018-11-28 16:05:51 +00:00
|
|
|
/* (Re)schedule the inactivity timer */
|
|
|
|
if (net->ncss_guard_timeout > 0) {
|
|
|
|
osmo_timer_schedule(&trans->ss.timer_guard,
|
|
|
|
net->ncss_guard_timeout, 0);
|
|
|
|
}
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
/* Allocate and prepare a new MT message */
|
|
|
|
ss_msg = gsm48_msgb_alloc_name("GSM 04.08 SS/USSD");
|
|
|
|
gh = (struct gsm48_hdr *) msgb_push(ss_msg, sizeof(*gh));
|
|
|
|
gh->proto_discr = GSM48_PDISC_NC_SS;
|
|
|
|
gh->proto_discr |= trans->transaction_id << 4;
|
|
|
|
|
2018-04-17 12:17:11 +00:00
|
|
|
/**
|
2018-06-12 01:21:20 +00:00
|
|
|
* Perform GSUP-interface to A-interface mapping,
|
|
|
|
* according to GSM TS 09.11, table 4.1.
|
|
|
|
*
|
|
|
|
* TODO: see (note 3), both CONTINUE and END may
|
|
|
|
* be also mapped to REGISTER if a new transaction
|
|
|
|
* has to be established.
|
2018-04-17 12:17:11 +00:00
|
|
|
*/
|
2018-06-12 01:21:20 +00:00
|
|
|
switch (gsup_msg->session_state) {
|
|
|
|
case OSMO_GSUP_SESSION_STATE_BEGIN:
|
|
|
|
gh->msg_type = GSM0480_MTYPE_REGISTER;
|
|
|
|
break;
|
|
|
|
case OSMO_GSUP_SESSION_STATE_CONTINUE:
|
|
|
|
gh->msg_type = GSM0480_MTYPE_FACILITY;
|
|
|
|
break;
|
|
|
|
case OSMO_GSUP_SESSION_STATE_END:
|
|
|
|
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
|
|
|
break;
|
2018-04-17 12:17:11 +00:00
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
/* Missing or incorrect session state */
|
|
|
|
case OSMO_GSUP_SESSION_STATE_NONE:
|
|
|
|
default:
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Unexpected session state %d\n",
|
|
|
|
gsup_msg->session_state);
|
|
|
|
/* FIXME: send ERROR back to the HLR */
|
|
|
|
msgb_free(ss_msg);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Facility IE is optional only for RELEASE COMPLETE */
|
|
|
|
if (gh->msg_type != GSM0480_MTYPE_RELEASE_COMPLETE) {
|
|
|
|
if (!gsup_msg->ss_info || gsup_msg->ss_info_len < 2) {
|
|
|
|
LOGP(DMM, LOGL_ERROR, "Missing mandatory Facility IE "
|
|
|
|
"for mapped 0x%02x message\n", gh->msg_type);
|
|
|
|
/* FIXME: send ERROR back to the HLR */
|
|
|
|
msgb_free(ss_msg);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append Facility IE if preset */
|
|
|
|
if (gsup_msg->ss_info && gsup_msg->ss_info_len > 2) {
|
|
|
|
/* Facility IE carries LV, others carry TLV */
|
|
|
|
if (gh->msg_type == GSM0480_MTYPE_FACILITY)
|
|
|
|
msgb_lv_put(ss_msg, gsup_msg->ss_info_len, gsup_msg->ss_info);
|
|
|
|
else
|
|
|
|
msgb_tlv_put(ss_msg, GSM0480_IE_FACILITY,
|
|
|
|
gsup_msg->ss_info_len, gsup_msg->ss_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Should we release the transaction? */
|
|
|
|
trans_end = (gh->msg_type == GSM0480_MTYPE_RELEASE_COMPLETE);
|
|
|
|
|
|
|
|
/* Sent to the MS, give ownership of ss_msg */
|
|
|
|
msc_tx_dtap(trans->conn, ss_msg);
|
|
|
|
|
|
|
|
/* Release transaction if required */
|
|
|
|
if (trans_end)
|
|
|
|
trans_free(trans);
|
|
|
|
|
2018-06-22 20:32:20 +00:00
|
|
|
/* Count established network-initiated NC SS/USSD sessions */
|
|
|
|
if (gsup_msg->session_state == OSMO_GSUP_SESSION_STATE_BEGIN)
|
|
|
|
rate_ctr_inc(&net->msc_ctrs->ctr[MSC_CTR_NC_SS_MT_ESTABLISHED]);
|
|
|
|
|
2018-06-12 01:21:20 +00:00
|
|
|
return 0;
|
2009-10-16 06:32:58 +00:00
|
|
|
}
|