blob: c016474c9c3b4e8ed9b6bbacd86d34a2efb0efba [file] [log] [blame]
Neels Hofmeyr84da6b12016-05-20 21:59:55 +02001/* Implementation of RANAP messages to/from an MSC via an Iu-CS interface.
2 * This keeps direct RANAP dependencies out of libmsc. */
3
4/* (C) 2016 by sysmocom s.m.f.c. GmbH <info@sysmocom.de>
5 *
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#include "../../bscconfig.h"
24
25#ifdef BUILD_IU
26
27#include <osmocom/core/logging.h>
28
29#include <osmocom/ranap/ranap_ies_defs.h>
30
31#include <openbsc/debug.h>
32#include <openbsc/gsm_data.h>
33#include <openbsc/gsm_subscriber.h>
34#include <openbsc/iu.h>
35#include <openbsc/iucs.h>
36#include <openbsc/vlr.h>
37#include <openbsc/iucs_ranap.h>
38#include <openbsc/osmo_msc.h>
39
40/* To continue authorization after a Security Mode Complete */
41int gsm0408_authorize(struct gsm_subscriber_connection *conn);
42
43static int iucs_rx_rab_assign(struct gsm_subscriber_connection *conn,
44 RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies)
45{
46 uint8_t rab_id;
47 RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem;
48
49 rab_id = item->rAB_ID.buf[0];
50
51 LOGP(DIUCS, LOGL_NOTICE,
52 "Received RAB assignment event for %s rab_id=%hhd\n",
53 vlr_subscr_name(conn->vsub), rab_id);
54
55 return 0;
56}
57
58int iucs_rx_sec_mode_compl(struct gsm_subscriber_connection *conn,
59 RANAP_SecurityModeCompleteIEs_t *ies)
60{
61 OSMO_ASSERT(conn->via_ran == RAN_UTRAN_IU);
62
63 /* TODO evalute ies */
64
65 msc_rx_sec_mode_compl(conn);
66 return 0;
67}
68
69int iucs_rx_ranap_event(struct gsm_network *network,
70 struct ue_conn_ctx *ue_ctx, int type, void *data)
71{
72 struct gsm_subscriber_connection *conn;
73
74 conn = subscr_conn_lookup_iu(network, ue_ctx);
75
76 if (!conn) {
77 LOGP(DRANAP, LOGL_ERROR, "Cannot find subscriber for IU event %u\n", type);
78 return -1;
79 }
80
81 switch (type) {
82 case IU_EVENT_IU_RELEASE:
83 case IU_EVENT_LINK_INVALIDATED:
84 LOGP(DIUCS, LOGL_INFO, "IuCS release for %s\n",
85 vlr_subscr_name(conn->vsub));
86 msc_subscr_conn_close(conn, 0);
87 return 0;
88
89 case IU_EVENT_SECURITY_MODE_COMPLETE:
90 LOGP(DIUCS, LOGL_INFO, "IuCS security mode complete for %s\n",
91 vlr_subscr_name(conn->vsub));
92 return iucs_rx_sec_mode_compl(conn,
93 (RANAP_SecurityModeCompleteIEs_t*)data);
94 case IU_EVENT_RAB_ASSIGN:
95 return iucs_rx_rab_assign(conn,
96 (RANAP_RAB_SetupOrModifiedItemIEs_t*)data);
97 default:
98 LOGP(DIUCS, LOGL_NOTICE, "Unknown message received:"
99 " RANAP event: %i\n", type);
100 return -1;
101 }
102}
103
104#endif /* BUILD_IU */