Add minimal MGCP parser/encoder based on TEXT codec
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
new file mode 100644
index 0000000..53cc94c
--- /dev/null
+++ b/mgw/MGCP_Test.ttcn
@@ -0,0 +1,51 @@
+module MGCP_Test {
+	import from MGCP_Types all;
+
+	type component dummy_CT {
+	};
+
+	testcase TC_selftest() runs on dummy_CT {
+		const charstring c_auep := "AUEP 158663169 ds/e1-1/2@172.16.6.66 MGCP 1.0\r\n";
+		const charstring c_mdcx3 := "MDCX 18983215 1@mgw MGCP 1.0\r\n";
+		const charstring c_mdcx3_ret := "200 18983215 OK\r\n" &
+						"I: 1\n" &
+						"\n" &
+						"v=0\r\n" &
+						"o=- 1 23 IN IP4 0.0.0.0\r\n" &
+						"s=-\r\n" &
+						"c=IN IP4 0.0.0.0\r\n" &
+						"t=0 0\r\n" &
+						"m=audio 0 RTP/AVP 126\r\n" &
+						"a=rtpmap:126 AMR/8000\r\n" &
+						"a=ptime:20\r\n";
+		const charstring c_mdcx4 :=	"MDCX 18983216 1@mgw MGCP 1.0\r\n" &
+						"M: sendrecv\r" &
+						"C: 2\r\n" &
+						"I: 1\r\n" &
+						"L: p:20, a:AMR, nt:IN\r\n" &
+						"\n" &
+						"v=0\r\n" &
+						"o=- 1 23 IN IP4 0.0.0.0\r\n" &
+						"c=IN IP4 0.0.0.0\r\n" &
+						"t=0 0\r\n" &
+						"m=audio 4441 RTP/AVP 99\r\n" &
+						"a=rtpmap:99 AMR/8000\r\n" &
+						"a=ptime:40\r\n";
+
+		log(c_auep);
+		log(dec_MgcpCommand(c_auep));
+
+		log(c_mdcx3);
+		log(dec_MgcpCommand(c_mdcx3));
+
+		log(c_mdcx3_ret);
+		log(dec_MgcpResponse(c_mdcx3_ret));
+
+		log(c_mdcx4);
+		log(dec_MgcpCommand(c_mdcx4));
+	}
+
+	control {
+		execute(TC_selftest());
+	}
+}
diff --git a/mgw/MGCP_Types.ttcn b/mgw/MGCP_Types.ttcn
new file mode 100644
index 0000000..efe7620
--- /dev/null
+++ b/mgw/MGCP_Types.ttcn
@@ -0,0 +1,104 @@
+module MGCP_Types {
+	import from SDP_Types all;
+
+	type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY",
+				  "AUEP", "AUCX", "RSIP") with {
+		variant "TEXT_CODING(,convert=upper_case,,case_insensitive)"
+	};
+	type charstring MgcpTransId 	(pattern "\d#(1,9)");
+	type charstring MgcpEndpoint	(pattern "*@*");
+	/* 3.2.2.5 */
+	type hexstring MgcpConnectionId length(32);
+	type charstring MgcpResponseCode (pattern "\d#(3)");
+
+	type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R",
+				      "S", "D", "O", "P", "E", "Z", "Q", "T",
+				      "RC", "LC", "A", "ES", "RM", "RD", "PL",
+				      "MD", "X-Osmo-CP") with {
+		variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)"
+	};
+
+	type charstring MgcpVersion (pattern "\d.\d") with {
+		variant "BEGIN('MGCP ')"
+	}
+
+	type record MgcpCommandLine {
+		MgcpVerb	verb,
+		MgcpTransId	trans_id,
+		MgcpEndpoint	ep,
+		MgcpVersion	ver
+	} with {
+		variant "SEPARATOR(' ', '[\t ]+')"
+		//variant "END('\r\n', '(\n)|(\r\n)')"
+		variant "END('\r\n', '([\r\n])|(\r\n)')"
+	}
+
+	external function enc_MgcpCommandLine(in MgcpCommandLine id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_MgcpCommandLine(in charstring  id) return MgcpCommandLine
+		with { extension "prototype(convert) decode(TEXT)" };
+
+	type record MgcpParameter {
+		MgcpInfoCode	code,
+		charstring	val optional
+	} with {
+		variant "BEGIN('')"
+		variant "SEPARATOR(': ', ':[\t ]+')"
+		//variant "END('\r\n', '(\n)|(\r\n)')"
+		variant "END('\r\n', '([\r\n])|(\r\n)')"
+	}
+
+	external function enc_MgcpParameter(in MgcpParameter id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_MgcpParameter(in charstring  id) return MgcpParameter
+		with { extension "prototype(convert) decode(TEXT)" };
+
+	type record of MgcpParameter MgcpParameterList with {
+		variant "BEGIN('')"
+	};
+
+	external function enc_MgcpParameterList(in MgcpParameterList id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_MgcpParameterList(in charstring  id) return MgcpParameterList
+		with { extension "prototype(convert) decode(TEXT)" };
+
+	type record MgcpCommand {
+		MgcpCommandLine		line,
+		MgcpParameterList 	params optional,
+		Sdp			sdp optional
+	} with {
+		variant "BEGIN('')"
+		variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
+	}
+
+	external function enc_MgcpCommand(in MgcpCommand id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_MgcpCommand(in charstring  id) return MgcpCommand
+		with { extension "prototype(convert) decode(TEXT)" };
+
+	type record MgcpResponseLine {
+		MgcpResponseCode	code,
+		MgcpTransId		trans_id,
+		charstring		string optional
+	} with {
+		variant "SEPARATOR(' ', '[\t ]+')"
+		//variant "END('\r\n', '(\n)|(\r\n)')"
+		variant "END('\r\n', '([\r\n])|(\r\n)')"
+	}
+
+	type record MgcpResponse {
+		MgcpResponseLine	line,
+		MgcpParameterList	params optional,
+		Sdp			sdp optional
+	} with {
+		variant "BEGIN('')"
+		variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
+	}
+
+	external function enc_MgcpResponse(in MgcpResponse id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_MgcpResponse(in charstring  id) return MgcpResponse
+		with { extension "prototype(convert) decode(TEXT)" };
+
+
+} with { encode "TEXT" }
diff --git a/mgw/SDP_Types.ttcn b/mgw/SDP_Types.ttcn
new file mode 100644
index 0000000..02e2f41
--- /dev/null
+++ b/mgw/SDP_Types.ttcn
@@ -0,0 +1,28 @@
+module SDP_Types {
+
+	type char SdpTag;
+	type record SdpLine {
+		SdpTag		tag,
+		charstring	val
+	} with {
+		variant "BEGIN('')"
+		variant "SEPARATOR('=')"
+		variant "END('\r\n')"
+	};
+
+	type record of SdpLine SdpLineList with {
+		variant "BEGIN('')"
+	};
+
+	type record Sdp {
+		SdpLineList lines
+	} with {
+		variant "BEGIN('')"
+	};
+
+	external function enc_Sdp(in Sdp id) return charstring
+		with { extension "prototype(convert) encode(TEXT)" };
+	external function dec_Sdp(in charstring id) return Sdp
+		with { extension "prototype(convert) decode(TEXT)" };
+
+} with { encode "TEXT" }
diff --git a/mgw/regen_makefile.sh b/mgw/regen_makefile.sh
new file mode 100755
index 0000000..098299d
--- /dev/null
+++ b/mgw/regen_makefile.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+FILES="*.ttcn"
+
+ttcn3_makefilegen -f MGCP_Test.ttcn $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