library: de-duplicate SCTP related templates

Change-Id: Ic2a0cba0cfb1909ccbd1ade9565d508fd239f78c
Related: SYS#6772
diff --git a/cbc/gen_links.sh b/cbc/gen_links.sh
index 3bb9e77..5c767e4 100755
--- a/cbc/gen_links.sh
+++ b/cbc/gen_links.sh
@@ -57,6 +57,7 @@
 FILES+="BSSMAP_Templates.ttcn "
 FILES+="CBSP_Types.ttcn CBSP_Templates.ttcn "
 FILES+="CBSP_CodecPort.ttcn CBSP_CodecPort_CtrlFunct.ttcn CBSP_CodecPort_CtrlFunctdef.cc CBSP_Adapter.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/dia2gsup/gen_links.sh b/dia2gsup/gen_links.sh
index d653781..f406ebb 100755
--- a/dia2gsup/gen_links.sh
+++ b/dia2gsup/gen_links.sh
@@ -41,6 +41,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+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/epdg/gen_links.sh b/epdg/gen_links.sh
index 55e449f..a0b2871 100755
--- a/epdg/gen_links.sh
+++ b/epdg/gen_links.sh
@@ -63,6 +63,7 @@
 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 "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh
index c79e4a8..bc17b64 100755
--- a/ggsn_tests/gen_links.sh
+++ b/ggsn_tests/gen_links.sh
@@ -65,6 +65,7 @@
 FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_212_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn DIAMETER_ts32_299_Templates.ttcn "
 FILES+="ICMP_Templates.ttcn ICMPv6_Templates.ttcn "
 FILES+="Osmocom_VTY_Functions.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/hnbgw/gen_links.sh b/hnbgw/gen_links.sh
index 62b3e44..e11b915 100755
--- a/hnbgw/gen_links.sh
+++ b/hnbgw/gen_links.sh
@@ -104,7 +104,7 @@
 FILES+="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn GSM_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunct.ttcn RTP_CodecPort_CtrlFunctDef.cc RTP_Emulation.ttcn IuUP_Types.ttcn IuUP_EncDec.cc IuUP_Emulation.ttcn "
 FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn "
 FILES+="L3_Templates.ttcn L3_Common.ttcn "
-
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/hnodeb/gen_links.sh b/hnodeb/gen_links.sh
index e4f453e..35aa039 100755
--- a/hnodeb/gen_links.sh
+++ b/hnodeb/gen_links.sh
@@ -66,6 +66,7 @@
 FILES+="GTPv1C_CodecPort.ttcn GTPv1C_CodecPort_CtrlFunct.ttcn GTPv1C_CodecPort_CtrlFunctDef.cc GTPv1C_Templates.ttcn "
 FILES+="GTPv1U_CodecPort.ttcn GTPv1U_CodecPort_CtrlFunct.ttcn GTPv1U_CodecPort_CtrlFunctDef.cc GTPv1U_Templates.ttcn "
 FILES+="GTP_Emulation.ttcn IPCP_Types.ttcn GSM_Types.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/hss/gen_links.sh b/hss/gen_links.sh
index 7160832..276eb1e 100755
--- a/hss/gen_links.sh
+++ b/hss/gen_links.sh
@@ -25,6 +25,7 @@
 FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc "
 FILES+="DIAMETER_Types.ttcn DIAMETER_CodecPort.ttcn DIAMETER_CodecPort_CtrlFunct.ttcn DIAMETER_CodecPort_CtrlFunctDef.cc DIAMETER_Emulation.ttcn "
 FILES+="DIAMETER_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/library/DIAMETER_Emulation.ttcn b/library/DIAMETER_Emulation.ttcn
index 69107d4..e5698fd 100644
--- a/library/DIAMETER_Emulation.ttcn
+++ b/library/DIAMETER_Emulation.ttcn
@@ -39,6 +39,7 @@
 import from IPL4asp_Types all;
 import from TCCConversion_Functions all;
 import from Native_Functions all;
+import from SCTP_Templates all;
 
 type hexstring IMSI;
 
@@ -308,24 +309,6 @@
 	}
 }
 
-private template (value) SctpTuple ts_SCTP(template (omit) integer ppid := omit) := {
-	sinfo_stream := omit,
-	sinfo_ppid := ppid,
-	remSocks := omit,
-	assocId := omit
-};
-
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
-
 private function f_diameter_xceive(template (value) PDU_DIAMETER tx,
 				   template PDU_DIAMETER rx_t := ?)
 runs on DIAMETER_Emulation_CT return PDU_DIAMETER {
@@ -341,7 +324,7 @@
 		mtc.stop;
 		}
 	[] DIAMETER.receive(tr_SctpAssocChange) { repeat; }
-	[] DIAMETER.receive(tr_SctpPeerAddrChange)  { repeat; }
+	[] DIAMETER.receive(tr_SctpPeerAddrChange) { repeat; }
 	[] T.timeout {
 		setverdict(fail, "Timeout waiting for ", rx_t);
 		mtc.stop;
@@ -360,10 +343,12 @@
 
 	map(self:DIAMETER, system:DIAMETER_CODEC_PT);
 	if (server_mode) {
-		res := DIAMETER_CodecPort_CtrlFunct.f_IPL4_listen(DIAMETER, p.local_ip, p.local_sctp_port, { sctp := valueof(ts_SCTP) });
+		res := DIAMETER_CodecPort_CtrlFunct.f_IPL4_listen(DIAMETER, p.local_ip, p.local_sctp_port,
+								  { sctp := valueof(ts_SctpTuple) });
 	} else {
 		res := DIAMETER_CodecPort_CtrlFunct.f_IPL4_connect(DIAMETER, p.remote_ip, p.remote_sctp_port,
-								p.local_ip, p.local_sctp_port, -1, { sctp := valueof(ts_SCTP) });
+								p.local_ip, p.local_sctp_port, -1,
+								{ sctp := valueof(ts_SctpTuple) });
 	}
 	if (not ispresent(res.connId)) {
 		setverdict(fail, "Could not connect DIAMETER socket, check your configuration");
@@ -459,7 +444,7 @@
 			}
 			}
 		[] DIAMETER.receive(tr_SctpAssocChange) { }
-		[] DIAMETER.receive(tr_SctpPeerAddrChange)  { }
+		[] DIAMETER.receive(tr_SctpPeerAddrChange) { }
 		[] DIAMETER_PROC.getcall(DIAMETEREM_register_imsi:{?,?}) -> param(imsi, vc_conn) {
 			f_create_expect(imsi, vc_conn);
 			DIAMETER_PROC.reply(DIAMETEREM_register_imsi:{imsi, vc_conn}) to vc_conn;
diff --git a/library/GTPv2_Emulation.ttcn b/library/GTPv2_Emulation.ttcn
index f3f09f8..15720f9 100644
--- a/library/GTPv2_Emulation.ttcn
+++ b/library/GTPv2_Emulation.ttcn
@@ -21,6 +21,7 @@
 import from GTPv2_Templates all;
 import from GTPv2_CodecPort all;
 import from GTPv2_CodecPort_CtrlFunct all;
+import from SCTP_Templates all;
 
 import from UECUPS_Types all;
 import from UECUPS_CodecPort all;
@@ -431,13 +432,6 @@
 	return false;
 }
 
-private template (value) SctpTuple ts_SCTP(template (omit) integer ppid := omit) := {
-	sinfo_stream := omit,
-	sinfo_ppid := ppid,
-	remSocks := omit,
-	assocId := omit
-};
-
 function tr_UECUPS_RecvFrom_R(template PDU_UECUPS msg)
 runs on GTPv2_Emulation_CT return template UECUPS_RecvFrom {
 	var template UECUPS_RecvFrom mrf := {
@@ -452,17 +446,6 @@
 }
 
 
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
-
 private function f_uecups_xceive(template (value) PDU_UECUPS tx,
 				template PDU_UECUPS rx_t := ?, float time_out := 10.0)
 runs on GTPv2_Emulation_CT  return PDU_UECUPS {
@@ -474,7 +457,7 @@
 	alt {
 	[] UECUPS.receive(tr_UECUPS_RecvFrom_R(rx_t)) -> value mrf { }
 	[] UECUPS.receive(tr_SctpAssocChange) { repeat; }
-	[] UECUPS.receive(tr_SctpPeerAddrChange)  { repeat; }
+	[] UECUPS.receive(tr_SctpPeerAddrChange) { repeat; }
 	[] T.timeout {
 		setverdict(fail, "Timeout waiting for ", rx_t);
 		mtc.stop;
@@ -504,7 +487,8 @@
 
 	if (g_gtp2_cfg.use_gtpu_daemon) {
 		map(self:UECUPS, system:UECUPS);
-		res := UECUPS_CodecPort_CtrlFunct.f_IPL4_connect(UECUPS, mp_uecups_host, mp_uecups_port, "", -1, -1, { sctp := valueof(ts_SCTP) });
+		res := UECUPS_CodecPort_CtrlFunct.f_IPL4_connect(UECUPS, mp_uecups_host, mp_uecups_port, "", -1, -1,
+								 { sctp := valueof(ts_SctpTuple) });
 		if (not ispresent(res.connId)) {
 			setverdict(fail, "Could not connect UECUPS socket, check your configuration");
 			testcase.stop;
diff --git a/library/Iuh_Emulation.ttcn b/library/Iuh_Emulation.ttcn
index e05afe5..e1f283f 100644
--- a/library/Iuh_Emulation.ttcn
+++ b/library/Iuh_Emulation.ttcn
@@ -31,6 +31,7 @@
 import from RUA_IEs all;
 import from RUA_Templates all;
 import from Iuh_Types all;
+import from SCTP_Templates all;
 
 import from General_Types all;
 import from Misc_Helpers all;
@@ -95,24 +96,6 @@
 	return mrf;
 }
 
-private template (value) SctpTuple ts_SCTP(template (omit) integer ppid := omit) := {
-	sinfo_stream := omit,
-	sinfo_ppid := ppid,
-	remSocks := omit,
-	assocId := omit
-};
-
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
-
 private function emu_is_server() runs on Iuh_Emulation_CT return boolean {
 	return g_pars.remote_sctp_port == -1
 }
@@ -148,10 +131,12 @@
 
 	map(self:Iuh, system:Iuh_CODEC_PT);
 	if (emu_is_server()) {
-		res := Iuh_CodecPort_CtrlFunct.f_IPL4_listen(Iuh, p.local_ip, p.local_sctp_port, { sctp := valueof(ts_SCTP) });
+		res := Iuh_CodecPort_CtrlFunct.f_IPL4_listen(Iuh, p.local_ip, p.local_sctp_port,
+							     { sctp := valueof(ts_SctpTuple) });
 	} else {
 		res := Iuh_CodecPort_CtrlFunct.f_IPL4_connect(Iuh, p.remote_ip, p.remote_sctp_port,
-								p.local_ip, p.local_sctp_port, -1, { sctp := valueof(ts_SCTP) });
+							      p.local_ip, p.local_sctp_port, -1,
+							      { sctp := valueof(ts_SctpTuple) });
 	}
 	if (not ispresent(res.connId)) {
 		f_shutdown(__FILE__, __LINE__, fail, "Could not connect Iuh socket, check your configuration");
diff --git a/library/S1AP_Emulation.ttcn b/library/S1AP_Emulation.ttcn
index 955c690..3cce091 100644
--- a/library/S1AP_Emulation.ttcn
+++ b/library/S1AP_Emulation.ttcn
@@ -40,6 +40,7 @@
 import from S1AP_PDU_Descriptions all;
 import from S1AP_IEs all;
 import from S1AP_Templates all;
+import from SCTP_Templates all;
 
 import from NAS_EPS_Types all;
 import from NAS_Templates all;
@@ -288,24 +289,6 @@
 	}
 }
 
-private template (value) SctpTuple ts_SCTP(template (omit) integer ppid := 18) := {
-	sinfo_stream := omit,
-	sinfo_ppid := ppid,
-	remSocks := omit,
-	assocId := omit
-};
-
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
-
 private function f_s1ap_xceive(template (value) S1AP_PDU tx,
 				template S1AP_PDU rx_t := ?)
 runs on S1AP_Emulation_CT  return S1AP_PDU {
@@ -412,10 +395,12 @@
 
 	map(self:S1AP, system:S1AP_CODEC_PT);
 	if (p.remote_sctp_port == -1) {
-		res := S1AP_CodecPort_CtrlFunct.f_IPL4_listen(S1AP, p.local_ip, p.local_sctp_port, { sctp := valueof(ts_SCTP) });
+		res := S1AP_CodecPort_CtrlFunct.f_IPL4_listen(S1AP, p.local_ip, p.local_sctp_port,
+							      { sctp := valueof(ts_SctpTuple(18)) });
 	} else {
 		res := S1AP_CodecPort_CtrlFunct.f_IPL4_connect(S1AP, p.remote_ip, p.remote_sctp_port,
-								p.local_ip, p.local_sctp_port, -1, { sctp := valueof(ts_SCTP) });
+							       p.local_ip, p.local_sctp_port, -1,
+							       { sctp := valueof(ts_SctpTuple(18)) });
 	}
 	if (not ispresent(res.connId)) {
 		setverdict(fail, "Could not connect S1AP socket, check your configuration");
diff --git a/library/SCTP_Templates.ttcn b/library/SCTP_Templates.ttcn
new file mode 100644
index 0000000..f63637f
--- /dev/null
+++ b/library/SCTP_Templates.ttcn
@@ -0,0 +1,68 @@
+module SCTP_Templates {
+
+/* (C) 2024 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ *
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+import from Socket_API_Definitions all;
+
+template (value) SctpTuple
+ts_SctpTuple(template (omit) integer ppid := omit,
+	     template (omit) AssociationId assoc_id := omit) := {
+	sinfo_stream := omit,
+	sinfo_ppid := ppid,
+	remSocks := omit,
+	assocId := assoc_id
+};
+template SctpTuple
+tr_SctpTuple(template integer ppid := *,
+	     template AssociationId assoc_id := *) := {
+	sinfo_stream := *,
+	sinfo_ppid := ppid,
+	remSocks := *,
+	assocId := assoc_id
+};
+
+
+template Socket_API_Definitions.PortEvent
+tr_SctpAssocChange(template (present) SAC_STATE state := ?,
+		   template (present) ConnectionId conn_id := ?,
+		   template (present) SctpTuple sctp := ?) := {
+	sctpEvent := {
+		sctpAssocChange := {
+			clientId := conn_id,
+			proto := {
+				sctp := sctp
+			},
+			sac_state := state
+		}
+	}
+}
+
+template Socket_API_Definitions.PortEvent
+tr_SctpPeerAddrChange(template (present) SPC_STATE state := ?,
+		      template (present) ConnectionId conn_id := ?) := {
+	sctpEvent := {
+		sctpPeerAddrChange := {
+			clientId := conn_id,
+			spc_state := state
+		}
+	}
+}
+
+template Socket_API_Definitions.PortEvent
+tr_SctpShutDownEvent(template (present) ConnectionId conn_id := ?) := {
+	sctpEvent := {
+		sctpShutDownEvent := {
+			clientId := conn_id
+		}
+	}
+}
+
+}
diff --git a/library/SGsAP_Emulation.ttcn b/library/SGsAP_Emulation.ttcn
index b860fe2..bb125a5 100644
--- a/library/SGsAP_Emulation.ttcn
+++ b/library/SGsAP_Emulation.ttcn
@@ -31,6 +31,7 @@
 import from SGsAP_CodecPort_CtrlFunct all;
 import from SGsAP_Types all;
 import from SGsAP_Templates all;
+import from SCTP_Templates all;
 import from Osmocom_Types all;
 import from IPL4asp_Types all;
 import from DNS_Helpers all;
@@ -245,24 +246,6 @@
 	return omit;
 }
 
-private template (value) SctpTuple ts_SCTP(template (omit) integer ppid := omit) := {
-	sinfo_stream := omit,
-	sinfo_ppid := ppid,
-	remSocks := omit,
-	assocId := omit
-};
-
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
-
 private function f_sgsap_xceive(template (value) PDU_SGsAP tx,
 				template PDU_SGsAP rx_t := ?)
 runs on SGsAP_Emulation_CT  return PDU_SGsAP {
@@ -290,10 +273,12 @@
 
 	map(self:SGsAP, system:SGsAP_CODEC_PT);
 	if (p.remote_sctp_port == -1) {
-		res := SGsAP_CodecPort_CtrlFunct.f_IPL4_listen(SGsAP, p.local_ip, p.local_sctp_port, { sctp := valueof(ts_SCTP) });
+		res := SGsAP_CodecPort_CtrlFunct.f_IPL4_listen(SGsAP, p.local_ip, p.local_sctp_port,
+							       { sctp := valueof(ts_SctpTuple) });
 	} else {
 		res := SGsAP_CodecPort_CtrlFunct.f_IPL4_connect(SGsAP, p.remote_ip, p.remote_sctp_port,
-								p.local_ip, p.local_sctp_port, -1, { sctp := valueof(ts_SCTP) });
+								p.local_ip, p.local_sctp_port, -1,
+							        { sctp := valueof(ts_SctpTuple) });
 	}
 	if (not ispresent(res.connId)) {
 		setverdict(fail, "Could not connect SGsAP socket, check your configuration");
diff --git a/library/sbcap/SBC_AP_Adapter.ttcn b/library/sbcap/SBC_AP_Adapter.ttcn
index 515a723..5adb648 100644
--- a/library/sbcap/SBC_AP_Adapter.ttcn
+++ b/library/sbcap/SBC_AP_Adapter.ttcn
@@ -21,6 +21,7 @@
 import from IPL4asp_Types all;
 import from IPL4asp_PortType all;
 import from Socket_API_Definitions all;
+import from SCTP_Templates all;
 import from Misc_Helpers all;
 
 
@@ -34,25 +35,14 @@
 	var IPL4asp_Types.ConnectionId g_SBC_AP_conn_id[NUM_SBC_AP] := { -1, -1, -1 };
 }
 
-private template Socket_API_Definitions.PortEvent tr_SctpAssocChange_COMM_UP(IPL4asp_Types.ConnectionId id) := {
-	sctpEvent := {
-		sctpAssocChange := {
-			clientId := id,
-			proto := {
-				sctp := ?
-			},
-			sac_state := SCTP_COMM_UP
-		}
-	}
-}
-
 function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
 		   charstring local_host, IPL4asp_Types.PortNumber local_port, integer idx := 0)
 runs on SBC_AP_Adapter_CT {
 	var IPL4asp_Types.Result res;
 	map(self:SBC_AP[idx], system:SBC_AP);
 	res := SBC_AP_CodecPort_CtrlFunct.f_IPL4_connect(SBC_AP[idx], remote_host, remote_port,
-							local_host, local_port, 0, { sctp := valueof(ts_SBC_AP_SctpTuple) });
+							local_host, local_port, 0,
+							{ sctp := c_SBC_AP_SctpTuple });
 	if (not ispresent(res.connId)) {
 		setverdict(fail, "Could not connect to SBC_AP port, check your configuration");
 		mtc.stop;
@@ -61,7 +51,7 @@
 	timer Tcommup := 10.0;
 	Tcommup.start;
 	alt {
-	[] SBC_AP[idx].receive(tr_SctpAssocChange_COMM_UP(g_SBC_AP_conn_id[idx])) {}
+	[] SBC_AP[idx].receive(tr_SctpAssocChange(SCTP_COMM_UP, g_SBC_AP_conn_id[idx])) {}
 	[] Tcommup.timeout {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting SCTP_COMM_UP");
 	}
@@ -73,7 +63,8 @@
 runs on SBC_AP_Adapter_CT {
 	var IPL4asp_Types.Result res;
 	map(self:SBC_AP[idx], system:SBC_AP);
-	res := SBC_AP_CodecPort_CtrlFunct.f_IPL4_listen(SBC_AP[idx], local_host, local_port, { sctp := valueof(ts_SBC_AP_SctpTuple) });
+	res := SBC_AP_CodecPort_CtrlFunct.f_IPL4_listen(SBC_AP[idx], local_host, local_port,
+							{ sctp := c_SBC_AP_SctpTuple });
 	g_SBC_AP_conn_id[idx] := res.connId;
 }
 
@@ -87,7 +78,7 @@
 	timer Tcommup := 10.0;
 	Tcommup.start;
 	alt {
-	[] SBC_AP[idx].receive(tr_SctpAssocChange_COMM_UP(g_SBC_AP_conn_id[idx])) {}
+	[] SBC_AP[idx].receive(tr_SctpAssocChange(SCTP_COMM_UP, g_SBC_AP_conn_id[idx])) {}
 	[] Tcommup.timeout {
 		Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting SCTP_COMM_UP");
 	}
diff --git a/library/sbcap/SBC_AP_CodecPort.ttcn b/library/sbcap/SBC_AP_CodecPort.ttcn
index bd17031..881e189 100644
--- a/library/sbcap/SBC_AP_CodecPort.ttcn
+++ b/library/sbcap/SBC_AP_CodecPort.ttcn
@@ -32,7 +32,7 @@
 		SBC_AP_PDU	msg
 	};
 
-	template (value) SctpTuple ts_SBC_AP_SctpTuple := {
+	const SctpTuple c_SBC_AP_SctpTuple := {
 		sinfo_stream := omit,
 		sinfo_ppid := c_SBC_AP_PPID,
 		remSocks := omit,
@@ -65,7 +65,7 @@
 	private function SBC_AP_to_IPL4_Send(in SBC_AP_Send pin, out ASP_Send pout) {
 		pout.connId := pin.connId;
 		pout.proto := {
-			sctp := valueof(ts_SBC_AP_SctpTuple)
+			sctp := c_SBC_AP_SctpTuple
 		};
 		pout.msg := enc_SBC_AP_PDU(pin.msg);
 	} with { extension "prototype(fast)" };
diff --git a/mme/gen_links.sh b/mme/gen_links.sh
index be08870..dad9c23 100755
--- a/mme/gen_links.sh
+++ b/mme/gen_links.sh
@@ -81,6 +81,7 @@
 FILES+="GTPv2_PrivateExtensions.ttcn GTPv2_Templates.ttcn "
 FILES+="GTPv2_CodecPort.ttcn GTPv2_CodecPort_CtrlFunctDef.cc GTPv2_CodecPort_CtrlFunct.ttcn GTPv2_Emulation.ttcn "
 FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/msc/gen_links.sh b/msc/gen_links.sh
index a15c42d..93e339c 100755
--- a/msc/gen_links.sh
+++ b/msc/gen_links.sh
@@ -102,6 +102,7 @@
 FILES+="SMPP_CodecPort.ttcn SMPP_CodecPort_CtrlFunct.ttcn SMPP_CodecPort_CtrlFunctDef.cc SMPP_Emulation.ttcn SMPP_Templates.ttcn "
 FILES+="SS_Templates.ttcn SCCP_Templates.ttcn USSD_Helpers.ttcn "
 FILES+="SGsAP_Templates.ttcn SGsAP_CodecPort.ttcn SGsAP_CodecPort_CtrlFunct.ttcn SGsAP_CodecPort_CtrlFunctDef.cc SGsAP_Emulation.ttcn DNS_Helpers.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/pgw/gen_links.sh b/pgw/gen_links.sh
index 9bdface..07907e7 100755
--- a/pgw/gen_links.sh
+++ b/pgw/gen_links.sh
@@ -65,6 +65,7 @@
 FILES+="DNS_Helpers.ttcn "
 FILES+="DIAMETER_Types.ttcn DIAMETER_CodecPort.ttcn DIAMETER_CodecPort_CtrlFunct.ttcn DIAMETER_CodecPort_CtrlFunctDef.cc DIAMETER_Emulation.ttcn "
 FILES+="DIAMETER_Templates.ttcn DIAMETER_rfc4004_Templates.ttcn DIAMETER_rfc5447_Templates.ttcn DIAMETER_ts29_212_Templates.ttcn DIAMETER_ts29_212_Templates.ttcn DIAMETER_ts29_229_Templates.ttcn DIAMETER_ts29_272_Templates.ttcn DIAMETER_ts29_273_Templates.ttcn DIAMETER_ts32_299_Templates.ttcn "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results
diff --git a/stp/STP_Tests_M3UA.ttcn b/stp/STP_Tests_M3UA.ttcn
index 24b3ae1..9c45a32 100644
--- a/stp/STP_Tests_M3UA.ttcn
+++ b/stp/STP_Tests_M3UA.ttcn
@@ -33,6 +33,7 @@
 import from SCCP_Templates all;
 import from SCCPasp_Types all;
 import from SCCP_Emulation all;
+import from SCTP_Templates all;
 
 import from STP_Tests_Common all;
 
@@ -151,16 +152,6 @@
 	var integer g_m3ua_conn_id[NR_M3UA+NR_M3UA_SRV];
 }
 
-private template PortEvent tr_SctpAssocChange := {
-	sctpEvent := {
-		sctpAssocChange := ?
-	}
-}
-private template PortEvent tr_SctpPeerAddrChange := {
-	sctpEvent := {
-		sctpPeerAddrChange := ?
-	}
-}
 private template PortEvent tr_ConnOpened := {
 	connOpened := ?
 }
diff --git a/stp/gen_links.sh b/stp/gen_links.sh
index aaf3421..ad5d605 100755
--- a/stp/gen_links.sh
+++ b/stp/gen_links.sh
@@ -52,6 +52,7 @@
 FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
 FILES+="SCCP_Templates.ttcn "
 FILES+="M3UA_Templates.ttcn M3UA_CodecPort.ttcn M3UA_CodecPort_CtrlFunct.ttcn M3UA_CodecPort_CtrlFunctDef.cc "
+FILES+="SCTP_Templates.ttcn "
 gen_links $DIR $FILES
 
 ignore_pp_results