Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 1 | module MGCP_Types { |
| 2 | import from SDP_Types all; |
| 3 | |
| 4 | type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY", |
| 5 | "AUEP", "AUCX", "RSIP") with { |
Harald Welte | 7dc5d37 | 2017-11-24 20:41:04 +0100 | [diff] [blame] | 6 | /* see https://www.eclipse.org/forums/index.php/t/1088893/ on why this |
| 7 | * match expression is needed here */ |
| 8 | variant "TEXT_CODING(,convert=upper_case,'((EPCF)|(CRCX)|(MDCX)|(DLCX)|(RQNT)|(NTFY)|(AUEP)|(AUCX)|(RSIP))',case_insensitive)" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 9 | }; |
| 10 | type charstring MgcpTransId (pattern "\d#(1,9)"); |
| 11 | type charstring MgcpEndpoint (pattern "*@*"); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 12 | type hexstring MgcpCallId length(1..32); /* 3.2.2.2 */ |
| 13 | type hexstring MgcpConnectionId length(1..32); /* 3.2.2.5 */ |
| 14 | type hexstring MgcpRequestId length(1..32); /* 3.2.2.18 */ |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 15 | type charstring MgcpResponseCode (pattern "\d#(3)"); |
| 16 | |
| 17 | type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R", |
| 18 | "S", "D", "O", "P", "E", "Z", "Q", "T", |
| 19 | "RC", "LC", "A", "ES", "RM", "RD", "PL", |
| 20 | "MD", "X-Osmo-CP") with { |
| 21 | variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)" |
| 22 | }; |
| 23 | |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 24 | /* 3.2.2.6 */ |
| 25 | type charstring MgcpConnectionMode ("sendonly", "recvonly", "sendrecv", "confrnce", |
| 26 | "inactive", "loopback", "conttest", "netwloop", |
| 27 | "netwtest"); |
| 28 | |
| 29 | /* 3.2.2.10 */ |
| 30 | type charstring MgcpLocalConnOptKeys ("a", "p", "b", "t", "e", "gc", "s", "r", "k", |
| 31 | "nt", "r"); |
| 32 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 33 | type charstring MgcpVersion (pattern "\d.\d") with { |
| 34 | variant "BEGIN('MGCP ')" |
| 35 | } |
| 36 | |
| 37 | type record MgcpCommandLine { |
| 38 | MgcpVerb verb, |
| 39 | MgcpTransId trans_id, |
| 40 | MgcpEndpoint ep, |
| 41 | MgcpVersion ver |
| 42 | } with { |
| 43 | variant "SEPARATOR(' ', '[\t ]+')" |
| 44 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 45 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 46 | } |
| 47 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 48 | type record MgcpParameter { |
| 49 | MgcpInfoCode code, |
| 50 | charstring val optional |
| 51 | } with { |
| 52 | variant "BEGIN('')" |
| 53 | variant "SEPARATOR(': ', ':[\t ]+')" |
| 54 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 55 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 56 | } |
| 57 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 58 | type set of MgcpParameter MgcpParameterList with { |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 59 | variant "BEGIN('')" |
| 60 | }; |
| 61 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 62 | type record MgcpCommand { |
| 63 | MgcpCommandLine line, |
| 64 | MgcpParameterList params optional, |
Harald Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 65 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 66 | } with { |
| 67 | variant "BEGIN('')" |
| 68 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 69 | } |
| 70 | |
| 71 | external function enc_MgcpCommand(in MgcpCommand id) return charstring |
| 72 | with { extension "prototype(convert) encode(TEXT)" }; |
| 73 | external function dec_MgcpCommand(in charstring id) return MgcpCommand |
| 74 | with { extension "prototype(convert) decode(TEXT)" }; |
| 75 | |
| 76 | type record MgcpResponseLine { |
| 77 | MgcpResponseCode code, |
| 78 | MgcpTransId trans_id, |
| 79 | charstring string optional |
| 80 | } with { |
| 81 | variant "SEPARATOR(' ', '[\t ]+')" |
| 82 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 83 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 84 | } |
| 85 | |
| 86 | type record MgcpResponse { |
| 87 | MgcpResponseLine line, |
| 88 | MgcpParameterList params optional, |
Harald Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 89 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 90 | } with { |
| 91 | variant "BEGIN('')" |
| 92 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 93 | } |
| 94 | |
| 95 | external function enc_MgcpResponse(in MgcpResponse id) return charstring |
| 96 | with { extension "prototype(convert) encode(TEXT)" }; |
| 97 | external function dec_MgcpResponse(in charstring id) return MgcpResponse |
| 98 | with { extension "prototype(convert) decode(TEXT)" }; |
| 99 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 100 | type union MgcpMessage { |
| 101 | MgcpCommand command, |
| 102 | MgcpResponse response |
| 103 | } with { |
| 104 | variant "BEGIN('')" |
| 105 | } |
| 106 | |
| 107 | external function enc_MgcpMessage(in MgcpMessage id) return charstring |
| 108 | with { extension "prototype(convert) encode(TEXT)" }; |
| 109 | external function dec_MgcpMessage(in charstring id) return MgcpMessage |
| 110 | with { extension "prototype(convert) decode(TEXT)" }; |
| 111 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 112 | |
| 113 | } with { encode "TEXT" } |