library/M3UA: support TCP transport, implement desegmentation

Change-Id: If1dcdb185d08a08dc5a06c37d9d6ffe7d6da9325
Related: libosmo-sccp.git I8c76d271472befacbeb998a93bbdc9e8660d9b5d
Related: SYS#5424
diff --git a/library/M3UA_CodecPort.ttcn b/library/M3UA_CodecPort.ttcn
index 94d16d6..e88b6a0 100644
--- a/library/M3UA_CodecPort.ttcn
+++ b/library/M3UA_CodecPort.ttcn
@@ -15,6 +15,7 @@
 
 	import from IPL4asp_PortType all;
 	import from IPL4asp_Types all;
+	import from M3UA_CodecPort_CtrlFunct all;
 	import from M3UA_Types all;
 
 	type record M3UA_RecvFrom {
@@ -37,7 +38,7 @@
 
 	type record M3UA_Send {
 		ConnectionId	connId,
-		integer		stream,
+		integer		stream optional,
 		PDU_M3UA	msg
 	}
 
@@ -59,14 +60,18 @@
 
 	private function M3UA_to_IPL4_Send(in M3UA_Send pin, out ASP_Send pout) {
 		pout.connId := pin.connId;
-		pout.proto := {
-			sctp := {
-				sinfo_stream := pin.stream,
-				sinfo_ppid := 3,
-				remSocks := omit,
-				assocId := omit
-			}
-		};
+		if (ispresent(pin.stream)) {
+			pout.proto := {
+				sctp := {
+					sinfo_stream := pin.stream,
+					sinfo_ppid := 3,
+					remSocks := omit,
+					assocId := omit
+				}
+			};
+		} else {
+			pout.proto := { tcp := { } };
+		}
 		pout.msg := enc_PDU_M3UA(pin.msg);
 	} with { extension "prototype(fast)" };
 
@@ -80,5 +85,12 @@
 		in(ASP_RecvFrom -> M3UA_RecvFrom: function(IPL4_to_M3UA_RecvFrom);
 		   ASP_ConnId_ReadyToRelease -> ASP_ConnId_ReadyToRelease: simple;
 		   ASP_Event -> ASP_Event: simple)"
+	};
+
+	function f_set_tcp_segmentation(M3UA_CODEC_PT pt, ConnectionId connId) {
+		/* Set function for dissecting the binary stream into packets */
+		var f_IPL4_getMsgLen vl_f := refers(f_IPL4_fixedMsgLen);
+		/* Offset: 4, size of length: 4, delta: 0, multiplier: 1, big-endian */
+		M3UA_CodecPort_CtrlFunct.f_IPL4_setGetMsgLen(pt, connId, vl_f, {4, 4, 0, 1, 0});
 	}
 }