diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-02-12 14:28:11 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-03 16:19:10 +0100 |
commit | 23e7f28c5c77a57aad5331c5e27b29e2eccfe7c3 (patch) | |
tree | fcef687b7a5207016fed467a5d6d188885515ae5 /openbsc/src/libmsc | |
parent | 243c7cb044c489b62d3cd4ad3631822d270989a8 (diff) |
mscsplit: getting grips on header scopes
Diffstat (limited to 'openbsc/src/libmsc')
-rw-r--r-- | openbsc/src/libmsc/Makefile.am | 2 | ||||
-rw-r--r-- | openbsc/src/libmsc/iu_cs.c | 8 | ||||
-rw-r--r-- | openbsc/src/libmsc/msc_api.c | 51 | ||||
-rw-r--r-- | openbsc/src/libmsc/msc_api.h | 17 | ||||
-rw-r--r-- | openbsc/src/libmsc/msc_ifaces.c | 50 | ||||
-rw-r--r-- | openbsc/src/libmsc/osmo_msc.c | 23 |
6 files changed, 107 insertions, 44 deletions
diff --git a/openbsc/src/libmsc/Makefile.am b/openbsc/src/libmsc/Makefile.am index 18314a386..fbbcbdc77 100644 --- a/openbsc/src/libmsc/Makefile.am +++ b/openbsc/src/libmsc/Makefile.am @@ -21,7 +21,7 @@ libmsc_a_SOURCES = auth.c \ vty_interface_layer3.c \ transaction.c \ osmo_msc.c ctrl_commands.c meas_feed.c \ - msc_api.c iu_cs.c + msc_api.c msc_ifaces.c iu_cs.c if BUILD_SMPP noinst_HEADERS += smpp_smsc.h diff --git a/openbsc/src/libmsc/iu_cs.c b/openbsc/src/libmsc/iu_cs.c index 289fe1410..b0426e82c 100644 --- a/openbsc/src/libmsc/iu_cs.c +++ b/openbsc/src/libmsc/iu_cs.c @@ -109,11 +109,3 @@ int gsm0408_rcvmsg_iucs(struct gsm_network *network, struct msgb *msg) } -int iucs_submit_dtap(struct gsm_subscriber_connection *conn, - struct msgb *msg) -{ - OSMO_ASSERT(conn->via_iface == IFACE_IU); - msg->dst = conn->iu.ue_ctx; - return iu_tx(msg, 0); -} - diff --git a/openbsc/src/libmsc/msc_api.c b/openbsc/src/libmsc/msc_api.c new file mode 100644 index 000000000..e896b24c9 --- /dev/null +++ b/openbsc/src/libmsc/msc_api.c @@ -0,0 +1,51 @@ +/* Implementations for receiving or sending MM|CC|... messages from/to the + * BSC|RNC direction, regardless of which particular external interface is + * actually involved (A or IuCS). */ + +/* (C) 2016 by sysmocom s.m.f.c GmbH <info@sysmocom.de> + * + * Based on parts of osmo_msc.c: + * (C) 2010,2013 by Holger Hans Peter Freyther <zecke@selfish.org> + * (C) 2010 by On-Waves + * + * 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 <openbsc/msc_api.h> +#include <openbsc/gsm_data.h> + +int msc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, + uint16_t chosen_channel) +{ + gsm0408_new_conn(conn); + gsm0408_dispatch(conn, msg); + + /* + * If this is a silent call we want the channel to remain open as long as + * possible and this is why we accept this connection regardless of any + * pending transaction or ongoing operation. + */ + if (conn->silent_call) + return MSC_CONN_ACCEPT; + if (conn->loc_operation || conn->sec_operation || conn->anch_operation) + return MSC_CONN_ACCEPT; + if (trans_has_conn(conn)) + return MSC_CONN_ACCEPT; + + LOGP(DRR, LOGL_INFO, "MSC Complete L3: Rejecting connection.\n"); + return MSC_CONN_REJECT; +} + diff --git a/openbsc/src/libmsc/msc_api.h b/openbsc/src/libmsc/msc_api.h index 4b4d32501..e3459a6ae 100644 --- a/openbsc/src/libmsc/msc_api.h +++ b/openbsc/src/libmsc/msc_api.h @@ -2,9 +2,22 @@ /* These functions receive or send MM|CC|... messages from/to the BSC|RNC * direction, while they are not concerned with which particular external - * interface is actually involved (A or IuCS). */ + * interface is actually involved (A or IuCS). + * + * For the interface specific decisions see msc_iface.[hc] */ -/* receive a Level 3 Complete message */ +#include <stdint.h> + +struct gsm_subscriber_connection; +struct msgb; + +enum { + MSC_CONN_ACCEPT = 0, + MSC_CONN_REJECT = 1, +}; + +/* receive a Level 3 Complete message and return MSC_CONN_ACCEPT or + * MSC_CONN_REJECT */ int msc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel); /* TODO: is chosen_channel NITB legacy? */ diff --git a/openbsc/src/libmsc/msc_ifaces.c b/openbsc/src/libmsc/msc_ifaces.c index f50ab3275..88100926d 100644 --- a/openbsc/src/libmsc/msc_ifaces.c +++ b/openbsc/src/libmsc/msc_ifaces.c @@ -1,4 +1,4 @@ -/* MSC decisions which interface to send messages out on. */ +/* Implementation for MSC decisions which interface to send messages out on. */ /* (C) 2016 by sysmocom s.m.f.c GmbH <info@sysmocom.de> * @@ -16,35 +16,63 @@ * * 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 <osmocom/core/logging.h> #include <openbsc/debug.h> #include <openbsc/gsm_data.h> -#include <openbsc/iu_cs.h> +#include <openbsc/msc_ifaces.h> + +static int tx_dummy_a(struct msgb *msg, uint8_t sapi) +{ + LOGP(DMSC, LOGL_ERROR, + "attempt to send message via uninitialized A-interface\n"); + return -1 +} + +static int tx_dummy_iu_cs(struct msgb *msg, uint8_t sapi) +{ + LOGP(DMSC, LOGL_ERROR, + "attempt to send message via uninitialized IuCS-interface\n"); + return -1 +} + +struct msc_ifaces *global_msc_ifaces = { + .a = { + .tx = tx_dummy_a, + }, + .iu_cs = { + .tx = tx_dummy_iu_cs, + } +}; -#include "msc_api.h" -int msc_submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg) +static int msc_tx(struct msc_ifaces *ifaces, + struct gsm_subscriber_connection *conn, + struct msgb *msg) { switch (conn->via_iface) { case IFACE_A: - //return gsm0808_submit_dtap(conn, msg, link_id, allow_sacch); - LOGP(DMSC, LOGL_ERROR, - "submit dtap: A-interface not implemented\n"); - return -1; + /* TODO: msg->dst = <A-iface token> */ + return ifaces->a.tx(msg, 0); case IFACE_IUCS: - return iucs_submit_dtap(conn, msg); + msg->dst = conn->iu.ue_ctx; + return ifaces->iu_cs.tx(msg, 0); default: LOGP(DMSC, LOGL_ERROR, - "submit dtap: conn->via_iface invalid (%d)\n", + "msc_tx(): conn->via_iface invalid (%d)\n", conn->via_iface); return -1; } } +int msc_tx_dtap(struct gsm_subscriber_connection *conn, + struct msgb *msg) +{ + msc_tx(global_msc_ifaces, conn, msg); +} + diff --git a/openbsc/src/libmsc/osmo_msc.c b/openbsc/src/libmsc/osmo_msc.c index 7f9dabb1b..8618b00f7 100644 --- a/openbsc/src/libmsc/osmo_msc.c +++ b/openbsc/src/libmsc/osmo_msc.c @@ -26,6 +26,7 @@ #include <openbsc/transaction.h> #include <openbsc/db.h> +#include <openbsc/msc_api.h> #include <openbsc/gsm_04_11.h> static void msc_sapi_n_reject(struct gsm_subscriber_connection *conn, int dlci) @@ -42,28 +43,6 @@ static int msc_clear_request(struct gsm_subscriber_connection *conn, uint32_t ca return 1; } -int msc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, - uint16_t chosen_channel) -{ - gsm0408_new_conn(conn); - gsm0408_dispatch(conn, msg); - - /* - * If this is a silent call we want the channel to remain open as long as - * possible and this is why we accept this connection regardless of any - * pending transaction or ongoing operation. - */ - if (conn->silent_call) - return BSC_API_CONN_POL_ACCEPT; - if (conn->loc_operation || conn->sec_operation || conn->anch_operation) - return BSC_API_CONN_POL_ACCEPT; - if (trans_has_conn(conn)) - return BSC_API_CONN_POL_ACCEPT; - - LOGP(DRR, LOGL_INFO, "MSC Complete L3: Rejecting connection.\n"); - return BSC_API_CONN_POL_REJECT; -} - static void msc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg) { gsm0408_dispatch(conn, msg); |