blob: d49345dc8a934d1fc27fe3b4954e8f68e375b64c [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 Welte3aa901d2018-08-13 18:32:36 +020090
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
Harald Welte769ab7d2019-03-09 15:10:36 +0100100ErrorCode ::= 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
Harald Welte3aa901d2018-08-13 18:32:36 +0200118-- 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
Harald Weltef0614df2018-08-16 14:45:23 +0200168-- BANKD->SERVER: SIM Bank connects to central server
Harald Welte3aa901d2018-08-13 18:32:36 +0200169ConnectBankReq ::= 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 ...
176}
177ConnectBankRes ::= SEQUENCE {
178 -- identity of the server to which the bank is connecting
179 identity ComponentIdentity,
180 result ResultCode,
181 ...
182}
183
Harald Weltef0614df2018-08-16 14:45:23 +0200184-- CLIENT->SERVER or CLIENT->BANKD
Harald Welte3aa901d2018-08-13 18:32:36 +0200185ConnectClientReq ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200186 -- identity of the client that is connecting to the server/bankd
Harald Welte3aa901d2018-08-13 18:32:36 +0200187 identity ComponentIdentity,
Harald Weltef1d70162018-10-11 12:56:00 +0200188 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
Harald Welte3aa901d2018-08-13 18:32:36 +0200189 ...
190}
191ConnectClientRes ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200192 -- identity of the bankd/server to which the client is connecting
Harald Welte3aa901d2018-08-13 18:32:36 +0200193 identity ComponentIdentity,
194 result ResultCode,
195 ...
196}
197
Harald Weltef0614df2018-08-16 14:45:23 +0200198-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200199CreateMappingReq ::= SEQUENCE {
200 client ClientSlot,
201 bank BankSlot,
202 ...
203}
204CreateMappingRes ::= SEQUENCE {
205 result ResultCode,
206 ...
207}
208
Harald Weltef0614df2018-08-16 14:45:23 +0200209-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200210RemoveMappingReq ::= SEQUENCE {
211 client ClientSlot,
212 bank BankSlot,
213 ...
214}
215RemoveMappingRes ::= SEQUENCE {
216 result ResultCode,
217 ...
218}
219
Harald Welted571a3e2019-03-11 22:09:50 +0100220-- SERVER->CLIENT: set Client ID
221ConfigClientIdReq ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200222 -- server-allocated assignment of a client ID
Harald Welte371d0262018-08-16 15:23:58 +0200223 clientSlot ClientSlot,
Harald Welted571a3e2019-03-11 22:09:50 +0100224 ...
225}
226ConfigClientIdRes ::= SEQUENCE {
227 result ResultCode,
228 ...
229}
230
231-- SERVER->CLIENT: set BankId/Slot and IP/Port
232ConfigClientBankReq ::= SEQUENCE {
233 -- server-allocated assignment of a client ID
234 bankSlot BankSlot,
Harald Welte3aa901d2018-08-13 18:32:36 +0200235 -- bank to which the client shall connect
236 bankd IpPort,
237 ...
238}
Harald Welted571a3e2019-03-11 22:09:50 +0100239ConfigClientBankRes ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200240 result ResultCode,
241 ...
242}
243
Harald Welted571a3e2019-03-11 22:09:50 +0100244
Harald Weltef0614df2018-08-16 14:45:23 +0200245-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
Harald Welte3aa901d2018-08-13 18:32:36 +0200246SetAtrReq ::= SEQUENCE {
247 slot ClientSlot,
248 atr ATR,
249 ...
250}
251SetAtrRes ::= SEQUENCE {
252 result ResultCode,
253 ...
254}
255
Harald Weltef0614df2018-08-16 14:45:23 +0200256-- CLIENT->BANKD: TPDU in Modem -> Card direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200257TpduModemToCard ::= SEQUENCE {
258 -- we include fully-qualified bank and client slots for easier debugging
259 fromClientSlot ClientSlot,
260 toBankSlot BankSlot,
261 flags TpduFlags,
262 data OCTET STRING,
263 ...
264}
265
Harald Weltef0614df2018-08-16 14:45:23 +0200266-- BANKD->CLIENT: TPDU in Card -> Modem direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200267TpduCardToModem ::= SEQUENCE {
268 -- we include fully-qualified bank and client slots for easier debugging
269 fromBankSlot BankSlot,
270 toClientSlot ClientSlot,
271 flags TpduFlags,
272 data OCTET STRING,
273 ...
274}
275
Harald Weltef0614df2018-08-16 14:45:23 +0200276-- CLIENT->BANKD: indciation about the current status of a client (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200277ClientSlotStatusInd ::= SEQUENCE {
278 fromClientSlot ClientSlot,
279 toBankSlot BankSlot,
280 slotPhysStatus SlotPhysStatus,
281 ...
282}
283
Harald Weltef0614df2018-08-16 14:45:23 +0200284-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200285BankSlotStatusInd ::= SEQUENCE {
286 fromBankSlot BankSlot,
287 toClientSlot ClientSlot,
288 slotPhysStatus SlotPhysStatus,
289 ...
290}
291
Harald Welte769ab7d2019-03-09 15:10:36 +0100292-- *->SERVER: indication about some kind of error
293ErrorInd ::= SEQUENCE {
294 -- whoever is detecting + sending us the error
295 sender ComponentType,
296 severity ErrorSeverity,
297 code ErrorCode,
298 -- any bank-side slot that's affected
299 bankSlot [0] BankSlot OPTIONAL,
300 -- any client-side slot that's affected
301 clientSlot [1] ClientSlot OPTIONAL,
302 -- any additional textual information
303 errorString [2] ErrorString OPTIONAL,
304 ...
305}
306
Harald Welte3f966322019-12-04 19:09:58 +0100307-- SERVER->*: request reset of all state on peer side
308ResetStateReq ::= SEQUENCE {
309 ...
310}
311
312-- *->SERVER: confirm reset of all state on peer side
313ResetStateRes ::= SEQUENCE {
314 result ResultCode,
315 ...
316}
317
Harald Welte769ab7d2019-03-09 15:10:36 +0100318
Harald Welte3aa901d2018-08-13 18:32:36 +0200319----------------------------------------------------------------------
320-- PDU
321----------------------------------------------------------------------
322
323RsproPDUchoice ::= CHOICE {
324 -- configuration + management
325 connectBankReq [0] ConnectBankReq,
326 connectBankRes [1] ConnectBankRes,
327 connectClientReq [2] ConnectClientReq,
328 connectClientRes [3] ConnectClientRes,
329 createMappingReq [4] CreateMappingReq,
330 createMappingRes [5] CreateMappingRes,
331 removeMappingReq [6] RemoveMappingReq,
332 removeMappingRes [7] RemoveMappingRes,
Harald Welted571a3e2019-03-11 22:09:50 +0100333 configClientIdReq [8] ConfigClientIdReq,
334 configClientIdRes [9] ConfigClientIdRes,
335 configClientBankReq [17] ConfigClientBankReq,
336 configClientBankRes [18] ConfigClientBankRes,
Harald Welte769ab7d2019-03-09 15:10:36 +0100337 errorInd [16] ErrorInd,
Harald Welte3f966322019-12-04 19:09:58 +0100338 resetStateReq [19] ResetStateReq,
339 resetStateRes [20] ResetStateRes,
Harald Welte3aa901d2018-08-13 18:32:36 +0200340 -- APDUs etc.
341 setAtrReq [10] SetAtrReq,
342 setAtrRes [11] SetAtrRes,
343 tpduModemToCard [12] TpduModemToCard,
344 tpduCardToModem [13] TpduCardToModem,
345 clientSlotStatusInd [14] ClientSlotStatusInd,
346 bankSlotStatusInd [15] BankSlotStatusInd,
347 ...
348}
349
350RsproPDU ::= SEQUENCE {
Harald Welte293478c2018-09-24 14:49:41 +0200351 version [0] INTEGER(0..32),
Harald Welte3aa901d2018-08-13 18:32:36 +0200352 tag [1] OperationTag,
353 msg [2] RsproPDUchoice
354}
355
356END