From c332a4e49d0468b1caa13311639fd4f2bb33534b Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Sat, 4 Mar 2017 01:29:03 +0100 Subject: move iucs_ranap.[hc] to include / libmsc to use in msc_vlr tests Change-Id: I99ca36857f5e4c9ae113017955611fd92256123c --- openbsc/include/openbsc/Makefile.am | 1 + openbsc/include/openbsc/iucs_ranap.h | 7 ++ openbsc/src/libmsc/Makefile.am | 2 + openbsc/src/libmsc/iucs_ranap.c | 119 ++++++++++++++++++++++++++++++++++ openbsc/src/osmo-msc/Makefile.am | 5 -- openbsc/src/osmo-msc/iucs_ranap.c | 120 ----------------------------------- openbsc/src/osmo-msc/iucs_ranap.h | 6 -- openbsc/src/osmo-msc/msc_main.c | 3 +- 8 files changed, 130 insertions(+), 133 deletions(-) create mode 100644 openbsc/include/openbsc/iucs_ranap.h create mode 100644 openbsc/src/libmsc/iucs_ranap.c delete mode 100644 openbsc/src/osmo-msc/iucs_ranap.c delete mode 100644 openbsc/src/osmo-msc/iucs_ranap.h diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 704696659..14396b74a 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -48,6 +48,7 @@ noinst_HEADERS = \ ipaccess.h \ iu.h \ iucs.h \ + iucs_ranap.h \ meas_feed.h \ meas_rep.h \ mgcp.h \ diff --git a/openbsc/include/openbsc/iucs_ranap.h b/openbsc/include/openbsc/iucs_ranap.h new file mode 100644 index 000000000..748de23d7 --- /dev/null +++ b/openbsc/include/openbsc/iucs_ranap.h @@ -0,0 +1,7 @@ +#pragma once + +struct gsm_network; +struct ue_conn_ctx; + +int iucs_rx_ranap_event(struct gsm_network *network, + struct ue_conn_ctx *ue_ctx, int type, void *data); diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index 9e13ca5af..a320f7d28 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -12,6 +12,7 @@ AM_CFLAGS = \ $(COVERAGE_CFLAGS) \ $(LIBCRYPTO_CFLAGS) \ $(LIBSMPP34_CFLAGS) \ + $(LIBASN1C_CFLAGS) \ $(NULL) noinst_HEADERS = \ @@ -32,6 +33,7 @@ libmsc_a_SOURCES = \ gsm_04_80.c \ gsm_subscriber.c \ iucs.c \ + iucs_ranap.c \ mncc.c \ mncc_builtin.c \ mncc_sock.c \ diff --git a/openbsc/src/libmsc/iucs_ranap.c b/openbsc/src/libmsc/iucs_ranap.c new file mode 100644 index 000000000..b16eebc47 --- /dev/null +++ b/openbsc/src/libmsc/iucs_ranap.c @@ -0,0 +1,119 @@ +/* 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 + * + * 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 . + * + */ + + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +/* To continue authorization after a Security Mode Complete */ +int gsm0408_authorize(struct gsm_subscriber_connection *conn); + +static int iucs_rx_rab_assign(struct gsm_subscriber_connection *conn, + RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies) +{ + uint8_t rab_id; + RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem; + + rab_id = item->rAB_ID.buf[0]; + + LOGP(DIUCS, LOGL_NOTICE, + "Received RAB assignment event for %s rab_id=%hhd\n", + vlr_subscr_name(conn->vsub), rab_id); + + return 0; +} + +int iucs_rx_sec_mode_compl(struct gsm_subscriber_connection *conn, + RANAP_SecurityModeCompleteIEs_t *ies) +{ + gsm_cbfn *cb; + + OSMO_ASSERT(conn->via_ran == RAN_UTRAN_IU); + + if (!conn->sec_operation) { + LOGP(DIUCS, LOGL_ERROR, + "Received Security Mode Complete message, but no" + " authentication/cipher operation in progress" + " for subscr %s\n", vlr_subscr_name(conn->vsub)); + return -EINVAL; + } + + /* TODO evalute ies */ + + if (conn->iu.integrity_protection) + LOGP(DIUCS, LOGL_NOTICE, "Integrity Protection" + " was already enabled for %s\n", + vlr_subscr_name(conn->vsub)); + + conn->iu.integrity_protection = INTEGRITY_PROTECTION_IK; + + cb = conn->sec_operation->cb; + if (cb) + cb(GSM_HOOK_RR_SECURITY, GSM_SECURITY_SUCCEEDED, NULL, + conn, conn->sec_operation->cb_data); + release_security_operation(conn); + return 0; +} + +int iucs_rx_ranap_event(struct gsm_network *network, + struct ue_conn_ctx *ue_ctx, int type, void *data) +{ + 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) { + case IU_EVENT_IU_RELEASE: + case IU_EVENT_LINK_INVALIDATED: + LOGP(DIUCS, LOGL_INFO, "IuCS release for %s\n", + vlr_subscr_name(conn->vsub)); + gsm0408_clear_request(conn, 0); + return 0; + + case IU_EVENT_SECURITY_MODE_COMPLETE: + 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); + case IU_EVENT_RAB_ASSIGN: + 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; + } +} diff --git a/openbsc/src/osmo-msc/Makefile.am b/openbsc/src/osmo-msc/Makefile.am index a606b58f6..1e6a35b86 100644 --- a/openbsc/src/osmo-msc/Makefile.am +++ b/openbsc/src/osmo-msc/Makefile.am @@ -27,13 +27,8 @@ bin_PROGRAMS = \ osmo-msc \ $(NULL) -noinst_HEADERS = \ - iucs_ranap.h \ - $(NULL) - osmo_msc_SOURCES = \ msc_main.c \ - iucs_ranap.c \ $(NULL) osmo_msc_LDADD = \ diff --git a/openbsc/src/osmo-msc/iucs_ranap.c b/openbsc/src/osmo-msc/iucs_ranap.c deleted file mode 100644 index 09b81489b..000000000 --- a/openbsc/src/osmo-msc/iucs_ranap.c +++ /dev/null @@ -1,120 +0,0 @@ -/* 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 - * - * 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 . - * - */ - - -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include "iucs_ranap.h" - -/* To continue authorization after a Security Mode Complete */ -int gsm0408_authorize(struct gsm_subscriber_connection *conn); - -static int iucs_rx_rab_assign(struct gsm_subscriber_connection *conn, - RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies) -{ - uint8_t rab_id; - RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem; - - rab_id = item->rAB_ID.buf[0]; - - LOGP(DIUCS, LOGL_NOTICE, - "Received RAB assignment event for %s rab_id=%hhd\n", - vlr_subscr_name(conn->vsub), rab_id); - - return 0; -} - -int iucs_rx_sec_mode_compl(struct gsm_subscriber_connection *conn, - RANAP_SecurityModeCompleteIEs_t *ies) -{ - gsm_cbfn *cb; - - OSMO_ASSERT(conn->via_ran == RAN_UTRAN_IU); - - if (!conn->sec_operation) { - LOGP(DIUCS, LOGL_ERROR, - "Received Security Mode Complete message, but no" - " authentication/cipher operation in progress" - " for subscr %s\n", vlr_subscr_name(conn->vsub)); - return -EINVAL; - } - - /* TODO evalute ies */ - - if (conn->iu.integrity_protection) - LOGP(DIUCS, LOGL_NOTICE, "Integrity Protection" - " was already enabled for %s\n", - vlr_subscr_name(conn->vsub)); - - conn->iu.integrity_protection = INTEGRITY_PROTECTION_IK; - - cb = conn->sec_operation->cb; - if (cb) - cb(GSM_HOOK_RR_SECURITY, GSM_SECURITY_SUCCEEDED, NULL, - conn, conn->sec_operation->cb_data); - release_security_operation(conn); - return 0; -} - -int iucs_rx_ranap_event(struct gsm_network *network, - struct ue_conn_ctx *ue_ctx, int type, void *data) -{ - 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) { - case IU_EVENT_IU_RELEASE: - case IU_EVENT_LINK_INVALIDATED: - LOGP(DIUCS, LOGL_INFO, "IuCS release for %s\n", - vlr_subscr_name(conn->vsub)); - gsm0408_clear_request(conn, 0); - return 0; - - case IU_EVENT_SECURITY_MODE_COMPLETE: - 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); - case IU_EVENT_RAB_ASSIGN: - 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; - } -} diff --git a/openbsc/src/osmo-msc/iucs_ranap.h b/openbsc/src/osmo-msc/iucs_ranap.h deleted file mode 100644 index 0aa1ee95a..000000000 --- a/openbsc/src/osmo-msc/iucs_ranap.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -struct ue_conn_ctx; - -int iucs_rx_ranap_event(struct gsm_network *network, - struct ue_conn_ctx *ue_ctx, int type, void *data); diff --git a/openbsc/src/osmo-msc/msc_main.c b/openbsc/src/osmo-msc/msc_main.c index b676168a6..b79f1617a 100644 --- a/openbsc/src/osmo-msc/msc_main.c +++ b/openbsc/src/osmo-msc/msc_main.c @@ -71,8 +71,7 @@ #include #include #include - -#include "iucs_ranap.h" +#include static const char * const osmomsc_copyright = "OsmoMSC - Osmocom Circuit-Switched Core Network implementation\r\n" -- cgit v1.2.3