blob: 9d1a4e138c4586b2e195b44c901662f3c586fab4 [file] [log] [blame]
Harald Welte00a067f2017-09-13 23:27:17 +02001module MGCP_Types {
Harald Welte35bb7162018-01-03 21:07:52 +01002
3/* Definition of abstract types for the MGCP protocol as specified in
4 * IETF RFC 3435. Uses the TITAN "TEXT" codec to auto-generate encoder/decoder
5 * functions, as well as the SDP type definitions and coder from Ericsson.
6 *
7 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
8 * All rights reserved.
9 *
10 * Released under the terms of GNU General Public License, Version 2 or
11 * (at your option) any later version.
12 */
13
Harald Welte00a067f2017-09-13 23:27:17 +020014 import from SDP_Types all;
15
16 type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY",
17 "AUEP", "AUCX", "RSIP") with {
Harald Welte7dc5d372017-11-24 20:41:04 +010018 /* see https://www.eclipse.org/forums/index.php/t/1088893/ on why this
19 * match expression is needed here */
20 variant "TEXT_CODING(,convert=upper_case,'((EPCF)|(CRCX)|(MDCX)|(DLCX)|(RQNT)|(NTFY)|(AUEP)|(AUCX)|(RSIP))',case_insensitive)"
Harald Welte00a067f2017-09-13 23:27:17 +020021 };
22 type charstring MgcpTransId (pattern "\d#(1,9)");
23 type charstring MgcpEndpoint (pattern "*@*");
Harald Welte3c6ebb92017-09-16 00:56:57 +080024 type hexstring MgcpCallId length(1..32); /* 3.2.2.2 */
25 type hexstring MgcpConnectionId length(1..32); /* 3.2.2.5 */
26 type hexstring MgcpRequestId length(1..32); /* 3.2.2.18 */
Harald Welte00a067f2017-09-13 23:27:17 +020027 type charstring MgcpResponseCode (pattern "\d#(3)");
28
29 type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R",
30 "S", "D", "O", "P", "E", "Z", "Q", "T",
31 "RC", "LC", "A", "ES", "RM", "RD", "PL",
32 "MD", "X-Osmo-CP") with {
33 variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)"
34 };
35
Harald Welte3c6ebb92017-09-16 00:56:57 +080036 /* 3.2.2.6 */
37 type charstring MgcpConnectionMode ("sendonly", "recvonly", "sendrecv", "confrnce",
38 "inactive", "loopback", "conttest", "netwloop",
39 "netwtest");
40
41 /* 3.2.2.10 */
42 type charstring MgcpLocalConnOptKeys ("a", "p", "b", "t", "e", "gc", "s", "r", "k",
43 "nt", "r");
44
Harald Welte00a067f2017-09-13 23:27:17 +020045 type charstring MgcpVersion (pattern "\d.\d") with {
46 variant "BEGIN('MGCP ')"
47 }
48
49 type record MgcpCommandLine {
50 MgcpVerb verb,
51 MgcpTransId trans_id,
52 MgcpEndpoint ep,
53 MgcpVersion ver
54 } with {
55 variant "SEPARATOR(' ', '[\t ]+')"
56 //variant "END('\r\n', '(\n)|(\r\n)')"
57 variant "END('\r\n', '([\r\n])|(\r\n)')"
58 }
59
Harald Welte00a067f2017-09-13 23:27:17 +020060 type record MgcpParameter {
61 MgcpInfoCode code,
62 charstring val optional
63 } with {
64 variant "BEGIN('')"
65 variant "SEPARATOR(': ', ':[\t ]+')"
66 //variant "END('\r\n', '(\n)|(\r\n)')"
67 variant "END('\r\n', '([\r\n])|(\r\n)')"
68 }
69
Harald Weltee636afd2017-09-17 16:24:09 +080070 type set of MgcpParameter MgcpParameterList with {
Harald Welte00a067f2017-09-13 23:27:17 +020071 variant "BEGIN('')"
72 };
73
Harald Welte00a067f2017-09-13 23:27:17 +020074 type record MgcpCommand {
75 MgcpCommandLine line,
76 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +080077 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +020078 } with {
79 variant "BEGIN('')"
80 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
81 }
82
83 external function enc_MgcpCommand(in MgcpCommand id) return charstring
84 with { extension "prototype(convert) encode(TEXT)" };
85 external function dec_MgcpCommand(in charstring id) return MgcpCommand
86 with { extension "prototype(convert) decode(TEXT)" };
87
88 type record MgcpResponseLine {
89 MgcpResponseCode code,
90 MgcpTransId trans_id,
91 charstring string optional
92 } with {
93 variant "SEPARATOR(' ', '[\t ]+')"
94 //variant "END('\r\n', '(\n)|(\r\n)')"
95 variant "END('\r\n', '([\r\n])|(\r\n)')"
96 }
97
98 type record MgcpResponse {
99 MgcpResponseLine line,
100 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +0800101 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +0200102 } with {
103 variant "BEGIN('')"
104 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
105 }
106
107 external function enc_MgcpResponse(in MgcpResponse id) return charstring
108 with { extension "prototype(convert) encode(TEXT)" };
109 external function dec_MgcpResponse(in charstring id) return MgcpResponse
110 with { extension "prototype(convert) decode(TEXT)" };
111
Harald Welte2c6dba12017-09-16 00:50:08 +0800112 type union MgcpMessage {
113 MgcpCommand command,
114 MgcpResponse response
115 } with {
116 variant "BEGIN('')"
117 }
118
119 external function enc_MgcpMessage(in MgcpMessage id) return charstring
120 with { extension "prototype(convert) encode(TEXT)" };
121 external function dec_MgcpMessage(in charstring id) return MgcpMessage
122 with { extension "prototype(convert) decode(TEXT)" };
123
Harald Welte00a067f2017-09-13 23:27:17 +0200124
125} with { encode "TEXT" }