ipa: Ability to transport MGCP over UDP rather than IPA Mux
diff --git a/ipa/IPA_Test.cfg b/ipa/IPA_Test.cfg
index 320ccf9..5dd7a04 100644
--- a/ipa/IPA_Test.cfg
+++ b/ipa/IPA_Test.cfg
@@ -14,6 +14,12 @@
#mp_nat_port := 5000;
#mp_nat_ip := "127.0.0.1";
+#mp_mgcp_uses_udp := true;
+#mp_callagent_ip := "127.0.0.1";
+#mp_callagent_udp_port := 2727;
+#mp_mgw_ip := "127.0.0.1";
+#mp_mgw_udp_port := 2427;
+
[MAIN_CONTROLLER]
[EXECUTE]
diff --git a/ipa/MGCP_Adapter.ttcn b/ipa/MGCP_Adapter.ttcn
new file mode 100644
index 0000000..1351997
--- /dev/null
+++ b/ipa/MGCP_Adapter.ttcn
@@ -0,0 +1,72 @@
+module MGCP_Adapter {
+
+import from IPL4asp_Types all;
+
+import from MGCP_Types all;
+import from MGCP_CodecPort all;
+import from MGCP_CodecPort_CtrlFunct all;
+
+import from IPA_Emulation all;
+
+
+type component MGCP_Adapter_CT {
+ /* MGCP Codec Port for MGCP-over-UDP */
+ port MGCP_CODEC_PT MGCP_UDP;
+ port IPA_MGCP_PT MGCP;
+ var integer g_mgcp_conn_id := -1;
+}
+
+modulepar {
+ charstring mp_callagent_ip := "127.0.0.1";
+ PortNumber mp_callagent_udp_port := 2727;
+ charstring mp_mgw_ip := "127.0.0.1";
+ PortNumber mp_mgw_udp_port := 2427;
+}
+
+/* build a receive template for receiving a MGCP message. You
+ * pass the MGCP response template in, and it will generate an
+ * MGCP_RecvFrom template that can match the primitives arriving on the
+ * MGCP_CodecPort */
+function tr_MGCP_RecvFrom_R(template MgcpResponse resp)
+runs on MGCP_Adapter_CT return template MGCP_RecvFrom {
+ var template MGCP_RecvFrom mrf := {
+ connId := g_mgcp_conn_id,
+ remName := mp_mgw_ip,
+ remPort := mp_mgw_udp_port,
+ locName := mp_callagent_ip,
+ locPort := mp_callagent_udp_port,
+ msg := { response := resp }
+ }
+ return mrf;
+}
+
+
+function main() runs on MGCP_Adapter_CT {
+ var Result res;
+ map(self:MGCP_UDP, system:MGCP_CODEC_PT);
+ res := MGCP_CodecPort_CtrlFunct.f_IPL4_connect(MGCP_UDP, mp_mgw_ip, mp_mgw_udp_port,
+ mp_callagent_ip, mp_callagent_udp_port,
+ 0, { udp:={} });
+ g_mgcp_conn_id := res.connId;
+
+ while (true) {
+ var MgcpCommand mgcp_cmd;
+ var MGCP_RecvFrom mrf;
+
+ alt {
+ /* From BSC/MGW via UDP up to MSC / Call Agent */
+ [] MGCP_UDP.receive(tr_MGCP_RecvFrom_R(?)) -> value mrf {
+ MGCP.send(mrf.msg.response);
+ }
+
+ /* From MSC / Call Agent down to BSC/MGW */
+ [] MGCP.receive(MgcpCommand:?) -> value mgcp_cmd {
+ var MgcpMessage msg := { command := mgcp_cmd };
+ MGCP_UDP.send(t_MGCP_Send(g_mgcp_conn_id, msg));
+ }
+
+ }
+ }
+}
+
+}
diff --git a/ipa/MSC_Simulation.ttcn b/ipa/MSC_Simulation.ttcn
index 21596f6..f9fb0d4 100755
--- a/ipa/MSC_Simulation.ttcn
+++ b/ipa/MSC_Simulation.ttcn
@@ -18,6 +18,8 @@
*/
import from BSSMAP_Emulation all;
+import from MGCP_Adapter all;
+
import from MSC_ConnectionHandler all;
type component MSC_CT {
@@ -25,10 +27,15 @@
var IPA_Emulation_CT vc_IPA;
var SCCP_CT vc_SCCP;
var BSSMAP_Emulation_CT vc_BSSMAP;
+ var MGCP_Adapter_CT vc_MGCP_UDP;
/* test port to SCCP emulation */
port SCCPasp_PT SCCP;
}
+modulepar {
+ boolean mp_mgcp_uses_udp := false;
+}
+
function main(charstring local_ip, PortNumber local_port,
MSC_SCCP_MTP3_parameters sccp_pars,
SCCP_PAR_Address sccp_addr_own, charstring id) runs on MSC_CT
@@ -46,8 +53,14 @@
/* connect BSSNAP dispatcher to upper side of SCCP */
connect(vc_BSSMAP:SCCP, vc_SCCP:SCCP_SP_PORT);
- /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
- connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
+ if (mp_mgcp_uses_udp == false) {
+ /* connect BSSMAP dispatcher to IPA_Emulation MGCP */
+ connect(vc_BSSMAP:MGCP, vc_IPA:IPA_MGCP_PORT);
+ } else {
+ vc_MGCP_UDP := MGCP_Adapter_CT.create(id & "-MGCP_UDP");
+ connect(vc_BSSMAP:MGCP, vc_MGCP_UDP:MGCP);
+ vc_MGCP_UDP.start(MGCP_Adapter.main());
+ }
vc_IPA.start(IPA_Emulation.main_server(local_ip, local_port));
vc_SCCP.start(SCCPStart(sccp_pars));
@@ -57,6 +70,9 @@
vc_IPA.done;
vc_BSSMAP.done;
vc_SCCP.done;
+ if (mp_mgcp_uses_udp) {
+ vc_MGCP_UDP.done;
+ }
}
}
diff --git a/ipa/gen_links.sh b/ipa/gen_links.sh
index 7dd5ed2..7be9a2d 100755
--- a/ipa/gen_links.sh
+++ b/ipa/gen_links.sh
@@ -55,5 +55,5 @@
gen_links $DIR $FILES
DIR=../library
-FILES="General_Types.ttcn Osmocom_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcn L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn"
+FILES="General_Types.ttcn Osmocom_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcn L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc"
gen_links $DIR $FILES
diff --git a/ipa/regen_makefile.sh b/ipa/regen_makefile.sh
index be79a35..b6f6bb5 100755
--- a/ipa/regen_makefile.sh
+++ b/ipa/regen_makefile.sh
@@ -2,7 +2,7 @@
MAIN=IPA_Test.ttcn
-FILES="*.ttcn SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc RTP_EncDec.cc SDP_EncDec *.c"
+FILES="*.ttcn SCCP_EncDec.cc IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc RTP_EncDec.cc SDP_EncDec.cc *.c MGCP_CodecPort_CtrlFunctDef.cc"
ttcn3_makefilegen -l -f $MAIN $FILES
sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile