Change in osmo-ttcn3-hacks[master]: Add SCCP_Tests_RAW for testing the actual SCCP implementation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Jan 12 10:52:28 UTC 2020


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16814 )


Change subject: Add SCCP_Tests_RAW for testing the actual SCCP implementation
......................................................................

Add SCCP_Tests_RAW for testing the actual SCCP implementation

Using SCCP_Tests_RAW.ttcn we can trasnceive decoded MTP3 primitives
containing decoded SCCP messages against a remote SCCP implementation.

Change-Id: I07c43cfac9cdbdeccf102cd08309ca9ec64968cc
---
A sccp/SCCP_CodecPort.ttcn
A sccp/SCCP_Tests_RAW.cfg
A sccp/SCCP_Tests_RAW.ttcn
3 files changed, 269 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/14/16814/1

diff --git a/sccp/SCCP_CodecPort.ttcn b/sccp/SCCP_CodecPort.ttcn
new file mode 100644
index 0000000..665ef9e
--- /dev/null
+++ b/sccp/SCCP_CodecPort.ttcn
@@ -0,0 +1,71 @@
+module SCCP_CodecPort {
+
+/* Simple SCCP Codec Port, translating between raw MTP3 primitives with
+ * octetstring payload towards the MTP3 imovider, and MTP3-SCCP primitives
+ * which carry the decoded SCCP data types as payload.
+ *
+ * (C) 2019 by Harald Welte <laforge at gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ */
+
+import from General_Types all;
+import from Osmocom_Types all;
+
+import from MTP3asp_Types all;
+import from MTP3asp_PortType all;
+import from SCCP_Types all;
+
+/* MTP3asp_Types.Types.MessageTypes.ASP_MTP3_TRANSFERind with PDU_SCCP instead of octetstring */
+type record SCCP_MTP3_TRANSFERind {
+	MTP3_Field_sio	sio,
+	integer		opc,
+	integer		dpc,
+	integer		sls,
+	PDU_SCCP	data
+};
+
+/* MTP3asp_Types.Types.MessageTypes.ASP_MTP3_TRANSFERreq with PDU_SCCP instead of octetstring */
+type record SCCP_MTP3_TRANSFERreq {
+	MTP3_Field_sio	sio,
+	integer		opc,
+	integer		dpc,
+	integer		sls,
+	PDU_SCCP	data
+};
+
+private function f_dec_TRANSFERind(in ASP_MTP3_TRANSFERind pin, out SCCP_MTP3_TRANSFERind pout) {
+	pout.sio := pin.sio;
+	pout.opc := pin.opc;
+	pout.dpc := pin.dpc;
+	pout.data := dec_PDU_SCCP(pin.data);
+	//port.setstate(0);
+} with {extension "prototype(fast)" }
+
+
+private function f_enc_TRANSFERreq(in SCCP_MTP3_TRANSFERreq pin, out ASP_MTP3_TRANSFERreq pout) {
+	pout.sio := pin.sio;
+	pout.opc := pin.opc;
+	pout.dpc := pin.dpc;
+	pout.data := enc_PDU_SCCP(pin.data);
+	//port.setstate(0);
+} with {extension "prototype(fast)" }
+
+type port SCCP_CODEC_PT message {
+	out	SCCP_MTP3_TRANSFERreq;
+	in	SCCP_MTP3_TRANSFERind,
+		ASP_MTP3_PAUSE,
+		ASP_MTP3_RESUME,
+		ASP_MTP3_STATUS;
+} with { extension "internal user MTP3asp_PT
+	out(SCCP_MTP3_TRANSFERreq -> ASP_MTP3_TRANSFERreq: function(f_enc_TRANSFERreq))
+	in(ASP_MTP3_TRANSFERind -> SCCP_MTP3_TRANSFERind: function(f_dec_TRANSFERind);
+	   ASP_MTP3_PAUSE -> ASP_MTP3_PAUSE: simple;
+	   ASP_MTP3_RESUME -> ASP_MTP3_RESUME: simple;
+	   ASP_MTP3_STATUS -> ASP_MTP3_STATUS: simple)"
+}
+
+
+}
diff --git a/sccp/SCCP_Tests_RAW.cfg b/sccp/SCCP_Tests_RAW.cfg
new file mode 100644
index 0000000..e2fc17b
--- /dev/null
+++ b/sccp/SCCP_Tests_RAW.cfg
@@ -0,0 +1,34 @@
+[ORDERED_INCLUDE]
+# Common configuration, shared between test suites
+"../Common.cfg"
+# testsuite specific configuration, not expected to change
+"./SCCP_Tests.default"
+
+# Local configuration below
+
+[LOGGING]
+
+[TESTPORT_PARAMETERS]
+*.SCCP_DEMO_USER_VTY.CTRL_PORTNUM := "2324"
+
+[MODULE_PARAMETERS]
+M3UA_Emulation.tsp_SCTP_Server_Mode := false;
+M3UA_Emulation.tsp_M3UA_Server_Mode := false;
+SCCP_Tests.sccp_cfg := {
+	{
+			sccp_service_type := "mtp3_itu",
+			//sctp_addr := { 2905, "127.0.0.1", 2905, "127.0.0.2" },
+			sctp_addr := { 2905, "127.0.0.2", 2905, "127.0.0.1" },
+			own_pc := 23,
+			own_ssn := 254,
+			peer_pc := 1,
+			peer_ssn := 254,
+			sio := '83'O,
+			rctx := 0
+	}
+};
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+SCCP_Tests_RAW.control
diff --git a/sccp/SCCP_Tests_RAW.ttcn b/sccp/SCCP_Tests_RAW.ttcn
new file mode 100644
index 0000000..5836e3e
--- /dev/null
+++ b/sccp/SCCP_Tests_RAW.ttcn
@@ -0,0 +1,164 @@
+/* (C) 2019 by Harald Welte <laforge at gnumonks.org>
+ * All Rights Reserved
+ *
+ * The idea is that these tests are executed against sccp_demo_user from
+ * libosmo-sccp.git in server mode.
+ *
+ * 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
+ */
+
+module SCCP_Tests_RAW {
+
+import from General_Types all;
+import from Osmocom_Types all;
+
+import from M3UA_Emulation all;
+
+import from SCCP_Types all;
+import from SCCPasp_Types all;
+import from SCCP_Templates all;
+import from SCCP_Emulation all;
+import from SCCP_CodecPort all;
+
+import from TELNETasp_PortType all;
+import from Osmocom_VTY_Functions all;
+
+import from SCCP_Tests all;
+
+type component SCCP_Test_RAW_CT {
+	/* VTY to sccp_demo_user (not used yet) */
+	port TELNETasp_PT SCCP_DEMO_USER_VTY;
+
+	/* SCCP raw port runs on top of M3UA Emulation.
+	 * "System Under Test" is libosmo-sccp's sccp_demo_user example program. */
+	var M3UA_CT vc_M3UA;
+	port SCCP_CODEC_PT MTP3;
+
+	var MSC_SCCP_MTP3_parameters g_param;
+}
+
+private function f_init_raw(SCCP_Configuration cfg) runs on SCCP_Test_RAW_CT {
+	g_param := {
+		sio := {
+			ni := substr(oct2bit(cfg.sio),0,2),
+			prio := substr(oct2bit(cfg.sio),2,2),
+			si := substr(oct2bit(cfg.sio),4,4)
+		},
+		opc := cfg.own_pc,
+		dpc := cfg.peer_pc,
+		sls := 0,
+		sccp_serviceType := cfg.sccp_service_type,
+		ssn := cfg.own_ssn
+	};
+
+	map(self:SCCP_DEMO_USER_VTY, system:SCCP_DEMO_USER_VTY);
+	f_vty_set_prompts(SCCP_DEMO_USER_VTY);
+	f_vty_transceive(SCCP_DEMO_USER_VTY, "enable");
+
+	/* Create and connect test components */
+	vc_M3UA := M3UA_CT.create;
+	connect(self:MTP3, vc_M3UA:MTP3_SP_PORT);
+	map(vc_M3UA:SCTP_PORT, system:sctp);
+
+	vc_M3UA.start(f_M3UA_Emulation(cfg.sctp_addr));
+}
+
+private function f_cleanup() runs on SCCP_Test_RAW_CT {
+	all component.stop;
+	unmap(vc_M3UA:SCTP_PORT, system:sctp);
+	disconnect(vc_M3UA:MTP3_SP_PORT, self:MTP3);
+	self.stop
+}
+
+/* connection oriented SCCP */
+const SCCP_param_ProtocolClass c_class2 := { class:='0010'B, messageHandling:='0000'B };//class 2
+
+template (value) PDU_SCCP ts_SCCP_CR(OCT3 source_lref, SCCP_PAR_Address called) := {
+	connrequest := {
+		messageType := cc,
+		sourceLocRef := source_lref,
+		protClass := c_class2,
+		pointer1 := 2,
+		pointer2 := 0,
+		calledPAddress := ConvertASPAddressToEncodedAddress_itu(called),
+		optionalPart := {
+			credit := omit,
+			callingPAddress := omit,
+			data := omit,
+			hopCounter := omit,
+			importance := omit
+		},
+		eop := omit
+	}
+}
+
+template (present) PDU_SCCP tr_SCCP_CC(template (present) OCT3 dest_lref,
+				       template (present) OCT3 source_lref) := {
+	connconfirm := {
+		messageType := cr,
+		destLocRef := dest_lref,
+		sourceLocRef := source_lref,
+		protClass := c_class2,
+		pointer1 := 1,
+		optionalPart := *,
+		eop := *
+	}
+}
+
+private function f_send_sccp(template PDU_SCCP sccp) runs on SCCP_Test_RAW_CT {
+	var SCCP_MTP3_TRANSFERreq tx := {
+		sio := g_param.sio,
+		opc := g_param.opc,
+		dpc := g_param.dpc,
+		sls := g_param.sls,
+		data := valueof(sccp)
+	};
+	MTP3.send(tx);
+}
+
+private function f_exp_sccp(template PDU_SCCP sccp) runs on SCCP_Test_RAW_CT {
+	var SCCP_MTP3_TRANSFERind rx;
+	var template SCCP_MTP3_TRANSFERind exp := {
+		sio := g_param.sio,
+		opc := g_param.opc,
+		dpc := g_param.dpc,
+		sls := g_param.sls,
+		data := sccp
+	};
+	timer T := 10.0;
+	T.start;
+	alt {
+	[] MTP3.receive(exp) -> value rx {
+		setverdict(pass);
+		}
+	[] MTP3.receive {
+		setverdict(fail, "Unexpected MTP/SCCP received");
+		}
+	[] T.timeout {
+		setverdict(fail, "Timeout waiting for ", exp);
+		}
+	}
+}
+
+
+testcase TC_foo() runs on SCCP_Test_RAW_CT {
+	var SCCP_PAR_Address calling, called;
+	called := valueof(ts_SccpAddr_PC_SSN(sccp_cfg[0].peer_pc, sccp_cfg[0].peer_ssn,
+					     sccp_cfg[0].sio, sccp_cfg[0].sccp_service_type));
+	calling := valueof(ts_SccpAddr_PC_SSN(sccp_cfg[0].own_pc, sccp_cfg[0].own_ssn,
+					     sccp_cfg[0].sio, sccp_cfg[0].sccp_service_type));
+	f_init_raw(sccp_cfg[0]);
+	f_sleep(1.0);
+	f_send_sccp(ts_SCCP_CR('000001'O, called));
+	f_exp_sccp(tr_SCCP_CC('000001'O, ?));
+}
+
+control {
+	
+}
+
+
+}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16814
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I07c43cfac9cdbdeccf102cd08309ca9ec64968cc
Gerrit-Change-Number: 16814
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200112/9ea0ab3d/attachment.htm>


More information about the gerrit-log mailing list