Change in osmo-ttcn3-hacks[master]: hlr: add TC_MSLookup_GSUP_proxy

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
Thu Feb 6 16:21:50 UTC 2020


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

Change subject: hlr: add TC_MSLookup_GSUP_proxy
......................................................................

hlr: add TC_MSLookup_GSUP_proxy

Let OsmoHLR act as proxy between MSC and home HLR during Location
update.

Related: OS#4380
Change-Id: I945e651f1346e56dbe3c02d9d08ccd95cc8d6626
---
M hlr/HLR_Tests.ttcn
M hlr/gen_links.sh
M library/MSLookup_mDNS_Templates.ttcn
3 files changed, 148 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 5e9eea6..82c74f4 100644
--- a/hlr/HLR_Tests.ttcn
+++ b/hlr/HLR_Tests.ttcn
@@ -34,6 +34,7 @@
 import from MSLookup_mDNS_Types all;
 import from MSLookup_mDNS_Emulation all;
 import from MSLookup_mDNS_Templates all;
+import from DNS_Helpers all;
 
 type component test_CT extends CTRL_Adapter_CT {
 	/* emulated GSUP client (MSC/SGSN) */
@@ -578,6 +579,45 @@
 	return ret;
 }
 
+/* Perform Location Update with IMSI that is unknown to OsmoHLR. Let it ask for the HLR that knows the IMSI via
+ * mslookup. The TTCN-3 testsuite pretends to be the home HLR, that knows the IMSI. The proxy HLR connects to the
+ * home HLR and forwards GSUP messages, until LU is complete.
+ * Make sure to let a timer run while calling this function (see TC_MSLookup_GSUP_proxy). */
+function f_perform_UL_proxy(hexstring imsi, hexstring msisdn, GSUP_CnDomain dom := OSMO_GSUP_CN_DOMAIN_PS)
+runs on HLR_ConnHdlr {
+	var MSLookup_mDNS mdns_msg;
+	var integer id;
+	var charstring domain := "gsup.hlr." & hex2str(imsi) & ".imsi.mdns.osmocom.org";
+	var octetstring destination_name := char2oct(ccm_pars_client.ser_nr) & '00'O; /* TS-MSC IPA name */
+
+	/* Testing the HLR as proxy. The MSC asking the proxy and the home HLR are both enacted by TTCN3 (TS).
+	 * MSC=vc_GSUP_client <---> osmo-hlr as proxy <---> vc_GSUP_server=home HLR
+	 * GSUP.send(..) to vc_GSUP_client ---> osmo-hlr ---> GSUP.receive(..) from vc_GSUP_server
+	 * GSUP.receive(..) from vc_GSUP_client <--- osmo-hlr <--- GSUP.send(..) to vc_GSUP_server */
+
+	/* [GSUP] TS-MSC  => HLR proxy: Update Location Request with unknown IMSI */
+	GSUP.send(ts_GSUP_UL_REQ(imsi, dom)) to vc_GSUP_client;
+
+	/* [GSUP] TS-HLR: expect GSUP messages with that IMSI */
+	f_create_gsup_expect_explicit(hex2str(imsi), vc_GSUP_server);
+
+	/* [mDNS] TS-HLR <=  HLR proxy: query for GSUP server who knows the IMSI */
+	mDNS.receive(tr_MSLookup_mDNS_query(domain)) -> value mdns_msg;
+
+	/* [mDNS] TS-HLR  => HLR proxy: result with IP/port of TS GSUP server */
+	id := mdns_msg.dnsMessage.header.id;
+	mDNS.send(ts_MSLookup_mDNS_result_IPv4(id, domain, f_enc_IPv4(mp_hlr_ts_ip), mp_hlr_ts_port));
+
+	/* [GSUP] TS-HLR <=> HLR proxy <=> TS-MSC: finish up UL */
+	GSUP.receive(tr_GSUP_UL_REQ(imsi)) from vc_GSUP_server;
+	GSUP.send(ts_GSUP_ISD_REQ(imsi, msisdn, destination_name)) to vc_GSUP_server;
+	GSUP.receive(tr_GSUP_ISD_REQ(imsi, g_pars.sub.msisdn)) from vc_GSUP_client;
+	GSUP.send(ts_GSUP_ISD_RES(imsi, destination_name)) to vc_GSUP_server;
+	GSUP.receive(tr_GSUP_ISD_RES(imsi)) from vc_GSUP_client;
+	GSUP.send(ts_GSUP_UL_RES(imsi, destination_name)) to vc_GSUP_server;
+	GSUP.receive(tr_GSUP_UL_RES(imsi)) from vc_GSUP_client;
+}
+
 /* perform PurgeMS for given imsi, return the GSUP response/error */
 function f_perform_PURGE(hexstring imsi, GSUP_CnDomain cn_dom,
 			 template (omit) integer exp_err_cause := omit)
@@ -1652,6 +1692,29 @@
 	vc_conn.done;
 }
 
+/* Let OsmoHLR act as proxy between MSC and another HLR during UL */
+private function f_TC_MSLookup_GSUP_proxy() runs on HLR_ConnHdlr {
+	f_perform_UL_proxy(g_pars.sub.imsi, g_pars.sub.msisdn, OSMO_GSUP_CN_DOMAIN_CS);
+	setverdict(pass);
+}
+testcase TC_MSLookup_GSUP_proxy() runs on test_CT {
+	var hexstring imsi := f_rnd_imsi('26242'H);
+	var hexstring msisdn := '49161'H & f_rnd_hexstring(7, 9);
+	var HLR_ConnHdlr vc_conn;
+	var HLR_ConnHdlrPars pars := valueof(t_Pars(imsi, msisdn));
+
+	f_init(false, true);
+	f_vty_config(VTY, "mslookup", "mdns bind");
+	vc_conn := f_start_handler(refers(f_TC_MSLookup_GSUP_proxy), pars, true);
+
+	timer T := 3.0;
+	T.start;
+	alt {
+	[] vc_conn.done {}
+	[] T.timeout { setverdict(fail, "Timeout"); mtc.stop; };
+	}
+}
+
 /* TODO:
   * UL with ISD error
   * UL with ISD timeout
@@ -1700,6 +1763,7 @@
 
 	if (mp_hlr_supports_dgsm) {
 		execute( TC_MSLookup_mDNS_service_other_home() );
+		execute( TC_MSLookup_GSUP_proxy() );
 	}
 };
 
diff --git a/hlr/gen_links.sh b/hlr/gen_links.sh
index 14a3f8d..c77920d 100755
--- a/hlr/gen_links.sh
+++ b/hlr/gen_links.sh
@@ -48,7 +48,7 @@
 FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
 FILES+="Osmocom_VTY_Functions.ttcn "
 FILES+="SS_Templates.ttcn USSD_Helpers.ttcn "
-FILES+="MSLookup_mDNS_Types.ttcn MSLookup_mDNS_Emulation.ttcn MSLookup_mDNS_Templates.ttcn"
+FILES+="MSLookup_mDNS_Types.ttcn MSLookup_mDNS_Emulation.ttcn MSLookup_mDNS_Templates.ttcn DNS_Helpers.ttcn "
 
 
 gen_links $DIR $FILES
diff --git a/library/MSLookup_mDNS_Templates.ttcn b/library/MSLookup_mDNS_Templates.ttcn
index 123ec16..3d4fafe 100644
--- a/library/MSLookup_mDNS_Templates.ttcn
+++ b/library/MSLookup_mDNS_Templates.ttcn
@@ -45,6 +45,89 @@
 	udpPort := 4266
 }
 
+template MSLookup_mDNS tr_MSLookup_mDNS_query(charstring domain) := {
+	dnsMessage := {
+		header := {
+			id := ?,
+			qr := DNS_QUERY,
+			opCode := 0,
+			aa := false,
+			tc := false,
+			rd := false,
+			ra := false,
+			z := '000'B,
+			rCode := DNS_NO_ERROR,
+			qdCount := 1,
+			anCount := 0,
+			nsCount := 0,
+			arCount := 0
+		},
+		queries := {
+			{
+				qName := domain,
+				qType := 255,
+				qClass := DNS_IN
+			}
+		},
+		answers := {},
+		nameServerRecords := {},
+		additionalRecords := {}
+	},
+	udpAddress := ?,
+	udpPort := ?
+}
+
+template MSLookup_mDNS ts_MSLookup_mDNS_result_IPv4(integer id, charstring domain, UInt32 ip_v4, integer port_v4) := {
+	dnsMessage := {
+		header := {
+			id := id,
+			qr := DNS_RESPONSE,
+			opCode := DNS_OP_QUERY,
+			aa := false,
+			tc := false,
+			rd := false,
+			ra := false,
+			z := '000'B,
+			rCode := DNS_NO_ERROR,
+			qdCount := 0,
+			anCount := 3,
+			nsCount := 0,
+			arCount := 0
+		},
+		queries := {},
+		answers := {
+			{
+				name := domain,
+				rrType := DNS_TXT,
+				rrClass := DNS_IN,
+				ttl := '00000000'O,
+				rdLength := 6,
+				rData := {txt := {"age=0"}}
+			},
+			{
+				name := domain,
+				rrType := DNS_A,
+				rrClass := DNS_IN,
+				ttl := '00000000'O,
+				rdLength := 4,
+				rData := {a := ip_v4}
+			},
+			{
+				name := domain,
+				rrType := DNS_TXT,
+				rrClass := DNS_IN,
+				ttl := '00000000'O,
+				rdLength := 1 + lengthof("port=" & int2str(port_v4)),
+				rData := {txt := {"port=" & int2str(port_v4)}}
+			}
+		},
+		nameServerRecords := {},
+		additionalRecords := {}
+	},
+	udpAddress := "239.192.23.42",
+	udpPort := 4266
+}
+
 template MSLookup_mDNS tr_MSLookup_mDNS_result_IPv4(integer id, charstring domain, UInt32 ip_v4, integer port_v4) := {
 	dnsMessage := {
 		header := {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17064
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: I945e651f1346e56dbe3c02d9d08ccd95cc8d6626
Gerrit-Change-Number: 17064
Gerrit-PatchSet: 5
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-CC: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200206/cdfb3fa6/attachment.htm>


More information about the gerrit-log mailing list