SABP CodecPort and SABP_Adapter

These modules allow TTCN-3 tests to interface with SABP peers over TCP.

Change-Id: I6c3cfff044ec447d3e58b646c85ccb0531843b51
diff --git a/library/SABP_CodecPort.ttcn b/library/SABP_CodecPort.ttcn
new file mode 100644
index 0000000..65fb542
--- /dev/null
+++ b/library/SABP_CodecPort.ttcn
@@ -0,0 +1,65 @@
+module SABP_CodecPort {
+
+/* Simple SABP Codec Port, translating between raw TCP octetstring payload
+ * towards the IPL4asp port provider, and SABP primitives
+ * which carry the decoded SABP data types as payload.
+ *
+ * (C) 2019 by Harald Welte <laforge@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 SABP_PDU_Descriptions all;
+import from SABP_Types all;
+
+type record SABP_RecvFrom {
+	ConnectionId	connId,
+	SABP_PDU	msg
+}
+
+type record SABP_Send {
+	ConnectionId	connId,
+	SABP_PDU	msg
+}
+
+template (value) SABP_Send ts_SABP_Send(ConnectionId conn_id, template (value) SABP_PDU msg) := {
+	connId := conn_id,
+	msg := msg
+}
+
+template SABP_RecvFrom tr_SABP_Recv(template ConnectionId conn_id, template SABP_PDU msg) := {
+	connId := conn_id,
+	msg := msg
+}
+
+private function IPL4_to_SABP_RecvFrom(in ASP_RecvFrom pin, out SABP_RecvFrom pout) {
+	pout.connId := pin.connId;
+	pout.msg := dec_SABP_PDU(pin.msg);
+} with { extension "prototype(fast)" }
+
+private function SABP_to_IPL4_Send(in SABP_Send pin, out ASP_Send pout) {
+	pout.connId := pin.connId;
+	pout.proto := { tcp := {} };
+	pout.msg := enc_SABP_PDU(pin.msg);
+} with { extension "prototype(fast)" }
+
+type port SABP_CODEC_PT message {
+	out	SABP_Send;
+	in	SABP_RecvFrom,
+		ASP_ConnId_ReadyToRelease,
+		ASP_Event;
+} with { extension "user IPL4asp_PT
+	out(SABP_Send -> ASP_Send: function(SABP_to_IPL4_Send))
+	in(ASP_RecvFrom -> SABP_RecvFrom: function(IPL4_to_SABP_RecvFrom);
+	   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
+	   ASP_Event -> ASP_Event: simple)"
+}
+
+
+
+}