initial import of new IPA test port
diff --git a/ipa/IPA_Test.cfg b/ipa/IPA_Test.cfg
new file mode 100644
index 0000000..e5a3d13
--- /dev/null
+++ b/ipa/IPA_Test.cfg
@@ -0,0 +1,19 @@
+[LOGGING]
+#FileMask := LOG_ALL | TTCN_DEBUG | TTCN_MATCHING | DEBUG_ENCDEC;
+#ConsoleMask := ERROR | WARNING | TESTCASE | TTCN_MATCHING | DEBUG_ENCDEC
+FileMask := LOG_ALL | TTCN_MATCHING;
+
+[TESTPORT_PARAMETERS]
+#*.*.udpReuseAddress := "yes";
+
+[MODULE_PARAMETERS]
+#mp_local_port := 2727;
+#mp_local_ip:= "127.0.0.1";
+#mp_remote_port := 2427;
+#mp_remote_ip:= "127.0.0.1";
+
+[MAIN_CONTROLLER]
+
+[EXECUTE]
+#MGCP_Test.TC_selftest
+IPA_Test.TC_recv_dump
diff --git a/ipa/IPA_Test.ttcn b/ipa/IPA_Test.ttcn
new file mode 100644
index 0000000..925f86f
--- /dev/null
+++ b/ipa/IPA_Test.ttcn
@@ -0,0 +1,46 @@
+module IPA_Test {
+
+	import from IPA_CodecPort all;
+	import from IPA_CodecPort_CtrlFunct all;
+	import from IPL4asp_Types all;
+
+	type component ipa_CT {
+		port IPA_CODEC_PT IPA;
+		var boolean g_initialized := false;
+
+		var ConnectionId g_ipa_conn_id := -1;
+	}
+
+	modulepar {
+		PortNumber mp_local_port := 0;
+		charstring mp_local_ip := "127.0.0.1";
+		PortNumber mp_remote_port := 3002;
+		charstring mp_remote_ip := "127.0.0.1";
+	}
+
+	private function f_init() runs on ipa_CT {
+		var Result res;
+
+		if (g_initialized == true) {
+			return;
+		}
+		g_initialized := true;
+		map(self:IPA, system:IPA_CODEC_PT);
+
+		res := IPA_CodecPort_CtrlFunct.f_IPL4_connect(IPA, mp_remote_ip, mp_remote_port,
+							mp_local_ip, mp_local_port, 0, { tcp:={} });
+		g_ipa_conn_id := res.connId;
+	}
+
+	testcase TC_recv_dump() runs on ipa_CT {
+		f_init();
+
+		while (true) {
+			IPA.receive;
+		}
+	}
+
+	control {
+		execute( TC_recv_dump() );
+	}
+}
diff --git a/ipa/gen_links.sh b/ipa/gen_links.sh
new file mode 100755
index 0000000..775ae71
--- /dev/null
+++ b/ipa/gen_links.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+BASEDIR=~/projects/git
+
+gen_links() {
+	DIR=$1
+	FILES=$*
+	for f in $FILES; do
+		echo "Linking $f"
+		ln -sf $DIR/$f $f
+	done
+}
+
+#DIR=$BASEDIR/titan.TestPorts.UNIX_DOMAIN_SOCKETasp/src
+#FILES="UD_PT.cc  UD_PT.hh  UD_PortType.ttcn  UD_Types.ttcn"
+#gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
+FILES="Socket_API_Definitions.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.IPL4asp/src
+FILES="IPL4asp_Functions.ttcn  IPL4asp_PT.cc  IPL4asp_PT.hh IPL4asp_PortType.ttcn  IPL4asp_Types.ttcn  IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"
+gen_links $DIR $FILES
+
+DIR=../library
+FILES="Osmocom_Types.ttcn IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc"
+gen_links $DIR $FILES
diff --git a/ipa/regen_makefile.sh b/ipa/regen_makefile.sh
new file mode 100755
index 0000000..a5d05de
--- /dev/null
+++ b/ipa/regen_makefile.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+MAIN=IPA_Test.ttcn
+
+FILES="*.ttcn IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc"
+
+ttcn3_makefilegen -l -f $MAIN $FILES
+sed -i -e 's/# TTCN3_DIR = /TTCN3_DIR = \/usr/' Makefile
+sed -i -e 's/LDFLAGS = /LDFLAGS = -L \/usr\/lib\/titan /' Makefile
+#sed -i -e 's/TTCN3_LIB = ttcn3-parallel/TTCN3_LIB = ttcn3/' Makefile
+sed -i -e 's/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include/CPPFLAGS = -D$(PLATFORM) -I$(TTCN3_DIR)\/include -I\/usr\/include\/titan/' Makefile
diff --git a/library/IPA_CodecPort.ttcn b/library/IPA_CodecPort.ttcn
new file mode 100644
index 0000000..70d3ccb
--- /dev/null
+++ b/library/IPA_CodecPort.ttcn
@@ -0,0 +1,44 @@
+module IPA_CodecPort {
+
+	import from IPL4asp_PortType all;
+	import from IPL4asp_Types all;
+	import from IPA_Types all;
+
+	type record IPA_RecvFrom {
+		ConnectionId	connId,
+		IpaStreamId	streamId,
+		octetstring	msg
+	}
+
+	type record IPA_Send {
+		ConnectionId	connId,
+		IpaStreamId	streamId,
+		octetstring	msg
+	}
+
+	private function IPL4_to_IPA_RecvFrom(in ASP_RecvFrom pin, out IPA_RecvFrom pout) {
+		var PDU_IPA ipa := dec_PDU_IPA(pin.msg);
+		pout.connId := pin.connId;
+		pout.streamId := ipa.streamId
+		pout.msg := ipa.payloadData;
+	} with { extension "prototype(fast)" }
+
+	private function IPA_to_IPL4_Send(in IPA_Send pin, out ASP_Send pout) {
+		var PDU_IPA ipa := { 0, pin.streamId, pin.msg };
+		pout.connId := pin.connId;
+		pout.proto := { tcp := {} };
+		pout.msg := enc_PDU_IPA(ipa);
+	} with { extension "prototype(fast)" }
+
+	type port IPA_CODEC_PT message {
+		out	IPA_Send;
+		in	IPA_RecvFrom,
+			ASP_ConnId_ReadyToRelease,
+			ASP_Event;
+	} with { extension "user IPL4asp_PT
+		out(IPA_Send -> ASP_Send:function(IPA_to_IPL4_Send))
+		in(ASP_RecvFrom -> IPA_RecvFrom: function(IPL4_to_IPA_RecvFrom);
+		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
+		   ASP_Event -> ASP_Event: simple)"
+	}
+}
diff --git a/library/IPA_CodecPort_CtrlFunct.ttcn b/library/IPA_CodecPort_CtrlFunct.ttcn
new file mode 100644
index 0000000..c0e7de6
--- /dev/null
+++ b/library/IPA_CodecPort_CtrlFunct.ttcn
@@ -0,0 +1,44 @@
+module IPA_CodecPort_CtrlFunct {
+
+  import from IPA_CodecPort all;
+  import from IPL4asp_Types all;
+
+  external function f_IPL4_listen(
+    inout IPA_CODEC_PT portRef,
+    in HostName locName,
+    in PortNumber locPort,
+    in ProtoTuple proto,
+    in OptionList options := {}
+  ) return Result;
+
+  external function f_IPL4_connect(
+    inout IPA_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 IPA_CODEC_PT portRef,
+    in ConnectionId id,
+    in ProtoTuple proto := { unspecified := {} }
+  ) return Result;
+
+  external function f_IPL4_setUserData(
+    inout IPA_CODEC_PT portRef,
+    in ConnectionId id,
+    in UserData userData
+  ) return Result;
+
+  external function f_IPL4_getUserData(
+    inout IPA_CODEC_PT portRef,
+    in ConnectionId id,
+    out UserData userData
+  ) return Result;
+
+}
+
diff --git a/library/IPA_CodecPort_CtrlFunctDef.cc b/library/IPA_CodecPort_CtrlFunctDef.cc
new file mode 100644
index 0000000..6d47305
--- /dev/null
+++ b/library/IPA_CodecPort_CtrlFunctDef.cc
@@ -0,0 +1,56 @@
+#include "IPL4asp_PortType.hh"
+#include "IPA_CodecPort.hh"
+#include "IPL4asp_PT.hh"
+
+namespace IPA__CodecPort__CtrlFunct {
+
+  IPL4asp__Types::Result f__IPL4__listen(
+    IPA__CodecPort::IPA__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(
+    IPA__CodecPort::IPA__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(
+    IPA__CodecPort::IPA__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(
+    IPA__CodecPort::IPA__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(
+    IPA__CodecPort::IPA__CODEC__PT& portRef,
+    const IPL4asp__Types::ConnectionId& connId,
+    IPL4asp__Types::UserData& userData)
+  {
+    return f__IPL4__PROVIDER__getUserData(portRef, connId, userData);
+  }
+  
+}
+
diff --git a/library/IPA_Types.ttcn b/library/IPA_Types.ttcn
new file mode 100644
index 0000000..ceb31ce
--- /dev/null
+++ b/library/IPA_Types.ttcn
@@ -0,0 +1,31 @@
+/* (C) 2017 by Harald Welte <laforge@gnumonks.org> */
+
+module IPA_Types {
+
+import from Osmocom_Types all;
+
+type uint8_t IpaStreamId;
+
+external function enc_PDU_IPA(in PDU_IPA pdu) return octetstring
+with { extension "prototype(convert)"
+       extension "encode(RAW)"
+     }
+
+external function dec_PDU_IPA(in octetstring stream) return PDU_IPA
+with { extension "prototype(convert)"
+       extension "decode(RAW)"
+     }
+
+type record PDU_IPA
+{
+	uint16_t	lengthInd,
+	IpaStreamId	streamId,
+	octetstring	payloadData
+} with {
+	variant (lengthInd) "LENGTHTO(lengthInd,streamId,payloadData)";
+	variant (lengthInd) "FIELDLENGTH(16)";
+	variant (lengthInd) "BYTEORDER(last)";
+	encode "RAW";
+}
+
+}