pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40745?usp=email )
Change subject: GTP1vU_Emulation: Make UECUPS support optional ......................................................................
GTP1vU_Emulation: Make UECUPS support optional
Some users may/do want to use the simple UDP/GTPU socket mode, so they don't need to depend on all UECUPS code.
Change-Id: I3b4671d8e637f70f790b08ed8e3b5145e7a95703 --- M epdg/gen_links.sh M epdg/regen_makefile.sh R library/GTPv1U_Emulation.ttcnpp M pgw/gen_links.sh M pgw/regen_makefile.sh 5 files changed, 49 insertions(+), 18 deletions(-)
Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve laforge: Looks good to me, but someone else must approve
diff --git a/epdg/gen_links.sh b/epdg/gen_links.sh index d41e2e1..c3fdf61 100755 --- a/epdg/gen_links.sh +++ b/epdg/gen_links.sh @@ -37,10 +37,6 @@ FILES="MobileL3_CommonIE_Types.ttcn MobileL3_GMM_SM_Types.ttcn MobileL3_MM_Types.ttcn " gen_links $DIR $FILES
-DIR=$BASEDIR/osmo-uecups/ttcn3 -FILES="UECUPS_CodecPort.ttcn UECUPS_CodecPort_CtrlFunct.ttcn UECUPS_CodecPort_CtrlFunctDef.cc UECUPS_Types.ttcn " -gen_links $DIR $FILES - DIR=$BASEDIR/titan.ProtocolModules.GTP_v13.5.0/src FILES="GTPU_EncDec.cc GTPU_Types.ttcn " gen_links $DIR $FILES @@ -59,7 +55,7 @@ FILES+="IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp " FILES+="PCO_Types.ttcn GSUP_Types.ttcn GSUP_Templates.ttcn GSUP_Emulation.ttcn " -FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Templates.ttcn GTPv1U_Emulation.ttcn " +FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Templates.ttcn GTPv1U_Emulation.ttcnpp " FILES+="GTPv2_PrivateExtensions.ttcn GTPv2_Templates.ttcn " FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn " FILES+="ICMP_Templates.ttcn " diff --git a/epdg/regen_makefile.sh b/epdg/regen_makefile.sh index 847c412..1cd2efb 100755 --- a/epdg/regen_makefile.sh +++ b/epdg/regen_makefile.sh @@ -17,7 +17,6 @@ TELNETasp_PT.cc DIAMETER_EncDec.cc DIAMETER_CodecPort_CtrlFunctDef.cc - UECUPS_CodecPort_CtrlFunctDef.cc GTPU_EncDec.cc GTPv1U_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunctDef.cc diff --git a/library/GTPv1U_Emulation.ttcn b/library/GTPv1U_Emulation.ttcnpp similarity index 91% rename from library/GTPv1U_Emulation.ttcn rename to library/GTPv1U_Emulation.ttcnpp index 7c031b7..b3de2ab 100644 --- a/library/GTPv1U_Emulation.ttcn +++ b/library/GTPv1U_Emulation.ttcnpp @@ -15,23 +15,28 @@ import from IPL4asp_Types all; import from General_Types all; import from Osmocom_Types all; +import from Misc_Helpers all; import from GTPU_Types all; import from GTPv1U_CodecPort all; import from GTPv1U_CodecPort_CtrlFunct all;
+#ifdef GTP1U_EMULATION_HAVE_UECUPS import from SCTP_Templates all; import from UECUPS_Types all; import from UECUPS_CodecPort all; import from UECUPS_CodecPort_CtrlFunct all; +#endif
/*********************************************************************** * Main Emulation Component ***********************************************************************/
+#ifdef GTP1U_EMULATION_HAVE_UECUPS modulepar { charstring mp_uecups_host := "127.0.0.1"; integer mp_uecups_port := UECUPS_SCTP_PORT; }; +#endif
const integer GTP1U_PORT := 2152;
@@ -45,9 +50,6 @@ /* Communication with underlying GTP CodecPort */ port GTPU_PT GTP1U;
- /* Control port to GTP-U Daemon */ - port UECUPS_CODEC_PT UECUPS; - /* Communication with Clients */ port GTP1UEM_PT TEID0; port GTP1UEM_PT CLIENT; @@ -61,9 +63,13 @@ var OCT1 g_restart_ctr; var uint16_t g_c_seq_nr; var TidTableRec TidTable[256]; - var PidTableRec PidTable[256];
+#ifdef GTP1U_EMULATION_HAVE_UECUPS + /* Control port to GTP-U Daemon */ + port UECUPS_CODEC_PT UECUPS; + var PidTableRec PidTable[256]; var integer g_uecups_conn_id := -1; +#endif };
/* local TEID <-> ConnHdlr mapping */ @@ -72,6 +78,7 @@ GTP1U_ConnHdlr vc_conn };
+#ifdef GTP1U_EMULATION_HAVE_UECUPS /* pid <-> ConnHdlr mapping (for UECUPS process termination indication) */ type record PidTableRec { /* process ID of the running process */ @@ -79,6 +86,7 @@ /* component that started it */ GTP1U_ConnHdlr vc_conn }; +#endif
private function f_teid_known(OCT4 teid) runs on GTPv1U_Emulation_CT return boolean { var integer i; @@ -101,6 +109,7 @@ mtc.stop; }
+#ifdef GTP1U_EMULATION_HAVE_UECUPS private function f_comp_by_pid(integer pid) runs on GTPv1U_Emulation_CT return GTP1U_ConnHdlr { var integer i; for (i := 0; i < sizeof(PidTable); i := i+1) { @@ -112,6 +121,7 @@ setverdict(fail, "No Component for PID ", pid); mtc.stop; } +#endif
private function f_tid_tbl_add(OCT4 teid, GTP1U_ConnHdlr vc_conn) runs on GTPv1U_Emulation_CT { var integer i; @@ -125,6 +135,7 @@ testcase.stop("No Space in TidTable for ", teid); }
+#ifdef GTP1U_EMULATION_HAVE_UECUPS private function f_pid_tbl_add(integer pid, GTP1U_ConnHdlr vc_conn) runs on GTPv1U_Emulation_CT { var integer i; for (i := 0; i < sizeof(PidTable); i := i+1) { @@ -136,6 +147,7 @@ } testcase.stop("No Space in PID Table for ", pid); } +#endif
/* allocate an unused local teid */ @@ -155,6 +167,7 @@ testcase.stop("Cannot find unused TEID after ", i, " attempts"); }
+#ifdef GTP1U_EMULATION_HAVE_UECUPS function tr_UECUPS_RecvFrom_R(template PDU_UECUPS msg) runs on GTPv1U_Emulation_CT return template UECUPS_RecvFrom { var template UECUPS_RecvFrom mrf := { @@ -168,7 +181,6 @@ return mrf; }
- private function f_uecups_xceive(template (value) PDU_UECUPS tx, template PDU_UECUPS rx_t := ?, float time_out := 10.0) runs on GTPv1U_Emulation_CT return PDU_UECUPS { @@ -188,6 +200,7 @@ } return mrf.msg; } +#endif
private function f_init(Gtp1uEmulationCfg cfg) runs on GTPv1U_Emulation_CT { var Result res; @@ -197,6 +210,7 @@ g_gtp1u_cfg := cfg;
if (g_gtp1u_cfg.use_gtpu_daemon) { +#ifdef GTP1U_EMULATION_HAVE_UECUPS map(self:UECUPS, system:UECUPS); res := UECUPS_CodecPort_CtrlFunct.f_IPL4_connect(UECUPS, mp_uecups_host, mp_uecups_port, "", -1, -1, { sctp := valueof(ts_SctpTuple) }); @@ -209,6 +223,9 @@ f_uecups_xceive({reset_all_state := {}}, {reset_all_state_res:=?}, 30.0); /* make sure we always pass incoming UECUPS indications whenever receiving fom the UECUPS port */ activate(as_uecups_ind()); +#else + Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Requested UECUPS but built without UECUPS support!"); +#endif } else if (isvalue(cfg.gtpu_bind_ip) and isvalue(cfg.gtpu_bind_port)) { map(self:GTP1U, system:GTP1U); res := GTPv1U_CodecPort_CtrlFunct.f_GTPU_listen(GTP1U, cfg.gtpu_bind_ip, @@ -217,6 +234,7 @@ } }
+#ifdef GTP1U_EMULATION_HAVE_UECUPS private altstep as_uecups_ind() runs on GTPv1U_Emulation_CT { var UECUPS_RecvFrom rx; var GTP1U_ConnHdlr vc_conn; @@ -228,15 +246,18 @@ repeat; } } +#endif
function main(Gtp1uEmulationCfg cfg) runs on GTPv1U_Emulation_CT { var Gtp1uUnitdata g1u_ud; var GTP1U_ConnHdlr vc_conn; var OCT4 teid; +#ifdef GTP1U_EMULATION_HAVE_UECUPS var PDU_UECUPS rx_uecups; var UECUPS_CreateTun gtc; var UECUPS_DestroyTun gtd; var UECUPS_StartProgram sprog; +#endif
f_init(cfg);
@@ -268,6 +289,7 @@ f_tid_tbl_add(t, vc_conn); CLIENT_PROC.reply(GTP1UEM_allocate_teid:{} value t) to vc_conn; } +#ifdef GTP1U_EMULATION_HAVE_UECUPS [] CLIENT_PROC.getcall(GTP1UEM_create_tunnel:{?}) -> param(gtc) sender vc_conn { rx_uecups := f_uecups_xceive({create_tun := gtc}, {create_tun_res:={result:=OK}}); CLIENT_PROC.reply(GTP1UEM_create_tunnel:{gtc}) to vc_conn; @@ -284,7 +306,7 @@ } CLIENT_PROC.reply(GTP1UEM_start_program:{sprog} value rx_uecups.start_program_res) to vc_conn; } - +#endif } } } @@ -294,18 +316,27 @@ * Interaction between Main and Client Components ***********************************************************************/ type port GTP1UEM_PT message { - inout Gtp1uUnitdata, UECUPS_ProgramTermInd; + inout Gtp1uUnitdata +#ifdef GTP1U_EMULATION_HAVE_UECUPS + , UECUPS_ProgramTermInd +#endif + ; } with { extension "internal" };
signature GTP1UEM_register_teid(OCT4 teid); signature GTP1UEM_allocate_teid() return OCT4; +#ifdef GTP1U_EMULATION_HAVE_UECUPS signature GTP1UEM_create_tunnel(UECUPS_CreateTun gtc); signature GTP1UEM_destroy_tunnel(UECUPS_DestroyTun gtd); signature GTP1UEM_start_program(UECUPS_StartProgram sprog) return UECUPS_StartProgramRes; +#endif
type port GTP1UEM_PROC_PT procedure { - inout GTP1UEM_register_teid, GTP1UEM_allocate_teid, - GTP1UEM_create_tunnel, GTP1UEM_destroy_tunnel, GTP1UEM_start_program; + inout GTP1UEM_register_teid, GTP1UEM_allocate_teid +#ifdef GTP1U_EMULATION_HAVE_UECUPS + , GTP1UEM_create_tunnel, GTP1UEM_destroy_tunnel, GTP1UEM_start_program +#endif + ; } with { extension "internal" };
/*********************************************************************** @@ -333,6 +364,7 @@ } }
+#ifdef GTP1U_EMULATION_HAVE_UECUPS function f_gtp1u_create_tunnel(template (value) UECUPS_CreateTun gtc) runs on GTP1U_ConnHdlr { GTP1U_PROC.call(GTP1UEM_create_tunnel:{valueof(gtc)}) { @@ -355,7 +387,6 @@ } return res; } - - +#endif
} diff --git a/pgw/gen_links.sh b/pgw/gen_links.sh index fa69ee4..e1bf469 100755 --- a/pgw/gen_links.sh +++ b/pgw/gen_links.sh @@ -60,7 +60,7 @@ DIR=../library FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPCP_Types.ttcn IPCP_Templates.ttcn PAP_Types.ttcn " FILES+="GTPv1C_CodecPort.ttcn GTPv1C_CodecPort_CtrlFunct.ttcn GTPv1C_CodecPort_CtrlFunctDef.cc GTPv1C_Templates.ttcn Osmocom_Gb_Types.ttcn " -FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Emulation.ttcn " +FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Emulation.ttcnpp " FILES+="GTPv2_PrivateExtensions.ttcn GTPv2_Templates.ttcn " FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn " FILES+="DNS_Helpers.ttcn " diff --git a/pgw/regen_makefile.sh b/pgw/regen_makefile.sh index ec40716..2bc71d0 100755 --- a/pgw/regen_makefile.sh +++ b/pgw/regen_makefile.sh @@ -4,6 +4,7 @@
FILES=" *.ttcn + *.ttcnpp BSSGP_EncDec.cc DIAMETER_CodecPort_CtrlFunctDef.cc DIAMETER_EncDec.cc @@ -25,4 +26,8 @@ UECUPS_CodecPort_CtrlFunctDef.cc "
+CPPFLAGS_TTCN3=" + -DGTP1U_EMULATION_HAVE_UECUPS +" + . ../_buildsystem/regen_makefile.inc.sh