Change in osmo-ttcn3-hacks[master]: PCU: fix: actually match IMSI in Packet Paging Request

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
Fri Jan 3 22:20:50 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16695 )

Change subject: PCU: fix: actually match IMSI in Packet Paging Request
......................................................................

PCU: fix: actually match IMSI in Packet Paging Request

Change-Id: I0afdd53fd5d2a89e139f65a7aec412a2e12511cc
---
M library/L3_Templates.ttcn
M library/RLCMAC_CSN1_Types.ttcn
M pcu/PCU_Tests_RAW.ttcn
3 files changed, 35 insertions(+), 11 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/library/L3_Templates.ttcn b/library/L3_Templates.ttcn
index 0556c97..6b5f5c2 100644
--- a/library/L3_Templates.ttcn
+++ b/library/L3_Templates.ttcn
@@ -2833,6 +2833,9 @@
 external function enc_MobileIdentityLV(in MobileIdentityLV si) return octetstring
 	with { extension "prototype(convert) encode(RAW)" };
 
+external function dec_MobileIdentityV(in octetstring mi) return MobileIdentityV
+	with { extension "prototype(convert) decode(RAW)" };
+
 
 
 /* SMS TPDU Layer */
diff --git a/library/RLCMAC_CSN1_Types.ttcn b/library/RLCMAC_CSN1_Types.ttcn
index 321049c..1bb6232 100644
--- a/library/RLCMAC_CSN1_Types.ttcn
+++ b/library/RLCMAC_CSN1_Types.ttcn
@@ -204,7 +204,10 @@
 		 * uses a byte. */
 		uint4_t			len,
 		octetstring		mobile_id
-	} with { variant (len) "LENGTHTO(mobile_id)" };
+	} with {
+		variant (len) "LENGTHTO(mobile_id)"
+		variant (mobile_id) "BYTEORDER(first)"
+	};
 	type record PageInfoPs {
 		BIT1			presence ('0'B),
 		BIT1			ptmsi_or_mobile_id,
diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index cd13ff5..d0181a9 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -1247,6 +1247,28 @@
 	f_tx_rlcmac_ul_block(ts_RLCMAC_DL_ACK_NACK(dl_block.data.mac_hdr.hdr_ext.tfi, ack_nack_desc), 0, sched_fn);
 }
 
+private function f_pkt_paging_match_imsi(in PacketPagingReq req, hexstring imsi) {
+	var MobileIdentityLV_Paging mi_lv := req.repeated_pageinfo.cs.mobile_identity;
+	var MobileIdentityV mi := dec_MobileIdentityV(mi_lv.mobile_id);
+
+	if (mi_lv.len != 8) { /* 8 octets: type of ID (3 bits) + even/odd flag (1 bit) + 15 BCD-encoded digits (60 bits) */
+		setverdict(fail, "Mobile Identity length mismatch: ",
+			   "expected: 8, got: ", mi_lv.len);
+		mtc.stop;
+	}
+
+	/* Make sure MI contains IMSI before referencing it */
+	if (mi.typeOfIdentity != '001'B) {
+		setverdict(fail, "Mobile Identity must be of type IMSI ('001'B), ",
+			   "got: ", mi.typeOfIdentity);
+		mtc.stop;
+	} else if (mi.oddEvenInd_identity.imsi.digits != imsi) {
+		setverdict(fail, "Mobile Identity contains unexpected IMSI, ",
+			   "expected: ", imsi, " got: ", mi.oddEvenInd_identity.imsi.digits);
+		mtc.stop;
+	}
+}
+
 /* Test CS paging over the BTS<->PCU socket.
  * When a (class B or C, not A) MS has an active TBF (or is on the PDCH), the MS can not react on CS paging over CCCH.
  * Paging should be send on the PACCH.
@@ -1263,7 +1285,6 @@
 	var OCT4 tlli := '00000001'O;
 	var MobileL3_CommonIE_Types.MobileIdentityLV mi;
 	var octetstring mi_enc_lv;
-	var MobileIdentityLV_Paging mi_res;
 	var hexstring imsi := f_gen_imsi(42);
 
 	/* Initialize NS/BSSGP side */
@@ -1300,12 +1321,9 @@
 	/* Receive it on BTS side towards MS */
 	f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block);
 
-	mi_res := dl_block.ctrl.payload.u.paging.repeated_pageinfo.cs.mobile_identity;
-	if (oct2int(substr(mi_enc_lv, 0, 1)) != mi_res.len) {
-		/* TODO: Verify MI contents encoded match */
-		setverdict(fail, "Mobile Identity not matching (imsi=", imsi, ")");
-		mtc.stop;
-	}
+	/* Make sure that Packet Paging Request contains the same IMSI */
+	f_pkt_paging_match_imsi(dl_block.ctrl.payload.u.paging, imsi);
+
 	setverdict(pass);
 }
 
@@ -1317,7 +1335,6 @@
 	var RlcmacDlBlock dl_block;
 	var boolean ok;
 	var OCT4 tlli := '00000001'O;
-	var MobileIdentityLV_Paging mi_res;
 	var hexstring imsi := f_gen_imsi(42);
 
 	/* Initialize NS/BSSGP side */
@@ -1349,8 +1366,9 @@
 	/* Receive it on BTS side towards MS */
 	f_rx_rlcmac_dl_block_exp_pkt_pag_req(dl_block);
 
-	/* FIXME: actually match the identity */
-	mi_res := dl_block.ctrl.payload.u.paging.repeated_pageinfo.cs.mobile_identity;
+	/* Make sure that Packet Paging Request contains the same IMSI */
+	f_pkt_paging_match_imsi(dl_block.ctrl.payload.u.paging, imsi);
+
 	setverdict(pass);
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/16695
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: I0afdd53fd5d2a89e139f65a7aec412a2e12511cc
Gerrit-Change-Number: 16695
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200103/1578d174/attachment.htm>


More information about the gerrit-log mailing list