Change in osmo-ttcn3-hacks[master]: sgsn: Actual first Iu test case

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu May 2 23:44:53 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13866


Change subject: sgsn: Actual first Iu test case
......................................................................

sgsn: Actual first Iu test case

Change-Id: I66069e31c30d33934ad57cc2b8794f56ffd5c7d6
---
M sgsn/SGSN_Tests.ttcn
A sgsn/SGSN_Tests_Iu.ttcn
2 files changed, 120 insertions(+), 8 deletions(-)



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

diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index 5dae397..8bd32b1 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -1,5 +1,7 @@
 module SGSN_Tests {
 
+friend module SGSN_Tests_Iu;
+
 import from General_Types all;
 import from Osmocom_Types all;
 import from Native_Functions all;
@@ -455,16 +457,72 @@
 	f_send_llc(ts_LLC_UI(l3_enc, sapi, '0'B, n_u));
 }
 
+/* trigger sending of a RANAP InitialUE and wait for SCCP connection confirmation */
+function f_send_l3_initial_ue(template PDU_L3_MS_SGSN l3_mo) runs on BSSGP_ConnHdlr {
+	log("Sending InitialUE: ", l3_mo);
+	var octetstring l3_enc := enc_PDU_L3_MS_SGSN(valueof(l3_mo));
+	var RANAP_PDU ranap;
+	var LAI lai := {
+		pLMNidentity := '62F224'O,
+		lAC := '1234'O,
+		iE_Extensions := omit
+	};
+	var SAI sai := {
+		pLMNidentity := lai.pLMNidentity,
+		lAC := lai.lAC,
+		sAC := '0000'O, /* FIXME */
+		iE_Extensions := omit
+	};
+	var IuSignallingConnectionIdentifier sigc_id := int2bit(23, 24); /* FIXME */
+	var GlobalRNC_ID grnc_id := {
+		pLMNidentity := lai.pLMNidentity,
+		rNC_ID := 2342 /* FIXME */
+	};
+
+	ranap := valueof(ts_RANAP_initialUE_CS(lai, sai, l3_enc, sigc_id, grnc_id));
+	BSSAP.send(ts_RANAP_Conn_Req(g_pars.sccp_addr_peer, g_pars.sccp_addr_local, ranap));
+	alt {
+	[] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND) {}
+	[] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
+		setverdict(fail, "DISC.ind from SCCP");
+		mtc.stop;
+		}
+	}
+}
+
+/* send a L3 (GMM/SM) message over whatever is the appropriate lower-layer bearer */
+function f_send_l3(template PDU_L3_MS_SGSN l3_mo, integer gb_index := 0, boolean initial := false) runs on BSSGP_ConnHdlr {
+	if (gb_index >= NUM_GB) {
+		if (initial) {
+			f_send_l3_initial_ue(l3_mo);
+		} else {
+			BSSAP.send(ts_PDU_DTAP_PS_MO(l3_mo));
+		}
+	} else {
+		f_send_l3_gmm_llc(l3_mo, gb_index);
+	}
+}
+
 altstep as_mm_identity(integer gb_idx := 0) runs on BSSGP_ConnHdlr {
 	var MobileL3_CommonIE_Types.MobileIdentityLV mi;
-	[] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('001'B)) {
+	[gb_idx < NUM_GB] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('001'B)) {
 		mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
-		f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi), gb_idx);
+		f_send_l3(ts_GMM_ID_RESP(mi), gb_idx);
 		repeat;
 	}
-	[] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('010'B)) {
+	[gb_idx >= NUM_GB] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_ID_REQ('001'B))) {
+		mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
+		f_send_l3(ts_GMM_ID_RESP(mi), gb_idx);
+		repeat;
+	}
+	[gb_idx < NUM_GB] BSSGP[gb_idx].receive(tr_GMM_ID_REQ('010'B)) {
 		mi := valueof(ts_MI_IMEI_LV(g_pars.imei));
-		f_send_l3_gmm_llc(ts_GMM_ID_RESP(mi), gb_idx);
+		f_send_l3(ts_GMM_ID_RESP(mi), gb_idx);
+		repeat;
+	}
+	[gb_idx >= NUM_GB] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_ID_REQ('010'B))) {
+		mi := valueof(ts_MI_IMEI_LV(g_pars.imei));
+		f_send_l3(ts_GMM_ID_RESP(mi), gb_idx);
 		repeat;
 	}
 }
@@ -475,7 +533,10 @@
 	var PDU_DTAP_PS_MT mt;
 	var PDU_L3_SGSN_MS l3_mt;
 	alt {
-	[] BSSGP[gb_idx].receive(rx_tpl) -> value l3_mt { }
+	[gb_idx < NUM_GB] BSSGP[gb_idx].receive(rx_tpl) -> value l3_mt { }
+	[gb_idx >= NUM_GB] BSSAP.receive(tr_PDU_DTAP_PS_MT(rx_tpl)) -> value mt {
+		l3_mt := mt.dtap;
+		}
 	}
 	return l3_mt;
 }
@@ -543,7 +604,17 @@
 			l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv :=
 						valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H));
 		}
-		f_send_l3_gmm_llc(l3_mo, gb_idx);
+		f_send_l3(l3_mo, gb_idx);
+
+		/* Security Mode Command + Complete on Iu case */
+		if (gb_idx >= NUM_GB) {
+			BSSAP.receive(tr_RANAP_SecurityModeCmd(uia_algs := ?, uia_key := oct2bit(g_pars.vec.ik),
+								key_sts := ?)) {
+				var IntegrityProtectionAlgorithm uia_chosen := 0; /*standard_UMTS_integrity_algorithm_UIA1;*/
+				BSSAP.send(ts_RANAP_SecurityModeComplete(uia_chosen));
+				//BSSAP.receive(tr_RANAP_CommonId(imsi_hex2oct(g_pars.imsi)));
+			}
+		}
 	} else {
 		/* wait for identity procedure */
 		f_sleep(1.0);
@@ -649,7 +720,7 @@
 	 * revisionLevelIndicatior is at the wrong place! */
 	attach_req.msgs.gprs_mm.attachRequest.msNetworkCapability.msNetworkCapabilityV.solSACapability := '0'B;
 
-	f_send_l3_gmm_llc(attach_req, gb_idx);
+	f_send_l3(attach_req, gb_idx, initial := true);
 	f_gmm_auth(umts_aka_challenge, force_gsm_sres, gb_idx);
 	/* Expect SGSN to perform LU with HLR */
 	f_gmm_gsup_lu_isd();
@@ -658,7 +729,12 @@
 	f_process_attach_accept(l3_mt.msgs.gprs_mm.attachAccept);
 
 	/* FIXME: Extract P-TMSI, if any. Only send Complete if necessary */
-	f_send_l3_gmm_llc(ts_GMM_ATTACH_COMPL, gb_idx);
+	f_send_l3(ts_GMM_ATTACH_COMPL, gb_idx);
+
+	/* IuPS case: Expect Iu Release */
+	if (gb_idx >= NUM_GB) {
+		as_iu_release_compl_disc();
+	}
 }
 
 private function f_TC_attach(charstring id) runs on BSSGP_ConnHdlr {
diff --git a/sgsn/SGSN_Tests_Iu.ttcn b/sgsn/SGSN_Tests_Iu.ttcn
new file mode 100644
index 0000000..2c2a8af
--- /dev/null
+++ b/sgsn/SGSN_Tests_Iu.ttcn
@@ -0,0 +1,36 @@
+module SGSN_Tests_Iu {
+
+import from Osmocom_Types all;
+
+import from SGSN_Tests all;
+
+import from RAN_Adapter all;
+import from RAN_Emulation all;
+import from RANAP_Templates all;
+import from RANAP_PDU_Descriptions all;
+import from RANAP_IEs all;
+
+
+private function f_TC_iu_attach(charstring id) runs on BSSGP_ConnHdlr {
+	var PdpActPars apars := valueof(t_PdpActPars(mp_ggsn_ip));
+
+	/* first perform regular attach */
+	f_gmm_attach(umts_aka_challenge := true, force_gsm_sres := false, gb_idx := 3);
+	setverdict(pass);
+}
+testcase TC_iu_attach() runs on test_CT {
+	var BSSGP_ConnHdlr vc_conn;
+	f_init();
+	f_sleep(1.0);
+	vc_conn := f_start_handler(refers(f_TC_iu_attach), testcasename(), g_gb, 1001);
+	vc_conn.done;
+}
+
+
+
+control {
+	execute( TC_iu_attach() );
+}
+
+
+}

-- 
To view, visit https://gerrit.osmocom.org/13866
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I66069e31c30d33934ad57cc2b8794f56ffd5c7d6
Gerrit-Change-Number: 13866
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190502/20f3d3c0/attachment.html>


More information about the gerrit-log mailing list