aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/osmocom/bsc/bsc_msc_data.h11
-rw-r--r--include/osmocom/bsc/osmo_bsc_sigtran.h9
-rw-r--r--src/osmo-bsc/Makefile.am1
-rw-r--r--src/osmo-bsc/osmo_bsc_ctrl.c59
-rw-r--r--src/osmo-bsc/osmo_bsc_mgcp.c92
-rw-r--r--src/osmo-bsc/osmo_bsc_msc.c31
-rw-r--r--src/osmo-bsc/osmo_bsc_sigtran.c4
-rw-r--r--tests/handover/Makefile.am20
8 files changed, 207 insertions, 20 deletions
diff --git a/include/osmocom/bsc/bsc_msc_data.h b/include/osmocom/bsc/bsc_msc_data.h
index 1f9872a41..2ad7c685e 100644
--- a/include/osmocom/bsc/bsc_msc_data.h
+++ b/include/osmocom/bsc/bsc_msc_data.h
@@ -33,6 +33,7 @@
#include "osmux.h"
#include <osmocom/core/timer.h>
+#include <osmocom/core/select.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
@@ -135,6 +136,16 @@ struct bsc_msc_data {
enum osmux_usage use_osmux;
/* Whether we detected the MSC supports Osmux (during BSSMAP_RESET) */
bool remote_supports_osmux;
+
+ /* Proxy between IPA/SCCPlite encapsulated MGCP and UDP */
+ struct {
+ /* local (BSC) IP address to be used */
+ char *local_addr;
+ /* local (BSC) UDP port to be used to talk with MGW */
+ uint16_t local_port;
+ /* UDP socket for proxying MGCP via SCCPlite/IPA */
+ struct osmo_fd ofd;
+ } mgcp_ipa;
};
/*
diff --git a/include/osmocom/bsc/osmo_bsc_sigtran.h b/include/osmocom/bsc/osmo_bsc_sigtran.h
index bd8b06398..b934d51d3 100644
--- a/include/osmocom/bsc/osmo_bsc_sigtran.h
+++ b/include/osmocom/bsc/osmo_bsc_sigtran.h
@@ -44,3 +44,12 @@ void osmo_bsc_sigtran_tx_reset_ack(const struct bsc_msc_data *msc);
/* receive + process a CTRL command from the piggy-back on the IPA/SCCPlite link */
int bsc_sccplite_rx_ctrl(struct osmo_ss7_asp *asp, struct msgb *msg);
+
+/* receive + process a MGCP message from the piggy-back on the IPA/SCCPlite link */
+int bsc_sccplite_rx_mgcp(struct osmo_ss7_asp *asp, struct msgb *msg);
+
+/* send a message via SCCPLite to given MSC */
+int bsc_sccplite_msc_send(struct bsc_msc_data *msc, struct msgb *msg);
+
+/* we received some data on the UDP proxy socket from the MGW. Pass it to MSC via IPA */
+int bsc_sccplite_mgcp_proxy_cb(struct osmo_fd *ofd, unsigned int what);
diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am
index e88e6144b..d50515b0f 100644
--- a/src/osmo-bsc/Makefile.am
+++ b/src/osmo-bsc/Makefile.am
@@ -78,6 +78,7 @@ osmo_bsc_SOURCES = \
osmo_bsc_grace.c \
osmo_bsc_lcls.c \
osmo_bsc_main.c \
+ osmo_bsc_mgcp.c \
osmo_bsc_msc.c \
osmo_bsc_sigtran.c \
osmo_bsc_vty.c \
diff --git a/src/osmo-bsc/osmo_bsc_ctrl.c b/src/osmo-bsc/osmo_bsc_ctrl.c
index 80699f877..afe061ecc 100644
--- a/src/osmo-bsc/osmo_bsc_ctrl.c
+++ b/src/osmo-bsc/osmo_bsc_ctrl.c
@@ -52,6 +52,39 @@ static struct osmo_ss7_as *msc_get_ss7_as(struct bsc_msc_data *msc)
return rt->dest.as;
}
+static int _ss7_as_send(struct osmo_ss7_as *as, struct msgb *msg)
+{
+ struct osmo_ss7_asp *asp;
+ unsigned int i;
+
+ /* FIXME: unify with xua_as_transmit_msg() and perform proper ASP lookup */
+ for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+ asp = as->cfg.asps[i];
+ if (!asp)
+ continue;
+ /* FIXME: deal with multiple ASPs per AS */
+ return osmo_ss7_asp_send(asp, msg);
+ }
+ msgb_free(msg);
+ return -1;
+}
+
+int bsc_sccplite_msc_send(struct bsc_msc_data *msc, struct msgb *msg)
+{
+ struct osmo_ss7_as *as;
+
+ as = msc_get_ss7_as(msc);
+ if (!as) {
+ msgb_free(msg);
+ return -1;
+ }
+
+ /* don't attempt to send CTRL on a non-SCCPlite AS */
+ if (as->cfg.proto != OSMO_SS7_ASP_PROT_IPA)
+ return 0;
+
+ return _ss7_as_send(as, msg);
+}
/* Encode a CTRL command and send it to the given ASP
* \param[in] asp ASP through which we shall send the encoded message
@@ -83,30 +116,20 @@ static int sccplite_asp_ctrl_cmd_send(struct osmo_ss7_asp *asp, struct ctrl_cmd
* Caller must hence free 'cmd' itself. */
static int sccplite_msc_ctrl_cmd_send(struct bsc_msc_data *msc, struct ctrl_cmd *cmd)
{
- struct osmo_ss7_as *as;
- struct osmo_ss7_asp *asp;
- unsigned int i;
+ struct msgb *msg;
- as = msc_get_ss7_as(msc);
- if (!as)
+ msg = ctrl_cmd_make(cmd);
+ if (!msg)
return -1;
- /* don't attempt to send CTRL on a non-SCCPlite AS */
- if (as->cfg.proto != OSMO_SS7_ASP_PROT_IPA)
- return 0;
+ ipa_prepend_header_ext(msg, IPAC_PROTO_EXT_CTRL);
+ ipa_prepend_header(msg, IPAC_PROTO_OSMO);
- /* FIXME: unify with xua_as_transmit_msg() and perform proper ASP lookup */
- for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
- asp = as->cfg.asps[i];
- if (!asp)
- continue;
- /* FIXME: deal with multiple ASPs per AS */
- return sccplite_asp_ctrl_cmd_send(asp, cmd);
- }
- return -1;
+ return bsc_sccplite_msc_send(msc, msg);
}
-/* receive + process a CTRL command from the piggy-back on the IPA/SCCPlite link */
+/* receive + process a CTRL command from the piggy-back on the IPA/SCCPlite link.
+ * Transfers msg ownership. */
int bsc_sccplite_rx_ctrl(struct osmo_ss7_asp *asp, struct msgb *msg)
{
struct ctrl_cmd *cmd;
diff --git a/src/osmo-bsc/osmo_bsc_mgcp.c b/src/osmo-bsc/osmo_bsc_mgcp.c
new file mode 100644
index 000000000..bec793032
--- /dev/null
+++ b/src/osmo-bsc/osmo_bsc_mgcp.c
@@ -0,0 +1,92 @@
+/*
+ * SCCPlite MGCP handling
+ *
+ * (C) 2018 by Harald Welte <laforge@gnumonks.org>
+ * 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 <osmocom/bsc/bsc_msc_data.h>
+#include <osmocom/bsc/osmo_bsc.h>
+#include <osmocom/bsc/gsm_data.h>
+#include <osmocom/bsc/debug.h>
+#include <osmocom/gsm/ipa.h>
+#include <osmocom/gsm/protocol/ipaccess.h>
+#include <osmocom/bsc/osmo_bsc_sigtran.h>
+
+#include <arpa/inet.h>
+
+/* Determine MSC based on the ASP over which the message was received */
+static struct bsc_msc_data *msc_from_asp(struct osmo_ss7_asp *asp)
+{
+ int msc_nr;
+ /* this is rather ugly, as we of course have MTP-level routing between
+ * the local SCCP user (BSC) and the AS/ASPs. However, for the most simple
+ * SCCPlite case, there is a 1:1 mapping between ASP and AS, and using
+ * the libosmo-sigtran "simple client", the names are "as[p]-clnt-msc-%u",
+ * as set in osmo_bsc_sigtran_init() */
+ if (sscanf(asp->cfg.name, "asp-clnt-msc-%u", &msc_nr) != 1) {
+ LOGP(DMSC, LOGL_ERROR, "Cannot find to which MSC the ASP %s belongs\n", asp->cfg.name);
+ return NULL;
+ }
+ return osmo_msc_data_find(bsc_gsmnet, msc_nr);
+}
+
+/* We received an IPA-encapsulated MGCP message from a MSC. Transfers msg ownership. */
+int bsc_sccplite_rx_mgcp(struct osmo_ss7_asp *asp, struct msgb *msg)
+{
+ struct bsc_msc_data *msc;
+ int rc;
+
+ LOGP(DMSC, LOGL_NOTICE, "%s: Received IPA-encapsulated MGCP: %s\n", asp->cfg.name, msg->l2h);
+ msc = msc_from_asp(asp);
+ if (msc) {
+ /* we don't have a write queue here as we simply expect the socket buffers
+ * to be large enough to deal with whatever small/infrequent MGCP messages */
+ rc = send(msc->mgcp_ipa.ofd.fd, msgb_l2(msg), msgb_l2len(msg), 0);
+ } else
+ rc = 0;
+
+ msgb_free(msg);
+ return rc;
+}
+
+/* we received some data on the UDP proxy socket from the MGW. Pass it to MSC via IPA */
+int bsc_sccplite_mgcp_proxy_cb(struct osmo_fd *ofd, unsigned int what)
+{
+ struct bsc_msc_data *msc = ofd->data;
+ struct msgb *msg;
+ int rc;
+
+ if (!(what & BSC_FD_READ))
+ return 0;
+
+ msg = msgb_alloc_headroom(1024, 16, "MGCP->IPA");
+ OSMO_ASSERT(msg);
+ rc = recv(ofd->fd, msg->data, msgb_tailroom(msg), 0);
+ if (rc <= 0) {
+ LOGP(DMSC, LOGL_ERROR, "error receiving data from MGCP<->IPA proxy UDP socket: "
+ "%s\n", strerror(errno));
+ msgb_free(msg);
+ return rc;
+ }
+ msg->l2h = msgb_put(msg, rc);
+ msg->l2h[rc] = '\0';
+ LOGP(DMSC, LOGL_NOTICE, "Received MGCP on UDP proxy socket: %s\n", msg->l2h);
+
+ ipa_prepend_header(msg, IPAC_PROTO_MGCP_OLD);
+ return bsc_sccplite_msc_send(msc, msg);
+}
diff --git a/src/osmo-bsc/osmo_bsc_msc.c b/src/osmo-bsc/osmo_bsc_msc.c
index 6a6b1a93d..7e78d947c 100644
--- a/src/osmo-bsc/osmo_bsc_msc.c
+++ b/src/osmo-bsc/osmo_bsc_msc.c
@@ -27,26 +27,49 @@
#include <osmocom/bsc/gsm_data.h>
#include <osmocom/bsc/ipaccess.h>
#include <osmocom/bsc/bsc_msc_data.h>
+#include <osmocom/bsc/osmo_bsc_sigtran.h>
#include <osmocom/bsc/signal.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/socket.h>
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/abis/ipa.h>
+#include <osmocom/mgcp_client/mgcp_client.h>
+
#include <sys/socket.h>
#include <netinet/tcp.h>
#include <unistd.h>
-int osmo_bsc_msc_init(struct bsc_msc_data *data)
+int osmo_bsc_msc_init(struct bsc_msc_data *msc)
{
+ struct gsm_network *net = msc->network;
+ uint16_t mgw_port;
+ int rc;
+
/* FIXME: This is a leftover from the old architecture that used
* sccp-lite with osmocom specific authentication. Since we now
* changed to AoIP the connected status and the authentication
* status is managed differently. However osmo_bsc_filter.c still
* needs the flags to be set to one. See also: OS#3112 */
- data->is_authenticated = 1;
+ msc->is_authenticated = 1;
+
+ if (net->mgw.conf->remote_port >= 0)
+ mgw_port = net->mgw.conf->remote_port;
+ else
+ mgw_port = MGCP_CLIENT_REMOTE_PORT_DEFAULT;
+
+ rc = osmo_sock_init2_ofd(&msc->mgcp_ipa.ofd, AF_INET, SOCK_DGRAM, IPPROTO_UDP,
+ msc->mgcp_ipa.local_addr, msc->mgcp_ipa.local_port,
+ net->mgw.conf->remote_addr, mgw_port,
+ OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT);
+ if (rc < 0) {
+ LOGP(DMSC, LOGL_ERROR, "msc %u: Could not create/connect/bind MGCP proxy socket: %d\n",
+ msc->nr, rc);
+ return rc;
+ }
return 0;
}
@@ -117,6 +140,10 @@ struct bsc_msc_data *osmo_msc_data_alloc(struct gsm_network *net, int nr)
msc_data->audio_support[4]->ver = 3;
msc_data->audio_support[4]->hr = 1;
+ osmo_fd_setup(&msc_data->mgcp_ipa.ofd, -1, BSC_FD_READ, &bsc_sccplite_mgcp_proxy_cb, msc_data, 0);
+ msc_data->mgcp_ipa.local_addr = talloc_strdup(msc_data, "0.0.0.0");
+ msc_data->mgcp_ipa.local_port = 0; /* dynamic */
+
return msc_data;
}
diff --git a/src/osmo-bsc/osmo_bsc_sigtran.c b/src/osmo-bsc/osmo_bsc_sigtran.c
index 18f269da0..763e1e161 100644
--- a/src/osmo-bsc/osmo_bsc_sigtran.c
+++ b/src/osmo-bsc/osmo_bsc_sigtran.c
@@ -611,8 +611,12 @@ static int asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *m
switch (iph_ext->proto) {
case IPAC_PROTO_EXT_CTRL:
return bsc_sccplite_rx_ctrl(asp, msg);
+ case IPAC_PROTO_EXT_MGCP:
+ return bsc_sccplite_rx_mgcp(asp, msg);
}
break;
+ case IPAC_PROTO_MGCP_OLD:
+ return bsc_sccplite_rx_mgcp(asp, msg);
default:
break;
}
diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am
index 56aea50af..84c341e25 100644
--- a/tests/handover/Makefile.am
+++ b/tests/handover/Makefile.am
@@ -8,6 +8,8 @@ AM_CFLAGS = \
-ggdb3 \
$(LIBOSMOCORE_CFLAGS) \
$(LIBOSMOGSM_CFLAGS) \
+ $(LIBOSMOCTRL_CFLAGS) \
+ $(LIBOSMOVTY_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
@@ -38,15 +40,24 @@ handover_test_LDFLAGS = \
$(NULL)
handover_test_LDADD = \
+ $(top_builddir)/src/libfilter/bsc_msg_acc.o \
+ $(top_builddir)/src/libfilter/bsc_msg_vty.o \
$(top_builddir)/src/osmo-bsc/a_reset.o \
$(top_builddir)/src/osmo-bsc/abis_nm.o \
+ $(top_builddir)/src/osmo-bsc/abis_nm_vty.o \
+ $(top_builddir)/src/osmo-bsc/abis_om2000.o \
+ $(top_builddir)/src/osmo-bsc/abis_om2000_vty.o \
$(top_builddir)/src/osmo-bsc/abis_rsl.o \
+ $(top_builddir)/src/osmo-bsc/acc_ramp.o \
$(top_builddir)/src/osmo-bsc/arfcn_range_encode.o \
$(top_builddir)/src/osmo-bsc/assignment_fsm.o \
+ $(top_builddir)/src/osmo-bsc/bsc_ctrl_commands.o \
$(top_builddir)/src/osmo-bsc/bsc_init.o \
+ $(top_builddir)/src/osmo-bsc/bsc_rf_ctrl.o \
$(top_builddir)/src/osmo-bsc/bsc_rll.o \
$(top_builddir)/src/osmo-bsc/bsc_subscr_conn_fsm.o \
$(top_builddir)/src/osmo-bsc/bsc_subscriber.o \
+ $(top_builddir)/src/osmo-bsc/bsc_vty.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
$(top_builddir)/src/osmo-bsc/bts_sysmobts.o \
@@ -60,14 +71,20 @@ handover_test_LDADD = \
$(top_builddir)/src/osmo-bsc/handover_decision_2.o \
$(top_builddir)/src/osmo-bsc/handover_fsm.o \
$(top_builddir)/src/osmo-bsc/handover_logic.o \
+ $(top_builddir)/src/osmo-bsc/handover_vty.o \
$(top_builddir)/src/osmo-bsc/lchan_fsm.o \
$(top_builddir)/src/osmo-bsc/lchan_rtp_fsm.o \
$(top_builddir)/src/osmo-bsc/lchan_select.o \
+ $(top_builddir)/src/osmo-bsc/meas_feed.o \
$(top_builddir)/src/osmo-bsc/meas_rep.o \
$(top_builddir)/src/osmo-bsc/neighbor_ident.o \
+ $(top_builddir)/src/osmo-bsc/neighbor_ident_vty.o \
$(top_builddir)/src/osmo-bsc/net_init.o \
+ $(top_builddir)/src/osmo-bsc/osmo_bsc_ctrl.o \
$(top_builddir)/src/osmo-bsc/osmo_bsc_lcls.o \
+ $(top_builddir)/src/osmo-bsc/osmo_bsc_mgcp.o \
$(top_builddir)/src/osmo-bsc/osmo_bsc_msc.o \
+ $(top_builddir)/src/osmo-bsc/osmo_bsc_vty.o \
$(top_builddir)/src/osmo-bsc/paging.o \
$(top_builddir)/src/osmo-bsc/pcu_sock.o \
$(top_builddir)/src/osmo-bsc/penalty_timers.o \
@@ -76,6 +93,8 @@ handover_test_LDADD = \
$(top_builddir)/src/osmo-bsc/timeslot_fsm.o \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOCTRL_LIBS) \
+ $(LIBOSMOVTY_LIBS) \
$(LIBOSMOABIS_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
@@ -89,6 +108,7 @@ neighbor_ident_test_LDADD = \
$(top_builddir)/src/osmo-bsc/neighbor_ident.o \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
+ $(LIBOSMOCTRL_LIBS) \
$(NULL)
.PHONY: update_exp