osmo-msc/src/libmsc/mncc_builtin.c

379 lines
10 KiB
C
Raw Normal View History

/* mncc_builtin.c - default, minimal built-in MNCC Application for
* standalone bsc_hack (network-in-the-box mode) */
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
* (C) 2009 by Andreas Eversberg <Andreas.Eversberg@versatel.de>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* GNU General Public License for more details.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <osmocom/msc/gsm_04_08.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/mncc.h>
#include <osmocom/msc/mncc_int.h>
#include <osmocom/core/talloc.h>
#include <osmocom/msc/gsm_data.h>
#include <osmocom/msc/transaction.h>
#define DEBUGCC(l, r, fmt, args...) DEBUGP(DMNCC, "(call %x, remote %x) " fmt, l->callref, r->callref, ##args)
void *tall_call_ctx;
static LLIST_HEAD(call_list);
static uint32_t new_callref = 0x00000001;
struct mncc_int mncc_int = {
.def_codec = { GSM48_CMODE_SPEECH_V1, GSM48_CMODE_SPEECH_V1 },
};
static void free_call(struct gsm_call *call)
{
llist_del(&call->entry);
DEBUGP(DMNCC, "(call %x) Call removed.\n", call->callref);
talloc_free(call);
}
static struct gsm_call *get_call_ref(uint32_t callref)
{
struct gsm_call *callt;
llist_for_each_entry(callt, &call_list, entry) {
if (callt->callref == callref)
return callt;
}
return NULL;
}
/* on incoming call, look up database and send setup to remote subscr. */
static int mncc_setup_ind(struct gsm_call *call,
struct gsm_mncc *setup)
{
struct gsm_mncc mncc;
struct gsm_call *remote;
memset(&mncc, 0, sizeof(struct gsm_mncc));
mncc.callref = call->callref;
/* already have remote call */
if (call->remote_ref)
return 0;
large refactoring: support inter-BSC and inter-MSC Handover 3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I and MSC-T' defines distinct roles: - MSC-A is responsible for managing subscribers, - MSC-I is the gateway to the RAN. - MSC-T is a second transitory gateway to another RAN during Handover. After inter-MSC Handover, the MSC-I is handled by a remote MSC instance, while the original MSC-A retains the responsibility of subscriber management. MSC-T exists in this patch but is not yet used, since Handover is only prepared for, not yet implemented. Facilitate Inter-MSC and inter-BSC Handover by the same internal split of MSC roles. Compared to inter-MSC Handover, mere inter-BSC has the obvious simplifications: - all of MSC-A, MSC-I and MSC-T roles will be served by the same osmo-msc instance, - messages between MSC-A and MSC-{I,T} don't need to be routed via E-interface (GSUP), - no call routing between MSC-A and -I via MNCC necessary. This is the largest code bomb I have submitted, ever. Out of principle, I apologize to everyone trying to read this as a whole. Unfortunately, I see no sense in trying to split this patch into smaller bits. It would be a huge amount of work to introduce these changes in separate chunks, especially if each should in turn be useful and pass all test suites. So, unfortunately, we are stuck with this code bomb. The following are some details and rationale for this rather huge refactoring: * separate MSC subscriber management from ran_conn struct ran_conn is reduced from the pivotal subscriber management entity it has been so far to a mere storage for an SCCP connection ID and an MSC subscriber reference. The new pivotal subscriber management entity is struct msc_a -- struct msub lists the msc_a, msc_i, msc_t roles, the vast majority of code paths however use msc_a, since MSC-A is where all the interesting stuff happens. Before handover, msc_i is an FSM implementation that encodes to the local ran_conn. After inter-MSC Handover, msc_i is a compatible but different FSM implementation that instead forwards via/from GSUP. Same goes for the msc_a struct: if osmo-msc is the MSC-I "RAN proxy" for a remote MSC-A role, the msc_a->fi is an FSM implementation that merely forwards via/from GSUP. * New SCCP implementation for RAN access To be able to forward BSSAP and RANAP messages via the GSUP interface, the individual message layers need to be cleanly separated. The IuCS implementation used until now (iu_client from libosmo-ranap) did not provide this level of separation, and needed a complete rewrite. It was trivial to implement this in such a way that both BSSAP and RANAP can be handled by the same SCCP code, hence the new SCCP-RAN layer also replaces BSSAP handling. sccp_ran.h: struct sccp_ran_inst provides an abstract handler for incoming RAN connections. A set of callback functions provides implementation specific details. * RAN Abstraction (BSSAP vs. RANAP) The common SCCP implementation did set the theme for the remaining refactoring: make all other MSC code paths entirely RAN-implementation-agnostic. ran_infra.c provides data structures that list RAN implementation specifics, from logging to RAN de-/encoding to SCCP callbacks and timers. A ran_infra pointer hence allows complete abstraction of RAN implementations: - managing connected RAN peers (BSC, RNC) in ran_peer.c, - classifying and de-/encoding RAN PDUs, - recording connected LACs and cell IDs and sending out Paging requests to matching RAN peers. * RAN RESET now also for RANAP ran_peer.c absorbs the reset_fsm from a_reset.c; in consequence, RANAP also supports proper RESET semantics now. Hence osmo-hnbgw now also needs to provide proper RESET handling, which it so far duly ignores. (TODO) * RAN de-/encoding abstraction The RAN abstraction mentioned above serves not only to separate RANAP and BSSAP implementations transparently, but also to be able to optionally handle RAN on distinct levels. Before Handover, all RAN messages are handled by the MSC-A role. However, after an inter-MSC Handover, a standalone MSC-I will need to decode RAN PDUs, at least in order to manage Assignment of RTP streams between BSS/RNC and MNCC call forwarding. ran_msg.h provides a common API with abstraction for: - receiving events from RAN, i.e. passing RAN decode from the BSC/RNC and MS/UE: struct ran_dec_msg represents RAN messages decoded from either BSSMAP or RANAP; - sending RAN events: ran_enc_msg is the counterpart to compose RAN messages that should be encoded to either BSSMAP or RANAP and passed down to the BSC/RNC and MS/UE. The RAN-specific implementations are completely contained by ran_msg_a.c and ran_msg_iu.c. In particular, Assignment and Ciphering have so far been distinct code paths for BSSAP and RANAP, with switch(via_ran){...} statements all over the place. Using RAN_DEC_* and RAN_ENC_* abstractions, these are now completely unified. Note that SGs does not qualify for RAN abstraction: the SGs interface always remains with the MSC-A role, and SGs messages follow quite distinct semantics from the fairly similar GERAN and UTRAN. * MGW and RTP stream management So far, managing MGW endpoints via MGCP was tightly glued in-between GSM-04.08-CC on the one and MNCC on the other side. Prepare for switching RTP streams between different RAN peers by moving to object-oriented implementations: implement struct call_leg and struct rtp_stream with distinct FSMs each. For MGW communication, use the osmo_mgcpc_ep API that has originated from osmo-bsc and recently moved to libosmo-mgcp-client for this purpose. Instead of implementing a sequence of events with code duplication for the RAN and CN sides, the idea is to manage each RTP stream separately by firing and receiving events as soon as codecs and RTP ports are negotiated, and letting the individual FSMs take care of the MGW management "asynchronously". The caller provides event IDs and an FSM instance that should be notified of RTP stream setup progress. Hence it becomes possible to reconnect RTP streams from one GSM-04.08-CC to another (inter-BSC Handover) or between CC and MNCC RTP peers (inter-MSC Handover) without duplicating the MGCP code for each transition. The number of FSM implementations used for MGCP handling may seem a bit of an overkill. But in fact, the number of perspectives on RTP forwarding are far from trivial: - an MGW endpoint is an entity with N connections, and MGCP "sessions" for configuring them by talking to the MGW; - an RTP stream is a remote peer connected to one of the endpoint's connections, which is asynchronously notified of codec and RTP port choices; - a call leg is the higher level view on either an MT or MO side of a voice call, a combination of two RTP streams to forward between two remote peers. BSC MGW PBX CI CI [MGW-endpoint] [--rtp_stream--] [--rtp_stream--] [----------------call_leg----------------] * Use counts Introduce using the new osmo_use_count API added to libosmocore for this purpose. Each use token has a distinct name in the logging, which can be a globally constant name or ad-hoc, like the local __func__ string constant. Use in the new struct msc_a, as well as change vlr_subscr to the new osmo_use_count API. * FSM Timeouts Introduce using the new osmo_tdef API, which provides a common VTY implementation for all timer numbers, and FSM state transitions with the correct timeout. Originated in osmo-bsc, recently moved to libosmocore. Depends: Ife31e6798b4e728a23913179e346552a7dd338c0 (libosmocore) Ib9af67b100c4583342a2103669732dab2e577b04 (libosmocore) Id617265337f09dfb6ddfe111ef5e578cd3dc9f63 (libosmocore) Ie9e2add7bbfae651c04e230d62e37cebeb91b0f5 (libosmo-sccp) I26be5c4b06a680f25f19797407ab56a5a4880ddc (osmo-mgw) Ida0e59f9a1f2dd18efea0a51680a67b69f141efa (osmo-mgw) I9a3effd38e72841529df6c135c077116981dea36 (osmo-mgw) Change-Id: I27e4988e0371808b512c757d2b52ada1615067bd
2018-12-07 13:47:34 +00:00
/* transfer mode 1 would be packet mode, which was never specified */
if (setup->bearer_cap.mode != 0) {
LOGP(DMNCC, LOGL_NOTICE, "(call %x) We don't support "
"packet mode\n", call->callref);
mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
goto out_reject;
}
/* we currently only do speech */
if (setup->bearer_cap.transfer != GSM_MNCC_BCAP_SPEECH) {
LOGP(DMNCC, LOGL_NOTICE, "(call %x) We only support "
"voice calls\n", call->callref);
mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
goto out_reject;
}
/* create remote call */
if (!(remote = talloc_zero(tall_call_ctx, struct gsm_call))) {
mncc_set_cause(&mncc, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
goto out_reject;
}
llist_add_tail(&remote->entry, &call_list);
remote->net = call->net;
remote->callref = new_callref++;
DEBUGCC(call, remote, "Creating new remote instance.\n");
/* link remote call */
call->remote_ref = remote->callref;
remote->remote_ref = call->callref;
/* send call proceeding */
memset(&mncc, 0, sizeof(struct gsm_mncc));
mncc.callref = call->callref;
mncc.msg_type = MNCC_CALL_PROC_REQ;
DEBUGCC(call, remote, "Accepting call.\n");
mncc_tx_to_cc(call->net, &mncc);
/* modify mode */
memset(&mncc, 0, sizeof(struct gsm_mncc));
mncc.callref = call->callref;
mncc.msg_type = MNCC_LCHAN_MODIFY;
DEBUGCC(call, remote, "Modify channel mode.\n");
mncc_tx_to_cc(call->net, &mncc);
/* send setup to remote */
// setup->fields |= MNCC_F_SIGNAL;
// setup->signal = GSM48_SIGNAL_DIALTONE;
setup->callref = remote->callref;
setup->msg_type = MNCC_SETUP_REQ;
DEBUGCC(call, remote, "Forwarding SETUP to remote.\n");
return mncc_tx_to_cc(remote->net, setup);
out_reject:
mncc.msg_type = MNCC_REJ_REQ;
mncc_tx_to_cc(call->net, &mncc);
free_call(call);
return 0;
}
static int mncc_alert_ind(struct gsm_call *call,
struct gsm_mncc *alert)
{
struct gsm_call *remote;
/* send alerting to remote */
if (!(remote = get_call_ref(call->remote_ref)))
return 0;
alert->callref = remote->callref;
alert->msg_type = MNCC_ALERT_REQ;
DEBUGCC(call, remote, "Forwarding ALERT to remote.\n");
return mncc_tx_to_cc(remote->net, alert);
}
static int mncc_notify_ind(struct gsm_call *call,
struct gsm_mncc *notify)
{
struct gsm_call *remote;
/* send notify to remote */
if (!(remote = get_call_ref(call->remote_ref)))
return 0;
notify->callref = remote->callref;
notify->msg_type = MNCC_NOTIFY_REQ;
DEBUGCC(call, remote, "Forwarding NOTIF to remote.\n");
return mncc_tx_to_cc(remote->net, notify);
}
static int mncc_setup_cnf(struct gsm_call *call,
struct gsm_mncc *connect)
{
struct gsm_mncc connect_ack;
struct gsm_call *remote;
struct gsm_mncc_bridge bridge = { .msg_type = MNCC_BRIDGE };
/* acknowledge connect */
memset(&connect_ack, 0, sizeof(struct gsm_mncc));
connect_ack.msg_type = MNCC_SETUP_COMPL_REQ;
connect_ack.callref = call->callref;
DEBUGP(DMNCC, "(call %x) Acknowledge SETUP.\n", call->callref);
mncc_tx_to_cc(call->net, &connect_ack);
/* send connect message to remote */
if (!(remote = get_call_ref(call->remote_ref)))
return 0;
connect->msg_type = MNCC_SETUP_RSP;
connect->callref = remote->callref;
DEBUGCC(call, remote, "Sending CONNECT to remote.\n");
mncc_tx_to_cc(remote->net, connect);
/* bridge tch */
bridge.msg_type = MNCC_BRIDGE;
bridge.callref[0] = call->callref;
bridge.callref[1] = call->remote_ref;
DEBUGCC(call, remote, "Bridging with remote.\n");
return mncc_tx_to_cc(call->net, &bridge);
}
static int mncc_disc_ind(struct gsm_call *call,
struct gsm_mncc *disc)
{
struct gsm_call *remote;
/* send release */
DEBUGP(DMNCC, "(call %x) Releasing call with cause %d\n",
call->callref, disc->cause.value);
disc->msg_type = MNCC_REL_REQ;
mncc_tx_to_cc(call->net, disc);
/* send disc to remote */
if (!(remote = get_call_ref(call->remote_ref))) {
return 0;
}
disc->msg_type = MNCC_DISC_REQ;
disc->callref = remote->callref;
DEBUGCC(call, remote, "Disconnecting remote with cause %d\n", disc->cause.value);
return mncc_tx_to_cc(remote->net, disc);
}
static int mncc_rel_ind(struct gsm_call *call, struct gsm_mncc *rel)
{
struct gsm_call *remote;
/* send release to remote */
if (!(remote = get_call_ref(call->remote_ref))) {
free_call(call);
return 0;
}
rel->msg_type = MNCC_REL_REQ;
rel->callref = remote->callref;
DEBUGCC(call, remote, "Releasing remote with cause %d\n", rel->cause.value);
/*
* Release this side of the call right now. Otherwise we end up
* in this method for the other call and will also try to release
* it and then we will end up with a double free and a crash
*/
free_call(call);
mncc_tx_to_cc(remote->net, rel);
return 0;
}
static int mncc_rel_cnf(struct gsm_call *call, struct gsm_mncc *rel)
{
free_call(call);
return 0;
}
/* Internal MNCC handler input function (from CC -> MNCC -> here) */
int int_mncc_recv(struct gsm_network *net, struct msgb *msg)
{
void *arg = msgb_data(msg);
struct gsm_mncc *data = arg;
int msg_type = data->msg_type;
int callref;
struct gsm_call *call = NULL, *callt;
int rc = 0;
/* find callref */
callref = data->callref;
llist_for_each_entry(callt, &call_list, entry) {
if (callt->callref == callref) {
call = callt;
break;
}
}
/* create callref, if setup is received */
if (!call) {
if (msg_type != MNCC_SETUP_IND)
goto out_free; /* drop */
/* create call */
if (!(call = talloc_zero(tall_call_ctx, struct gsm_call))) {
struct gsm_mncc rel;
large refactoring: support inter-BSC and inter-MSC Handover 3GPP TS 49.008 '4.3 Roles of MSC-A, MSC-I and MSC-T' defines distinct roles: - MSC-A is responsible for managing subscribers, - MSC-I is the gateway to the RAN. - MSC-T is a second transitory gateway to another RAN during Handover. After inter-MSC Handover, the MSC-I is handled by a remote MSC instance, while the original MSC-A retains the responsibility of subscriber management. MSC-T exists in this patch but is not yet used, since Handover is only prepared for, not yet implemented. Facilitate Inter-MSC and inter-BSC Handover by the same internal split of MSC roles. Compared to inter-MSC Handover, mere inter-BSC has the obvious simplifications: - all of MSC-A, MSC-I and MSC-T roles will be served by the same osmo-msc instance, - messages between MSC-A and MSC-{I,T} don't need to be routed via E-interface (GSUP), - no call routing between MSC-A and -I via MNCC necessary. This is the largest code bomb I have submitted, ever. Out of principle, I apologize to everyone trying to read this as a whole. Unfortunately, I see no sense in trying to split this patch into smaller bits. It would be a huge amount of work to introduce these changes in separate chunks, especially if each should in turn be useful and pass all test suites. So, unfortunately, we are stuck with this code bomb. The following are some details and rationale for this rather huge refactoring: * separate MSC subscriber management from ran_conn struct ran_conn is reduced from the pivotal subscriber management entity it has been so far to a mere storage for an SCCP connection ID and an MSC subscriber reference. The new pivotal subscriber management entity is struct msc_a -- struct msub lists the msc_a, msc_i, msc_t roles, the vast majority of code paths however use msc_a, since MSC-A is where all the interesting stuff happens. Before handover, msc_i is an FSM implementation that encodes to the local ran_conn. After inter-MSC Handover, msc_i is a compatible but different FSM implementation that instead forwards via/from GSUP. Same goes for the msc_a struct: if osmo-msc is the MSC-I "RAN proxy" for a remote MSC-A role, the msc_a->fi is an FSM implementation that merely forwards via/from GSUP. * New SCCP implementation for RAN access To be able to forward BSSAP and RANAP messages via the GSUP interface, the individual message layers need to be cleanly separated. The IuCS implementation used until now (iu_client from libosmo-ranap) did not provide this level of separation, and needed a complete rewrite. It was trivial to implement this in such a way that both BSSAP and RANAP can be handled by the same SCCP code, hence the new SCCP-RAN layer also replaces BSSAP handling. sccp_ran.h: struct sccp_ran_inst provides an abstract handler for incoming RAN connections. A set of callback functions provides implementation specific details. * RAN Abstraction (BSSAP vs. RANAP) The common SCCP implementation did set the theme for the remaining refactoring: make all other MSC code paths entirely RAN-implementation-agnostic. ran_infra.c provides data structures that list RAN implementation specifics, from logging to RAN de-/encoding to SCCP callbacks and timers. A ran_infra pointer hence allows complete abstraction of RAN implementations: - managing connected RAN peers (BSC, RNC) in ran_peer.c, - classifying and de-/encoding RAN PDUs, - recording connected LACs and cell IDs and sending out Paging requests to matching RAN peers. * RAN RESET now also for RANAP ran_peer.c absorbs the reset_fsm from a_reset.c; in consequence, RANAP also supports proper RESET semantics now. Hence osmo-hnbgw now also needs to provide proper RESET handling, which it so far duly ignores. (TODO) * RAN de-/encoding abstraction The RAN abstraction mentioned above serves not only to separate RANAP and BSSAP implementations transparently, but also to be able to optionally handle RAN on distinct levels. Before Handover, all RAN messages are handled by the MSC-A role. However, after an inter-MSC Handover, a standalone MSC-I will need to decode RAN PDUs, at least in order to manage Assignment of RTP streams between BSS/RNC and MNCC call forwarding. ran_msg.h provides a common API with abstraction for: - receiving events from RAN, i.e. passing RAN decode from the BSC/RNC and MS/UE: struct ran_dec_msg represents RAN messages decoded from either BSSMAP or RANAP; - sending RAN events: ran_enc_msg is the counterpart to compose RAN messages that should be encoded to either BSSMAP or RANAP and passed down to the BSC/RNC and MS/UE. The RAN-specific implementations are completely contained by ran_msg_a.c and ran_msg_iu.c. In particular, Assignment and Ciphering have so far been distinct code paths for BSSAP and RANAP, with switch(via_ran){...} statements all over the place. Using RAN_DEC_* and RAN_ENC_* abstractions, these are now completely unified. Note that SGs does not qualify for RAN abstraction: the SGs interface always remains with the MSC-A role, and SGs messages follow quite distinct semantics from the fairly similar GERAN and UTRAN. * MGW and RTP stream management So far, managing MGW endpoints via MGCP was tightly glued in-between GSM-04.08-CC on the one and MNCC on the other side. Prepare for switching RTP streams between different RAN peers by moving to object-oriented implementations: implement struct call_leg and struct rtp_stream with distinct FSMs each. For MGW communication, use the osmo_mgcpc_ep API that has originated from osmo-bsc and recently moved to libosmo-mgcp-client for this purpose. Instead of implementing a sequence of events with code duplication for the RAN and CN sides, the idea is to manage each RTP stream separately by firing and receiving events as soon as codecs and RTP ports are negotiated, and letting the individual FSMs take care of the MGW management "asynchronously". The caller provides event IDs and an FSM instance that should be notified of RTP stream setup progress. Hence it becomes possible to reconnect RTP streams from one GSM-04.08-CC to another (inter-BSC Handover) or between CC and MNCC RTP peers (inter-MSC Handover) without duplicating the MGCP code for each transition. The number of FSM implementations used for MGCP handling may seem a bit of an overkill. But in fact, the number of perspectives on RTP forwarding are far from trivial: - an MGW endpoint is an entity with N connections, and MGCP "sessions" for configuring them by talking to the MGW; - an RTP stream is a remote peer connected to one of the endpoint's connections, which is asynchronously notified of codec and RTP port choices; - a call leg is the higher level view on either an MT or MO side of a voice call, a combination of two RTP streams to forward between two remote peers. BSC MGW PBX CI CI [MGW-endpoint] [--rtp_stream--] [--rtp_stream--] [----------------call_leg----------------] * Use counts Introduce using the new osmo_use_count API added to libosmocore for this purpose. Each use token has a distinct name in the logging, which can be a globally constant name or ad-hoc, like the local __func__ string constant. Use in the new struct msc_a, as well as change vlr_subscr to the new osmo_use_count API. * FSM Timeouts Introduce using the new osmo_tdef API, which provides a common VTY implementation for all timer numbers, and FSM state transitions with the correct timeout. Originated in osmo-bsc, recently moved to libosmocore. Depends: Ife31e6798b4e728a23913179e346552a7dd338c0 (libosmocore) Ib9af67b100c4583342a2103669732dab2e577b04 (libosmocore) Id617265337f09dfb6ddfe111ef5e578cd3dc9f63 (libosmocore) Ie9e2add7bbfae651c04e230d62e37cebeb91b0f5 (libosmo-sccp) I26be5c4b06a680f25f19797407ab56a5a4880ddc (osmo-mgw) Ida0e59f9a1f2dd18efea0a51680a67b69f141efa (osmo-mgw) I9a3effd38e72841529df6c135c077116981dea36 (osmo-mgw) Change-Id: I27e4988e0371808b512c757d2b52ada1615067bd
2018-12-07 13:47:34 +00:00
memset(&rel, 0, sizeof(struct gsm_mncc));
rel.msg_type = MNCC_REL_REQ;
rel.callref = callref;
mncc_set_cause(&rel, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
mncc_tx_to_cc(net, &rel);
goto out_free;
}
llist_add_tail(&call->entry, &call_list);
call->net = net;
call->callref = callref;
DEBUGP(DMNCC, "(call %x) Call created.\n", call->callref);
}
if (mncc_is_data_frame(msg_type)) {
mscsplit: various preparations to separate MSC from BSC Disable large parts of the code that depend on BSC presence. The code sections disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of adding the A-interface. Don't set msg->lchan nor msg->dst. Don't use lchan in libmsc. Decouple lac from bts. Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication: Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to different interfaces depending on the actual subscriber connection. While iu_tx() is going to be functional fairly soon, the a_tx() is going to be just a dummy for some time (see comment). Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer and an indicator for the Integrity Protection status on Iu (to be fully implemented in later commits). Add lac member to gsm_subscriber_connection, to allow decoupling from bts->location_area_code. The conn->lac will actually be set in iu.c in an upcoming commit ("add iucs.[hc]"). move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi(). libmsc: duplicate gsm0808 / gsm48 functions (towards BSC). In osmo-nitb, libmsc would directly call the functions on the BSC level, not always via the bsc_api. When separating libmsc from libbsc, some functions are missing from the linkage. Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also add a _tx to gsm0808_cipher_mode(): * add msc_gsm0808_tx_cipher_mode() (dummy/stub) * add msc_gsm48_tx_mm_serv_ack() * add msc_gsm48_tx_mm_serv_rej() Call these from libmsc instead of * gsm0808_cipher_mode() * gsm48_tx_mm_serv_ack() * gsm48_tx_mm_serv_rej() Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places. Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC, this will be done with an external MGCP gateway. Remove LCHAN_MODIFY from internal MNCC state machine. Temporarily disable all paging to be able to link libmsc without libbsc. Skip the paging part of channel_test because the paging is now disabled. Employ fake paging shims in order for msc_vlr_tests to still work. msc_compl_l3(): publish in .h, tweak return value. Use new libmsc enum values for return val, to avoid dependency on libbsc headers. Make callable from other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c add gsm_encr to subscr_conn move subscr_request to gsm_subscriber.h subscr_request_channel() -> subscr_request_conn() move to libmsc: osmo_stats_vty_add_cmds() gsm_04_08: remove apply_codec_restrictions() gsm0408_test: use NULL for root ctx move to libbsc: gsm_bts_neighbor() move to libbsc: lchan_next_meas_rep() move vty config for t3212 to network level (periodic lu) remove unneccessary linking from some tests remove handle_abisip_signal() abis_rsl.c: don't use libvlr from libbsc gsm_subscriber_connection: put the LAC here, so that it is available without accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of transition: Iu and A will use this new field to pass the LAC around, but in a completely separate OsmoBSC this is not actually needed. It can be removed again from osmo-bsc.git when the time has come. Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall be added in osmo-bsc once the A-Interface code has settled. See OS#2389. Related: OS#1845 OS#2257 OS#2389 Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-05-08 13:12:20 +00:00
LOGP(DMNCC, LOGL_ERROR, "(call %x) Received data frame, which is not supported.\n",
call->callref);
goto out_free;
}
DEBUGP(DMNCC, "(call %x) Received message %s\n", call->callref,
get_mncc_name(msg_type));
switch (msg_type) {
case MNCC_SETUP_IND:
rc = mncc_setup_ind(call, arg);
break;
case MNCC_SETUP_CNF:
rc = mncc_setup_cnf(call, arg);
break;
case MNCC_SETUP_COMPL_IND:
break;
case MNCC_CALL_CONF_IND:
/* we now need to MODIFY the channel */
data->msg_type = MNCC_LCHAN_MODIFY;
mncc_tx_to_cc(call->net, data);
break;
case MNCC_ALERT_IND:
rc = mncc_alert_ind(call, arg);
break;
case MNCC_NOTIFY_IND:
rc = mncc_notify_ind(call, arg);
break;
case MNCC_DISC_IND:
rc = mncc_disc_ind(call, arg);
break;
case MNCC_REL_IND:
case MNCC_REJ_IND:
rc = mncc_rel_ind(call, arg);
break;
case MNCC_REL_CNF:
rc = mncc_rel_cnf(call, arg);
break;
case MNCC_FACILITY_IND:
break;
case MNCC_START_DTMF_IND:
data->msg_type = MNCC_START_DTMF_REJ;
rc = mncc_tx_to_cc(net, data);
break;
case MNCC_STOP_DTMF_IND:
data->msg_type = MNCC_STOP_DTMF_RSP;
rc = mncc_tx_to_cc(net, data);
break;
case MNCC_MODIFY_IND:
mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
DEBUGP(DMNCC, "(call %x) Rejecting MODIFY with cause %d\n",
call->callref, data->cause.value);
data->msg_type = MNCC_MODIFY_REJ;
rc = mncc_tx_to_cc(net, data);
break;
case MNCC_MODIFY_CNF:
break;
case MNCC_HOLD_IND:
mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
DEBUGP(DMNCC, "(call %x) Rejecting HOLD with cause %d\n",
call->callref, data->cause.value);
data->msg_type = MNCC_HOLD_REJ;
rc = mncc_tx_to_cc(net, data);
break;
case MNCC_RETRIEVE_IND:
mncc_set_cause(data, GSM48_CAUSE_LOC_PRN_S_LU,
GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
DEBUGP(DMNCC, "(call %x) Rejecting RETRIEVE with cause %d\n",
call->callref, data->cause.value);
data->msg_type = MNCC_RETRIEVE_REJ;
rc = mncc_tx_to_cc(net, data);
break;
default:
LOGP(DMNCC, LOGL_NOTICE, "(call %x) Message '%s' unhandled\n",
callref, get_mncc_name(msg_type));
break;
}
out_free:
msgb_free(msg);
return rc;
}