blob: 8587593f0b0a7674d8863e5060436011b2b9cb2f [file] [log] [blame]
Harald Welte3aa901d2018-08-13 18:32:36 +02001----------------------------------------------------------------------
2-- RSPRO - Remote SIM Protocol, part of Osmocom Remote SIM Suite
3-- (C) 2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte3dcdd202019-03-09 13:06:46 +01004-- All Rights Reserved
5--
6-- SPDX-License-Identifier: GPL-2.0+
7--
8-- This program is free software; you can redistribute it and/or modify
9-- it under the terms of the GNU General Public License as published by
10-- the Free Software Foundation; either version 2 of the License, or
11-- (at your option) any later version.
12--
13-- This program is distributed in the hope that it will be useful,
14-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-- GNU General Public License for more details.
17--
18-- You should have received a copy of the GNU General Public License along
19-- with this program; if not, write to the Free Software Foundation, Inc.,
20-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21--
Harald Welte3aa901d2018-08-13 18:32:36 +020022----------------------------------------------------------------------
23
24RSPRO {} DEFINITIONS
25
26IMPLICIT TAGS
27
28::=
29
30BEGIN
31
32EXPORTS
33 RsproPDU
34;
35
36----------------------------------------------------------------------
37-- Elementary Data Types
38----------------------------------------------------------------------
39
40-- Some random ID the requestor can chose and which the client echos back in a response.
41-- This allows multiple outstanding commands in flight and matching of responses to requests.
42OperationTag ::= INTEGER(0..2147483647)
43
44-- Unique identifier of a given SIM bank
45BankId ::= INTEGER(0..1023)
46
47-- Unique identifier of a given client (modem)
48ClientId ::= INTEGER(0..1023)
49
50ComponentType ::= ENUMERATED {
51 -- client: Modems / Phones
52 remsimClient (0),
53 -- server: Coordination
54 remsimServer (1),
55 -- bank daemon: SIM cards
56 remsimBankd (2)
57}
58ComponentName ::= IA5String (SIZE (1..32))
59ComponentIdentity ::= SEQUENCE {
60 type ComponentType,
61 name ComponentName,
62 software [0] ComponentName,
63 swVersion [1] ComponentName,
64 hwManufacturer [2] ComponentName OPTIONAL,
65 hwModel [3] ComponentName OPTIONAL,
66 hwSerialNr [4] ComponentName OPTIONAL,
67 hwVersion [5] ComponentName OPTIONAL,
68 fwVersion [6] ComponentName OPTIONAL,
69 ...
70}
71
72-- IP address / port details
73Ipv4Address ::= OCTET STRING (SIZE (4))
74Ipv6Address ::= OCTET STRING (SIZE (16))
75IpAddress ::= CHOICE {
76 ipv4 [0] Ipv4Address,
77 ipv6 [1] Ipv6Address
78}
79PortNumber ::= INTEGER (0..65535)
80IpPort ::= SEQUENCE {
81 ip IpAddress,
82 port PortNumber
83}
84
85-- Result of a given operation
86ResultCode ::= ENUMERATED {
87 ok (0),
88 -- client / bank / slot ID not accepted
89 illegalClientId (1),
90 illegalBankId (2),
91 illegalSlotId (3),
92
93 -- no card is present in given slot
94 cardNotPresent (100),
95 -- card is present but unresponsive in given slot
96 cardUnresponsive (101),
97 -- unrecoverable transmission errors detected
98 cardTransmissionError (102),
99 ...
100}
101
102-- Slot number within a SIM bank or a client.
103SlotNumber ::= INTEGER(0..1023)
104
105-- Slot identity on client (modem) side
106ClientSlot ::= SEQUENCE {
107 clientId ClientId,
108 slotNr SlotNumber,
109 ...
110}
111
112-- Slot identity on SIM bank side
113BankSlot ::= SEQUENCE {
114 bankId BankId,
115 slotNr SlotNumber,
116 ...
117}
118
119ATR ::= OCTET STRING (SIZE (1..55))
120
121-- flags related to a TPDU in either of the two directions
122TpduFlags ::= SEQUENCE {
123 -- indicates a TPDU header is present in this message
124 tpduHeaderPresent BOOLEAN,
125 -- indicates last part of transmission in this direction
126 finalPart BOOLEAN,
127 -- indicates a PB is present and we should continue with TX
128 procByteContinueTx BOOLEAN,
129 -- indicates a PB is present and we should continue with RX
130 procByteContinueRx BOOLEAN,
131 ...
132}
133
134--- physical state of a given slot
135SlotPhysStatus ::= SEQUENCE {
136 -- is RST activated by the modem?
137 resetActive [0] BOOLEAN,
138 -- is VCC applied by the modem?
139 vccPresent [1] BOOLEAN OPTIONAL,
140 -- is CLK applied by the modem?
141 clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
142 -- is card presence signalled to the modem?
143 cardPresent [3] BOOLEAN OPTIONAL,
144 ...
145}
146
147----------------------------------------------------------------------
148-- Messages
149----------------------------------------------------------------------
150
151
Harald Weltef0614df2018-08-16 14:45:23 +0200152-- BANKD->SERVER: SIM Bank connects to central server
Harald Welte3aa901d2018-08-13 18:32:36 +0200153ConnectBankReq ::= SEQUENCE {
154 -- identity of the bank that is connecting to the server
155 identity ComponentIdentity,
156 -- bank number, pre-configured on bank side
157 bankId BankId,
158 numberOfSlots SlotNumber,
159 ...
160}
161ConnectBankRes ::= SEQUENCE {
162 -- identity of the server to which the bank is connecting
163 identity ComponentIdentity,
164 result ResultCode,
165 ...
166}
167
Harald Weltef0614df2018-08-16 14:45:23 +0200168-- CLIENT->SERVER or CLIENT->BANKD
Harald Welte3aa901d2018-08-13 18:32:36 +0200169ConnectClientReq ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200170 -- identity of the client that is connecting to the server/bankd
Harald Welte3aa901d2018-08-13 18:32:36 +0200171 identity ComponentIdentity,
Harald Weltef1d70162018-10-11 12:56:00 +0200172 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
Harald Welte3aa901d2018-08-13 18:32:36 +0200173 ...
174}
175ConnectClientRes ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200176 -- identity of the bankd/server to which the client is connecting
Harald Welte3aa901d2018-08-13 18:32:36 +0200177 identity ComponentIdentity,
178 result ResultCode,
179 ...
180}
181
Harald Weltef0614df2018-08-16 14:45:23 +0200182-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200183CreateMappingReq ::= SEQUENCE {
184 client ClientSlot,
185 bank BankSlot,
186 ...
187}
188CreateMappingRes ::= SEQUENCE {
189 result ResultCode,
190 ...
191}
192
Harald Weltef0614df2018-08-16 14:45:23 +0200193-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200194RemoveMappingReq ::= SEQUENCE {
195 client ClientSlot,
196 bank BankSlot,
197 ...
198}
199RemoveMappingRes ::= SEQUENCE {
200 result ResultCode,
201 ...
202}
203
Harald Weltef0614df2018-08-16 14:45:23 +0200204-- SERVER->CLIENT: set configuration (client ID and BANK IP/Port)
Harald Welte3aa901d2018-08-13 18:32:36 +0200205ConfigClientReq ::= SEQUENCE {
206 -- server-allocated assignment of a client ID
Harald Welte371d0262018-08-16 15:23:58 +0200207 clientSlot ClientSlot,
Harald Welte3aa901d2018-08-13 18:32:36 +0200208 -- bank to which the client shall connect
209 bankd IpPort,
210 ...
211}
212ConfigClientRes ::= SEQUENCE {
213 result ResultCode,
214 ...
215}
216
Harald Weltef0614df2018-08-16 14:45:23 +0200217-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
Harald Welte3aa901d2018-08-13 18:32:36 +0200218SetAtrReq ::= SEQUENCE {
219 slot ClientSlot,
220 atr ATR,
221 ...
222}
223SetAtrRes ::= SEQUENCE {
224 result ResultCode,
225 ...
226}
227
Harald Weltef0614df2018-08-16 14:45:23 +0200228-- CLIENT->BANKD: TPDU in Modem -> Card direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200229TpduModemToCard ::= SEQUENCE {
230 -- we include fully-qualified bank and client slots for easier debugging
231 fromClientSlot ClientSlot,
232 toBankSlot BankSlot,
233 flags TpduFlags,
234 data OCTET STRING,
235 ...
236}
237
Harald Weltef0614df2018-08-16 14:45:23 +0200238-- BANKD->CLIENT: TPDU in Card -> Modem direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200239TpduCardToModem ::= SEQUENCE {
240 -- we include fully-qualified bank and client slots for easier debugging
241 fromBankSlot BankSlot,
242 toClientSlot ClientSlot,
243 flags TpduFlags,
244 data OCTET STRING,
245 ...
246}
247
Harald Weltef0614df2018-08-16 14:45:23 +0200248-- CLIENT->BANKD: indciation about the current status of a client (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200249ClientSlotStatusInd ::= SEQUENCE {
250 fromClientSlot ClientSlot,
251 toBankSlot BankSlot,
252 slotPhysStatus SlotPhysStatus,
253 ...
254}
255
Harald Weltef0614df2018-08-16 14:45:23 +0200256-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200257BankSlotStatusInd ::= SEQUENCE {
258 fromBankSlot BankSlot,
259 toClientSlot ClientSlot,
260 slotPhysStatus SlotPhysStatus,
261 ...
262}
263
264----------------------------------------------------------------------
265-- PDU
266----------------------------------------------------------------------
267
268RsproPDUchoice ::= CHOICE {
269 -- configuration + management
270 connectBankReq [0] ConnectBankReq,
271 connectBankRes [1] ConnectBankRes,
272 connectClientReq [2] ConnectClientReq,
273 connectClientRes [3] ConnectClientRes,
274 createMappingReq [4] CreateMappingReq,
275 createMappingRes [5] CreateMappingRes,
276 removeMappingReq [6] RemoveMappingReq,
277 removeMappingRes [7] RemoveMappingRes,
278 configClientReq [8] ConfigClientReq,
279 configClientRes [9] ConfigClientRes,
280 -- APDUs etc.
281 setAtrReq [10] SetAtrReq,
282 setAtrRes [11] SetAtrRes,
283 tpduModemToCard [12] TpduModemToCard,
284 tpduCardToModem [13] TpduCardToModem,
285 clientSlotStatusInd [14] ClientSlotStatusInd,
286 bankSlotStatusInd [15] BankSlotStatusInd,
287 ...
288}
289
290RsproPDU ::= SEQUENCE {
Harald Welte293478c2018-09-24 14:49:41 +0200291 version [0] INTEGER(0..32),
Harald Welte3aa901d2018-08-13 18:32:36 +0200292 tag [1] OperationTag,
293 msg [2] RsproPDUchoice
294}
295
296END