Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 1 | module MGCP_Types { |
Harald Welte | 35bb716 | 2018-01-03 21:07:52 +0100 | [diff] [blame] | 2 | |
| 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 14 | import from SDP_Types all; |
| 15 | |
| 16 | type charstring MgcpVerb ("EPCF", "CRCX", "MDCX", "DLCX", "RQNT", "NTFY", |
| 17 | "AUEP", "AUCX", "RSIP") with { |
Harald Welte | 7dc5d37 | 2017-11-24 20:41:04 +0100 | [diff] [blame] | 18 | /* 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 21 | }; |
| 22 | type charstring MgcpTransId (pattern "\d#(1,9)"); |
| 23 | type charstring MgcpEndpoint (pattern "*@*"); |
Harald Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 24 | 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 27 | 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 Welte | 3c6ebb9 | 2017-09-16 00:56:57 +0800 | [diff] [blame] | 36 | /* 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 Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 45 | 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 ]+')" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 56 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 57 | } |
| 58 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 59 | type record MgcpParameter { |
| 60 | MgcpInfoCode code, |
| 61 | charstring val optional |
| 62 | } with { |
| 63 | variant "BEGIN('')" |
| 64 | variant "SEPARATOR(': ', ':[\t ]+')" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 65 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 66 | } |
| 67 | |
Harald Welte | e636afd | 2017-09-17 16:24:09 +0800 | [diff] [blame] | 68 | type set of MgcpParameter MgcpParameterList with { |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 69 | variant "BEGIN('')" |
| 70 | }; |
| 71 | |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 72 | type record MgcpCommand { |
| 73 | MgcpCommandLine line, |
| 74 | MgcpParameterList params optional, |
Harald Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 75 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 76 | } with { |
| 77 | variant "BEGIN('')" |
| 78 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 79 | } |
| 80 | |
| 81 | external function enc_MgcpCommand(in MgcpCommand id) return charstring |
| 82 | with { extension "prototype(convert) encode(TEXT)" }; |
| 83 | external function dec_MgcpCommand(in charstring id) return MgcpCommand |
| 84 | with { extension "prototype(convert) decode(TEXT)" }; |
| 85 | |
| 86 | type record MgcpResponseLine { |
| 87 | MgcpResponseCode code, |
| 88 | MgcpTransId trans_id, |
| 89 | charstring string optional |
| 90 | } with { |
| 91 | variant "SEPARATOR(' ', '[\t ]+')" |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 92 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 93 | } |
| 94 | |
| 95 | type record MgcpResponse { |
| 96 | MgcpResponseLine line, |
| 97 | MgcpParameterList params optional, |
Harald Welte | 12000e2 | 2017-09-14 22:43:08 +0800 | [diff] [blame] | 98 | SDP_Message sdp optional |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 99 | } with { |
| 100 | variant "BEGIN('')" |
| 101 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 102 | } |
| 103 | |
| 104 | external function enc_MgcpResponse(in MgcpResponse id) return charstring |
| 105 | with { extension "prototype(convert) encode(TEXT)" }; |
| 106 | external function dec_MgcpResponse(in charstring id) return MgcpResponse |
| 107 | with { extension "prototype(convert) decode(TEXT)" }; |
| 108 | |
Harald Welte | 2c6dba1 | 2017-09-16 00:50:08 +0800 | [diff] [blame] | 109 | type union MgcpMessage { |
| 110 | MgcpCommand command, |
| 111 | MgcpResponse response |
| 112 | } with { |
| 113 | variant "BEGIN('')" |
| 114 | } |
| 115 | |
| 116 | external function enc_MgcpMessage(in MgcpMessage id) return charstring |
| 117 | with { extension "prototype(convert) encode(TEXT)" }; |
| 118 | external function dec_MgcpMessage(in charstring id) return MgcpMessage |
| 119 | with { extension "prototype(convert) decode(TEXT)" }; |
| 120 | |
Philipp Maier | 11a5894 | 2018-06-25 16:40:48 +0200 | [diff] [blame] | 121 | /* IANA / 3gpp assigned payload type numbers */ |
| 122 | type enumerated SDP_FIELD_PayloadType { |
| 123 | PT_PCMU(0), |
| 124 | PT_GSM(3), |
| 125 | PT_PCMA(8), |
| 126 | PT_G729(18), |
| 127 | PT_GSMEFR(110), |
| 128 | PT_GSMHR(111), |
| 129 | PT_AMR(112), |
| 130 | PT_AMRWB(113) |
| 131 | } |
Harald Welte | 00a067f | 2017-09-13 23:27:17 +0200 | [diff] [blame] | 132 | |
| 133 | } with { encode "TEXT" } |