sccp: Add TC_callingparty_ssn_only()

This test verifies that libosmo-sccp will properly respond to SCCP
traffic that only has a SSN in the CallingPartyAddress.  That situation
poses the unique challenge of how to route a response, as we lack
a GT and a PC to do the routing.

In order to support this, libosm-sccp now adds the PC into the
CallingPartyAddr when passing such messages from M3UA to SCCP. This
way the recipient can simply respond back to that address and it will
be routed on PC.

Change-Id: Ided599a922fb7f6dbbfe90f817c5419ab793f293
Related: OS#5146
diff --git a/library/SCCP_Templates.ttcn b/library/SCCP_Templates.ttcn
index 55bf745..5167e4b 100644
--- a/library/SCCP_Templates.ttcn
+++ b/library/SCCP_Templates.ttcn
@@ -15,6 +15,19 @@
 import from SCCPasp_Types all;
 import from SCCP_Emulation all;
 
+/* construct a SCCP_PAR_Address with just SSN and no PC or GT */
+template (value) SCCP_PAR_Address ts_SccpAddr_SSN(integer ssn) := {
+	addressIndicator := {
+		pointCodeIndic := '0'B,
+		ssnIndicator := '1'B,
+		globalTitleIndic := '0000'B,
+		routingIndicator := '1'B
+	},
+	signPointCode := omit,
+	subsystemNumber := ssn,
+	globalTitle := omit
+}
+
 /* construct a SCCP_PAR_Address with just PC + SSN and no GT */
 template (value) SCCP_PAR_Address ts_SccpAddr_PC_SSN(integer pc, integer ssn, octetstring sio,
 							charstring sccp_srv_type) := {
diff --git a/sccp/SCCP_Tests_RAW.ttcn b/sccp/SCCP_Tests_RAW.ttcn
index 356fbb2..1ac82a2 100644
--- a/sccp/SCCP_Tests_RAW.ttcn
+++ b/sccp/SCCP_Tests_RAW.ttcn
@@ -312,7 +312,8 @@
 
 function f_scmg_xceive(SCCP_PAR_Address calling, SCCP_PAR_Address called,
 		       template (value) PDU_SCMG_message tx,
-		       template (omit) PDU_SCMG_message rx_exp) runs on SCCP_Test_RAW_CT
+		       template (omit) PDU_SCMG_message rx_exp,
+		       boolean accept_other_called_resp := false) runs on SCCP_Test_RAW_CT
 {
 	var boolean exp_something := true;
 	timer T := 5.0;
@@ -328,6 +329,9 @@
 	[exp_something] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, decmatch rx_exp))) {
 		setverdict(pass);
 		}
+	[exp_something and accept_other_called_resp] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, ?, decmatch rx_exp))) {
+		setverdict(pass);
+		}
 	[] MTP3.receive(tr_SCCP_MTP3_TRANSFERind(tr_SCCP_UDT(called, calling, ?))) {
 		setverdict(fail, "Received unexpected SCCP waiting for ", rx_exp);
 		}
@@ -402,6 +406,22 @@
 	f_scmg_xceive(calling, called, tx, rx_exp);
 }
 
+/* Test CallingParty(only SSN) solicits response (OS#5146) */
+testcase TC_callingparty_ssn_only() runs on SCCP_Test_RAW_CT {
+	var SCCP_PAR_Address calling, called;
+	var template (value) PDU_SCMG_message tx;
+	var template (present) PDU_SCMG_message rx_exp;
+
+	f_init_raw(mp_sccp_cfg[0]);
+	f_sleep(1.0);
+
+	called := valueof(ts_SccpAddr_SSN(1));
+	calling := valueof(ts_SccpAddr_SSN(1));
+
+	tx := ts_SCMG_SST(1, mp_sccp_cfg[0].peer_pc);
+	rx_exp := ts_SCMG_SSA(1, mp_sccp_cfg[0].peer_pc);
+	f_scmg_xceive(calling, called, tx, rx_exp, accept_other_called_resp:=true);
+}
 
 
 control {
@@ -413,6 +433,8 @@
 	execute( TC_scmg_sst_ssn1() );
 	execute( TC_scmg_sst_ssn_valid() );
 	execute( TC_scmg_sst_ssn_invalid() );
+
+	execute( TC_callingparty_ssn_only() );
 }