blob: 7cba1b9c984cda52a5d4009224cf0f548564238d [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--
Harald Welte3aa901d2018-08-13 18:32:36 +020018----------------------------------------------------------------------
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),
Harald Welte71752dd2019-03-09 15:07:01 +010088 unsupportedProtocolVersion (4),
89 unknownSlotmap (5),
Harald Welte65006582022-05-03 16:22:37 +020090 identityInUse (6),
Harald Welte3aa901d2018-08-13 18:32:36 +020091
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
Harald Welte769ab7d2019-03-09 15:10:36 +0100101ErrorCode ::= 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
Harald Welte3aa901d2018-08-13 18:32:36 +0200119-- 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
Harald Weltef0614df2018-08-16 14:45:23 +0200169-- BANKD->SERVER: SIM Bank connects to central server
Harald Welte3aa901d2018-08-13 18:32:36 +0200170ConnectBankReq ::= 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 ...
177}
178ConnectBankRes ::= SEQUENCE {
179 -- identity of the server to which the bank is connecting
180 identity ComponentIdentity,
181 result ResultCode,
182 ...
183}
184
Harald Weltef0614df2018-08-16 14:45:23 +0200185-- CLIENT->SERVER or CLIENT->BANKD
Harald Welte3aa901d2018-08-13 18:32:36 +0200186ConnectClientReq ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200187 -- identity of the client that is connecting to the server/bankd
Harald Welte3aa901d2018-08-13 18:32:36 +0200188 identity ComponentIdentity,
Harald Weltef1d70162018-10-11 12:56:00 +0200189 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
Harald Welte3aa901d2018-08-13 18:32:36 +0200190 ...
191}
192ConnectClientRes ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200193 -- identity of the bankd/server to which the client is connecting
Harald Welte3aa901d2018-08-13 18:32:36 +0200194 identity ComponentIdentity,
195 result ResultCode,
196 ...
197}
198
Harald Weltef0614df2018-08-16 14:45:23 +0200199-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200200CreateMappingReq ::= SEQUENCE {
201 client ClientSlot,
202 bank BankSlot,
203 ...
204}
205CreateMappingRes ::= SEQUENCE {
206 result ResultCode,
207 ...
208}
209
Harald Weltef0614df2018-08-16 14:45:23 +0200210-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200211RemoveMappingReq ::= SEQUENCE {
212 client ClientSlot,
213 bank BankSlot,
214 ...
215}
216RemoveMappingRes ::= SEQUENCE {
217 result ResultCode,
218 ...
219}
220
Harald Welted571a3e2019-03-11 22:09:50 +0100221-- SERVER->CLIENT: set Client ID
222ConfigClientIdReq ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200223 -- server-allocated assignment of a client ID
Harald Welte371d0262018-08-16 15:23:58 +0200224 clientSlot ClientSlot,
Harald Welted571a3e2019-03-11 22:09:50 +0100225 ...
226}
227ConfigClientIdRes ::= SEQUENCE {
228 result ResultCode,
229 ...
230}
231
232-- SERVER->CLIENT: set BankId/Slot and IP/Port
233ConfigClientBankReq ::= SEQUENCE {
234 -- server-allocated assignment of a client ID
235 bankSlot BankSlot,
Harald Welte3aa901d2018-08-13 18:32:36 +0200236 -- bank to which the client shall connect
237 bankd IpPort,
238 ...
239}
Harald Welted571a3e2019-03-11 22:09:50 +0100240ConfigClientBankRes ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200241 result ResultCode,
242 ...
243}
244
Harald Welted571a3e2019-03-11 22:09:50 +0100245
Harald Weltef0614df2018-08-16 14:45:23 +0200246-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
Harald Welte3aa901d2018-08-13 18:32:36 +0200247SetAtrReq ::= SEQUENCE {
248 slot ClientSlot,
249 atr ATR,
250 ...
251}
252SetAtrRes ::= SEQUENCE {
253 result ResultCode,
254 ...
255}
256
Harald Weltef0614df2018-08-16 14:45:23 +0200257-- CLIENT->BANKD: TPDU in Modem -> Card direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200258TpduModemToCard ::= SEQUENCE {
259 -- we include fully-qualified bank and client slots for easier debugging
260 fromClientSlot ClientSlot,
261 toBankSlot BankSlot,
262 flags TpduFlags,
263 data OCTET STRING,
264 ...
265}
266
Harald Weltef0614df2018-08-16 14:45:23 +0200267-- BANKD->CLIENT: TPDU in Card -> Modem direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200268TpduCardToModem ::= SEQUENCE {
269 -- we include fully-qualified bank and client slots for easier debugging
270 fromBankSlot BankSlot,
271 toClientSlot ClientSlot,
272 flags TpduFlags,
273 data OCTET STRING,
274 ...
275}
276
Harald Weltef0614df2018-08-16 14:45:23 +0200277-- CLIENT->BANKD: indciation about the current status of a client (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200278ClientSlotStatusInd ::= SEQUENCE {
279 fromClientSlot ClientSlot,
280 toBankSlot BankSlot,
281 slotPhysStatus SlotPhysStatus,
282 ...
283}
284
Harald Weltef0614df2018-08-16 14:45:23 +0200285-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200286BankSlotStatusInd ::= SEQUENCE {
287 fromBankSlot BankSlot,
288 toClientSlot ClientSlot,
289 slotPhysStatus SlotPhysStatus,
290 ...
291}
292
Harald Welte769ab7d2019-03-09 15:10:36 +0100293-- *->SERVER: indication about some kind of error
294ErrorInd ::= SEQUENCE {
295 -- whoever is detecting + sending us the error
296 sender ComponentType,
297 severity ErrorSeverity,
298 code ErrorCode,
299 -- any bank-side slot that's affected
300 bankSlot [0] BankSlot OPTIONAL,
301 -- any client-side slot that's affected
302 clientSlot [1] ClientSlot OPTIONAL,
303 -- any additional textual information
304 errorString [2] ErrorString OPTIONAL,
305 ...
306}
307
Harald Welte3f966322019-12-04 19:09:58 +0100308-- SERVER->*: request reset of all state on peer side
309ResetStateReq ::= SEQUENCE {
310 ...
311}
312
313-- *->SERVER: confirm reset of all state on peer side
314ResetStateRes ::= SEQUENCE {
315 result ResultCode,
316 ...
317}
318
Harald Welte769ab7d2019-03-09 15:10:36 +0100319
Harald Welte3aa901d2018-08-13 18:32:36 +0200320----------------------------------------------------------------------
321-- PDU
322----------------------------------------------------------------------
323
324RsproPDUchoice ::= CHOICE {
325 -- configuration + management
326 connectBankReq [0] ConnectBankReq,
327 connectBankRes [1] ConnectBankRes,
328 connectClientReq [2] ConnectClientReq,
329 connectClientRes [3] ConnectClientRes,
330 createMappingReq [4] CreateMappingReq,
331 createMappingRes [5] CreateMappingRes,
332 removeMappingReq [6] RemoveMappingReq,
333 removeMappingRes [7] RemoveMappingRes,
Harald Welted571a3e2019-03-11 22:09:50 +0100334 configClientIdReq [8] ConfigClientIdReq,
335 configClientIdRes [9] ConfigClientIdRes,
336 configClientBankReq [17] ConfigClientBankReq,
337 configClientBankRes [18] ConfigClientBankRes,
Harald Welte769ab7d2019-03-09 15:10:36 +0100338 errorInd [16] ErrorInd,
Harald Welte3f966322019-12-04 19:09:58 +0100339 resetStateReq [19] ResetStateReq,
340 resetStateRes [20] ResetStateRes,
Harald Welte3aa901d2018-08-13 18:32:36 +0200341 -- APDUs etc.
342 setAtrReq [10] SetAtrReq,
343 setAtrRes [11] SetAtrRes,
344 tpduModemToCard [12] TpduModemToCard,
345 tpduCardToModem [13] TpduCardToModem,
346 clientSlotStatusInd [14] ClientSlotStatusInd,
347 bankSlotStatusInd [15] BankSlotStatusInd,
348 ...
349}
350
351RsproPDU ::= SEQUENCE {
Harald Welte293478c2018-09-24 14:49:41 +0200352 version [0] INTEGER(0..32),
Harald Welte3aa901d2018-08-13 18:32:36 +0200353 tag [1] OperationTag,
354 msg [2] RsproPDUchoice
355}
356
357END