Revert "move ASS-COMPL MGCP handling out of a_iface_bssap.c"
Two reasons:
- the caller of msc_mgcp_ass_complete() from Iu, iucs_rx_rab_assign(), failed
to be adjusted, breaking IuCS, as an --enable-iu --enable-werror build shows.
Unfortunately our gerrit verification doesn't --enable-werror for osmo-msc.
- the condition of requiring ST_MDCX_RAN is faulty, breaking GSM CS.
This reverts commit 212c0c9bdaf1166e3bcbab85f3ab31dc17162f5b.
Change-Id: I8348675c2f7c8856ea1682d05ee54160d4cfeb96
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index 4e8b146..d84a234 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -34,6 +34,7 @@
#include <osmocom/core/byteswap.h>
#include <osmocom/msc/a_reset.h>
#include <osmocom/msc/transaction.h>
+#include <osmocom/msc/msc_mgcp.h>
#include <errno.h>
@@ -497,12 +498,51 @@
return 0;
}
+/* Use the speech codec info we go with the assignment complete to dtermine
+ * which codec we will signal to the MGW */
+static enum mgcp_codecs mgcp_codec_from_sc(struct gsm0808_speech_codec *sc)
+{
+ switch (sc->type) {
+ case GSM0808_SCT_FR1:
+ return CODEC_GSM_8000_1;
+ break;
+ case GSM0808_SCT_FR2:
+ return CODEC_GSMEFR_8000_1;
+ break;
+ case GSM0808_SCT_FR3:
+ return CODEC_AMR_8000_1;
+ break;
+ case GSM0808_SCT_FR4:
+ return CODEC_AMRWB_16000_1;
+ break;
+ case GSM0808_SCT_FR5:
+ return CODEC_AMRWB_16000_1;
+ break;
+ case GSM0808_SCT_HR1:
+ return CODEC_GSMHR_8000_1;
+ break;
+ case GSM0808_SCT_HR3:
+ return CODEC_AMR_8000_1;
+ break;
+ case GSM0808_SCT_HR4:
+ return CODEC_AMRWB_16000_1;
+ break;
+ case GSM0808_SCT_HR6:
+ return CODEC_AMRWB_16000_1;
+ break;
+ default:
+ return CODEC_PCMU_8000_1;
+ break;
+ }
+}
+
/* Endpoint to handle assignment complete */
static int bssmap_rx_ass_compl(struct ran_conn *conn, struct msgb *msg,
struct tlv_parsed *tp)
{
struct sockaddr_storage rtp_addr;
struct gsm0808_speech_codec sc;
+ struct sockaddr_in *rtp_addr_in;
int rc;
LOGPCONN(conn, LOGL_INFO, "Rx BSSMAP ASSIGNMENT COMPLETE message\n");
@@ -527,8 +567,18 @@
LOGPCONN(conn, LOGL_ERROR, "Unable to decode speech codec (choosen).\n");
return -EINVAL;
}
+ conn->rtp.codec_ran = mgcp_codec_from_sc(&sc);
- ran_conn_assign_compl(conn, &sc, &rtp_addr);
+ /* use address / port supplied with the AoIP
+ * transport address element */
+ if (rtp_addr.ss_family == AF_INET) {
+ rtp_addr_in = (struct sockaddr_in *)&rtp_addr;
+ msc_mgcp_ass_complete(conn, osmo_ntohs(rtp_addr_in->sin_port), inet_ntoa(rtp_addr_in->sin_addr));
+ } else {
+ LOGPCONN(conn, LOGL_ERROR, "Unsopported addressing scheme. (supports only IPV4)\n");
+ return -EINVAL;
+ }
+
return 0;
}
diff --git a/src/libmsc/msc_mgcp.c b/src/libmsc/msc_mgcp.c
index 7aeab4a..1ddec08 100644
--- a/src/libmsc/msc_mgcp.c
+++ b/src/libmsc/msc_mgcp.c
@@ -26,8 +26,6 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/byteswap.h>
-#include <osmocom/gsm/protocol/gsm_08_08.h>
-
#include <osmocom/msc/msc_mgcp.h>
#include <osmocom/msc/debug.h>
#include <osmocom/msc/transaction.h>
@@ -1027,89 +1025,51 @@
return 0;
}
-static enum mgcp_codecs mgcp_codec_from_sc(const struct gsm0808_speech_codec *sc)
+/* Inform the FSM that the assignment (RAN connection) is now complete.
+ * Parameter:
+ * conn: RAN connection context.
+ * port: port number of the remote leg.
+ * addr: IP-address of the remote leg.
+ * Returns -EINVAL on error, 0 on success. */
+int msc_mgcp_ass_complete(struct ran_conn *conn, uint16_t port, char *addr)
{
- switch (sc->type) {
- case GSM0808_SCT_FR1:
- return CODEC_GSM_8000_1;
- break;
- case GSM0808_SCT_FR2:
- return CODEC_GSMEFR_8000_1;
- break;
- case GSM0808_SCT_FR3:
- return CODEC_AMR_8000_1;
- break;
- case GSM0808_SCT_FR4:
- return CODEC_AMRWB_16000_1;
- break;
- case GSM0808_SCT_FR5:
- return CODEC_AMRWB_16000_1;
- break;
- case GSM0808_SCT_HR1:
- return CODEC_GSMHR_8000_1;
- break;
- case GSM0808_SCT_HR3:
- return CODEC_AMR_8000_1;
- break;
- case GSM0808_SCT_HR4:
- return CODEC_AMRWB_16000_1;
- break;
- case GSM0808_SCT_HR6:
- return CODEC_AMRWB_16000_1;
- break;
- default:
- return CODEC_PCMU_8000_1;
- break;
- }
-}
+ struct mgcp_ctx *mgcp_ctx;
-int msc_mgcp_ass_complete(struct ran_conn *conn, const struct gsm0808_speech_codec *speech_codec_chosen,
- const struct sockaddr_storage *aoip_transport_addr)
-{
- struct sockaddr_in *rtp_addr_in;
- const char *addr;
- uint16_t port;
- struct mgcp_ctx *mgcp_ctx = conn->rtp.mgcp_ctx;
- struct osmo_fsm_inst *fi;
-
- if (!mgcp_ctx || !mgcp_ctx->fsm) {
- LOGPCONN(conn, LOGL_ERROR, "Invalid MGCP context, Assignment Complete failed.\n");
- return -EINVAL;
- }
-
- fi = mgcp_ctx->fsm;
-
- if (fi->state != ST_MDCX_RAN) {
- LOGPFSML(fi, LOGL_ERROR, "Assignment Complete not allowed in this state\n");
- return -ENOTSUP;
- }
-
- /* use address / port supplied with the AoIP transport address element */
- if (aoip_transport_addr->ss_family != AF_INET) {
- LOGPCONN(conn, LOGL_ERROR, "Assignment Complete: Unsupported addressing scheme (only IPV4 supported)\n");
- return -EINVAL;
- }
-
- rtp_addr_in = (struct sockaddr_in *)&aoip_transport_addr;
- addr = inet_ntoa(rtp_addr_in->sin_addr);
- port = osmo_ntohs(rtp_addr_in->sin_port);
+ OSMO_ASSERT(conn);
if (port == 0) {
- LOGPCONN(conn, LOGL_ERROR, "Assignment Complete: invalid remote call leg port (0)\n");
+ LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) invalid remote call leg port, assignment completion failed\n",
+ vlr_subscr_name(conn->vsub));
return -EINVAL;
}
if (!addr || strlen(addr) <= 0) {
- LOGPCONN(conn, LOGL_ERROR, "Assignment Complete: invalid remote call leg address (empty)\n");
+ LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) missing remote call leg address, assignment completion failed\n",
+ vlr_subscr_name(conn->vsub));
return -EINVAL;
}
- conn->rtp.codec_ran = mgcp_codec_from_sc(speech_codec_chosen);
- osmo_strlcpy(conn->rtp.remote_addr_ran, addr, sizeof(conn->rtp.remote_addr_ran));
+ mgcp_ctx = conn->rtp.mgcp_ctx;
+ if (!mgcp_ctx) {
+ LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) invalid mgcp context, assignment completion failed.\n",
+ vlr_subscr_name(conn->vsub));
+ return -EINVAL;
+ }
+
+ /* Memorize port and IP-Address of the remote RAN call leg. We need this
+ * information at latest when we enter the MDCX phase for the RAN side. */
conn->rtp.remote_port_ran = port;
+ osmo_strlcpy(conn->rtp.remote_addr_ran, addr, sizeof(conn->rtp.remote_addr_ran));
- LOGPCONN(conn, LOGL_DEBUG, "Assignment Complete: rtp %s:%u\n", addr, port);
+ LOGP(DMGCP, LOGL_DEBUG, "(subscriber:%s) assignment completed, rtp %s:%d.\n",
+ vlr_subscr_name(conn->vsub), conn->rtp.remote_addr_ran, port);
- return osmo_fsm_inst_dispatch(fi, EV_ASSIGN, mgcp_ctx);
+ /* Note: We only dispatch the event if we are really waiting for the
+ * assignment, if we are not yet waiting, there is no need to loudly
+ * broadcast an event that the all other states do not understand anyway */
+ if (mgcp_ctx->fsm->state == ST_MDCX_RAN)
+ osmo_fsm_inst_dispatch(mgcp_ctx->fsm, EV_ASSIGN, mgcp_ctx);
+
+ return 0;
}
/* Make the connection of a previously assigned call complete
diff --git a/src/libmsc/osmo_msc.c b/src/libmsc/osmo_msc.c
index 8cc5ee7..37c1d15 100644
--- a/src/libmsc/osmo_msc.c
+++ b/src/libmsc/osmo_msc.c
@@ -28,7 +28,6 @@
#include <osmocom/msc/a_iface.h>
#include <osmocom/msc/gsm_04_08.h>
#include <osmocom/msc/gsm_04_11.h>
-#include <osmocom/msc/msc_mgcp.h>
#include "../../bscconfig.h"
#ifdef BUILD_IU
@@ -114,18 +113,17 @@
}
/* Receive an ASSIGNMENT COMPLETE from BSC */
-void ran_conn_assign_compl(struct ran_conn *conn, const struct gsm0808_speech_codec *speech_codec_chosen,
- const struct sockaddr_storage *aoip_transport_addr)
+void msc_assign_compl(struct ran_conn *conn,
+ uint8_t rr_cause, uint8_t chosen_channel,
+ uint8_t encr_alg_id, uint8_t speec)
{
- msc_mgcp_ass_complete(conn, speech_codec_chosen, aoip_transport_addr);
- /* FIXME: tear down conn upon failure */
+ LOGP(DRR, LOGL_DEBUG, "MSC assign complete (do nothing).\n");
}
/* Receive an ASSIGNMENT FAILURE from BSC */
void ran_conn_assign_fail(struct ran_conn *conn, uint8_t cause, uint8_t *rr_cause)
{
LOGP(DRR, LOGL_DEBUG, "MSC assign failure (do nothing).\n");
- /* FIXME: tear down conn upon failure */
}
/* Receive a CLASSMARK CHANGE from BSC */