msc: derive altsteps from f_expect_paging() and use them

Change-Id: Ia0e787fc376acec09e8985a63862872eb89b53a4
diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index 5714fbf..a979953 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -1357,19 +1357,37 @@
 	log("f_mt_call_complete DONE");
 }
 
+/* expect BSSMAP/RANAP Paging for any IMSI and/or TMSI */
+altstep as_paging_any()
+runs on BSC_ConnHdlr {
+	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(?, *));
+	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(?, ?));
+}
+
+/* expect BSSMAP/RANAP Paging for registered IMSI and the given TMSI */
+altstep as_paging_tmsi(template OCT4 tmsi := *)
+runs on BSC_ConnHdlr {
+	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi, tmsi));
+	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi)));
+}
+
+/* convenience wrapper for as_paging_tmsi() using g_pars.tmsi */
+altstep as_paging()
+runs on BSC_ConnHdlr {
+	[] as_paging_tmsi(g_pars.tmsi);
+}
+
+/* expect BSSMAP/RANAP Paging for registered IMSI and the given TMSI
+ * fail on BSSMAP/RANAP Paging for non-matching IMSI/TMSI
+ * wait up to Tval seconds before declaring timeout */
 function f_expect_paging_tmsi(template OCT4 tmsi := *, float Tval := 4.0)
 runs on BSC_ConnHdlr {
 	timer T;
 
 	T.start(Tval);
 	alt {
-	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi, tmsi));
-	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(?, *)) {
-		setverdict(fail, "Paging message doesn't match expectations");
-		mtc.stop;
-		}
-	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi)));
-	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(?, ?)) {
+	[] as_paging_tmsi(tmsi) { setverdict(pass); }
+	[] as_paging_any() {
 		setverdict(fail, "Paging message doesn't match expectations");
 		mtc.stop;
 		}
@@ -1380,6 +1398,7 @@
 	}
 }
 
+/* convenience wrapper for f_expect_paging_tmsi() using g_pars.tmsi */
 function f_expect_paging(float Tval := 4.0)
 runs on BSC_ConnHdlr {
 	f_expect_paging_tmsi(g_pars.tmsi, Tval);
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 513e346..3effd52 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -2540,11 +2540,7 @@
 	timer T := 20.0;
 	T.start
 	alt {
-	[pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
-		setverdict(fail, "paging seems not to stop!");
-		mtc.stop;
-		}
-	[not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
+	[] as_paging_any() {
 		setverdict(fail, "paging seems not to stop!");
 		mtc.stop;
 		}
@@ -2597,13 +2593,18 @@
 	timer T := 5.0;
 	T.start;
 	alt {
-	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
-		setverdict(fail, "GERAN should not repeat Paging, but received a second Paging");
-		mtc.stop;
+	[] as_paging() {
+		if (g_pars.ran_is_geran) {
+			setverdict(fail, "GERAN should not repeat Paging, but received a second Paging");
+			mtc.stop;
+		} else {
+			log("UTRAN: second Paging received, as expected");
+			setverdict(pass);
 		}
-	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
-		log("UTRAN: second Paging received, as expected");
-		setverdict(pass);
+		}
+	[] as_paging_any() {
+		setverdict(fail, "Rx unexpected BSSMAP/RANAP Paging");
+		mtc.stop;
 		}
 	[] T.timeout {
 		if (g_pars.ran_is_geran) {
@@ -3578,13 +3579,11 @@
 	GSUP.send(gsup_req);
 	T.start;
 	alt {
-	[pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
-		setverdict(pass);
+	[] as_paging() { setverdict(pass); }
+	[] as_paging_any() {
+		setverdict(fail, "Rx unexpected BSSMAP/RANAP Paging");
+		mtc.stop;
 		}
-	[not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
-		setverdict(pass);
-		}
-	/* We don't expect anything else */
 	[] as_unexp_gsup_or_bssap_msg();
 	[] T.timeout {
 		setverdict(fail, "Timeout waiting for Paging Request");
@@ -4193,13 +4192,11 @@
 	/* Send it to MSC and expect Paging Request */
 	TP.start;
 	alt {
-	[pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
-		setverdict(pass);
+	[] as_paging() { setverdict(pass); }
+	[] as_paging_any() {
+		setverdict(fail, "Rx unexpected BSSMAP/RANAP Paging");
+		mtc.stop;
 		}
-	[not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
-		setverdict(pass);
-		}
-	/* We don't expect anything else */
 	[] as_unexp_gsup_or_bssap_msg();
 	[] TP.timeout {
 		setverdict(fail, "Timeout waiting for Paging Request");
@@ -4267,13 +4264,11 @@
 	/* Expect Paging Request */
 	TP.start;
 	alt {
-	[pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)) {
-		setverdict(pass);
+	[] as_paging() { setverdict(pass); }
+	[] as_paging_any() {
+		setverdict(fail, "Rx unexpected BSSMAP/RANAP Paging");
+		mtc.stop;
 		}
-	[not pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
-		setverdict(pass);
-		}
-	/* We don't expect anything else */
 	[] as_unexp_gsup_or_bssap_msg();
 	[] TP.timeout {
 		setverdict(fail, "Timeout waiting for Paging Request");
@@ -4592,11 +4587,10 @@
 	f_vty_transceive(MSCVTY, "subscriber imsi " & hex2str(g_pars.imsi) & " paging");
 
 	alt {
-	[g_pars.ran_is_geran] BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi)); {
-		setverdict(pass);
-		}
-	[not g_pars.ran_is_geran] BSSAP.receive(tr_RANAP_Paging(cs_domain, imsi_hex2oct(g_pars.imsi))) {
-		setverdict(pass);
+	[] as_paging() { setverdict(pass); }
+	[] as_paging_any() {
+		setverdict(fail, "Rx unexpected BSSMAP/RANAP Paging");
+		mtc.stop;
 		}
 	[] SGsAP.receive {
 		setverdict(fail, "Received unexpected message on SGs");