Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 1 | /* 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> |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 30 | #include <osmocom/ranap/iu_client.h> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 31 | |
| 32 | #include <openbsc/debug.h> |
| 33 | #include <openbsc/gsm_data.h> |
| 34 | #include <openbsc/gsm_subscriber.h> |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 */ |
| 41 | int gsm0408_authorize(struct gsm_subscriber_connection *conn); |
| 42 | |
| 43 | static 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 | |
| 58 | int 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 | |
| 69 | int iucs_rx_ranap_event(struct gsm_network *network, |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 70 | struct ranap_ue_conn_ctx *ue_ctx, int type, void *data) |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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) { |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 82 | case RANAP_IU_EVENT_IU_RELEASE: |
| 83 | case RANAP_IU_EVENT_LINK_INVALIDATED: |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 | |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 89 | case RANAP_IU_EVENT_SECURITY_MODE_COMPLETE: |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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); |
Neels Hofmeyr | 00e82d6 | 2017-07-05 15:19:52 +0200 | [diff] [blame] | 94 | case RANAP_IU_EVENT_RAB_ASSIGN: |
Neels Hofmeyr | 84da6b1 | 2016-05-20 21:59:55 +0200 | [diff] [blame] | 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 */ |