blob: faf9cec5da0d4f66d3b7a040f56c2c9504f507d1 [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),
90
91 -- no card is present in given slot
92 cardNotPresent (100),
93 -- card is present but unresponsive in given slot
94 cardUnresponsive (101),
95 -- unrecoverable transmission errors detected
96 cardTransmissionError (102),
97 ...
98}
99
100ErrorCode ::= ENUMERATED {
101 -- Bankd or Server has received connection form unknown client (no mapping)
102 unknownClientConnected (1),
103 -- unexpected disconnect (typically bankd reports client disconnect)
104 unexpectedDisconnect (2),
105 unexpectedProtocolVersion (3),
106 ...
107}
108
109ErrorString ::= IA5String (SIZE (1..255))
110
111ErrorSeverity ::= ENUMERATED {
112 minor (1),
113 major (2),
114 fatal (3),
115 ...
116}
117
118-- Slot number within a SIM bank or a client.
119SlotNumber ::= INTEGER(0..1023)
120
121-- Slot identity on client (modem) side
122ClientSlot ::= SEQUENCE {
123 clientId ClientId,
124 slotNr SlotNumber,
125 ...
126}
127
128-- Slot identity on SIM bank side
129BankSlot ::= SEQUENCE {
130 bankId BankId,
131 slotNr SlotNumber,
132 ...
133}
134
135ATR ::= OCTET STRING (SIZE (1..55))
136
137-- flags related to a TPDU in either of the two directions
138TpduFlags ::= SEQUENCE {
139 -- indicates a TPDU header is present in this message
140 tpduHeaderPresent BOOLEAN,
141 -- indicates last part of transmission in this direction
142 finalPart BOOLEAN,
143 -- indicates a PB is present and we should continue with TX
144 procByteContinueTx BOOLEAN,
145 -- indicates a PB is present and we should continue with RX
146 procByteContinueRx BOOLEAN,
147 ...
148}
149
150--- physical state of a given slot
151SlotPhysStatus ::= SEQUENCE {
152 -- is RST activated by the modem?
153 resetActive [0] BOOLEAN,
154 -- is VCC applied by the modem?
155 vccPresent [1] BOOLEAN OPTIONAL,
156 -- is CLK applied by the modem?
157 clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
158 -- is card presence signalled to the modem?
159 cardPresent [3] BOOLEAN OPTIONAL,
160 ...
161}
162
163----------------------------------------------------------------------
164-- Messages
165----------------------------------------------------------------------
166
167
168-- BANKD->SERVER: SIM Bank connects to central server
169ConnectBankReq ::= SEQUENCE {
170 -- identity of the bank that is connecting to the server
171 identity ComponentIdentity,
172 -- bank number, pre-configured on bank side
173 bankId BankId,
174 numberOfSlots SlotNumber,
175 -- IP/Port to which this bankd has bound and is listening for clients
176 bound IpPort OPTIONAL,
177 ...
178}
179ConnectBankRes ::= SEQUENCE {
180 -- identity of the server to which the bank is connecting
181 identity ComponentIdentity,
182 result ResultCode,
183 ...
184}
185
186-- CLIENT->SERVER or CLIENT->BANKD
187ConnectClientReq ::= SEQUENCE {
188 -- identity of the client that is connecting to the server/bankd
189 identity ComponentIdentity,
190 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
191 ...
192}
193ConnectClientRes ::= SEQUENCE {
194 -- identity of the bankd/server to which the client is connecting
195 identity ComponentIdentity,
196 result ResultCode,
197 ...
198}
199
200-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
201CreateMappingReq ::= SEQUENCE {
202 client ClientSlot,
203 bank BankSlot,
204 ...
205}
206CreateMappingRes ::= SEQUENCE {
207 result ResultCode,
208 ...
209}
210
211-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
212RemoveMappingReq ::= SEQUENCE {
213 client ClientSlot,
214 bank BankSlot,
215 ...
216}
217RemoveMappingRes ::= SEQUENCE {
218 result ResultCode,
219 ...
220}
221
222-- SERVER->CLIENT: set Client ID
223ConfigClientIdReq ::= SEQUENCE {
224 -- server-allocated assignment of a client ID
225 clientSlot ClientSlot,
226 ...
227}
228ConfigClientIdRes ::= SEQUENCE {
229 result ResultCode,
230 ...
231}
232
233-- SERVER->CLIENT: set BankId/Slot and IP/Port
234ConfigClientBankReq ::= SEQUENCE {
235 -- server-allocated assignment of a client ID
236 bankSlot BankSlot,
237 -- bank to which the client shall connect
238 bankd IpPort,
239 ...
240}
241ConfigClientBankRes ::= SEQUENCE {
242 result ResultCode,
243 ...
244}
245
246
247-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
248SetAtrReq ::= SEQUENCE {
249 slot ClientSlot,
250 atr ATR,
251 ...
252}
253SetAtrRes ::= SEQUENCE {
254 result ResultCode,
255 ...
256}
257
258-- CLIENT->BANKD: TPDU in Modem -> Card direction
259TpduModemToCard ::= SEQUENCE {
260 -- we include fully-qualified bank and client slots for easier debugging
261 fromClientSlot ClientSlot,
262 toBankSlot BankSlot,
263 flags TpduFlags,
264 data OCTET STRING,
265 ...
266}
267
268-- BANKD->CLIENT: TPDU in Card -> Modem direction
269TpduCardToModem ::= SEQUENCE {
270 -- we include fully-qualified bank and client slots for easier debugging
271 fromBankSlot BankSlot,
272 toClientSlot ClientSlot,
273 flags TpduFlags,
274 data OCTET STRING,
275 ...
276}
277
278-- CLIENT->BANKD: indciation about the current status of a client (modem side)
279ClientSlotStatusInd ::= SEQUENCE {
280 fromClientSlot ClientSlot,
281 toBankSlot BankSlot,
282 slotPhysStatus SlotPhysStatus,
283 ...
284}
285
286-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
287BankSlotStatusInd ::= SEQUENCE {
288 fromBankSlot BankSlot,
289 toClientSlot ClientSlot,
290 slotPhysStatus SlotPhysStatus,
291 ...
292}
293
294-- *->SERVER: indication about some kind of error
295ErrorInd ::= SEQUENCE {
296 -- whoever is detecting + sending us the error
297 sender ComponentType,
298 severity ErrorSeverity,
299 code ErrorCode,
300 -- any bank-side slot that's affected
301 bankSlot [0] BankSlot OPTIONAL,
302 -- any client-side slot that's affected
303 clientSlot [1] ClientSlot OPTIONAL,
304 -- any additional textual information
305 errorString [2] ErrorString OPTIONAL,
306 ...
307}
308
Harald Welteeb172b32019-12-04 20:54:15 +0100309-- SERVER->*: request reset of all state on peer side
310ResetStateReq ::= SEQUENCE {
311 ...
312}
313
314-- *->SERVER: confirm reset of all state on peer side
315ResetStateRes ::= SEQUENCE {
316 result ResultCode,
317 ...
318}
319
Harald Weltefaa42922019-03-04 18:31:11 +0100320
321----------------------------------------------------------------------
322-- PDU
323----------------------------------------------------------------------
324
325RsproPDUchoice ::= CHOICE {
326 -- configuration + management
327 connectBankReq [0] ConnectBankReq,
328 connectBankRes [1] ConnectBankRes,
329 connectClientReq [2] ConnectClientReq,
330 connectClientRes [3] ConnectClientRes,
331 createMappingReq [4] CreateMappingReq,
332 createMappingRes [5] CreateMappingRes,
333 removeMappingReq [6] RemoveMappingReq,
334 removeMappingRes [7] RemoveMappingRes,
335 configClientIdReq [8] ConfigClientIdReq,
336 configClientIdRes [9] ConfigClientIdRes,
337 configClientBankReq [17] ConfigClientBankReq,
338 configClientBankRes [18] ConfigClientBankRes,
339 errorInd [16] ErrorInd,
Harald Welteeb172b32019-12-04 20:54:15 +0100340 resetStateReq [19] ResetStateReq,
341 resetStateRes [20] ResetStateRes,
Harald Weltefaa42922019-03-04 18:31:11 +0100342 -- APDUs etc.
343 setAtrReq [10] SetAtrReq,
344 setAtrRes [11] SetAtrRes,
345 tpduModemToCard [12] TpduModemToCard,
346 tpduCardToModem [13] TpduCardToModem,
347 clientSlotStatusInd [14] ClientSlotStatusInd,
348 bankSlotStatusInd [15] BankSlotStatusInd,
349 ...
350}
351
352RsproPDU ::= SEQUENCE {
353 version [0] INTEGER(0..32),
354 tag [1] OperationTag,
355 msg [2] RsproPDUchoice
356}
357
358END