blob: 4d2406d430b0feff16757ef56467d1ff618b1ad8 [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 */
Harald Weltefdfa0462017-12-10 18:09:40 +01006 variant "TEXT_CODING(,convert=upper_case,'((GET)|(SET))',case_insensitive)"
Harald Weltea76c4bb2017-12-09 02:06:07 +01007};
8
Harald Welte03c0e562017-12-09 02:55:12 +01009type charstring CtrlReplyVerb ("GET_REPLY", "SET_REPLY") with {
10 variant "TEXT_CODING(,convert=upper_case,'((GET_REPLY)|(SET_REPLY))',case_insensitive)"
Harald Weltea76c4bb2017-12-09 02:06:07 +010011};
12
13type charstring CtrlId (pattern "\d#(1,9)");
Harald Welte0ac46672017-12-09 14:19:58 +010014type charstring CtrlVariable (pattern "[^, \{\}\[\]\(\)<>\|~\\\^`'\"\?=;/\+&%$\#!]#(1,)");
15type charstring CtrlValue (pattern "[^ ]#(0,)");
Harald Weltea76c4bb2017-12-09 02:06:07 +010016type 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 {
Harald Welte03c0e562017-12-09 02:55:12 +010029 CtrlReplyVerb verb,
Harald Weltea76c4bb2017-12-09 02:06:07 +010030 CtrlId id,
31 CtrlVariable variable,
32 CtrlValue val
33} with {
Harald Weltea76c4bb2017-12-09 02:06:07 +010034 variant "SEPARATOR(' ',)"
35};
36
37type record CtrlError {
38 CtrlId id,
39 CtrlReason reason
40} with {
41 variant "BEGIN('ERROR ',,case_insensitive)"
42 variant "SEPARATOR(' ',)"
43};
44
45type record CtrlTrap {
46 CtrlVariable variable,
47 CtrlValue val
48} with {
Harald Weltefdfa0462017-12-10 18:09:40 +010049 variant "BEGIN('TRAP 0 ',,case_insensitive)"
Harald Weltea76c4bb2017-12-09 02:06:07 +010050 variant "SEPARATOR(' ',)"
51};
52
53type union CtrlMessage {
54 CtrlCommand cmd,
55 CtrlResponse resp,
56 CtrlError err,
57 CtrlTrap trap
Harald Welte16979762017-12-13 00:45:44 +010058} with { variant "BEGIN('')" };
Harald Weltea76c4bb2017-12-09 02:06:07 +010059
60external function enc_CtrlMessage(in CtrlMessage id) return charstring
61 with { extension "prototype(convert) encode(TEXT)"};
62
63external function dec_CtrlMessage(in charstring id) return CtrlMessage
64 with { extension "prototype(convert) decode(TEXT)"};
65
66
Harald Welte03c0e562017-12-09 02:55:12 +010067template CtrlMessage ts_CtrlMsgGet(CtrlId id, CtrlVariable variable) := {
68 cmd := {
69 verb := "GET",
70 id := id,
71 variable := variable,
72 val := omit
73 }
74};
75
76template CtrlMessage ts_CtrlMsgSet(CtrlId id, CtrlVariable variable, CtrlValue val) := {
77 cmd := {
78 verb := "SET",
79 id := id,
80 variable := variable,
81 val := omit
82 }
83}
84
85template CtrlMessage tr_CtrlMsgGetRepl(template CtrlId id, template CtrlVariable variable := ?) := {
86 resp := {
87 verb := "GET_REPLY",
88 id := id,
89 variable := variable,
90 val := ?
91 }
92}
93
94template CtrlMessage tr_CtrlMsgSetRepl(template CtrlId id, template CtrlVariable variable := ?,
95 template CtrlValue val := ?) := {
96 resp := {
97 verb := "SET_REPLY",
98 id := id,
99 variable := variable,
100 val := val
101 }
102}
103
104template CtrlMessage tr_CtrlMsgTrap(template CtrlVariable variable := ?,
105 template CtrlValue val := ?) := {
106 trap := {
107 variable := variable,
108 val := val
109 }
110}
111
112template CtrlMessage tr_CtrlMsgError(template CtrlId id := ?, template CtrlReason reason := ?) := {
113 err := {
114 id := id,
115 reason := reason
116 }
117}
118
119
Harald Weltea76c4bb2017-12-09 02:06:07 +0100120} with { encode "TEXT" }