Change in osmo-ttcn3-hacks[master]: library/RSL_Emulation: server mode: handle multiple transceivers

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

fixeria gerrit-no-reply at lists.osmocom.org
Mon May 25 15:15:17 UTC 2020


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


Change subject: library/RSL_Emulation: server mode: handle multiple transceivers
......................................................................

library/RSL_Emulation: server mode: handle multiple transceivers

Change-Id: I86afb55ecc6703ce7a229aaa626223f9331a4778
Related: OS#4546
---
M library/RSL_Emulation.ttcn
1 file changed, 79 insertions(+), 1 deletion(-)



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

diff --git a/library/RSL_Emulation.ttcn b/library/RSL_Emulation.ttcn
index ffd60a7..6c595fa 100644
--- a/library/RSL_Emulation.ttcn
+++ b/library/RSL_Emulation.ttcn
@@ -314,6 +314,69 @@
 	}
 }
 
+private function f_trx_conn_map_init()
+runs on RSL_Emulation_CT {
+	for (var integer i := 0; i < sizeof(TrxConnMap); i := i + 1) {
+		TrxConnMap[i] := -1;
+	}
+}
+
+private function f_trx_conn_map_register(integer conn_id, in IpaCcmIdResp id_resp)
+runs on RSL_Emulation_CT {
+	var template charstring unit_id_fmt := pattern "(\d+)/(\d+)/(\d+)";
+	var charstring unit_id;
+	var integer trx_nr;
+
+	/* Check if we have room for a new connection */
+	if (TrxConnNum >= sizeof(TrxConnMap)) {
+		testcase.stop("We cannot handle more than ", sizeof(TrxConnMap), " transceivers");
+	}
+
+	/* Find IPAC_IDTAG_UNITID in the IPA IDENTITY RESPONSE */
+	for (var integer i := 0; i < sizeof(id_resp); i := i + 1) {
+		if (id_resp[i].tag == IPAC_IDTAG_UNITID) {
+			unit_id := oct2char(id_resp[i].data);
+			break;
+		}
+
+		/* If this is the last element, nothing is found */
+		if (i + 1 == sizeof(id_resp)) {
+			testcase.stop("IPA IDENTITY RESPONSE contains no unit-id");
+		}
+	}
+
+	/* Make sure that IPA unit-id is valid */
+	if (not match(unit_id, unit_id_fmt)) {
+		testcase.stop("IPA unit-id has unknown/unexpected format");
+	}
+
+	/* Parse transceiver number (site/bts/trx) */
+	unit_id := regexp(unit_id, unit_id_fmt, 2);
+	trx_nr  := str2int(unit_id);
+
+	if (trx_nr >= sizeof(TrxConnMap)) {
+		testcase.stop("Transceiver #", trx_nr, " does not fit");
+	} else if (TrxConnMap[trx_nr] != -1) {
+		testcase.stop("Transceiver #", trx_nr, " is already connected?!?");
+	}
+
+	/* Finally, store the connection ID */
+	log("Mapped TRX#", trx_nr, " to TCP/IP conn_id=", conn_id);
+	TrxConnMap[trx_nr] := conn_id;
+	TrxConnNum := TrxConnNum + 1;
+}
+
+private function f_trx_conn_map_resolve(IpaStreamId id)
+runs on RSL_Emulation_CT return integer {
+	var integer trx_nr := f_trx_by_streamId(id);
+
+	if (TrxConnMap[trx_nr] == -1) {
+		testcase.stop("Transceiver #", trx_nr, " is not connected");
+	}
+
+	return TrxConnMap[trx_nr];
+}
+
 type component RSL_Emulation_CT {
 	/* port facing down towards IPA emulation */
 	port IPA_RSL_PT IPA_PT;
@@ -329,6 +392,10 @@
 
 	/* last RSL CHAN ACT for each chan_nr */
 	var LastActData LastActTable[64];
+
+	/* IPA stream ID -> TCP/IP connection ID mapping for transceivers */
+	var integer TrxConnNum := 0; /* number of connected transceivers */
+	var integer TrxConnMap[4]; /* up to 4 transceivers for now */
 }
 
 
@@ -362,6 +429,7 @@
 	var boolean dchan_suspended := false;
 
 	f_conn_table_init();
+	f_trx_conn_map_init();
 	f_last_act_table_init();
 
 	while (true) {
@@ -369,7 +437,15 @@
 		[bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) {
 			}
 		[not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_UP)) -> value evt {
-			CCHAN_PT.send(evt);
+			log("A new IPA/RSL connection has been established (conn_id=",
+			    evt.conn_id, "), waiting for IDENTITY RESPONSE...");
+			}
+		[not bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_RESP)) -> value evt {
+			log("Got IDENTITY RESPONSE (conn_id=", evt.conn_id, "): ", evt.id_resp);
+			/* Update [ IPA stream ID -> TCP/IP connection ID ] mapping */
+			f_trx_conn_map_register(evt.conn_id, evt.id_resp);
+			/* FIXME: craft and send our own event type with TRX number */
+			CCHAN_PT.send(ts_ASP_IPA_EV(ASP_IPA_EVENT_UP, evt.conn_id));
 			}
 		[bts_role] IPA_PT.receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
 			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Lost IPA connection!");
@@ -485,12 +561,14 @@
 			f_cid_create(chan_rqd.ra, chan_rqd.fn, vc_conn);
 			}
 
+		/* RSL message from a component that runs on RSL_DchanHdlr */
 		[] CLIENT_PT.receive(tr_RSL_MsgType(?)) -> value rx_rsl_msg sender vc_conn {
 			/* forward to BSC */
 			cid := f_cid_by_comp_ref(vc_conn);
 			IPA_PT.send(ts_ASP_RSL_UD(rx_rsl_msg, ConnectionTable[cid].stream_id));
 			}
 
+		/* RSL message from MTC */
 		[] CCHAN_PT.receive(tr_ASP_RSL_UD(?)) -> value rx_rsl {
 			IPA_PT.send(ts_ASP_RSL_UD(rx_rsl.rsl, rx_rsl.streamId));
 			}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/18465
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: I86afb55ecc6703ce7a229aaa626223f9331a4778
Gerrit-Change-Number: 18465
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200525/1ac97722/attachment.htm>


More information about the gerrit-log mailing list