blob: 3616ddf30826ee9fb909c8a0b6846c864f0f3090 [file] [log] [blame]
Harald Welte00a067f2017-09-13 23:27:17 +02001module MGCP_Types {
2 import from SDP_Types all;
3
4 type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY",
5 "AUEP", "AUCX", "RSIP") with {
6 variant "TEXT_CODING(,convert=upper_case,,case_insensitive)"
7 };
8 type charstring MgcpTransId (pattern "\d#(1,9)");
9 type charstring MgcpEndpoint (pattern "*@*");
Harald Welte3c6ebb92017-09-16 00:56:57 +080010 type hexstring MgcpCallId length(1..32); /* 3.2.2.2 */
11 type hexstring MgcpConnectionId length(1..32); /* 3.2.2.5 */
12 type hexstring MgcpRequestId length(1..32); /* 3.2.2.18 */
Harald Welte00a067f2017-09-13 23:27:17 +020013 type charstring MgcpResponseCode (pattern "\d#(3)");
14
15 type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R",
16 "S", "D", "O", "P", "E", "Z", "Q", "T",
17 "RC", "LC", "A", "ES", "RM", "RD", "PL",
18 "MD", "X-Osmo-CP") with {
19 variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)"
20 };
21
Harald Welte3c6ebb92017-09-16 00:56:57 +080022 /* 3.2.2.6 */
23 type charstring MgcpConnectionMode ("sendonly", "recvonly", "sendrecv", "confrnce",
24 "inactive", "loopback", "conttest", "netwloop",
25 "netwtest");
26
27 /* 3.2.2.10 */
28 type charstring MgcpLocalConnOptKeys ("a", "p", "b", "t", "e", "gc", "s", "r", "k",
29 "nt", "r");
30
Harald Welte00a067f2017-09-13 23:27:17 +020031 type charstring MgcpVersion (pattern "\d.\d") with {
32 variant "BEGIN('MGCP ')"
33 }
34
35 type record MgcpCommandLine {
36 MgcpVerb verb,
37 MgcpTransId trans_id,
38 MgcpEndpoint ep,
39 MgcpVersion ver
40 } with {
41 variant "SEPARATOR(' ', '[\t ]+')"
42 //variant "END('\r\n', '(\n)|(\r\n)')"
43 variant "END('\r\n', '([\r\n])|(\r\n)')"
44 }
45
Harald Welte00a067f2017-09-13 23:27:17 +020046 type record MgcpParameter {
47 MgcpInfoCode code,
48 charstring val optional
49 } with {
50 variant "BEGIN('')"
51 variant "SEPARATOR(': ', ':[\t ]+')"
52 //variant "END('\r\n', '(\n)|(\r\n)')"
53 variant "END('\r\n', '([\r\n])|(\r\n)')"
54 }
55
Harald Welte00a067f2017-09-13 23:27:17 +020056 type record of MgcpParameter MgcpParameterList with {
57 variant "BEGIN('')"
58 };
59
Harald Welte00a067f2017-09-13 23:27:17 +020060 type record MgcpCommand {
61 MgcpCommandLine line,
62 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +080063 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +020064 } with {
65 variant "BEGIN('')"
66 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
67 }
68
69 external function enc_MgcpCommand(in MgcpCommand id) return charstring
70 with { extension "prototype(convert) encode(TEXT)" };
71 external function dec_MgcpCommand(in charstring id) return MgcpCommand
72 with { extension "prototype(convert) decode(TEXT)" };
73
74 type record MgcpResponseLine {
75 MgcpResponseCode code,
76 MgcpTransId trans_id,
77 charstring string optional
78 } with {
79 variant "SEPARATOR(' ', '[\t ]+')"
80 //variant "END('\r\n', '(\n)|(\r\n)')"
81 variant "END('\r\n', '([\r\n])|(\r\n)')"
82 }
83
84 type record MgcpResponse {
85 MgcpResponseLine line,
86 MgcpParameterList params optional,
Harald Welte12000e22017-09-14 22:43:08 +080087 SDP_Message sdp optional
Harald Welte00a067f2017-09-13 23:27:17 +020088 } with {
89 variant "BEGIN('')"
90 variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')"
91 }
92
93 external function enc_MgcpResponse(in MgcpResponse id) return charstring
94 with { extension "prototype(convert) encode(TEXT)" };
95 external function dec_MgcpResponse(in charstring id) return MgcpResponse
96 with { extension "prototype(convert) decode(TEXT)" };
97
Harald Welte2c6dba12017-09-16 00:50:08 +080098 type union MgcpMessage {
99 MgcpCommand command,
100 MgcpResponse response
101 } with {
102 variant "BEGIN('')"
103 }
104
105 external function enc_MgcpMessage(in MgcpMessage id) return charstring
106 with { extension "prototype(convert) encode(TEXT)" };
107 external function dec_MgcpMessage(in charstring id) return MgcpMessage
108 with { extension "prototype(convert) decode(TEXT)" };
109
Harald Welte00a067f2017-09-13 23:27:17 +0200110
111} with { encode "TEXT" }