Harald Welte | a76c4bb | 2017-12-09 02:06:07 +0100 | [diff] [blame^] | 1 | module Osmocom_CTRL_Types { |
| 2 | |
| 3 | type charstring CtrlVerb ("GET", "SET") with { |
| 4 | /* see https://www.eclipse.org/forums/index.php/t/1088893/ on why this |
| 5 | * match expression is needed here */ |
| 6 | variant "TEXT_CODING(,convert=upper_case,'((GET)|(SET)|(TRAP))',case_insensitive)" |
| 7 | }; |
| 8 | |
| 9 | type charstring CtrlReplyToken ("REPLY") with { |
| 10 | variant "TEXT_CODING(,convert=upper_case,'(REPLY)',case_insensitive)" |
| 11 | }; |
| 12 | |
| 13 | type charstring CtrlId (pattern "\d#(1,9)"); |
| 14 | type charstring CtrlVariable (pattern "[^, \{\}\[\]\(\)<>\|~\\\^`'\"\?=;/\+\*&%$\#!]*"); |
| 15 | type charstring CtrlValue (pattern "[^ ]"); |
| 16 | type charstring CtrlReason; |
| 17 | |
| 18 | |
| 19 | type record CtrlCommand { |
| 20 | CtrlVerb verb, |
| 21 | CtrlId id, |
| 22 | CtrlVariable variable, |
| 23 | CtrlValue val optional /* only for SET */ |
| 24 | } with { |
| 25 | variant "SEPARATOR(' ',)" |
| 26 | }; |
| 27 | |
| 28 | type record CtrlResponse { |
| 29 | CtrlVerb verb, |
| 30 | CtrlReplyToken repl, |
| 31 | CtrlId id, |
| 32 | CtrlVariable variable, |
| 33 | CtrlValue val |
| 34 | } with { |
| 35 | variant "TEXT_CODING(,,'* REPLY *',case_insensitive)" |
| 36 | variant "SEPARATOR(' ',)" |
| 37 | }; |
| 38 | |
| 39 | type record CtrlError { |
| 40 | CtrlId id, |
| 41 | CtrlReason reason |
| 42 | } with { |
| 43 | variant "BEGIN('ERROR ',,case_insensitive)" |
| 44 | variant "SEPARATOR(' ',)" |
| 45 | }; |
| 46 | |
| 47 | type record CtrlTrap { |
| 48 | CtrlVariable variable, |
| 49 | CtrlValue val |
| 50 | } with { |
| 51 | variant "BEGIN('TRAP ',,case_insensitive)" |
| 52 | variant "SEPARATOR(' ',)" |
| 53 | }; |
| 54 | |
| 55 | type union CtrlMessage { |
| 56 | CtrlCommand cmd, |
| 57 | CtrlResponse resp, |
| 58 | CtrlError err, |
| 59 | CtrlTrap trap |
| 60 | }; |
| 61 | |
| 62 | external function enc_CtrlMessage(in CtrlMessage id) return charstring |
| 63 | with { extension "prototype(convert) encode(TEXT)"}; |
| 64 | |
| 65 | external function dec_CtrlMessage(in charstring id) return CtrlMessage |
| 66 | with { extension "prototype(convert) decode(TEXT)"}; |
| 67 | |
| 68 | |
| 69 | } with { encode "TEXT" } |