Harald Welte | faa4292 | 2019-03-04 18:31:11 +0100 | [diff] [blame] | 1 | module RSRES { |
| 2 | |
| 3 | /* Implementation of the REmote Sim RESt (RSRES) JSON data types in TTCN-3. |
| 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 | */ |
| 13 | |
| 14 | import from RSPRO all; |
| 15 | |
| 16 | /* resembles "enum remsim_server_client_fsm_state" */ |
| 17 | type enumerated ConnectionState { |
| 18 | INIT, |
| 19 | ESTABLISHED, |
| 20 | CONNECTED_CLIENT, |
| 21 | CONNECTED_BANKD |
| 22 | }; |
| 23 | |
| 24 | type record JsBank { |
| 25 | charstring peer, |
| 26 | ConnectionState state, |
| 27 | ComponentIdentity component_id, |
| 28 | BankId bankId, |
| 29 | SlotNumber numberOfSlots |
| 30 | }; |
| 31 | type record of JsBank JsBanks; |
| 32 | |
| 33 | template JsBank tr_JsBank(template ConnectionState state, |
| 34 | template ComponentIdentity comp_id, |
| 35 | template BankId bank_id, |
| 36 | template SlotNumber num_of_slots) := { |
| 37 | peer := ?, |
| 38 | state := state, |
| 39 | component_id := comp_id, |
| 40 | bankId := bank_id, |
| 41 | numberOfSlots := num_of_slots |
| 42 | } |
| 43 | |
| 44 | type record JsClient { |
| 45 | charstring peer, |
| 46 | ConnectionState state, |
| 47 | ComponentIdentity component_id |
| 48 | }; |
| 49 | type record of JsClient JsClients; |
| 50 | |
| 51 | template JsClient tr_JsClient(template ConnectionState state, |
| 52 | template ComponentIdentity comp_id) := { |
| 53 | peer := ?, |
| 54 | state := state, |
| 55 | component_id := comp_id |
| 56 | } |
| 57 | |
| 58 | /* resembles "enum slot_mapping_state" */ |
| 59 | type enumerated SlotmapState { |
| 60 | NEW, |
| 61 | UNACKNOWLEDGED, |
| 62 | ACTIVE, |
| 63 | DELETE_REQ, |
| 64 | DELETING |
| 65 | }; |
| 66 | |
| 67 | type record JsSlotmap { |
| 68 | BankSlot bank, |
| 69 | ClientSlot client, |
| 70 | SlotmapState state optional |
| 71 | }; |
| 72 | type record of JsSlotmap JsSlotmaps; |
| 73 | |
| 74 | template (value) JsSlotmap ts_JsSlotmap(template (value) BankSlot bslot, |
| 75 | template (value) ClientSlot cslot, |
| 76 | template (omit) SlotmapState state := omit) := { |
| 77 | bank := bslot, |
| 78 | client := cslot, |
| 79 | state := state |
| 80 | } |
| 81 | template JsSlotmap tr_JsSlotmap(template BankSlot bslot, |
| 82 | template ClientSlot cslot, |
| 83 | template SlotmapState state := ?) := { |
| 84 | bank := bslot, |
| 85 | client := cslot, |
| 86 | state := state |
| 87 | } |
| 88 | |
| 89 | |
| 90 | |
| 91 | /* root JSON type expressing what remsim-server can return */ |
| 92 | type record JsRoot { |
| 93 | JsClients clients optional, |
| 94 | JsBanks banks optional, |
| 95 | JsSlotmaps slotmaps optional |
| 96 | }; |
| 97 | |
| 98 | external function f_enc_JsRoot(in JsRoot inp) return octetstring |
| 99 | with { extension "prototype(convert) encode(JSON)" } |
| 100 | external function f_dec_JsRoot(in octetstring inp) return JsRoot |
| 101 | with { extension "prototype(convert) decode(JSON)" } |
| 102 | |
| 103 | external function f_enc_JsSlotmap(in JsSlotmap inp) return octetstring |
| 104 | with { extension "prototype(convert) encode(JSON)" } |
| 105 | external function f_dec_JsSlotmap(in octetstring inp) return JsSlotmap |
| 106 | with { extension "prototype(convert) decode(JSON)" } |
| 107 | |
| 108 | |
| 109 | |
| 110 | } with { encode "JSON" } |