library: de-duplicate SCTP related templates
Change-Id: Ic2a0cba0cfb1909ccbd1ade9565d508fd239f78c
Related: SYS#6772
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)" };