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 { |
| 6 | variant "TEXT_CODING(,convert=upper_case,,case_insensitive)" |
| 7 | }; |
| 8 | type charstring MgcpTransId (pattern "\d#(1,9)"); |
| 9 | type charstring MgcpEndpoint (pattern "*@*"); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 10 | 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 13 | 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 Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 22 | /* 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 31 | 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 46 | 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 Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 56 | type set of MgcpParameter MgcpParameterList with { |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 57 | variant "BEGIN('')" |
| 58 | }; |
| 59 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 60 | type record MgcpCommand { |
| 61 | MgcpCommandLine line, |
| 62 | MgcpParameterList params optional, |
Harald Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 63 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 64 | } 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 Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 87 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 88 | } 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 Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 98 | 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 110 | |
| 111 | } with { encode "TEXT" } |