<p>Harald Welte <strong>merged</strong> this change.</p><p><a href="https://gerrit.osmocom.org/9653">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">introduce a TTCN3 test suite for SCCP<br><br>This test suite acts as an SCCP server on top of M3UA.<br><br>SCCP tests are run against the sccp_demo_user program which<br>can be found in libosmo-sccp/examples. This program must be<br>started in client mode: sccp_demo_user -c<br>The SCCP test suite should then work out of the box with<br>the provided SCCP_Tests.cfg file and this additional change<br>to sccp_demo_user default point codes:<br>https://gerrit.osmocom.org/#/c/libosmo-sccp/+/9652/<br><br>There is currently only one test, for the libosmo-sccp crash<br>reported as issue OS#2666. The implementation of this test<br>is currently using an ugly workaround due to shortcomings of<br>the M3UA Emulation layer (see source code comments). Whether<br>a better solution is feasible is still to be determined.<br><br>The test requires a patch to the SCCP Protocol Emulation which<br>has been submitted upstream: https://git.eclipse.org/r/#/c/124552/<br><br>Change-Id: I03f5e8b282a7396b45417495c88d8fb81b26cda8<br>Related: OS#2666<br>---<br>M Makefile<br>M bsc/BSC_Tests.ttcn<br>M bsc/gen_links.sh<br>M library/BSSAP_Adapter.ttcn<br>A library/SCCP_Templates.ttcn<br>M msc/MSC_Tests.ttcn<br>M msc/gen_links.sh<br>A sccp/SCCP_Tests.cfg<br>A sccp/SCCP_Tests.default<br>A sccp/SCCP_Tests.ttcn<br>A sccp/gen_links.sh<br>A sccp/regen_makefile.sh<br>12 files changed, 336 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/Makefile b/Makefile</span><br><span>index a12a504..074e151 100644</span><br><span>--- a/Makefile</span><br><span>+++ b/Makefile</span><br><span>@@ -1,4 +1,4 @@</span><br><span style="color: hsl(0, 100%, 40%);">-SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu selftest sgsn sip sysinfo</span><br><span style="color: hsl(120, 100%, 40%);">+SUBDIRS=bsc bsc-nat bts ggsn_tests hlr lapdm mgw msc pcu sccp selftest sgsn sip sysinfo</span><br><span> </span><br><span> NPROC=$(shell nproc 2>/dev/null)</span><br><span> ifeq ($(NPROC),)</span><br><span>diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn</span><br><span>index d71d3dc..9412251 100644</span><br><span>--- a/bsc/BSC_Tests.ttcn</span><br><span>+++ b/bsc/BSC_Tests.ttcn</span><br><span>@@ -46,6 +46,7 @@</span><br><span> import from L3_Templates all;</span><br><span> import from GSM_RR_Types all;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Templates all;</span><br><span> import from BSSMAP_Templates all;</span><br><span> </span><br><span> const integer NUM_BTS := 3;</span><br><span>diff --git a/bsc/gen_links.sh b/bsc/gen_links.sh</span><br><span>index a6a1b0a..3e27cb1 100755</span><br><span>--- a/bsc/gen_links.sh</span><br><span>+++ b/bsc/gen_links.sh</span><br><span>@@ -67,7 +67,7 @@</span><br><span> gen_links $DIR $FILES</span><br><span> </span><br><span> DIR=../library</span><br><span style="color: hsl(0, 100%, 40%);">-FILES="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 L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn RLCMAC_CSN1_Types.ttcn GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc BSSAP_CodecPort.ttcn BSSAP_Adapter.ttcn 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 "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="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 L3_Templates.ttcn BSSMAP_Templates.ttcn BSSMAP_Emulation.ttcn RLCMAC_CSN1_Types.ttcn GSM_RR_Types.ttcn RSL_Types.ttcn RSL_Emulation.ttcn MGCP_Emulation.ttcn MGCP_Types.ttcn MGCP_Templates.ttcn MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunct.ttcn MGCP_CodecPort_CtrlFunctDef.cc BSSAP_CodecPort.ttcn BSSAP_Adapter.ttcn 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 SCCP_Templates.ttcn"</span><br><span> gen_links $DIR $FILES</span><br><span> </span><br><span> ignore_pp_results</span><br><span>diff --git a/library/BSSAP_Adapter.ttcn b/library/BSSAP_Adapter.ttcn</span><br><span>index b29d03f..ada66d2 100644</span><br><span>--- a/library/BSSAP_Adapter.ttcn</span><br><span>+++ b/library/BSSAP_Adapter.ttcn</span><br><span>@@ -18,6 +18,7 @@</span><br><span> import from SCCP_Types all;</span><br><span> import from SCCPasp_Types all;</span><br><span> import from SCCP_Emulation all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Templates all;</span><br><span> </span><br><span> import from SCTPasp_Types all;</span><br><span> import from SCTPasp_PortType all;</span><br><span>@@ -59,20 +60,6 @@</span><br><span>       integer rctx</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* construct a SCCP_PAR_Address with just PC + SSN and no GT */</span><br><span style="color: hsl(0, 100%, 40%);">-template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,</span><br><span style="color: hsl(0, 100%, 40%);">-                                                     charstring sccp_srv_type) := {</span><br><span style="color: hsl(0, 100%, 40%);">-  addressIndicator := {</span><br><span style="color: hsl(0, 100%, 40%);">-           pointCodeIndic := '1'B,</span><br><span style="color: hsl(0, 100%, 40%);">-         ssnIndicator := '1'B,</span><br><span style="color: hsl(0, 100%, 40%);">-           globalTitleIndic := '0000'B,</span><br><span style="color: hsl(0, 100%, 40%);">-            routingIndicator := '1'B</span><br><span style="color: hsl(0, 100%, 40%);">-        },</span><br><span style="color: hsl(0, 100%, 40%);">-      signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),</span><br><span style="color: hsl(0, 100%, 40%);">-      subsystemNumber := ssn,</span><br><span style="color: hsl(0, 100%, 40%);">- globalTitle := omit</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> private function init_pars(inout BSSAP_Adapter ba, in BSSAP_Configuration cfg) {</span><br><span>     ba.sccp_pars := {</span><br><span>            sio := {</span><br><span>diff --git a/library/SCCP_Templates.ttcn b/library/SCCP_Templates.ttcn</span><br><span>new file mode 100644</span><br><span>index 0000000..f4019b8</span><br><span>--- /dev/null</span><br><span>+++ b/library/SCCP_Templates.ttcn</span><br><span>@@ -0,0 +1,47 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Released under the terms of GNU General Public License, Version 2 or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+module SCCP_Templates {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Types all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCPasp_Types all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Emulation all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* construct a SCCP_PAR_Address with just PC + SSN and no GT */</span><br><span style="color: hsl(120, 100%, 40%);">+template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,</span><br><span style="color: hsl(120, 100%, 40%);">+                                                      charstring sccp_srv_type) := {</span><br><span style="color: hsl(120, 100%, 40%);">+        addressIndicator := {</span><br><span style="color: hsl(120, 100%, 40%);">+         pointCodeIndic := '1'B,</span><br><span style="color: hsl(120, 100%, 40%);">+               ssnIndicator := '1'B,</span><br><span style="color: hsl(120, 100%, 40%);">+         globalTitleIndic := '0000'B,</span><br><span style="color: hsl(120, 100%, 40%);">+          routingIndicator := '1'B</span><br><span style="color: hsl(120, 100%, 40%);">+      },</span><br><span style="color: hsl(120, 100%, 40%);">+    signPointCode := SCCP_SPC_int2bit(pc, sccp_srv_type, sio),</span><br><span style="color: hsl(120, 100%, 40%);">+    subsystemNumber := ssn,</span><br><span style="color: hsl(120, 100%, 40%);">+       globalTitle := omit</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* construct a SCCP_PAR_Address with only GT */</span><br><span style="color: hsl(120, 100%, 40%);">+template (value) SCCP_PAR_Address ts_SccpAddr_GT(hexstring global_address) := {</span><br><span style="color: hsl(120, 100%, 40%);">+    addressIndicator := {</span><br><span style="color: hsl(120, 100%, 40%);">+         pointCodeIndic := '0'B,</span><br><span style="color: hsl(120, 100%, 40%);">+               ssnIndicator := '0'B,</span><br><span style="color: hsl(120, 100%, 40%);">+         globalTitleIndic := '0001'B, // NAI only</span><br><span style="color: hsl(120, 100%, 40%);">+              routingIndicator := cg_route_on_GT // route on GT</span><br><span style="color: hsl(120, 100%, 40%);">+     },</span><br><span style="color: hsl(120, 100%, 40%);">+    signPointCode := omit,</span><br><span style="color: hsl(120, 100%, 40%);">+        subsystemNumber := omit,</span><br><span style="color: hsl(120, 100%, 40%);">+      globalTitle := {</span><br><span style="color: hsl(120, 100%, 40%);">+              gti0001 := {</span><br><span style="color: hsl(120, 100%, 40%);">+                  natureOfAddress := '0000011'B,</span><br><span style="color: hsl(120, 100%, 40%);">+                        oddeven := '0'B,</span><br><span style="color: hsl(120, 100%, 40%);">+                      globalTitleAddress := global_address</span><br><span style="color: hsl(120, 100%, 40%);">+          }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn</span><br><span>index 63cab84..1427fd0 100644</span><br><span>--- a/msc/MSC_Tests.ttcn</span><br><span>+++ b/msc/MSC_Tests.ttcn</span><br><span>@@ -51,6 +51,8 @@</span><br><span> import from SMPP_Templates all;</span><br><span> import from SMPP_Emulation all;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Templates all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> import from SS_Types all;</span><br><span> import from SS_Templates all;</span><br><span> import from USSD_Helpers all;</span><br><span>diff --git a/msc/gen_links.sh b/msc/gen_links.sh</span><br><span>index 8b40268..d8a7d22 100755</span><br><span>--- a/msc/gen_links.sh</span><br><span>+++ b/msc/gen_links.sh</span><br><span>@@ -90,7 +90,7 @@</span><br><span> FILES+="RTP_CodecPort.ttcn RTP_CodecPort_CtrlFunctDef.cc "</span><br><span> FILES+="MGCP_CodecPort.ttcn MGCP_CodecPort_CtrlFunctDef.cc "</span><br><span> FILES+="SMPP_CodecPort.ttcn SMPP_CodecPort_CtrlFunct.ttcn SMPP_CodecPort_CtrlFunctDef.cc SMPP_Emulation.ttcn SMPP_Templates.ttcn "</span><br><span style="color: hsl(0, 100%, 40%);">-FILES+="SS_Templates.ttcn "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+="SS_Templates.ttcn SCCP_Templates.ttcn"</span><br><span> gen_links $DIR $FILES</span><br><span> </span><br><span> ignore_pp_results</span><br><span>diff --git a/sccp/SCCP_Tests.cfg b/sccp/SCCP_Tests.cfg</span><br><span>new file mode 100644</span><br><span>index 0000000..4b7e742</span><br><span>--- /dev/null</span><br><span>+++ b/sccp/SCCP_Tests.cfg</span><br><span>@@ -0,0 +1,19 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[ORDERED_INCLUDE]</span><br><span style="color: hsl(120, 100%, 40%);">+# Common configuration, shared between test suites</span><br><span style="color: hsl(120, 100%, 40%);">+"../Common.cfg"</span><br><span style="color: hsl(120, 100%, 40%);">+# testsuite specific configuration, not expected to change</span><br><span style="color: hsl(120, 100%, 40%);">+"./SCCP_Tests.default"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Local configuration below</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[LOGGING]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[TESTPORT_PARAMETERS]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[MODULE_PARAMETERS]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[MAIN_CONTROLLER]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[EXECUTE]</span><br><span style="color: hsl(120, 100%, 40%);">+SCCP_Tests.control</span><br><span style="color: hsl(120, 100%, 40%);">+#SCCP_Tests.TC_routing_global_title_crash</span><br><span>diff --git a/sccp/SCCP_Tests.default b/sccp/SCCP_Tests.default</span><br><span>new file mode 100644</span><br><span>index 0000000..7d16e5b</span><br><span>--- /dev/null</span><br><span>+++ b/sccp/SCCP_Tests.default</span><br><span>@@ -0,0 +1,41 @@</span><br><span style="color: hsl(120, 100%, 40%);">+[LOGGING]</span><br><span style="color: hsl(120, 100%, 40%);">+FileMask := LOG_ALL | TTCN_MATCHING | DEBUG_ENCDEC;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+BSSAP.FileMask := LOG_NOTHING;</span><br><span style="color: hsl(120, 100%, 40%);">+"SCCP_Test_M3UA".FileMask := ERROR | WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+"SCCP_Test_SCCP".FileMask := ERROR | WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+"IPA-CTRL-IPA".FileMask := ERROR | WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+mtc.FileMask := ERROR | WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[TESTPORT_PARAMETERS]</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_MODE := "client"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_HOSTNAME := "127.0.0.1"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_PORTNUM := "2325"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_LOGIN_SKIPPED := "yes"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_DETECT_SERVER_DISCONNECTED := "yes"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_READMODE := "buffered"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.CTRL_CLIENT_CLEANUP_LINEFEED := "yes"</span><br><span style="color: hsl(120, 100%, 40%);">+*.SCCP_DEMO_USER_VTY.PROMPT1 := "sccp-demo-user> "</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[MODULE_PARAMETERS]</span><br><span style="color: hsl(120, 100%, 40%);">+M3UA_Emulation.tsp_logVerbose := true;</span><br><span style="color: hsl(120, 100%, 40%);">+M3UA_Emulation.tsp_SCTP_Server_Mode := true;</span><br><span style="color: hsl(120, 100%, 40%);">+M3UA_Emulation.tsp_M3UA_Server_Mode := true;</span><br><span style="color: hsl(120, 100%, 40%);">+SCCP_Tests.sccp_cfg := {</span><br><span style="color: hsl(120, 100%, 40%);">+      {</span><br><span style="color: hsl(120, 100%, 40%);">+                     sccp_service_type := "mtp3_itu",</span><br><span style="color: hsl(120, 100%, 40%);">+                    sctp_addr := { 2905, "127.0.0.1", 2905, "127.0.0.2" },</span><br><span style="color: hsl(120, 100%, 40%);">+                    own_pc := 185,</span><br><span style="color: hsl(120, 100%, 40%);">+                        own_ssn := 254,</span><br><span style="color: hsl(120, 100%, 40%);">+                       peer_pc := 23,</span><br><span style="color: hsl(120, 100%, 40%);">+                        peer_ssn := 254,</span><br><span style="color: hsl(120, 100%, 40%);">+                      sio := '83'O,</span><br><span style="color: hsl(120, 100%, 40%);">+                 rctx := 0</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Osmocom_VTY_Functions.mp_prompt_prefix := "sccp-demo-user";</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[MAIN_CONTROLLER]</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[EXECUTE]</span><br><span>diff --git a/sccp/SCCP_Tests.ttcn b/sccp/SCCP_Tests.ttcn</span><br><span>new file mode 100644</span><br><span>index 0000000..ea2522a</span><br><span>--- /dev/null</span><br><span>+++ b/sccp/SCCP_Tests.ttcn</span><br><span>@@ -0,0 +1,153 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom s.f.m.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Stefan Sperling <ssperling@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Released under the terms of GNU General Public License, Version 2 or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+module SCCP_Tests {</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from M3UA_Emulation all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCPasp_Types all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Types all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Emulation all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCCP_Templates all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from SCTPasp_PortType all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from Osmocom_CTRL_Adapter all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+import from TELNETasp_PortType all;</span><br><span style="color: hsl(120, 100%, 40%);">+import from Osmocom_VTY_Functions all;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+type component system_CT {</span><br><span style="color: hsl(120, 100%, 40%);">+     port SCTPasp_PT sctp;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+type component MTC_CT extends CTRL_Adapter_CT {</span><br><span style="color: hsl(120, 100%, 40%);">+     /* VTY to sccp_demo_user (not used yet) */</span><br><span style="color: hsl(120, 100%, 40%);">+    port TELNETasp_PT SCCP_DEMO_USER_VTY;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       /* SCCP protocol runs on top of M3UA Emulation.</span><br><span style="color: hsl(120, 100%, 40%);">+        * "System Under Test" is libosmo-sccp's sccp_demo_user example program. */</span><br><span style="color: hsl(120, 100%, 40%);">+     var SCCP_CT vc_SCCP_A;</span><br><span style="color: hsl(120, 100%, 40%);">+        var M3UA_CT vc_M3UA;</span><br><span style="color: hsl(120, 100%, 40%);">+  port SCCPasp_PT A_PORT;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+type record SCCP_Configuration {</span><br><span style="color: hsl(120, 100%, 40%);">+        charstring sccp_service_type,</span><br><span style="color: hsl(120, 100%, 40%);">+ SCTP_Association_Address sctp_addr,</span><br><span style="color: hsl(120, 100%, 40%);">+   integer own_pc,</span><br><span style="color: hsl(120, 100%, 40%);">+       integer own_ssn,</span><br><span style="color: hsl(120, 100%, 40%);">+      integer peer_pc,</span><br><span style="color: hsl(120, 100%, 40%);">+      integer peer_ssn,</span><br><span style="color: hsl(120, 100%, 40%);">+     octetstring sio,</span><br><span style="color: hsl(120, 100%, 40%);">+      integer rctx</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+type record of SCCP_Configuration SCCP_Configurations;</span><br><span style="color: hsl(120, 100%, 40%);">+modulepar {</span><br><span style="color: hsl(120, 100%, 40%);">+       SCCP_Configurations sccp_cfg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function f_init(SCCP_Configuration cfg) runs on MTC_CT {</span><br><span style="color: hsl(120, 100%, 40%);">+  var MSC_SCCP_MTP3_parameters v_param := {</span><br><span style="color: hsl(120, 100%, 40%);">+             sio := {</span><br><span style="color: hsl(120, 100%, 40%);">+                      ni := substr(oct2bit(cfg.sio),0,2),</span><br><span style="color: hsl(120, 100%, 40%);">+                   prio := substr(oct2bit(cfg.sio),2,2),</span><br><span style="color: hsl(120, 100%, 40%);">+                 si := substr(oct2bit(cfg.sio),4,4)</span><br><span style="color: hsl(120, 100%, 40%);">+            },</span><br><span style="color: hsl(120, 100%, 40%);">+            opc := cfg.own_pc,</span><br><span style="color: hsl(120, 100%, 40%);">+            dpc := cfg.peer_pc,</span><br><span style="color: hsl(120, 100%, 40%);">+           sls := 0,</span><br><span style="color: hsl(120, 100%, 40%);">+             sccp_serviceType := cfg.sccp_service_type,</span><br><span style="color: hsl(120, 100%, 40%);">+            ssn := cfg.own_ssn</span><br><span style="color: hsl(120, 100%, 40%);">+    };</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  map(self:SCCP_DEMO_USER_VTY, system:SCCP_DEMO_USER_VTY);</span><br><span style="color: hsl(120, 100%, 40%);">+      f_vty_set_prompts(SCCP_DEMO_USER_VTY);</span><br><span style="color: hsl(120, 100%, 40%);">+        f_vty_transceive(SCCP_DEMO_USER_VTY, "enable");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   /* Create and connect test components for an SCCP connection with M3UA beneath. */</span><br><span style="color: hsl(120, 100%, 40%);">+    vc_SCCP_A := SCCP_CT.create;</span><br><span style="color: hsl(120, 100%, 40%);">+  vc_M3UA := M3UA_CT.create;</span><br><span style="color: hsl(120, 100%, 40%);">+    connect(self:A_PORT, vc_SCCP_A:SCCP_SP_PORT);</span><br><span style="color: hsl(120, 100%, 40%);">+ connect(vc_M3UA:MTP3_SP_PORT, vc_SCCP_A:MTP3_SCCP_PORT);</span><br><span style="color: hsl(120, 100%, 40%);">+      map(vc_M3UA:SCTP_PORT, system:sctp);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr));</span><br><span style="color: hsl(120, 100%, 40%);">+       vc_SCCP_A.start(SCCPStart(v_param));</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+function f_cleanup() runs on MTC_CT {</span><br><span style="color: hsl(120, 100%, 40%);">+      all component.stop;</span><br><span style="color: hsl(120, 100%, 40%);">+   unmap(vc_M3UA:SCTP_PORT, system:sctp);</span><br><span style="color: hsl(120, 100%, 40%);">+        disconnect(vc_M3UA:MTP3_SP_PORT, vc_SCCP_A:MTP3_SCCP_PORT);</span><br><span style="color: hsl(120, 100%, 40%);">+   disconnect(self:A_PORT, vc_SCCP_A:SCCP_SP_PORT);</span><br><span style="color: hsl(120, 100%, 40%);">+      self.stop</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * libosmo-sccp does not support Global Title address as a routing indicator.</span><br><span style="color: hsl(120, 100%, 40%);">+ * But sccp_demo_user should not crash if such a message is received (see OS#2666).</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+testcase TC_routing_global_title_crash() runs on MTC_CT system system_CT {</span><br><span style="color: hsl(120, 100%, 40%);">+       timer TL_timer:= 10.0; /* twice the sccp_demo_user connection attempt interval */</span><br><span style="color: hsl(120, 100%, 40%);">+     var SCCP_PAR_Address v_CallingAddress;</span><br><span style="color: hsl(120, 100%, 40%);">+        var SCCP_PAR_Address v_CalledAddress;</span><br><span style="color: hsl(120, 100%, 40%);">+ var octetstring vl_userdata :='12345678901234567890'O;</span><br><span style="color: hsl(120, 100%, 40%);">+        var ASP_SCCP_N_UNITDATA_ind vl_N_UNITDATA_ind;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      f_init(sccp_cfg[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        /* Called address with routing indicator set to Global Title Address. This used to trigger the crash. */</span><br><span style="color: hsl(120, 100%, 40%);">+      v_CalledAddress := valueof(ts_SccpAddr_GT('012345'H));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      v_CallingAddress := valueof(ts_SccpAddr_PC_SSN(sccp_cfg[0].own_pc, sccp_cfg[0].own_ssn,</span><br><span style="color: hsl(120, 100%, 40%);">+                                                      sccp_cfg[0].sio, sccp_cfg[0].sccp_service_type));</span><br><span style="color: hsl(120, 100%, 40%);">+      A_PORT.send(t_ASP_N_UNITDATA_req(v_CalledAddress, v_CallingAddress, '00000001'B /* sequence control */,</span><br><span style="color: hsl(120, 100%, 40%);">+                                        '00000001'B /* return option */, vl_userdata, omit));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Start a timeout within which our DATA packet will be sent out.</span><br><span style="color: hsl(120, 100%, 40%);">+      * The M3UA Emulation layer has buffered the packet and is going</span><br><span style="color: hsl(120, 100%, 40%);">+       * to send it when the sccp_demo_user SCCP client connects.</span><br><span style="color: hsl(120, 100%, 40%);">+    *</span><br><span style="color: hsl(120, 100%, 40%);">+     * libosmo-sccp will echo the packet back at us in an SCCP UDTS packet.</span><br><span style="color: hsl(120, 100%, 40%);">+        * However, the current M3UA Emulation implementation will discard this</span><br><span style="color: hsl(120, 100%, 40%);">+        * response because it arrives on a separate SCTP association and the</span><br><span style="color: hsl(120, 100%, 40%);">+  * emulation only supports one association at a time.</span><br><span style="color: hsl(120, 100%, 40%);">+  *</span><br><span style="color: hsl(120, 100%, 40%);">+     * As a workaround, we wait for a fixed amount of time and then issue</span><br><span style="color: hsl(120, 100%, 40%);">+  * another command to the VTY of sccp_demo_user. If sccp_demo_user</span><br><span style="color: hsl(120, 100%, 40%);">+     * has crashed, this will result in a test failure.</span><br><span style="color: hsl(120, 100%, 40%);">+    */</span><br><span style="color: hsl(120, 100%, 40%);">+   TL_timer.start;</span><br><span style="color: hsl(120, 100%, 40%);">+       alt {</span><br><span style="color: hsl(120, 100%, 40%);">+         [] A_PORT.receive(tr_ASP_N_UNITDATA_ind) -> value vl_N_UNITDATA_ind {</span><br><span style="color: hsl(120, 100%, 40%);">+                      log("Received data from SCCP client.");</span><br><span style="color: hsl(120, 100%, 40%);">+                     repeat;</span><br><span style="color: hsl(120, 100%, 40%);">+               }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           [] TL_timer.timeout {</span><br><span style="color: hsl(120, 100%, 40%);">+                 log("Timeout....");</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     TL_timer.stop;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      /* Check that the VTY is still active (implying that the process hasn't crashed). */</span><br><span style="color: hsl(120, 100%, 40%);">+      f_vty_transceive_ret(SCCP_DEMO_USER_VTY, "?");</span><br><span style="color: hsl(120, 100%, 40%);">+      setverdict(pass);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   f_cleanup();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+control {</span><br><span style="color: hsl(120, 100%, 40%);">+  execute( TC_routing_global_title_crash() );</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/sccp/gen_links.sh b/sccp/gen_links.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..faf347c</span><br><span>--- /dev/null</span><br><span>+++ b/sccp/gen_links.sh</span><br><span>@@ -0,0 +1,62 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/bash</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+BASEDIR=../deps</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+. ../gen_links.sh.inc</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.UNIX_DOMAIN_SOCKETasp/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="UD_PT.cc  UD_PT.hh  UD_PortType.ttcn  UD_Types.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+=" TCCEncoding_Functions.ttcn TCCEncoding.cc " # GSM 7-bit coding</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="Socket_API_Definitions.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Required by MGCP and IPA</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.IPL4asp/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="IPL4asp_Functions.ttcn  IPL4asp_PT.cc  IPL4asp_PT.hh IPL4asp_PortType.ttcn  IPL4asp_Types.ttcn  IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# required by M3UA_Emulation</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.ProtocolModules.M3UA/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="M3UA_Types.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# required by M3UA_Emulation</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.SCTPasp/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="SCTPasp_PT.cc  SCTPasp_PT.hh  SCTPasp_PortType.ttcn  SCTPasp_Types.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# required by M3UA Emulation</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.MTP3asp/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="MTP3asp_PortType.ttcn  MTP3asp_Types.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# required by SCCP Emulation</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.ProtocolEmulations.M3UA/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="M3UA_Emulation.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.ProtocolEmulations.SCCP/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="SCCP_Emulation.ttcn  SCCP_EncDec.cc  SCCP_Mapping.ttcnpp  SCCP_Types.ttcn  SCCPasp_Types.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=$BASEDIR/titan.TestPorts.TELNETasp/src</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="TELNETasp_PT.cc  TELNETasp_PT.hh  TELNETasp_PortType.ttcn"</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DIR=../library</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+="Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+="IPA_Types.ttcn IPA_Emulation.ttcnpp IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "</span><br><span style="color: hsl(120, 100%, 40%);">+FILES+="SCCP_Templates.ttcn "</span><br><span style="color: hsl(120, 100%, 40%);">+gen_links $DIR $FILES</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ignore_pp_results</span><br><span>diff --git a/sccp/regen_makefile.sh b/sccp/regen_makefile.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..fc9e6d2</span><br><span>--- /dev/null</span><br><span>+++ b/sccp/regen_makefile.sh</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+FILES="*.ttcn *.ttcnpp SCCP_EncDec.cc  SCTPasp_PT.cc  TCCConversion.cc TCCInterface.cc UD_PT.cc IPL4asp_PT.cc IPL4asp_discovery.cc IPA_CodecPort_CtrlFunctDef.cc TELNETasp_PT.cc Native_FunctionDefs.cc TCCEncoding.cc "</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+export CPPFLAGS_TTCN3="-DIPA_EMULATION_SCCP -DUSE_MTP3_DISTRIBUTOR"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+../regen-makefile.sh SCCP_Tests.ttcn $FILES</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9653">change 9653</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9653"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ttcn3-hacks </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I03f5e8b282a7396b45417495c88d8fb81b26cda8 </div>
<div style="display:none"> Gerrit-Change-Number: 9653 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Stefan Sperling <ssperling@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: Stefan Sperling <ssperling@sysmocom.de> </div>