[MERGED] osmo-ttcn3-hacks[master]: sgsn: test GMM Attach with 3-digit leading-zero MNC

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Mar 16 18:52:45 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: sgsn: test GMM Attach with 3-digit leading-zero MNC
......................................................................


sgsn: test GMM Attach with 3-digit leading-zero MNC

Add general infrastructure to
- pass an MCC-MNC for BSSGP to use into f_init();
- verify that the Attach Accept PLMN matches the BSSGP one.

Add TC_attach_mnc3() to feed an MNC with three digits and a leading zero, to
verify the recent mnc3 patches. When testing against a libosmocore and
osmo-sgsn before mnc3, this results in:

Test case TC_attach_mnc3 finished. Verdict: fail reason: "mismatching PLMN in Attach Accept: 02342F; expected 023042"

With the current master branches the proper 3-digit MNC with leading zero is
fed back into the Attach Accept message.

Change-Id: I8901ec0b090e342ebb04a04f9d759fc46c7d9cab
---
M library/L3_Common.ttcn
M sgsn/SGSN_Tests.ttcn
2 files changed, 31 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/L3_Common.ttcn b/library/L3_Common.ttcn
index 19e52eb..5b36056 100644
--- a/library/L3_Common.ttcn
+++ b/library/L3_Common.ttcn
@@ -84,5 +84,15 @@
 	return ret;
 }
 
+function f_RAI_to_plmn_hexstr(RoutingAreaIdentificationV rai) return hexstring {
+	var hexstring plmn :=
+		  rai.mccDigit1
+		& rai.mccDigit2
+		& rai.mccDigit3
+		& rai.mncDigit1
+		& rai.mncDigit2
+		& rai.mncDigit3;
+	return plmn;
+}
 
 }
diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn
index a853c6d..79aa166 100644
--- a/sgsn/SGSN_Tests.ttcn
+++ b/sgsn/SGSN_Tests.ttcn
@@ -33,6 +33,8 @@
 import from TELNETasp_PortType all;
 import from Osmocom_VTY_Functions all;
 
+import from GSM_RR_Types all;
+
 
 modulepar {
 	/* IP/port on which we run our internal GSUP/HLR emulation */
@@ -157,7 +159,7 @@
 }
 
 
-function f_init() runs on test_CT {
+function f_init(BcdMccMnc mcc_mnc := '26242F'H) runs on test_CT {
 	if (g_initialized == true) {
 		return;
 	}
@@ -168,7 +170,7 @@
 		cell_id := {
 			ra_id := {
 				lai := {
-					mcc_mnc := '26242F'H, lac := 13135},
+					mcc_mnc := mcc_mnc, lac := 13135},
 					rac := 0
 				},
 			cell_id := 20960
@@ -271,7 +273,7 @@
 }
 
 altstep as_mm_identity() runs on BSSGP_ConnHdlr {
-	var MobileIdentityLV mi;
+	var MobileL3_CommonIE_Types.MobileIdentityLV mi;
 	[] BSSGP.receive(tr_BD_L3_MT(tr_GMM_ID_REQ('001'B))) {
 		mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 		BSSGP.send(ts_GMM_ID_RESP(mi));
@@ -325,6 +327,12 @@
 
 function f_process_attach_accept(PDU_GMM_AttachAccept aa) runs on BSSGP_ConnHdlr {
 	/* mandatory IE */
+	var hexstring aa_plmn := f_RAI_to_plmn_hexstr(aa.routingAreaIdentification);
+	if (not (g_pars.bssgp_cell_id.ra_id.lai.mcc_mnc == aa_plmn)) {
+		  setverdict(fail, "mismatching PLMN in Attach Accept: " & hex2str(aa_plmn)
+				   & "; expected " & hex2str(g_pars.bssgp_cell_id.ra_id.lai.mcc_mnc));
+		  self.stop;
+	}
 	g_pars.ra := aa.routingAreaIdentification;
 	if (ispresent(aa.allocatedPTMSI)) {
 		if (not g_pars.net.expect_ptmsi) {
@@ -375,7 +383,7 @@
 }
 
 /* return a MobileIdentityLV: P-TMSI if we have one, IMSI otherwise */
-private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileIdentityLV {
+private function f_mi_get_lv() runs on BSSGP_ConnHdlr return MobileL3_CommonIE_Types.MobileIdentityLV {
 	if (ispresent(g_pars.p_tmsi)) {
 		return valueof(ts_MI_TMSI_LV(g_pars.p_tmsi));
 	} else {
@@ -416,6 +424,14 @@
 	f_init();
 	f_sleep(1.0);
 	vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb[0], 1);
+	vc_conn.done;
+}
+
+testcase TC_attach_mnc3() runs on test_CT {
+	var BSSGP_ConnHdlr vc_conn;
+	f_init('023042'H);
+	f_sleep(1.0);
+	vc_conn := f_start_handler(refers(f_TC_attach), testcasename(), g_gb[0], 1001);
 	vc_conn.done;
 }
 
@@ -1136,6 +1152,7 @@
 
 control {
 	execute( TC_attach() );
+	execute( TC_attach_mnc3() );
 	execute( TC_attach_auth_id_timeout() );
 	execute( TC_attach_auth_sai_timeout() );
 	execute( TC_attach_auth_sai_reject() );

-- 
To view, visit https://gerrit.osmocom.org/7316
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8901ec0b090e342ebb04a04f9d759fc46c7d9cab
Gerrit-PatchSet: 2
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list