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 "*@*"); |
| 10 | /* 3.2.2.5 */ |
| 11 | type hexstring MgcpConnectionId length(32); |
| 12 | type charstring MgcpResponseCode (pattern "\d#(3)"); |
| 13 | |
| 14 | type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R", |
| 15 | "S", "D", "O", "P", "E", "Z", "Q", "T", |
| 16 | "RC", "LC", "A", "ES", "RM", "RD", "PL", |
| 17 | "MD", "X-Osmo-CP") with { |
| 18 | variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)" |
| 19 | }; |
| 20 | |
| 21 | type charstring MgcpVersion (pattern "\d.\d") with { |
| 22 | variant "BEGIN('MGCP ')" |
| 23 | } |
| 24 | |
| 25 | type record MgcpCommandLine { |
| 26 | MgcpVerb verb, |
| 27 | MgcpTransId trans_id, |
| 28 | MgcpEndpoint ep, |
| 29 | MgcpVersion ver |
| 30 | } with { |
| 31 | variant "SEPARATOR(' ', '[\t ]+')" |
| 32 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 33 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 34 | } |
| 35 | |
| 36 | external function enc_MgcpCommandLine(in MgcpCommandLine id) return charstring |
| 37 | with { extension "prototype(convert) encode(TEXT)" }; |
| 38 | external function dec_MgcpCommandLine(in charstring id) return MgcpCommandLine |
| 39 | with { extension "prototype(convert) decode(TEXT)" }; |
| 40 | |
| 41 | type record MgcpParameter { |
| 42 | MgcpInfoCode code, |
| 43 | charstring val optional |
| 44 | } with { |
| 45 | variant "BEGIN('')" |
| 46 | variant "SEPARATOR(': ', ':[\t ]+')" |
| 47 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 48 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 49 | } |
| 50 | |
| 51 | external function enc_MgcpParameter(in MgcpParameter id) return charstring |
| 52 | with { extension "prototype(convert) encode(TEXT)" }; |
| 53 | external function dec_MgcpParameter(in charstring id) return MgcpParameter |
| 54 | with { extension "prototype(convert) decode(TEXT)" }; |
| 55 | |
| 56 | type record of MgcpParameter MgcpParameterList with { |
| 57 | variant "BEGIN('')" |
| 58 | }; |
| 59 | |
| 60 | external function enc_MgcpParameterList(in MgcpParameterList id) return charstring |
| 61 | with { extension "prototype(convert) encode(TEXT)" }; |
| 62 | external function dec_MgcpParameterList(in charstring id) return MgcpParameterList |
| 63 | with { extension "prototype(convert) decode(TEXT)" }; |
| 64 | |
| 65 | type record MgcpCommand { |
| 66 | MgcpCommandLine line, |
| 67 | MgcpParameterList params optional, |
| 68 | Sdp sdp optional |
| 69 | } with { |
| 70 | variant "BEGIN('')" |
| 71 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 72 | } |
| 73 | |
| 74 | external function enc_MgcpCommand(in MgcpCommand id) return charstring |
| 75 | with { extension "prototype(convert) encode(TEXT)" }; |
| 76 | external function dec_MgcpCommand(in charstring id) return MgcpCommand |
| 77 | with { extension "prototype(convert) decode(TEXT)" }; |
| 78 | |
| 79 | type record MgcpResponseLine { |
| 80 | MgcpResponseCode code, |
| 81 | MgcpTransId trans_id, |
| 82 | charstring string optional |
| 83 | } with { |
| 84 | variant "SEPARATOR(' ', '[\t ]+')" |
| 85 | //variant "END('\r\n', '(\n)|(\r\n)')" |
| 86 | variant "END('\r\n', '([\r\n])|(\r\n)')" |
| 87 | } |
| 88 | |
| 89 | type record MgcpResponse { |
| 90 | MgcpResponseLine line, |
| 91 | MgcpParameterList params optional, |
| 92 | Sdp sdp optional |
| 93 | } with { |
| 94 | variant "BEGIN('')" |
| 95 | variant (sdp) "BEGIN('\r\n','([\r\n])|(\r\n)')" |
| 96 | } |
| 97 | |
| 98 | external function enc_MgcpResponse(in MgcpResponse id) return charstring |
| 99 | with { extension "prototype(convert) encode(TEXT)" }; |
| 100 | external function dec_MgcpResponse(in charstring id) return MgcpResponse |
| 101 | with { extension "prototype(convert) decode(TEXT)" }; |
| 102 | |
| 103 | |
| 104 | } with { encode "TEXT" } |