Change in osmo-msc[master]: move ASS-COMPL MGCP handling out of a_iface_bssap.c

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Dec 7 14:07:18 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/12201


Change subject: move ASS-COMPL MGCP handling out of a_iface_bssap.c
......................................................................

move ASS-COMPL MGCP handling out of a_iface_bssap.c

BSSMAP Assignment Complete: sort MGCP handling upon Assignment Complete to the
proper locations. a_iface_bssap.c is not the right place to invoke the MGCP
related procedures.

- in a_iface_bssap.c only decode the IEs.
- call ran_conn_assign_compl() and pass decoded values.
- drop msc_assign_compl(), it was dead code; instead:
- add ran_conn_assign_compl()
- pass on all MGCP related info to msc_mgcp_ass_complete()
- move all MGCP ctx related handling from a_iface_bssap.c to msc_mgcp.c.

I'm dropping some comments to save some time, because if I adjust them IMHO
they would still anyway restate the obvious.

ran_conn_assign_compl() is now quite a thin shim, but it makes sense to have
it:

- This is the place that should tear down the ran_conn in case assignment
  failed, left for a future patch.

- In the light of upcoming inter-MSC handover, ran_conn_assign_compl() will be
  the place where the Assignment Complete message might be relayed to a remote
  MSC.

Change-Id: I8137215c443239bddf3e69b5715839a365b73b6c
---
M include/osmocom/msc/msc_mgcp.h
M include/osmocom/msc/ran_conn.h
M src/libmsc/a_iface_bssap.c
M src/libmsc/msc_mgcp.c
M src/libmsc/osmo_msc.c
5 files changed, 81 insertions(+), 88 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/01/12201/1

diff --git a/include/osmocom/msc/msc_mgcp.h b/include/osmocom/msc/msc_mgcp.h
index 9d8b01d..f405f45 100644
--- a/include/osmocom/msc/msc_mgcp.h
+++ b/include/osmocom/msc/msc_mgcp.h
@@ -58,6 +58,7 @@
 };
 
 int msc_mgcp_call_assignment(struct gsm_trans *trans);
-int msc_mgcp_ass_complete(struct ran_conn *conn, uint16_t port, char *addr);
+int msc_mgcp_ass_complete(struct ran_conn *conn, const struct gsm0808_speech_codec *speech_codec_chosen,
+			  const struct sockaddr_storage *aoip_transport_addr);
 int msc_mgcp_call_complete(struct gsm_trans *trans, uint16_t port, char *addr);
 int msc_mgcp_call_release(struct gsm_trans *trans);
diff --git a/include/osmocom/msc/ran_conn.h b/include/osmocom/msc/ran_conn.h
index d71872e..228d595 100644
--- a/include/osmocom/msc/ran_conn.h
+++ b/include/osmocom/msc/ran_conn.h
@@ -197,6 +197,8 @@
 void ran_conn_classmark_chg(struct ran_conn *conn,
 			    const uint8_t *cm2, uint8_t cm2_len,
 			    const uint8_t *cm3, uint8_t cm3_len);
+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 ran_conn_assign_fail(struct ran_conn *conn, uint8_t cause, uint8_t *rr_cause);
 
 void ran_conn_init(void);
diff --git a/src/libmsc/a_iface_bssap.c b/src/libmsc/a_iface_bssap.c
index d84a234..4e8b146 100644
--- a/src/libmsc/a_iface_bssap.c
+++ b/src/libmsc/a_iface_bssap.c
@@ -34,7 +34,6 @@
 #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>
 
@@ -498,51 +497,12 @@
 	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");
@@ -567,18 +527,8 @@
 		LOGPCONN(conn, LOGL_ERROR, "Unable to decode speech codec (choosen).\n");
 		return -EINVAL;
 	}
-	conn->rtp.codec_ran = mgcp_codec_from_sc(&sc);
 
-	/* 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;
-	}
-
+	ran_conn_assign_compl(conn, &sc, &rtp_addr);
 	return 0;
 }
 
diff --git a/src/libmsc/msc_mgcp.c b/src/libmsc/msc_mgcp.c
index 1ddec08..e85254e 100644
--- a/src/libmsc/msc_mgcp.c
+++ b/src/libmsc/msc_mgcp.c
@@ -1025,51 +1025,89 @@
 	return 0;
 }
 
-/* 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)
+static enum mgcp_codecs mgcp_codec_from_sc(const struct gsm0808_speech_codec *sc)
 {
-	struct mgcp_ctx *mgcp_ctx;
+	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;
+	}
+}
 
-	OSMO_ASSERT(conn);
+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);
 
 	if (port == 0) {
-		LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) invalid remote call leg port, assignment completion failed\n",
-		     vlr_subscr_name(conn->vsub));
+		LOGPCONN(conn, LOGL_ERROR, "Assignment Complete: invalid remote call leg port (0)\n");
 		return -EINVAL;
 	}
 	if (!addr || strlen(addr) <= 0) {
-		LOGP(DMGCP, LOGL_ERROR, "(subscriber:%s) missing remote call leg address, assignment completion failed\n",
-		     vlr_subscr_name(conn->vsub));
+		LOGPCONN(conn, LOGL_ERROR, "Assignment Complete: invalid remote call leg address (empty)\n");
 		return -EINVAL;
 	}
 
-	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;
+	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));
+	conn->rtp.remote_port_ran = port;
 
-	LOGP(DMGCP, LOGL_DEBUG, "(subscriber:%s) assignment completed, rtp %s:%d.\n",
-	     vlr_subscr_name(conn->vsub), conn->rtp.remote_addr_ran, port);
+	LOGPCONN(conn, LOGL_DEBUG, "Assignment Complete: rtp %s:%u\n", addr, port);
 
-	/* 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;
+	return osmo_fsm_inst_dispatch(fi, EV_ASSIGN, mgcp_ctx);
 }
 
 /* Make the connection of a previously assigned call complete
diff --git a/src/libmsc/osmo_msc.c b/src/libmsc/osmo_msc.c
index 37c1d15..8cc5ee7 100644
--- a/src/libmsc/osmo_msc.c
+++ b/src/libmsc/osmo_msc.c
@@ -28,6 +28,7 @@
 #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
@@ -113,17 +114,18 @@
 }
 
 /* Receive an ASSIGNMENT COMPLETE from BSC */
-void msc_assign_compl(struct ran_conn *conn,
-		      uint8_t rr_cause, uint8_t chosen_channel,
-		      uint8_t encr_alg_id, uint8_t speec)
+void ran_conn_assign_compl(struct ran_conn *conn, const struct gsm0808_speech_codec *speech_codec_chosen,
+			   const struct sockaddr_storage *aoip_transport_addr)
 {
-	LOGP(DRR, LOGL_DEBUG, "MSC assign complete (do nothing).\n");
+	msc_mgcp_ass_complete(conn, speech_codec_chosen, aoip_transport_addr);
+	/* FIXME: tear down conn upon failure */
 }
 
 /* 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 */

-- 
To view, visit https://gerrit.osmocom.org/12201
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8137215c443239bddf3e69b5715839a365b73b6c
Gerrit-Change-Number: 12201
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181207/215b5f6b/attachment.htm>


More information about the gerrit-log mailing list