blob: da1b7f63ad7c7aa20c4d2de7007d0ac0b966d237 [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 */
Pau Espin Pedrolb2c6b382019-05-14 13:40:49 +020027 type integer MgcpOsmuxCID (-1 .. 255);
Harald Welte00a067f2017-09-13 23:27:17 +020028 type charstring MgcpResponseCode (pattern "\d#(3)");
29
30 type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R",
31 "S", "D", "O", "P", "E", "Z", "Q", "T",
32 "RC", "LC", "A", "ES", "RM", "RD", "PL",
Pau Espin Pedrolbefd3aa2020-09-21 10:54:42 +020033 "MD", "X-OSMO-CP", "X-OSMO-IGN", "X-OSMUX") with {
34 variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-OSMO-CP)|(X-OSMO-IGN)|(X-OSMUX)',case_insensitive)"
Harald Welte00a067f2017-09-13 23:27:17 +020035 };
36
Harald Welte3c6ebb92017-09-16 00:56:57 +080037 /* 3.2.2.6 */
38 type charstring MgcpConnectionMode ("sendonly", "recvonly", "sendrecv", "confrnce",
39 "inactive", "loopback", "conttest", "netwloop",
40 "netwtest");
41
42 /* 3.2.2.10 */
43 type charstring MgcpLocalConnOptKeys ("a", "p", "b", "t", "e", "gc", "s", "r", "k",
44 "nt", "r");
45
Harald Welte00a067f2017-09-13 23:27:17 +020046 type charstring MgcpVersion (pattern "\d.\d") with {
47 variant "BEGIN('MGCP ')"
48 }
49
50 type record MgcpCommandLine {
51 MgcpVerb verb,
52 MgcpTransId trans_id,
53 MgcpEndpoint ep,
54 MgcpVersion ver
55 } with {
56 variant "SEPARATOR(' ', '[\t ]+')"
Neels Hofmeyrf6e991c2019-09-18 19:43:28 +020057 variant "END('\r\n', '([\r\n])|(\r\n)')"
Harald Welte00a067f2017-09-13 23:27:17 +020058 }
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 ]+')"
Neels Hofmeyrf6e991c2019-09-18 19:43:28 +020066 variant "END('\r\n', '([\r\n])|(\r\n)')"
Harald Welte00a067f2017-09-13 23:27:17 +020067 }
68
Harald Weltee636afd2017-09-17 16:24:09 +080069 type set of MgcpParameter MgcpParameterList with {
Harald Welte00a067f2017-09-13 23:27:17 +020070 variant "BEGIN('')"
71 };
72
Harald Welte00a067f2017-09-13 23:27:17 +020073 type record MgcpCommand {
74 MgcpCommandLine line,
75 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +080076 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +020077 } with {
78 variant "BEGIN('')"
Neels Hofmeyrf6e991c2019-09-18 19:43:28 +020079 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
Harald Welte00a067f2017-09-13 23:27:17 +020080 }
81
82 external function enc_MgcpCommand(in MgcpCommand id) return charstring
83 with { extension "prototype(convert) encode(TEXT)" };
84 external function dec_MgcpCommand(in charstring id) return MgcpCommand
85 with { extension "prototype(convert) decode(TEXT)" };
86
87 type record MgcpResponseLine {
88 MgcpResponseCode code,
89 MgcpTransId trans_id,
90 charstring string optional
91 } with {
92 variant "SEPARATOR(' ', '[\t ]+')"
Neels Hofmeyrf6e991c2019-09-18 19:43:28 +020093 variant "END('\r\n', '([\r\n])|(\r\n)')"
Harald Welte00a067f2017-09-13 23:27:17 +020094 }
95
96 type record MgcpResponse {
97 MgcpResponseLine line,
98 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +080099 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +0200100 } with {
101 variant "BEGIN('')"
Neels Hofmeyrf6e991c2019-09-18 19:43:28 +0200102 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
Harald Welte00a067f2017-09-13 23:27:17 +0200103 }
104
105 external function enc_MgcpResponse(in MgcpResponse id) return charstring
106 with { extension "prototype(convert) encode(TEXT)" };
107 external function dec_MgcpResponse(in charstring id) return MgcpResponse
108 with { extension "prototype(convert) decode(TEXT)" };
109
Harald Welte2c6dba12017-09-16 00:50:08 +0800110 type union MgcpMessage {
111 MgcpCommand command,
112 MgcpResponse response
113 } with {
114 variant "BEGIN('')"
115 }
116
117 external function enc_MgcpMessage(in MgcpMessage id) return charstring
118 with { extension "prototype(convert) encode(TEXT)" };
119 external function dec_MgcpMessage(in charstring id) return MgcpMessage
120 with { extension "prototype(convert) decode(TEXT)" };
121
Philipp Maier11a58942018-06-25 16:40:48 +0200122 /* IANA / 3gpp assigned payload type numbers */
123 type enumerated SDP_FIELD_PayloadType {
124 PT_PCMU(0),
125 PT_GSM(3),
126 PT_PCMA(8),
127 PT_G729(18),
128 PT_GSMEFR(110),
129 PT_GSMHR(111),
130 PT_AMR(112),
Oliver Smithbc392a82023-04-17 14:06:42 +0200131 PT_AMRWB(113),
132 PT_CSD(120)
Philipp Maier11a58942018-06-25 16:40:48 +0200133 }
Harald Welte00a067f2017-09-13 23:27:17 +0200134
135} with { encode "TEXT" }