[MERGED] osmo-ttcn3-hacks[master]: msc: Introduce BSC_ConnHdlrNetworkPars

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
Sun Jan 28 00:13:24 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: msc: Introduce BSC_ConnHdlrNetworkPars
......................................................................


msc: Introduce BSC_ConnHdlrNetworkPars

This record collects information about the network configuration,
such as whether or not authentication, tmsi allocation and/or
encryption are enabled.  The individual helper functions can then
react according to this information, without having to pass long
argument lists along the call chain.

Change-Id: I01a931f1cbbca4593fff2fd12689f040ceaa79b6
---
M msc/BSC_ConnectionHandler.ttcn
M msc/MSC_Tests.ttcn
2 files changed, 55 insertions(+), 41 deletions(-)

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



diff --git a/msc/BSC_ConnectionHandler.ttcn b/msc/BSC_ConnectionHandler.ttcn
index a7ce1ea..a801e51 100644
--- a/msc/BSC_ConnectionHandler.ttcn
+++ b/msc/BSC_ConnectionHandler.ttcn
@@ -40,6 +40,13 @@
 	/* FIXME: 3G elements */
 }
 
+type record BSC_ConnHdlrNetworkPars {
+	OCT1	kc_support,
+	boolean expect_tmsi,
+	boolean	expect_auth,
+	boolean	expect_ciph
+}
+
 type record BSC_ConnHdlrPars {
 	SCCP_PAR_Address sccp_addr_own,
 	SCCP_PAR_Address sccp_addr_peer,
@@ -50,7 +57,8 @@
 	OCT4 tmsi optional,
 	BSSMAP_IE_ClassmarkInformationType2 cm2,
 	BSSMAP_IE_ClassmarkInformationType3 cm3 optional,
-	AuthVector vec optional
+	AuthVector vec optional,
+	BSC_ConnHdlrNetworkPars net
 };
 
 /* altstep for the global guard timer */
@@ -133,7 +141,7 @@
 }
 
 /* helper function to fully establish a dedicated channel */
-function f_establish_fully(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
+function f_establish_fully(MobileIdentityLV mi)
 runs on BSC_ConnHdlr {
 	var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
 	var PDU_DTAP_MT dtap_mt;
@@ -141,8 +149,8 @@
 	/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
 	f_bssap_compl_l3(l3_info);
 
-	f_mm_common(expect_auth, expect_ciph);
-	if (expect_ciph) {
+	f_mm_common();
+	if (g_pars.net.expect_ciph) {
 		/* implicit CM SERVICE ACCEPT? */
 	} else {
 		/* explicit CM SERVICE ACCEPT */
@@ -151,7 +159,7 @@
 }
 
 /* helper function to fully establish a dedicated channel */
-function f_establish_fully_pag(MobileIdentityLV mi, boolean expect_auth, boolean expect_ciph)
+function f_establish_fully_pag(MobileIdentityLV mi)
 runs on BSC_ConnHdlr {
 	var PDU_ML3_MS_NW l3_info := valueof(ts_PAG_RESP(mi));
 	var PDU_DTAP_MT dtap_mt;
@@ -159,7 +167,7 @@
 	/* Send BSSAP_Conn_Req with COMPL L3 INFO to MSC */
 	f_bssap_compl_l3(l3_info);
 
-	f_mm_common(expect_auth, expect_ciph);
+	f_mm_common();
 }
 
 
@@ -205,9 +213,9 @@
 }
 
 
-function f_mm_common(boolean expect_auth, boolean expect_ciph) runs on BSC_ConnHdlr
+function f_mm_common() runs on BSC_ConnHdlr
 {
-	if (expect_auth) {
+	if (g_pars.net.expect_auth) {
 		g_pars.vec := f_gen_auth_vec_2g();
 		var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
 									 g_pars.vec.sres,
@@ -219,14 +227,13 @@
 		BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(g_pars.vec.sres)));
 	}
 
-	if (expect_ciph) {
+	if (g_pars.net.expect_ciph) {
 		BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, g_pars.vec.kc));
 		BSSAP.send(ts_BSSMAP_CipherModeCompl('02'O));
 	}
 }
 
-function f_perform_lu(boolean expect_auth, boolean expect_tmsi, boolean send_early_cm,
-		      boolean expect_ciph := false)
+function f_perform_lu(boolean send_early_cm)
 runs on BSC_ConnHdlr {
 	var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
 	var PDU_DTAP_MT dtap_mt;
@@ -241,7 +248,7 @@
 		BSSAP.send(ts_BSSMAP_ClassmarkUpd(g_pars.cm2, g_pars.cm3));
 	}
 
-	f_mm_common(expect_auth, expect_ciph);
+	f_mm_common();
 
 	/* Expect MSC to perform LU with HLR */
 	GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
@@ -252,7 +259,7 @@
 	alt {
 	[] BSSAP.receive(tr_PDU_DTAP_MT(tr_ML3_MT_LU_Acc)) -> value dtap_mt {
 		var PDU_ML3_LocationUpdateAccept lu_acc := dtap_mt.dtap.msgs.mm.locationUpdateAccept;
-		if (expect_tmsi) {
+		if (g_pars.net.expect_tmsi) {
 			if (not ispresent(lu_acc.mobileIdentityTLV) or
 			    not ischosen(lu_acc.mobileIdentityTLV.mobileIdentityLV.mobileIdentityV.oddEvenInd_identity.tmsi_ptmsi)) {
 				setverdict(fail, "Expected TMSI but no TMSI was allocated");
@@ -299,9 +306,6 @@
 
 /* parameters related to a (MO?) voice call */
 type record CallParameters {
-	boolean expect_auth,				/* do we expect AUTHENTICATE from network */
-	boolean expect_ciph,				/* do we expect CIPHER MODE from network */
-
 	/* CC related parameters */
 	hexstring called_party,				/* whom are we calling */
 	integer transaction_id optional,		/* which TS 04.08 CC transaction ID to use */
@@ -330,8 +334,6 @@
 }
 
 template (value) CallParameters t_CallParams(hexstring called, integer tid) := {
-	expect_auth := false,
-	expect_ciph := false,
 	called_party := called,
 	transaction_id := tid,
 	bearer_cap := valueof(ts_Bcap_voice),
@@ -367,7 +369,7 @@
 	} else {
 		mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 	}
-	f_establish_fully(mi, cpars.expect_auth, cpars.expect_ciph);
+	f_establish_fully(mi);
 
 	/* Create MNCC and MGCP expect */
 	f_create_mncc_expect(hex2str(cpars.called_party));
diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index b6b38dd..90f308f 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -354,6 +354,12 @@
 /* FIXME: move into BSC_ConnectionHandler? */
 function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on MTC_CT return BSC_ConnHdlr {
 	var BSC_ConnHdlr vc_conn;
+	var BSC_ConnHdlrNetworkPars net_pars := {
+		kc_support := '0A'O,	/* A5/1 and A5/3 enabled */
+		expect_tmsi := true,
+		expect_auth := false,
+		expect_ciph := false
+	};
 	var BSC_ConnHdlrPars pars := {
 		sccp_addr_own := g_sccp_addr_own,
 		sccp_addr_peer := g_sccp_addr_peer,
@@ -364,7 +370,8 @@
 		tmsi := omit,
 		cm2 := valueof(ts_CM2_default),
 		cm3 := omit,
-		vec := omit
+		vec := omit,
+		net := net_pars
 	};
 
 	vc_conn := BSC_ConnHdlr.create(id);
@@ -400,7 +407,7 @@
 
 private function f_tc_lu_imsi_noauth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
 	f_init_handler(pars);
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 }
 testcase TC_lu_imsi_noauth_tmsi() runs on MTC_CT {
 	var BSC_ConnHdlr vc_conn;
@@ -411,8 +418,9 @@
 }
 
 private function f_tc_lu_imsi_noauth_notmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+	pars.net.expect_tmsi := false;
 	f_init_handler(pars);
-	f_perform_lu(false, false, true);
+	f_perform_lu(true);
 }
 testcase TC_lu_imsi_noauth_notmsi() runs on MTC_CT {
 	var BSC_ConnHdlr vc_conn;
@@ -477,8 +485,9 @@
 }
 
 private function f_tc_lu_imsi_auth_tmsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+	pars.net.expect_auth := true;
 	f_init_handler(pars);
-	f_perform_lu(true, true, true);
+	f_perform_lu(true);
 }
 testcase TC_lu_imsi_auth_tmsi() runs on MTC_CT {
 	var BSC_ConnHdlr vc_conn;
@@ -532,7 +541,7 @@
 	cpars.mgcp_connection_id_bss := '22222'H;
 	cpars.mgcp_connection_id_mss := '33333'H;
 
-	f_perform_lu(cpars.expect_auth, true, true);
+	f_perform_lu(true);
 	f_mo_call(cpars);
 }
 testcase TC_lu_and_mo_call() runs on MTC_CT {
@@ -883,7 +892,7 @@
 private function f_tc_emerg_call_imsi(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
 	f_init_handler(pars);
 	/* First perform location update to ensure subscriber is known */
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 	/* Then issue emergency call identified by IMSI */
 	f_emerg_call(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 }
@@ -900,7 +909,7 @@
 	f_init_handler(pars);
 
 	/* First perform location update to ensure subscriber is known */
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 
 	var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 	var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VGCS, mi));
@@ -921,7 +930,7 @@
 	f_init_handler(pars);
 
 	/* First perform location update to ensure subscriber is known */
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 
 	var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 	var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_VBS, mi));
@@ -942,7 +951,7 @@
 	f_init_handler(pars);
 
 	/* First perform location update to ensure subscriber is known */
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 
 	var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 	var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_LCS, mi));
@@ -963,7 +972,7 @@
 	f_init_handler(pars);
 
 	/* First perform location update to ensure subscriber is known */
-	f_perform_lu(false, true, true);
+	f_perform_lu(true);
 
 	var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
 	var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REEST_REQ(0, mi));
@@ -1019,9 +1028,12 @@
 	vc_conn.done;
 }
 
+/* A5/1 + A5/3 permitted on network side, and MS capable to do it */
 private function f_tc_lu_imsi_auth_tmsi_encr_13_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+	pars.net.expect_auth := true;
+	pars.net.expect_ciph := true;
 	f_init_handler(pars);
-	f_perform_lu(true, true, true, true);
+	f_perform_lu(true);
 }
 testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT {
 	var BSC_ConnHdlr vc_conn;
@@ -1106,9 +1118,9 @@
 private function f_tc_establish_and_nothing(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
 	f_init_handler(pars);
 
-	f_perform_lu(false, true, true, false);
+	f_perform_lu(true);
 
-	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
+	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 	f_expect_clear();
 }
 testcase TC_establish_and_nothing() runs on MTC_CT {
@@ -1125,9 +1137,9 @@
 
 	var CallParameters cpars := valueof(t_CallParams('12345'H, 0));
 
-	f_perform_lu(false, true, true, false);
+	f_perform_lu(true);
 
-	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
+	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 	f_create_mncc_expect(hex2str(cpars.called_party));
 	f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
 
@@ -1150,9 +1162,9 @@
 	var MNCC_PDU mncc;
 	var MgcpCommand mgcp_cmd;
 
-	f_perform_lu(false, true, true, false);
+	f_perform_lu(true);
 
-	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
+	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 	f_create_mncc_expect(hex2str(cpars.called_party));
 	f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
 
@@ -1184,9 +1196,9 @@
 	var MNCC_PDU mncc;
 	var MgcpCommand mgcp_cmd;
 
-	f_perform_lu(false, true, true, false);
+	f_perform_lu(true);
 
-	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
+	f_establish_fully(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 	f_create_mncc_expect(hex2str(cpars.called_party));
 	f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
 
@@ -1246,7 +1258,7 @@
 	var MgcpCommand mgcp_cmd;
 	var OCT4 tmsi;
 
-	f_perform_lu(false, true, true, false);
+	f_perform_lu(true);
 	if (isvalue(g_pars.tmsi)) {
 		tmsi := g_pars.tmsi;
 	} else {
@@ -1262,7 +1274,7 @@
 	/* MSC->BSC: expect PAGING from MSC */
 	BSSAP.receive(tr_BSSMAP_Paging(g_pars.imsi));
 	/* MS -> MSC: PAGING RESPONSE */
-	f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)), false, false);
+	f_establish_fully_pag(valueof(ts_MI_IMSI_LV(g_pars.imsi)));
 
 	f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
 
@@ -1390,7 +1402,7 @@
 	cpars.mgcp_connection_id_mss := '33333'H;
 
 	/* Location Update to make subscriber known */
-	f_perform_lu(cpars.expect_auth, true, true);
+	f_perform_lu(true);
 
 	/* First MO call should succeed */
 	f_mo_call(cpars);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I01a931f1cbbca4593fff2fd12689f040ceaa79b6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list