Change in ...osmo-ttcn3-hacks[master]: Add CBSP_CodecPort + CBSP_Adapter

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
Wed Sep 4 10:45:41 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15375 )

Change subject: Add CBSP_CodecPort + CBSP_Adapter
......................................................................

Add CBSP_CodecPort + CBSP_Adapter

Change-Id: I36b39b320c21502395f9d51d769d76adf5f5d602
---
A library/CBSP_Adapter.ttcn
A library/CBSP_CodecPort.ttcn
A library/CBSP_CodecPort_CtrlFunct.ttcn
A library/CBSP_CodecPort_CtrlFunctdef.cc
4 files changed, 259 insertions(+), 0 deletions(-)

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



diff --git a/library/CBSP_Adapter.ttcn b/library/CBSP_Adapter.ttcn
new file mode 100644
index 0000000..8dbee6a
--- /dev/null
+++ b/library/CBSP_Adapter.ttcn
@@ -0,0 +1,77 @@
+module CBSP_Adapter {
+
+/* CBSP Adapter layer, sitting on top of CBSP_CodecPort.
+ * test suites can 'inherit' in order to have a CBSP connection to the IUT which they're testing
+ *
+ * (C) 2018-2019 by Harald Welte <laforge at gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ */
+
+
+import from Osmocom_Types all;
+import from General_Types all;
+import from CBSP_Types all;
+import from CBSP_Templates all;
+import from CBSP_CodecPort all;
+import from CBSP_CodecPort_CtrlFunct all;
+import from IPL4asp_Types all;
+import from IPL4asp_PortType all;
+import from Socket_API_Definitions all;
+
+const integer NUM_CBSP := 3;
+
+type component CBSP_Adapter_CT {
+	/* down-facing port to CBSP Codec port */
+	port CBSP_CODEC_PT CBSP[NUM_CBSP];
+	var IPL4asp_Types.ConnectionId g_cbsp_conn_id[NUM_CBSP] := { -1, -1, -1 };
+}
+
+private function f_set_tcp_segmentation(integer idx) runs on CBSP_Adapter_CT {
+	/* Set function for dissecting the binary stream into packets */
+	var f_IPL4_getMsgLen vl_f := refers(f_IPL4_fixedMsgLen);
+	/* Offset: 1, size of length: 3, delta: 4, multiplier: 1, big-endian */
+	CBSP_CodecPort_CtrlFunct.f_IPL4_setGetMsgLen(CBSP[idx], g_cbsp_conn_id[idx], vl_f, {1, 3, 4, 1, 0});
+}
+
+function f_connect(charstring remote_host, IPL4asp_Types.PortNumber remote_port,
+		   charstring local_host, IPL4asp_Types.PortNumber local_port, integer idx := 0)
+runs on CBSP_Adapter_CT {
+	var IPL4asp_Types.Result res;
+	map(self:CBSP[idx], system:CBSP);
+	res := CBSP_CodecPort_CtrlFunct.f_IPL4_connect(CBSP[idx], remote_host, remote_port,
+							local_host, local_port, 0, { tcp :={} });
+	if (not ispresent(res.connId)) {
+		setverdict(fail, "Could not connect to CBSP port, check your configuration");
+		mtc.stop;
+	}
+	g_cbsp_conn_id[idx] := res.connId;
+
+	f_set_tcp_segmentation(idx);
+}
+
+/* Function to use to bind to a local port as IPA server, accepting remote clients */
+function f_bind(charstring local_host, IPL4asp_Types.PortNumber local_port, integer idx := 0)
+runs on CBSP_Adapter_CT {
+	var IPL4asp_Types.Result res;
+	map(self:CBSP[idx], system:CBSP);
+	res := CBSP_CodecPort_CtrlFunct.f_IPL4_listen(CBSP[idx], local_host, local_port, { tcp:={} });
+	g_cbsp_conn_id[idx] := res.connId;
+
+	f_set_tcp_segmentation(idx);
+}
+
+function f_cbsp_send(template (value) CBSP_PDU pdu, integer idx := 0) runs on CBSP_Adapter_CT {
+	CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], pdu));
+}
+
+function f_cbsp_exp(template CBSP_PDU exp, integer idx := 0) runs on CBSP_Adapter_CT return CBSP_PDU {
+	var CBSP_RecvFrom rf;
+	CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], exp)) -> value rf;
+	return rf.msg;
+}
+
+
+}
diff --git a/library/CBSP_CodecPort.ttcn b/library/CBSP_CodecPort.ttcn
new file mode 100644
index 0000000..442b3e4
--- /dev/null
+++ b/library/CBSP_CodecPort.ttcn
@@ -0,0 +1,64 @@
+module CBSP_CodecPort {
+
+/* Simple CBSP Codec Port, translating between raw TCP octetstring payload
+ * towards the IPL4asp port provider, and CBSP primitives
+ * which carry the decoded CBSP data types as payload.
+ *
+ * (C) 2018 by Harald Welte <laforge at gnumonks.org>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ */
+
+
+import from IPL4asp_PortType all;
+import from IPL4asp_Types all;
+import from CBSP_Types all;
+
+type record CBSP_RecvFrom {
+	ConnectionId	connId,
+	CBSP_PDU	msg
+}
+
+type record CBSP_Send {
+	ConnectionId	connId,
+	CBSP_PDU	msg
+}
+
+template (value) CBSP_Send ts_CBSP_Send(ConnectionId conn_id, template (value) CBSP_PDU msg) := {
+	connId := conn_id,
+	msg := msg
+}
+
+template CBSP_RecvFrom tr_CBSP_Recv(template ConnectionId conn_id, template CBSP_PDU msg) := {
+	connId := conn_id,
+	msg := msg
+}
+
+private function IPL4_to_CBSP_RecvFrom(in ASP_RecvFrom pin, out CBSP_RecvFrom pout) {
+	pout.connId := pin.connId;
+	pout.msg := dec_CBSP_PDU(pin.msg);
+} with { extension "prototype(fast)" }
+
+private function CBSP_to_IPL4_Send(in CBSP_Send pin, out ASP_Send pout) {
+	pout.connId := pin.connId;
+	pout.proto := { tcp := {} };
+	pout.msg := enc_CBSP_PDU(pin.msg);
+} with { extension "prototype(fast)" }
+
+type port CBSP_CODEC_PT message {
+	out	CBSP_Send;
+	in	CBSP_RecvFrom,
+		ASP_ConnId_ReadyToRelease,
+		ASP_Event;
+} with { extension "user IPL4asp_PT
+	out(CBSP_Send -> ASP_Send: function(CBSP_to_IPL4_Send))
+	in(ASP_RecvFrom -> CBSP_RecvFrom: function(IPL4_to_CBSP_RecvFrom);
+	   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
+	   ASP_Event -> ASP_Event: simple)"
+}
+
+
+
+}
diff --git a/library/CBSP_CodecPort_CtrlFunct.ttcn b/library/CBSP_CodecPort_CtrlFunct.ttcn
new file mode 100644
index 0000000..9a5d44b
--- /dev/null
+++ b/library/CBSP_CodecPort_CtrlFunct.ttcn
@@ -0,0 +1,52 @@
+module CBSP_CodecPort_CtrlFunct {
+
+  import from CBSP_CodecPort all;
+  import from IPL4asp_Types all;
+
+  external function f_IPL4_listen(
+    inout CBSP_CODEC_PT portRef,
+    in HostName locName,
+    in PortNumber locPort,
+    in ProtoTuple proto,
+    in OptionList options := {}
+  ) return Result;
+
+  external function f_IPL4_connect(
+    inout CBSP_CODEC_PT portRef,
+    in HostName remName,
+    in PortNumber remPort,
+    in HostName locName,
+    in PortNumber locPort,
+    in ConnectionId connId,
+    in ProtoTuple proto,
+    in OptionList options := {}
+  ) return Result;
+
+  external function f_IPL4_close(
+    inout CBSP_CODEC_PT portRef,
+    in ConnectionId id,
+    in ProtoTuple proto := { unspecified := {} }
+  ) return Result;
+
+  external function f_IPL4_setUserData(
+    inout CBSP_CODEC_PT portRef,
+    in ConnectionId id,
+    in UserData userData
+  ) return Result;
+
+  external function f_IPL4_getUserData(
+    inout CBSP_CODEC_PT portRef,
+    in ConnectionId id,
+    out UserData userData
+  ) return Result;
+
+  external function f_IPL4_setGetMsgLen(
+    inout CBSP_CODEC_PT portRef,
+    in ConnectionId id,
+    inout f_IPL4_getMsgLen f,
+    in ro_integer msgLenArgs
+  );
+
+
+}
+
diff --git a/library/CBSP_CodecPort_CtrlFunctdef.cc b/library/CBSP_CodecPort_CtrlFunctdef.cc
new file mode 100644
index 0000000..6d5e96b
--- /dev/null
+++ b/library/CBSP_CodecPort_CtrlFunctdef.cc
@@ -0,0 +1,66 @@
+#include "IPL4asp_PortType.hh"
+#include "CBSP_CodecPort.hh"
+#include "IPL4asp_PT.hh"
+
+namespace CBSP__CodecPort__CtrlFunct {
+
+  IPL4asp__Types::Result f__IPL4__listen(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef,
+    const IPL4asp__Types::HostName& locName,
+    const IPL4asp__Types::PortNumber& locPort,
+    const IPL4asp__Types::ProtoTuple& proto,
+    const IPL4asp__Types::OptionList& options)
+  {
+    return f__IPL4__PROVIDER__listen(portRef, locName, locPort, proto, options);
+  }
+  
+  IPL4asp__Types::Result f__IPL4__connect(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef,
+    const IPL4asp__Types::HostName& remName,
+    const IPL4asp__Types::PortNumber& remPort,
+    const IPL4asp__Types::HostName& locName,
+    const IPL4asp__Types::PortNumber& locPort,
+    const IPL4asp__Types::ConnectionId& connId,
+    const IPL4asp__Types::ProtoTuple& proto,
+    const IPL4asp__Types::OptionList& options)
+  {
+    return f__IPL4__PROVIDER__connect(portRef, remName, remPort,
+                                      locName, locPort, connId, proto, options);
+  }
+
+  IPL4asp__Types::Result f__IPL4__close(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef, 
+    const IPL4asp__Types::ConnectionId& connId, 
+    const IPL4asp__Types::ProtoTuple& proto)
+  {
+      return f__IPL4__PROVIDER__close(portRef, connId, proto);
+  }
+
+  IPL4asp__Types::Result f__IPL4__setUserData(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef,
+    const IPL4asp__Types::ConnectionId& connId,
+    const IPL4asp__Types::UserData& userData)
+  {
+    return f__IPL4__PROVIDER__setUserData(portRef, connId, userData);
+  }
+  
+  IPL4asp__Types::Result f__IPL4__getUserData(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef,
+    const IPL4asp__Types::ConnectionId& connId,
+    IPL4asp__Types::UserData& userData)
+  {
+    return f__IPL4__PROVIDER__getUserData(portRef, connId, userData);
+  }
+
+  void f__IPL4__setGetMsgLen(
+    CBSP__CodecPort::CBSP__CODEC__PT& portRef,
+    const IPL4asp__Types::ConnectionId& connId,
+    Socket__API__Definitions::f__getMsgLen& f,
+    const Socket__API__Definitions::ro__integer& msgLenArgs)
+  {
+    return f__IPL4__PROVIDER__setGetMsgLen(portRef, connId, f, msgLenArgs);
+  }
+
+
+}
+

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/15375
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: I36b39b320c21502395f9d51d769d76adf5f5d602
Gerrit-Change-Number: 15375
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190904/b6884a2b/attachment.htm>


More information about the gerrit-log mailing list