add ran_infra.force_mgw_codecs_to_ran

Indicate in the ran_infra data structure whether a RAN needs specific
codecs to be set up on the RAN facing MGW endpoint.

This allows setting forced RAN codecs as first-class citizen in the
ran_infra data structure, instead of special cases in the code (for IuUP
on IuCS).

Will be used in subsequent commit
I37f65c36af2679ecba1040a11a9aa0eb9481d817, submitted separately for
easier readability.

Change-Id: I37f65c36af2679ecba1040a11a9aa0eb9481d817
diff --git a/include/osmocom/msc/ran_infra.h b/include/osmocom/msc/ran_infra.h
index 38c424f..262a9c8 100644
--- a/include/osmocom/msc/ran_infra.h
+++ b/include/osmocom/msc/ran_infra.h
@@ -4,6 +4,7 @@
 #include <osmocom/gsm/gsup.h>
 #include <osmocom/msc/sccp_ran.h>
 #include <osmocom/msc/ran_msg.h>
+#include <osmocom/msc/sdp_msg.h>
 
 struct osmo_tdef;
 
@@ -25,6 +26,10 @@
 	const ran_dec_l2_t ran_dec_l2;
 	const ran_encode_t ran_encode;
 	struct sccp_ran_inst *sri;
+	/* To always set up the MGW endpoint facing the RAN side with specific codecs, list those here. Otherwise leave
+	 * empty (to use the result of codecs filtering). This exists for IuCS, to always set the MGW endpoint facing
+	 * RAN to IUFP, to decapsulate the IuUP headers. */
+	struct sdp_audio_codecs force_mgw_codecs_to_ran;
 };
 
 extern struct ran_infra msc_ran_infra[];
diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index 4c7f763..7db1d0a 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -1791,6 +1791,8 @@
 		return osmo_fsm_inst_dispatch(msc_a->c.fi, MSC_EV_CALL_LEG_RTP_LOCAL_ADDR_AVAILABLE, cl->rtp[RTP_TO_RAN]);
 
 	if (msc_a->c.ran->type == OSMO_RAT_UTRAN_IU) {
+		/* FUTURE: ran_infra->force_mgw_codecs_to_ran is intended to be used here instead of the special
+		 * condition on OSMO_RAT_UTRAN_IU and the mgcp_codecs value CODEC_IUFP */
 		codec = CODEC_IUFP;
 		codec_ptr = &codec;
 	} else {
diff --git a/src/libmsc/ran_infra.c b/src/libmsc/ran_infra.c
index c0eaa1a..35dfd61 100644
--- a/src/libmsc/ran_infra.c
+++ b/src/libmsc/ran_infra.c
@@ -108,6 +108,16 @@
 		.ran_dec_l2 = ran_iu_decode_l2,
 		.ran_encode = ran_iu_encode,
 #endif
+		.force_mgw_codecs_to_ran = {
+			.count = 1,
+			.codec = {
+				{
+					.payload_type = 96,
+					.subtype_name = "VND.3GPP.IUFP",
+					.rate = 16000,
+				},
+			},
+		},
 	},
 	[OSMO_RAT_EUTRAN_SGS] = {
 		.type = OSMO_RAT_EUTRAN_SGS,
diff --git a/tests/msc_vlr/msc_vlr_tests.c b/tests/msc_vlr/msc_vlr_tests.c
index 6b80452..b0c60ed 100644
--- a/tests/msc_vlr/msc_vlr_tests.c
+++ b/tests/msc_vlr/msc_vlr_tests.c
@@ -408,6 +408,16 @@
 		.log_subsys = DIUCS,
 		.tdefs = msc_tdefs_utran,
 		.ran_encode = dont_ran_encode,
+		.force_mgw_codecs_to_ran = {
+			.count = 1,
+			.codec = {
+				{
+					.payload_type = 96,
+					.subtype_name = "VND.3GPP.IUFP",
+					.rate = 16000,
+				},
+			},
+		},
 	},
 };