blob: db5012c3c78e63c6d8f335ddd2211064297cceef [file] [log] [blame]
Harald Weltea76c4bb2017-12-09 02:06:07 +01001module Osmocom_CTRL_Types {
2
3type 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
9type charstring CtrlReplyToken ("REPLY") with {
10 variant "TEXT_CODING(,convert=upper_case,'(REPLY)',case_insensitive)"
11};
12
13type charstring CtrlId (pattern "\d#(1,9)");
14type charstring CtrlVariable (pattern "[^, \{\}\[\]\(\)<>\|~\\\^`'\"\?=;/\+\*&%$\#!]*");
15type charstring CtrlValue (pattern "[^ ]");
16type charstring CtrlReason;
17
18
19type 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
28type 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
39type record CtrlError {
40 CtrlId id,
41 CtrlReason reason
42} with {
43 variant "BEGIN('ERROR ',,case_insensitive)"
44 variant "SEPARATOR(' ',)"
45};
46
47type record CtrlTrap {
48 CtrlVariable variable,
49 CtrlValue val
50} with {
51 variant "BEGIN('TRAP ',,case_insensitive)"
52 variant "SEPARATOR(' ',)"
53};
54
55type union CtrlMessage {
56 CtrlCommand cmd,
57 CtrlResponse resp,
58 CtrlError err,
59 CtrlTrap trap
60};
61
62external function enc_CtrlMessage(in CtrlMessage id) return charstring
63 with { extension "prototype(convert) encode(TEXT)"};
64
65external function dec_CtrlMessage(in charstring id) return CtrlMessage
66 with { extension "prototype(convert) decode(TEXT)"};
67
68
69} with { encode "TEXT" }