2016-05-20 19:59:55 +00:00
|
|
|
/* Implementation of RANAP messages to/from an MSC via an Iu-CS interface.
|
|
|
|
* This keeps direct RANAP dependencies out of libmsc. */
|
|
|
|
|
|
|
|
/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
|
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* 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
|
|
|
|
* (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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../bscconfig.h"
|
|
|
|
|
|
|
|
#ifdef BUILD_IU
|
|
|
|
|
|
|
|
#include <osmocom/core/logging.h>
|
|
|
|
|
|
|
|
#include <osmocom/ranap/ranap_ies_defs.h>
|
2017-07-05 13:19:52 +00:00
|
|
|
#include <osmocom/ranap/iu_client.h>
|
2017-11-07 16:19:25 +00:00
|
|
|
#include <osmocom/ranap/RANAP_IuTransportAssociation.h>
|
|
|
|
#include <osmocom/ranap/iu_helpers.h>
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-09-04 13:04:35 +00:00
|
|
|
#include <osmocom/msc/debug.h>
|
|
|
|
#include <osmocom/msc/gsm_data.h>
|
|
|
|
#include <osmocom/msc/gsm_subscriber.h>
|
|
|
|
#include <osmocom/msc/iucs.h>
|
|
|
|
#include <osmocom/msc/vlr.h>
|
|
|
|
#include <osmocom/msc/iucs_ranap.h>
|
|
|
|
#include <osmocom/msc/osmo_msc.h>
|
2017-11-07 16:19:25 +00:00
|
|
|
#include <osmocom/msc/msc_mgcp.h>
|
|
|
|
|
|
|
|
#include <asn1c/asn1helpers.h>
|
2016-05-20 19:59:55 +00:00
|
|
|
|
|
|
|
/* To continue authorization after a Security Mode Complete */
|
|
|
|
int gsm0408_authorize(struct gsm_subscriber_connection *conn);
|
|
|
|
|
2017-11-07 16:19:25 +00:00
|
|
|
static int iucs_rx_rab_assign(struct gsm_subscriber_connection *conn, RANAP_RAB_SetupOrModifiedItemIEs_t * setup_ies)
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
|
|
|
uint8_t rab_id;
|
|
|
|
RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem;
|
2017-11-07 16:19:25 +00:00
|
|
|
RANAP_TransportLayerAddress_t *transp_layer_addr;
|
|
|
|
RANAP_IuTransportAssociation_t *transp_assoc;
|
|
|
|
uint16_t port = 0;
|
|
|
|
int rc;
|
|
|
|
char addr[INET_ADDRSTRLEN];
|
2016-05-20 19:59:55 +00:00
|
|
|
|
|
|
|
rab_id = item->rAB_ID.buf[0];
|
|
|
|
|
|
|
|
LOGP(DIUCS, LOGL_NOTICE,
|
2017-11-07 16:19:25 +00:00
|
|
|
"Received RAB assignment event for %s rab_id=%hhd\n", vlr_subscr_name(conn->vsub), rab_id);
|
|
|
|
|
|
|
|
if (item->iuTransportAssociation && item->transportLayerAddress) {
|
|
|
|
transp_layer_addr = item->transportLayerAddress;
|
|
|
|
transp_assoc = item->iuTransportAssociation;
|
|
|
|
|
|
|
|
rc = ranap_transp_assoc_decode(&port, transp_assoc);
|
|
|
|
if (rc != 0) {
|
|
|
|
LOGP(DIUCS, LOGL_ERROR,
|
|
|
|
"Unable to decode RTP port in RAB assignment (%s rab_id=%hhd)\n",
|
|
|
|
vlr_subscr_name(conn->vsub), rab_id);
|
|
|
|
return 0;
|
|
|
|
}
|
2016-05-20 19:59:55 +00:00
|
|
|
|
2017-11-07 16:19:25 +00:00
|
|
|
rc = ranap_transp_layer_addr_decode(addr, sizeof(addr), transp_layer_addr);
|
|
|
|
if (rc != 0) {
|
|
|
|
LOGP(DIUCS, LOGL_ERROR,
|
|
|
|
"Unable to decode IP-Address in RAB assignment (%s rab_id=%hhd)\n",
|
|
|
|
vlr_subscr_name(conn->vsub), rab_id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return msc_mgcp_ass_complete(conn, port, addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
LOGP(DIUCS, LOGL_ERROR,
|
|
|
|
"RAB assignment lacks RTP connection information. (%s rab_id=%hhd)\n",
|
|
|
|
vlr_subscr_name(conn->vsub), rab_id);
|
2016-05-20 19:59:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iucs_rx_sec_mode_compl(struct gsm_subscriber_connection *conn,
|
|
|
|
RANAP_SecurityModeCompleteIEs_t *ies)
|
|
|
|
{
|
|
|
|
OSMO_ASSERT(conn->via_ran == RAN_UTRAN_IU);
|
|
|
|
|
|
|
|
/* TODO evalute ies */
|
|
|
|
|
|
|
|
msc_rx_sec_mode_compl(conn);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int iucs_rx_ranap_event(struct gsm_network *network,
|
2017-07-05 13:19:52 +00:00
|
|
|
struct ranap_ue_conn_ctx *ue_ctx, int type, void *data)
|
2016-05-20 19:59:55 +00:00
|
|
|
{
|
|
|
|
struct gsm_subscriber_connection *conn;
|
|
|
|
|
|
|
|
conn = subscr_conn_lookup_iu(network, ue_ctx);
|
|
|
|
|
|
|
|
if (!conn) {
|
|
|
|
LOGP(DRANAP, LOGL_ERROR, "Cannot find subscriber for IU event %u\n", type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
2017-07-05 13:19:52 +00:00
|
|
|
case RANAP_IU_EVENT_IU_RELEASE:
|
|
|
|
case RANAP_IU_EVENT_LINK_INVALIDATED:
|
2016-05-20 19:59:55 +00:00
|
|
|
LOGP(DIUCS, LOGL_INFO, "IuCS release for %s\n",
|
|
|
|
vlr_subscr_name(conn->vsub));
|
2018-04-01 18:55:54 +00:00
|
|
|
msc_subscr_conn_rx_iu_release_complete(conn);
|
2016-05-20 19:59:55 +00:00
|
|
|
return 0;
|
|
|
|
|
2017-07-05 13:19:52 +00:00
|
|
|
case RANAP_IU_EVENT_SECURITY_MODE_COMPLETE:
|
2016-05-20 19:59:55 +00:00
|
|
|
LOGP(DIUCS, LOGL_INFO, "IuCS security mode complete for %s\n",
|
|
|
|
vlr_subscr_name(conn->vsub));
|
|
|
|
return iucs_rx_sec_mode_compl(conn,
|
|
|
|
(RANAP_SecurityModeCompleteIEs_t*)data);
|
2017-07-05 13:19:52 +00:00
|
|
|
case RANAP_IU_EVENT_RAB_ASSIGN:
|
2016-05-20 19:59:55 +00:00
|
|
|
return iucs_rx_rab_assign(conn,
|
|
|
|
(RANAP_RAB_SetupOrModifiedItemIEs_t*)data);
|
|
|
|
default:
|
|
|
|
LOGP(DIUCS, LOGL_NOTICE, "Unknown message received:"
|
|
|
|
" RANAP event: %i\n", type);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* BUILD_IU */
|