blob: 44b80f6c192bd714afd6e044c933700bd460e7f8 [file] [log] [blame]
Harald Weltefaa42922019-03-04 18:31:11 +01001module RSPRO_Types {
2
3/* Templates and utility functions for the RSPRO protocol.
4 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13import from RSPRO all;
14import from Native_Functions all;
15
16template ResultCode tr_Status_ok_or_nocard := (ok, cardNotPresent);
17
18external function dec_RsproPDU(in octetstring stream) return RsproPDU;
19external function enc_RsproPDU(in RsproPDU pdu) return octetstring;
20
21type integer RsproVersion (0..32);
22
23template (value) BankSlot ts_BankSlot(template (value) BankId bid,
24 template (value) SlotNumber slot) := {
25 bankId := bid,
26 slotNr := slot
27}
28
29template (value) ClientSlot ts_ClientSlot(template (value) ClientId cid,
30 template (value) SlotNumber slot) := {
31 clientId := cid,
32 slotNr := slot
33}
34
35template (value) ComponentIdentity ts_CompId(template (value) ComponentType ctype,
36 template (value) ComponentName name,
37 template (value) ComponentName sw := "TTCN3",
38 template (value) ComponentName sw_version := "0.1") := {
39 type_ := ctype,
40 name := name,
41 software := sw,
42 swVersion := sw_version,
43 hwManufacturer := "sysmocom",
44 hwModel := omit,
45 hwSerialNr := omit,
46 hwVersion := omit,
47 fwVersion := omit
48}
49template ComponentIdentity tr_CompId(template ComponentType ctype,
50 template ComponentName name,
51 template ComponentName sw := "TTCN3",
52 template ComponentName sw_version := "0.1") := {
53 type_ := ctype,
54 name := name,
55 software := sw,
56 swVersion := sw_version,
57 hwManufacturer := *,
58 hwModel := *,
59 hwSerialNr := *,
60 hwVersion := *,
61 fwVersion := *
62}
63
64template (value) IpPort ts_IpPort(template (value) IpAddress ip,
65 template (value) PortNumber port_nr) := {
66 ip := ip,
67 port_ := port_nr
68}
69template IpPort tr_IpPort(template IpAddress ip, template PortNumber port_nr) := {
70 ip := ip,
71 port_ := port_nr
72}
73
74template (value) IpAddress ts_IPv4(charstring ip_str) := {
75 ipv4 := f_inet_addr(ip_str)
76}
77
78
79
80
81template (value) RsproPDU ts_RSPRO(template (value) RsproPDUchoice msg,
82 template (value) RsproVersion version := 2,
83 template (value) OperationTag tag := 0) := {
84 version := version,
85 tag := tag,
86 msg := msg
87}
88
89template RsproPDU tr_RSPRO(template RsproPDUchoice msg,
90 template RsproVersion version := 2,
91 template OperationTag tag := ?) := {
92 version := version,
93 tag := tag,
94 msg := msg
95}
96
97
98template (value) RsproPDU ts_RSPRO_ConnectClientReq(template (value) ComponentIdentity id,
99 template (omit) ClientSlot clslot) :=
100 ts_RSPRO(RsproPDUchoice:{
101 connectClientReq := {
102 identity := id,
103 clientSlot := clslot
104 }
105 });
106template RsproPDU tr_RSPRO_ConnectClientReq(template ComponentIdentity id,
107 template ClientSlot clslot) :=
108 tr_RSPRO(RsproPDUchoice:{
109 connectClientReq := {
110 identity := id,
111 clientSlot := clslot
112 }
113 });
114
115
116template (value) RsproPDU ts_RSPRO_ConnectClientRes(template (value) ComponentIdentity id,
117 template (value) ResultCode res) :=
118 ts_RSPRO(RsproPDUchoice:{
119 connectClientRes := {
120 identity := id,
121 result := res
122 }
123 });
124template RsproPDU tr_RSPRO_ConnectClientRes(template ComponentIdentity id := ?,
125 template ResultCode res := ?) :=
126 tr_RSPRO(RsproPDUchoice:{
127 connectClientRes := {
128 identity := id,
129 result := res
130 }
131 });
132
133template (value) RsproPDU ts_RSPRO_ConnectBankReq(template (value) ComponentIdentity id,
134 template (value) BankId bid,
135 template (value) SlotNumber nslots,
136 template (omit) IpPort bound) :=
137 ts_RSPRO(RsproPDUchoice:{
138 connectBankReq := {
139 identity := id,
140 bankId := bid,
141 numberOfSlots := nslots,
142 bound := bound
143 }
144 });
145template RsproPDU tr_RSPRO_ConnectBankReq(template ComponentIdentity id,
146 template BankId bid,
147 template SlotNumber nslots,
148 template IpPort bound := *) :=
149 tr_RSPRO(RsproPDUchoice:{
150 connectBankReq := {
151 identity := id,
152 bankId := bid,
153 numberOfSlots := nslots,
154 bound := *
155 }
156 });
157
158
159template (value) RsproPDU ts_RSPRO_ConnectBankRes(template (value) ComponentIdentity id,
160 template (value) ResultCode res) :=
161 ts_RSPRO(RsproPDUchoice:{
162 connectBankRes := {
163 identity := id,
164 result := res
165 }
166 });
167template RsproPDU tr_RSPRO_ConnectBankRes(template ComponentIdentity id := ?,
168 template ResultCode res := ?) :=
169 tr_RSPRO(RsproPDUchoice:{
170 connectBankRes := {
171 identity := id,
172 result := res
173 }
174 });
175
176
177template (value) RsproPDU ts_RSPRO_SetAtrReq(template (value) ClientSlot clslot,
178 template (value) ATR atr) :=
179 ts_RSPRO(RsproPDUchoice:{
180 setAtrReq := {
181 slot := clslot,
182 atr := atr
183 }
184 });
185template RsproPDU tr_RSPRO_SetAtrReq(template ClientSlot clslot := ?,
186 template ATR atr := ?) :=
187 tr_RSPRO(RsproPDUchoice:{
188 setAtrReq := {
189 slot := clslot,
190 atr := atr
191 }
192 });
193
194template (value) RsproPDU ts_RSPRO_SetAtrRes(template (value) ResultCode res) :=
195 ts_RSPRO(RsproPDUchoice:{
196 setAtrRes := {
197 result := res
198 }
199 });
200template RsproPDU tr_RSPRO_SetAtrRes(template ResultCode res := ?) :=
201 tr_RSPRO(RsproPDUchoice:{
202 setAtrRes := {
203 result := res
204 }
205 });
206
207template (value) RsproPDU ts_RSPRO_TpduModemToCard(template (value) ClientSlot from_clslot,
208 template (value) BankSlot to_bslot,
209 template (value) TpduFlags flags,
210 template (value) octetstring data) :=
211 ts_RSPRO(RsproPDUchoice:{
212 tpduModemToCard := {
213 fromClientSlot := from_clslot,
214 toBankSlot := to_bslot,
215 flags := flags,
216 data := data
217 }
218 });
219template RsproPDU tr_RSPRO_TpduModemToCard(template ClientSlot from_clslot := ?,
220 template BankSlot to_bslot := ?,
221 template TpduFlags flags := ?,
222 template octetstring data := ?) :=
223 tr_RSPRO(RsproPDUchoice:{
224 tpduModemToCard := {
225 fromClientSlot := from_clslot,
226 toBankSlot := to_bslot,
227 flags := flags,
228 data := data
229 }
230 });
231
232template (value) RsproPDU ts_RSPRO_TpduCardToModem(template (value) BankSlot from_bslot,
233 template (value) ClientSlot to_clslot,
234 template (value) TpduFlags flags,
235 template (value) octetstring data) :=
236 ts_RSPRO(RsproPDUchoice:{
237 tpduCardToModem := {
238 fromBankSlot := from_bslot,
239 toClientSlot := to_clslot,
240 flags := flags,
241 data := data
242 }
243 });
244template RsproPDU tr_RSPRO_TpduCardToModem(template BankSlot from_bslot := ?,
245 template ClientSlot to_clslot := ?,
246 template TpduFlags flags := ?,
247 template octetstring data := ?) :=
248 tr_RSPRO(RsproPDUchoice:{
249 tpduCardToModem := {
250 fromBankSlot := from_bslot,
251 toClientSlot := to_clslot,
252 flags := flags,
253 data := data
254 }
255 });
256
257template (value) RsproPDU ts_RSPRO_CreateMappingReq(template (value) ClientSlot cslot,
258 template (value) BankSlot bslot) :=
259 ts_RSPRO(RsproPDUchoice:{
260 createMappingReq := {
261 client := cslot,
262 bank := bslot
263 }
264 });
265template RsproPDU tr_RSPRO_CreateMappingReq(template ClientSlot cslot,
266 template BankSlot bslot) :=
267 tr_RSPRO(RsproPDUchoice:{
268 createMappingReq := {
269 client := cslot,
270 bank := bslot
271 }
272 });
273
274template (value) RsproPDU ts_RSPRO_CreateMappingRes(template (value) ResultCode res) :=
275 ts_RSPRO(RsproPDUchoice:{
276 createMappingRes := {
277 result := res
278 }
279 });
280template RsproPDU tr_RSPRO_CreateMappingRes(template ResultCode res) :=
281 tr_RSPRO(RsproPDUchoice:{
282 createMappingRes := {
283 result := res
284 }
285 });
286
287template (value) RsproPDU ts_RSPRO_RemoveMappingReq(template (value) ClientSlot cslot,
288 template (value) BankSlot bslot) :=
289 ts_RSPRO(RsproPDUchoice:{
290 removeMappingReq := {
291 client := cslot,
292 bank := bslot
293 }
294 });
295template RsproPDU tr_RSPRO_RemoveMappingReq(template ClientSlot cslot,
296 template BankSlot bslot) :=
297 tr_RSPRO(RsproPDUchoice:{
298 removeMappingReq := {
299 client := cslot,
300 bank := bslot
301 }
302 });
303
304template (value) RsproPDU ts_RSPRO_RemoveMappingRes(template (value) ResultCode res) :=
305 ts_RSPRO(RsproPDUchoice:{
306 removeMappingRes := {
307 result := res
308 }
309 });
310template RsproPDU tr_RSPRO_RemoveMappingRes(template ResultCode res) :=
311 tr_RSPRO(RsproPDUchoice:{
312 removeMappingRes := {
313 result := res
314 }
315 });
316
317
318template (value) RsproPDU ts_RSPRO_ConfigClientIdReq(template (value) ClientSlot cslot) :=
319 ts_RSPRO(RsproPDUchoice: {
320 configClientIdReq := {
321 clientSlot := cslot
322 }
323 });
324template RsproPDU tr_RSPRO_ConfigClientIdReq(template ClientSlot cslot) :=
325 tr_RSPRO(RsproPDUchoice: {
326 configClientIdReq := {
327 clientSlot := cslot
328 }
329 });
330
331template (value) RsproPDU ts_RSPRO_ConfigClientIdRes(template (value) ResultCode res) :=
332 ts_RSPRO(RsproPDUchoice:{
333 configClientIdRes := {
334 result := res
335 }
336 });
337template RsproPDU tr_RSPRO_ConfigClientIdRes(template ResultCode res) :=
338 tr_RSPRO(RsproPDUchoice:{
339 configClientIdRes := {
340 result := res
341 }
342 });
343
344template (value) RsproPDU ts_RSPRO_ConfigClientBankReq(template (value) BankSlot bslot,
345 template (value) IpPort ip_port) :=
346 ts_RSPRO(RsproPDUchoice: {
347 configClientBankReq := {
348 bankSlot := bslot,
349 bankd := ip_port
350 }
351 });
352template RsproPDU tr_RSPRO_ConfigClientBankReq(template BankSlot bslot,
353 template IpPort ip_port) :=
354 tr_RSPRO(RsproPDUchoice: {
355 configClientBankReq := {
356 bankSlot := bslot,
357 bankd := ip_port
358 }
359 });
360
361template (value) RsproPDU ts_RSPRO_ConfigClientBankRes(template (value) ResultCode res) :=
362 ts_RSPRO(RsproPDUchoice:{
363 configClientBankRes := {
364 result := res
365 }
366 });
367template RsproPDU tr_RSPRO_ConfigClientBankRes(template ResultCode res) :=
368 tr_RSPRO(RsproPDUchoice:{
369 configClientBankRes := {
370 result := res
371 }
372 });
373
Harald Welteeb172b32019-12-04 20:54:15 +0100374template (value) RsproPDU ts_RSPRO_ResetStateReq :=
375 ts_RSPRO(RsproPDUchoice: {
376 resetStateReq := {}
377 });
378template RsproPDU tr_RSPRO_ResetStateReq :=
379 tr_RSPRO(RsproPDUchoice: {
380 resetStateReq := {}
381 });
382
383template (value) RsproPDU ts_RSPRO_ResetStateRes(template (value) ResultCode res) :=
384 ts_RSPRO(RsproPDUchoice:{
385 resetStateRes := {
386 result := res
387 }
388 });
389template RsproPDU tr_RSPRO_ResetStateRes(template ResultCode res) :=
390 tr_RSPRO(RsproPDUchoice:{
391 resetStateRes := {
392 result := res
393 }
394 });
395
396
Harald Weltefaa42922019-03-04 18:31:11 +0100397
398}