diff options
author | Harald Welte <laforge@gnumonks.org> | 2018-05-26 22:56:59 +0200 |
---|---|---|
committer | laforge <laforge@gnumonks.org> | 2019-06-18 18:09:26 +0000 |
commit | 1626f909461becfe1bb09707640ab23685b970dd (patch) | |
tree | 53813aaf3aef62737bb66bc25d97c14b48fecb56 /src/osmo-bsc/osmo_bsc_msc.c | |
parent | 062cd20993f6c6c0525c17cfe94b8721db79964d (diff) |
Re-introduce support for IPA-encapsulated MGCP
Old osmo-bsc-sccplite already supported this, but in the migration
over to libosmo-sigtran and to real 3GPP AoIP, this functionality
got lost.
We now create a UDP proxy socket. Any MGCP commands received via IPA
from MSC (or rather: bsc_nat) are retransmitted to the MGW via UDP on
this socket. Any responses back from the MGW received on the UDP
socket are retransmitted back to MSC/bsc_nat as MGCP inside the IPA
multiplex.
Closes: OS#2536
Change-Id: I38ad8fa645c08900e0e1f1b4b96136bc6d96b3ab
Diffstat (limited to 'src/osmo-bsc/osmo_bsc_msc.c')
-rw-r--r-- | src/osmo-bsc/osmo_bsc_msc.c | 31 |
1 files changed, 29 insertions, 2 deletions
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; } |