Change in osmo-ttcn3-hacks[master]: NS_Emulation: Add [optional] support for FrameRelay transport

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
Sun Oct 4 11:33:01 UTC 2020


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

Change subject: NS_Emulation: Add [optional] support for FrameRelay transport
......................................................................

NS_Emulation: Add [optional] support for FrameRelay transport

This adds a NS_Provider_FR which interfaces between FrameRelay_Emulation
and NS_Emulation.  Include support for it only if enabled at compile
time to avoid pulling in a dependency on the FrameRelay stack for every
user of NS_Emulation.

Change-Id: I42ca811d23e383e362d2527c8ff2c916a62a5b42
---
R library/NS_Emulation.ttcnpp
A library/NS_Provider_FR.ttcn
M pcu/gen_links.sh
M sgsn/gen_links.sh
4 files changed, 94 insertions(+), 8 deletions(-)

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



diff --git a/library/NS_Emulation.ttcn b/library/NS_Emulation.ttcnpp
similarity index 92%
rename from library/NS_Emulation.ttcn
rename to library/NS_Emulation.ttcnpp
index a0b24c9..32746b4 100644
--- a/library/NS_Emulation.ttcn
+++ b/library/NS_Emulation.ttcnpp
@@ -12,9 +12,12 @@
 module NS_Emulation {
 	import from NS_Types all;
 	import from BSSGP_Types all;
+	import from Osmocom_Types all;
 	import from Osmocom_Gb_Types all;
 	import from NS_Provider_IPL4 all;
-	import from Osmocom_Types all;
+#ifdef NS_EMULATION_FR
+	import from NS_Provider_FR all;
+#endif
 	import from IPL4asp_Types all;
 
 	type record NsUnitdataRequest {
@@ -91,10 +94,18 @@
 	private function f_init() runs on NS_CT {
 		var Result res;
 
-		/* Connect the UDP socket */
-		vc_NSP_IP := NS_Provider_IPL4_CT.create;
-		connect(self:NSCP, vc_NSP_IP:NSE);
-		vc_NSP_IP.start(NS_Provider_IPL4.main(config));
+		if (ischosen(config.provider.ip)) {
+			/* Connect the UDP socket */
+			vc_NSP_IP := NS_Provider_IPL4_CT.create;
+			connect(self:NSCP, vc_NSP_IP:NSE);
+			vc_NSP_IP.start(NS_Provider_IPL4.main(config));
+#ifdef NS_EMULATION_FR
+		} else if (ischosen(config.provider.fr)) {
+			vc_NSP_FR := NS_Provider_FR_CT.create;
+			connect(self:NSCP, vc_NSP_FR:NSE);
+			vc_NSP_FR.start(NS_Provider_FR.main(config));
+#endif
+		}
 
 		f_change_state(NSE_S_DEAD_BLOCKED);
 		/* Send the first NS-ALIVE to test the connection */
@@ -118,6 +129,9 @@
 		/* UDP port towards the bottom (IUT) */
 		port NS_PROVIDER_PT NSCP;
 		var NS_Provider_IPL4_CT vc_NSP_IP;
+#ifdef NS_EMULATION_FR
+		var NS_Provider_FR_CT vc_NSP_FR;
+#endif
 
 		/* NS-User SAP towards the user */
 		port NS_SP_PT NS_SP;
@@ -138,8 +152,13 @@
 		PortNumber remote_udp_port,
 		charstring remote_ip
 	};
+	type record NSConfigurationFR {
+		charstring netdev,	/* HDLC net-device for AF_PACKET socket */
+		integer dlci
+	};
 	type union NSConfigurationP {
-		NSConfigurationIP ip
+		NSConfigurationIP ip,
+		NSConfigurationFR fr
 	};
 	type record NSConfiguration {
 		NSConfigurationP provider,
diff --git a/library/NS_Provider_FR.ttcn b/library/NS_Provider_FR.ttcn
new file mode 100644
index 0000000..851e6c4
--- /dev/null
+++ b/library/NS_Provider_FR.ttcn
@@ -0,0 +1,67 @@
+/* NS Provider for NS/FR/E1
+ * (C) 2020 Harald Welte <laforge at gnumonks.org>
+ * contributions by sysmocom - s.f.m.c. GmbH
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+module NS_Provider_FR {
+
+import from NS_Emulation all;
+import from NS_Types all;
+
+import from AF_PACKET_PortType all;
+import from FrameRelay_Types all;
+import from FrameRelay_Emulation all;
+
+
+type component NS_Provider_FR_CT extends NS_Provider_CT, FR_Client_CT {
+	/* component reference to Frame Relay emulation */
+	var FR_Emulation_CT vc_FREMU;
+};
+
+function main(NSConfiguration config) runs on NS_Provider_FR_CT system af_packet {
+
+	/* start Frame Relay Emulation */
+	vc_FREMU := FR_Emulation_CT.create();
+	var Q933em_Config q933_cfg := valueof(ts_Q933em_Config(ats_is_user := not config.role_sgsn, bidirectional := false));
+	map(vc_FREMU:FR, system:AF_PACKET) param (config.provider.fr.netdev);
+	vc_FREMU.start(FrameRelay_Emulation.main(q933_cfg));
+
+	/* connect ourselves to frame relay emulation */
+	connect(self:FR, vc_FREMU:CLIENT);
+	connect(self:FR_PROC, vc_FREMU:PROC);
+
+	/* register ourselves for the specified DLCI */
+	f_fremu_register(config.provider.fr.dlci);
+
+	/* transceive between user-facing port and FR socket */
+	while (true) {
+		var FrameRelayFrame rx_fr;
+		var FRemu_Event rx_frevt;
+		var PDU_NS rx_pdu;
+		alt {
+
+		[] FR.receive(FrameRelayFrame:?) -> value rx_fr {
+			NSE.send(dec_PDU_NS(rx_fr.payload));
+			}
+
+		[] FR.receive(FRemu_Event:?) -> value rx_frevt {
+			/* TODO: dispatch to user */
+			}
+		[] NSE.receive(PDU_NS:?) -> value rx_pdu {
+			FR.send(ts_FR(config.provider.fr.dlci, enc_PDU_NS(rx_pdu), true));
+			}
+
+		}
+	}
+
+} /* main */
+
+
+
+} /* module */
diff --git a/pcu/gen_links.sh b/pcu/gen_links.sh
index fbb79a0..a33cb27 100755
--- a/pcu/gen_links.sh
+++ b/pcu/gen_links.sh
@@ -51,7 +51,7 @@
 DIR=../library
 FILES="Misc_Helpers.ttcn General_Types.ttcn Osmocom_VTY_Functions.ttcn Native_Functions.ttcn Native_FunctionDefs.cc GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
 FILES+="StatsD_Types.ttcn StatsD_CodecPort.ttcn StatsD_CodecPort_CtrlFunct.ttcn StatsD_CodecPort_CtrlFunctdef.cc StatsD_Checker.ttcn "
-FILES+="NS_Provider_IPL4.ttcn NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
+FILES+="NS_Provider_IPL4.ttcn NS_Emulation.ttcnpp NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
 FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
 FILES+="LLC_Templates.ttcn L3_Templates.ttcn L3_Common.ttcn "
 FILES+="PCUIF_Types.ttcn PCUIF_CodecPort.ttcn RAW_NS.ttcn "
diff --git a/sgsn/gen_links.sh b/sgsn/gen_links.sh
index 334df59..47baa54 100755
--- a/sgsn/gen_links.sh
+++ b/sgsn/gen_links.sh
@@ -84,7 +84,7 @@
 
 DIR=../library
 FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Templates.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Templates.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc "
-FILES+="NS_Provider_IPL4.ttcn NS_Emulation.ttcn PCUIF_Types.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
+FILES+="NS_Provider_IPL4.ttcn NS_Emulation.ttcnpp PCUIF_Types.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
 FILES+="BSSGP_Emulation.ttcnpp Osmocom_Gb_Types.ttcn "
 FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
 FILES+="Osmocom_VTY_Functions.ttcn "

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/20118
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: I42ca811d23e383e362d2527c8ff2c916a62a5b42
Gerrit-Change-Number: 20118
Gerrit-PatchSet: 13
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201004/203dcbc9/attachment.htm>


More information about the gerrit-log mailing list