blob: 5e2c05b6ac2195c42396b1d8d006abc852b86e94 [file] [log] [blame]
Harald Weltefaa42922019-03-04 18:31:11 +01001----------------------------------------------------------------------
2-- RSPRO - Remote SIM Protocol, part of Osmocom Remote SIM Suite
3-- (C) 2018 by Harald Welte <laforge@gnumonks.org>
4-- 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--
Harald Weltefaa42922019-03-04 18:31:11 +010018----------------------------------------------------------------------
19
20RSPRO {} DEFINITIONS
21
22IMPLICIT TAGS
23
24::=
25
26BEGIN
27
28EXPORTS
29 RsproPDU
30;
31
32----------------------------------------------------------------------
33-- Elementary Data Types
34----------------------------------------------------------------------
35
36-- Some random ID the requestor can chose and which the client echos back in a response.
37-- This allows multiple outstanding commands in flight and matching of responses to requests.
38OperationTag ::= INTEGER(0..2147483647)
39
40-- Unique identifier of a given SIM bank
41BankId ::= INTEGER(0..1023)
42
43-- Unique identifier of a given client (modem)
44ClientId ::= INTEGER(0..1023)
45
46ComponentType ::= ENUMERATED {
47 -- client: Modems / Phones
48 remsimClient (0),
49 -- server: Coordination
50 remsimServer (1),
51 -- bank daemon: SIM cards
52 remsimBankd (2)
53}
54ComponentName ::= IA5String (SIZE (1..32))
55ComponentIdentity ::= SEQUENCE {
56 type ComponentType,
57 name ComponentName,
58 software [0] ComponentName,
59 swVersion [1] ComponentName,
60 hwManufacturer [2] ComponentName OPTIONAL,
61 hwModel [3] ComponentName OPTIONAL,
62 hwSerialNr [4] ComponentName OPTIONAL,
63 hwVersion [5] ComponentName OPTIONAL,
64 fwVersion [6] ComponentName OPTIONAL,
65 ...
66}
67
68-- IP address / port details
69Ipv4Address ::= OCTET STRING (SIZE (4))
70Ipv6Address ::= OCTET STRING (SIZE (16))
71IpAddress ::= CHOICE {
72 ipv4 [0] Ipv4Address,
73 ipv6 [1] Ipv6Address
74}
75PortNumber ::= INTEGER (0..65535)
76IpPort ::= SEQUENCE {
77 ip IpAddress,
78 port PortNumber
79}
80
81-- Result of a given operation
82ResultCode ::= ENUMERATED {
83 ok (0),
84 -- client / bank / slot ID not accepted
85 illegalClientId (1),
86 illegalBankId (2),
87 illegalSlotId (3),
88 unsupportedProtocolVersion (4),
89 unknownSlotmap (5),
Harald Welte7c083af2022-05-03 17:46:25 +020090 identityInUse (6),
Harald Weltefaa42922019-03-04 18:31:11 +010091
92 -- no card is present in given slot
93 cardNotPresent (100),
94 -- card is present but unresponsive in given slot
95 cardUnresponsive (101),
96 -- unrecoverable transmission errors detected
97 cardTransmissionError (102),
98 ...
99}
100
101ErrorCode ::= ENUMERATED {
102 -- Bankd or Server has received connection form unknown client (no mapping)
103 unknownClientConnected (1),
104 -- unexpected disconnect (typically bankd reports client disconnect)
105 unexpectedDisconnect (2),
106 unexpectedProtocolVersion (3),
107 ...
108}
109
110ErrorString ::= IA5String (SIZE (1..255))
111
112ErrorSeverity ::= ENUMERATED {
113 minor (1),
114 major (2),
115 fatal (3),
116 ...
117}
118
119-- Slot number within a SIM bank or a client.
120SlotNumber ::= INTEGER(0..1023)
121
122-- Slot identity on client (modem) side
123ClientSlot ::= SEQUENCE {
124 clientId ClientId,
125 slotNr SlotNumber,
126 ...
127}
128
129-- Slot identity on SIM bank side
130BankSlot ::= SEQUENCE {
131 bankId BankId,
132 slotNr SlotNumber,
133 ...
134}
135
136ATR ::= OCTET STRING (SIZE (1..55))
137
138-- flags related to a TPDU in either of the two directions
139TpduFlags ::= SEQUENCE {
140 -- indicates a TPDU header is present in this message
141 tpduHeaderPresent BOOLEAN,
142 -- indicates last part of transmission in this direction
143 finalPart BOOLEAN,
144 -- indicates a PB is present and we should continue with TX
145 procByteContinueTx BOOLEAN,
146 -- indicates a PB is present and we should continue with RX
147 procByteContinueRx BOOLEAN,
148 ...
149}
150
151--- physical state of a given slot
152SlotPhysStatus ::= SEQUENCE {
153 -- is RST activated by the modem?
154 resetActive [0] BOOLEAN,
155 -- is VCC applied by the modem?
156 vccPresent [1] BOOLEAN OPTIONAL,
157 -- is CLK applied by the modem?
158 clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
159 -- is card presence signalled to the modem?
160 cardPresent [3] BOOLEAN OPTIONAL,
161 ...
162}
163
164----------------------------------------------------------------------
165-- Messages
166----------------------------------------------------------------------
167
168
169-- BANKD->SERVER: SIM Bank connects to central server
170ConnectBankReq ::= SEQUENCE {
171 -- identity of the bank that is connecting to the server
172 identity ComponentIdentity,
173 -- bank number, pre-configured on bank side
174 bankId BankId,
175 numberOfSlots SlotNumber,
176 -- IP/Port to which this bankd has bound and is listening for clients
177 bound IpPort OPTIONAL,
178 ...
179}
180ConnectBankRes ::= SEQUENCE {
181 -- identity of the server to which the bank is connecting
182 identity ComponentIdentity,
183 result ResultCode,
184 ...
185}
186
187-- CLIENT->SERVER or CLIENT->BANKD
188ConnectClientReq ::= SEQUENCE {
189 -- identity of the client that is connecting to the server/bankd
190 identity ComponentIdentity,
191 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
192 ...
193}
194ConnectClientRes ::= SEQUENCE {
195 -- identity of the bankd/server to which the client is connecting
196 identity ComponentIdentity,
197 result ResultCode,
198 ...
199}
200
201-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
202CreateMappingReq ::= SEQUENCE {
203 client ClientSlot,
204 bank BankSlot,
205 ...
206}
207CreateMappingRes ::= SEQUENCE {
208 result ResultCode,
209 ...
210}
211
212-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
213RemoveMappingReq ::= SEQUENCE {
214 client ClientSlot,
215 bank BankSlot,
216 ...
217}
218RemoveMappingRes ::= SEQUENCE {
219 result ResultCode,
220 ...
221}
222
223-- SERVER->CLIENT: set Client ID
224ConfigClientIdReq ::= SEQUENCE {
225 -- server-allocated assignment of a client ID
226 clientSlot ClientSlot,
227 ...
228}
229ConfigClientIdRes ::= SEQUENCE {
230 result ResultCode,
231 ...
232}
233
234-- SERVER->CLIENT: set BankId/Slot and IP/Port
235ConfigClientBankReq ::= SEQUENCE {
236 -- server-allocated assignment of a client ID
237 bankSlot BankSlot,
238 -- bank to which the client shall connect
239 bankd IpPort,
240 ...
241}
242ConfigClientBankRes ::= SEQUENCE {
243 result ResultCode,
244 ...
245}
246
247
248-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
249SetAtrReq ::= SEQUENCE {
250 slot ClientSlot,
251 atr ATR,
252 ...
253}
254SetAtrRes ::= SEQUENCE {
255 result ResultCode,
256 ...
257}
258
259-- CLIENT->BANKD: TPDU in Modem -> Card direction
260TpduModemToCard ::= SEQUENCE {
261 -- we include fully-qualified bank and client slots for easier debugging
262 fromClientSlot ClientSlot,
263 toBankSlot BankSlot,
264 flags TpduFlags,
265 data OCTET STRING,
266 ...
267}
268
269-- BANKD->CLIENT: TPDU in Card -> Modem direction
270TpduCardToModem ::= SEQUENCE {
271 -- we include fully-qualified bank and client slots for easier debugging
272 fromBankSlot BankSlot,
273 toClientSlot ClientSlot,
274 flags TpduFlags,
275 data OCTET STRING,
276 ...
277}
278
279-- CLIENT->BANKD: indciation about the current status of a client (modem side)
280ClientSlotStatusInd ::= SEQUENCE {
281 fromClientSlot ClientSlot,
282 toBankSlot BankSlot,
283 slotPhysStatus SlotPhysStatus,
284 ...
285}
286
287-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
288BankSlotStatusInd ::= SEQUENCE {
289 fromBankSlot BankSlot,
290 toClientSlot ClientSlot,
291 slotPhysStatus SlotPhysStatus,
292 ...
293}
294
295-- *->SERVER: indication about some kind of error
296ErrorInd ::= SEQUENCE {
297 -- whoever is detecting + sending us the error
298 sender ComponentType,
299 severity ErrorSeverity,
300 code ErrorCode,
301 -- any bank-side slot that's affected
302 bankSlot [0] BankSlot OPTIONAL,
303 -- any client-side slot that's affected
304 clientSlot [1] ClientSlot OPTIONAL,
305 -- any additional textual information
306 errorString [2] ErrorString OPTIONAL,
307 ...
308}
309
Harald Welteeb172b32019-12-04 20:54:15 +0100310-- SERVER->*: request reset of all state on peer side
311ResetStateReq ::= SEQUENCE {
312 ...
313}
314
315-- *->SERVER: confirm reset of all state on peer side
316ResetStateRes ::= SEQUENCE {
317 result ResultCode,
318 ...
319}
320
Harald Weltefaa42922019-03-04 18:31:11 +0100321
322----------------------------------------------------------------------
323-- PDU
324----------------------------------------------------------------------
325
326RsproPDUchoice ::= CHOICE {
327 -- configuration + management
328 connectBankReq [0] ConnectBankReq,
329 connectBankRes [1] ConnectBankRes,
330 connectClientReq [2] ConnectClientReq,
331 connectClientRes [3] ConnectClientRes,
332 createMappingReq [4] CreateMappingReq,
333 createMappingRes [5] CreateMappingRes,
334 removeMappingReq [6] RemoveMappingReq,
335 removeMappingRes [7] RemoveMappingRes,
336 configClientIdReq [8] ConfigClientIdReq,
337 configClientIdRes [9] ConfigClientIdRes,
338 configClientBankReq [17] ConfigClientBankReq,
339 configClientBankRes [18] ConfigClientBankRes,
340 errorInd [16] ErrorInd,
Harald Welteeb172b32019-12-04 20:54:15 +0100341 resetStateReq [19] ResetStateReq,
342 resetStateRes [20] ResetStateRes,
Harald Weltefaa42922019-03-04 18:31:11 +0100343 -- APDUs etc.
344 setAtrReq [10] SetAtrReq,
345 setAtrRes [11] SetAtrRes,
346 tpduModemToCard [12] TpduModemToCard,
347 tpduCardToModem [13] TpduCardToModem,
348 clientSlotStatusInd [14] ClientSlotStatusInd,
349 bankSlotStatusInd [15] BankSlotStatusInd,
350 ...
351}
352
353RsproPDU ::= SEQUENCE {
354 version [0] INTEGER(0..32),
355 tag [1] OperationTag,
356 msg [2] RsproPDUchoice
357}
358
359END