aboutsummaryrefslogtreecommitdiffstats
path: root/library/MGCP_Types.ttcn
blob: b56734cf586eade4fe22542a8c6290ca2c55e6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
module MGCP_Types {

/* Definition of abstract types for the MGCP protocol as specified in
 * IETF RFC 3435.  Uses the TITAN "TEXT" codec to auto-generate encoder/decoder
 * functions, as well as the SDP type definitions and coder from Ericsson.
 *
 * (C) 2017 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 SDP_Types all;

	type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY",
				  "AUEP", "AUCX", "RSIP") with {
		/* see https://www.eclipse.org/forums/index.php/t/1088893/ on why this
		 * match expression is needed here */
		variant "TEXT_CODING(,convert=upper_case,'((EPCF)|(CRCX)|(MDCX)|(DLCX)|(RQNT)|(NTFY)|(AUEP)|(AUCX)|(RSIP))',case_insensitive)"
	};
	type charstring MgcpTransId 	(pattern "\d#(1,9)");
	type charstring MgcpEndpoint	(pattern "*@*");
	type hexstring MgcpCallId	length(1..32);	/* 3.2.2.2 */
	type hexstring MgcpConnectionId	length(1..32);	/* 3.2.2.5 */
	type hexstring MgcpRequestId	length(1..32);	/* 3.2.2.18 */
	type integer MgcpOsmuxCID	(-1 .. 255);
	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", "X-OSMUX") with {
		variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-OSMO-CP)|(X-OSMUX)',case_insensitive)"
	};

	/* 3.2.2.6 */
	type charstring MgcpConnectionMode ("sendonly", "recvonly", "sendrecv", "confrnce",
					    "inactive", "loopback", "conttest", "netwloop",
					    "netwtest");

	/* 3.2.2.10 */
	type charstring MgcpLocalConnOptKeys ("a", "p", "b", "t", "e", "gc", "s", "r", "k",
					      "nt", "r");

	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', '([\r\n])|(\r\n)')"
	}

	type record MgcpParameter {
		MgcpInfoCode	code,
		charstring	val optional
	} with {
		variant "BEGIN('')"
		variant "SEPARATOR(': ', ':[\t ]+')"
		variant "END('\r\n', '([\r\n])|(\r\n)')"
	}

	type set of MgcpParameter MgcpParameterList with {
		variant "BEGIN('')"
	};

	type record MgcpCommand {
		MgcpCommandLine		line,
		MgcpParameterList 	params optional,
		SDP_Message		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', '([\r\n])|(\r\n)')"
	}

	type record MgcpResponse {
		MgcpResponseLine	line,
		MgcpParameterList	params optional,
		SDP_Message		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)" };

	type union MgcpMessage {
		MgcpCommand	command,
		MgcpResponse	response
	} with {
		variant "BEGIN('')"
	}

	external function enc_MgcpMessage(in MgcpMessage id) return charstring
		with { extension "prototype(convert) encode(TEXT)" };
	external function dec_MgcpMessage(in charstring  id) return MgcpMessage
		with { extension "prototype(convert) decode(TEXT)" };

	/* IANA / 3gpp assigned payload type numbers */
	type enumerated SDP_FIELD_PayloadType {
		PT_PCMU(0),
		PT_GSM(3),
		PT_PCMA(8),
		PT_G729(18),
		PT_GSMEFR(110),
		PT_GSMHR(111),
		PT_AMR(112),
		PT_AMRWB(113)
	}

} with { encode "TEXT" }