Change in osmo-ttcn3-hacks[master]: hlr: new test: 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/.

osmith gerrit-no-reply at lists.osmocom.org
Wed Jan 29 14:25:19 UTC 2020


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17064 )


Change subject: hlr: new test: TC_MSLookup_GSUP_proxy
......................................................................

hlr: new test: TC_MSLookup_GSUP_proxy

Let OsmoHLR act as proxy between MSC and another 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, 137 insertions(+), 1 deletion(-)



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

diff --git a/hlr/HLR_Tests.ttcn b/hlr/HLR_Tests.ttcn
index 2becad8..04b257d 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) */
@@ -1651,6 +1652,57 @@
 	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 {
+	var MSLookup_mDNS mdns_msg;
+	var integer id;
+	var hexstring imsi := g_pars.sub.imsi;
+	var hexstring msisdn := g_pars.sub.msisdn;
+	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 */
+
+	/* [GSUP] TS-MSC  => HLR proxy: Update Location Request with unknown IMSI */
+	GSUP.send(valueof(ts_GSUP_UL_REQ(imsi, OSMO_GSUP_CN_DOMAIN_CS))) 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(t_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(valueof(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(valueof(ts_GSUP_ISD_RES(imsi, destination_name))) to vc_GSUP_server;
+	GSUP.receive(tr_GSUP_ISD_RES(imsi)) from vc_GSUP_client;
+	GSUP.send(valueof(ts_GSUP_UL_RES(imsi, destination_name))) to vc_GSUP_server;
+	GSUP.receive(tr_GSUP_UL_RES(imsi)) from vc_GSUP_client;
+
+	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
@@ -1699,6 +1751,7 @@
 
 	if (mp_hlr_supports_dgsm) {
 		execute( TC_MSLookup_mDNS_server() );
+		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 e2426fa..e8158eb 100644
--- a/library/MSLookup_mDNS_Templates.ttcn
+++ b/library/MSLookup_mDNS_Templates.ttcn
@@ -45,6 +45,38 @@
 	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 tr_MSLookup_mDNS_result_IPv4(integer id, charstring domain, UInt32 ip_v4, integer port_v4) := {
 	dnsMessage := {
 		header := {
@@ -96,4 +128,55 @@
 	udpPort := ?
 }
 
+template MSLookup_mDNS t_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
+}
+
 }

-- 
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: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200129/d54ace97/attachment.htm>


More information about the gerrit-log mailing list