blob: 65152eca80dbda307e3aa1d215c13fcd3c417afe [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),
Harald Welte71752dd2019-03-09 15:07:01 +010092 unsupportedProtocolVersion (4),
93 unknownSlotmap (5),
Harald Welte3aa901d2018-08-13 18:32:36 +020094
95 -- no card is present in given slot
96 cardNotPresent (100),
97 -- card is present but unresponsive in given slot
98 cardUnresponsive (101),
99 -- unrecoverable transmission errors detected
100 cardTransmissionError (102),
101 ...
102}
103
Harald Welte769ab7d2019-03-09 15:10:36 +0100104ErrorCode ::= ENUMERATED {
105 -- Bankd or Server has received connection form unknown client (no mapping)
106 unknownClientConnected (1),
107 -- unexpected disconnect (typically bankd reports client disconnect)
108 unexpectedDisconnect (2),
109 unexpectedProtocolVersion (3),
110 ...
111}
112
113ErrorString ::= IA5String (SIZE (1..255))
114
115ErrorSeverity ::= ENUMERATED {
116 minor (1),
117 major (2),
118 fatal (3),
119 ...
120}
121
Harald Welte3aa901d2018-08-13 18:32:36 +0200122-- Slot number within a SIM bank or a client.
123SlotNumber ::= INTEGER(0..1023)
124
125-- Slot identity on client (modem) side
126ClientSlot ::= SEQUENCE {
127 clientId ClientId,
128 slotNr SlotNumber,
129 ...
130}
131
132-- Slot identity on SIM bank side
133BankSlot ::= SEQUENCE {
134 bankId BankId,
135 slotNr SlotNumber,
136 ...
137}
138
139ATR ::= OCTET STRING (SIZE (1..55))
140
141-- flags related to a TPDU in either of the two directions
142TpduFlags ::= SEQUENCE {
143 -- indicates a TPDU header is present in this message
144 tpduHeaderPresent BOOLEAN,
145 -- indicates last part of transmission in this direction
146 finalPart BOOLEAN,
147 -- indicates a PB is present and we should continue with TX
148 procByteContinueTx BOOLEAN,
149 -- indicates a PB is present and we should continue with RX
150 procByteContinueRx BOOLEAN,
151 ...
152}
153
154--- physical state of a given slot
155SlotPhysStatus ::= SEQUENCE {
156 -- is RST activated by the modem?
157 resetActive [0] BOOLEAN,
158 -- is VCC applied by the modem?
159 vccPresent [1] BOOLEAN OPTIONAL,
160 -- is CLK applied by the modem?
161 clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
162 -- is card presence signalled to the modem?
163 cardPresent [3] BOOLEAN OPTIONAL,
164 ...
165}
166
167----------------------------------------------------------------------
168-- Messages
169----------------------------------------------------------------------
170
171
Harald Weltef0614df2018-08-16 14:45:23 +0200172-- BANKD->SERVER: SIM Bank connects to central server
Harald Welte3aa901d2018-08-13 18:32:36 +0200173ConnectBankReq ::= SEQUENCE {
174 -- identity of the bank that is connecting to the server
175 identity ComponentIdentity,
176 -- bank number, pre-configured on bank side
177 bankId BankId,
178 numberOfSlots SlotNumber,
179 ...
180}
181ConnectBankRes ::= SEQUENCE {
182 -- identity of the server to which the bank is connecting
183 identity ComponentIdentity,
184 result ResultCode,
185 ...
186}
187
Harald Weltef0614df2018-08-16 14:45:23 +0200188-- CLIENT->SERVER or CLIENT->BANKD
Harald Welte3aa901d2018-08-13 18:32:36 +0200189ConnectClientReq ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200190 -- identity of the client that is connecting to the server/bankd
Harald Welte3aa901d2018-08-13 18:32:36 +0200191 identity ComponentIdentity,
Harald Weltef1d70162018-10-11 12:56:00 +0200192 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
Harald Welte3aa901d2018-08-13 18:32:36 +0200193 ...
194}
195ConnectClientRes ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200196 -- identity of the bankd/server to which the client is connecting
Harald Welte3aa901d2018-08-13 18:32:36 +0200197 identity ComponentIdentity,
198 result ResultCode,
199 ...
200}
201
Harald Weltef0614df2018-08-16 14:45:23 +0200202-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200203CreateMappingReq ::= SEQUENCE {
204 client ClientSlot,
205 bank BankSlot,
206 ...
207}
208CreateMappingRes ::= SEQUENCE {
209 result ResultCode,
210 ...
211}
212
Harald Weltef0614df2018-08-16 14:45:23 +0200213-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200214RemoveMappingReq ::= SEQUENCE {
215 client ClientSlot,
216 bank BankSlot,
217 ...
218}
219RemoveMappingRes ::= SEQUENCE {
220 result ResultCode,
221 ...
222}
223
Harald Welted571a3e2019-03-11 22:09:50 +0100224-- SERVER->CLIENT: set Client ID
225ConfigClientIdReq ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200226 -- server-allocated assignment of a client ID
Harald Welte371d0262018-08-16 15:23:58 +0200227 clientSlot ClientSlot,
Harald Welted571a3e2019-03-11 22:09:50 +0100228 ...
229}
230ConfigClientIdRes ::= SEQUENCE {
231 result ResultCode,
232 ...
233}
234
235-- SERVER->CLIENT: set BankId/Slot and IP/Port
236ConfigClientBankReq ::= SEQUENCE {
237 -- server-allocated assignment of a client ID
238 bankSlot BankSlot,
Harald Welte3aa901d2018-08-13 18:32:36 +0200239 -- bank to which the client shall connect
240 bankd IpPort,
241 ...
242}
Harald Welted571a3e2019-03-11 22:09:50 +0100243ConfigClientBankRes ::= SEQUENCE {
Harald Welte3aa901d2018-08-13 18:32:36 +0200244 result ResultCode,
245 ...
246}
247
Harald Welted571a3e2019-03-11 22:09:50 +0100248
Harald Weltef0614df2018-08-16 14:45:23 +0200249-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
Harald Welte3aa901d2018-08-13 18:32:36 +0200250SetAtrReq ::= SEQUENCE {
251 slot ClientSlot,
252 atr ATR,
253 ...
254}
255SetAtrRes ::= SEQUENCE {
256 result ResultCode,
257 ...
258}
259
Harald Weltef0614df2018-08-16 14:45:23 +0200260-- CLIENT->BANKD: TPDU in Modem -> Card direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200261TpduModemToCard ::= SEQUENCE {
262 -- we include fully-qualified bank and client slots for easier debugging
263 fromClientSlot ClientSlot,
264 toBankSlot BankSlot,
265 flags TpduFlags,
266 data OCTET STRING,
267 ...
268}
269
Harald Weltef0614df2018-08-16 14:45:23 +0200270-- BANKD->CLIENT: TPDU in Card -> Modem direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200271TpduCardToModem ::= SEQUENCE {
272 -- we include fully-qualified bank and client slots for easier debugging
273 fromBankSlot BankSlot,
274 toClientSlot ClientSlot,
275 flags TpduFlags,
276 data OCTET STRING,
277 ...
278}
279
Harald Weltef0614df2018-08-16 14:45:23 +0200280-- CLIENT->BANKD: indciation about the current status of a client (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200281ClientSlotStatusInd ::= SEQUENCE {
282 fromClientSlot ClientSlot,
283 toBankSlot BankSlot,
284 slotPhysStatus SlotPhysStatus,
285 ...
286}
287
Harald Weltef0614df2018-08-16 14:45:23 +0200288-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200289BankSlotStatusInd ::= SEQUENCE {
290 fromBankSlot BankSlot,
291 toClientSlot ClientSlot,
292 slotPhysStatus SlotPhysStatus,
293 ...
294}
295
Harald Welte769ab7d2019-03-09 15:10:36 +0100296-- *->SERVER: indication about some kind of error
297ErrorInd ::= SEQUENCE {
298 -- whoever is detecting + sending us the error
299 sender ComponentType,
300 severity ErrorSeverity,
301 code ErrorCode,
302 -- any bank-side slot that's affected
303 bankSlot [0] BankSlot OPTIONAL,
304 -- any client-side slot that's affected
305 clientSlot [1] ClientSlot OPTIONAL,
306 -- any additional textual information
307 errorString [2] ErrorString OPTIONAL,
308 ...
309}
310
311
Harald Welte3aa901d2018-08-13 18:32:36 +0200312----------------------------------------------------------------------
313-- PDU
314----------------------------------------------------------------------
315
316RsproPDUchoice ::= CHOICE {
317 -- configuration + management
318 connectBankReq [0] ConnectBankReq,
319 connectBankRes [1] ConnectBankRes,
320 connectClientReq [2] ConnectClientReq,
321 connectClientRes [3] ConnectClientRes,
322 createMappingReq [4] CreateMappingReq,
323 createMappingRes [5] CreateMappingRes,
324 removeMappingReq [6] RemoveMappingReq,
325 removeMappingRes [7] RemoveMappingRes,
Harald Welted571a3e2019-03-11 22:09:50 +0100326 configClientIdReq [8] ConfigClientIdReq,
327 configClientIdRes [9] ConfigClientIdRes,
328 configClientBankReq [17] ConfigClientBankReq,
329 configClientBankRes [18] ConfigClientBankRes,
Harald Welte769ab7d2019-03-09 15:10:36 +0100330 errorInd [16] ErrorInd,
Harald Welte3aa901d2018-08-13 18:32:36 +0200331 -- APDUs etc.
332 setAtrReq [10] SetAtrReq,
333 setAtrRes [11] SetAtrRes,
334 tpduModemToCard [12] TpduModemToCard,
335 tpduCardToModem [13] TpduCardToModem,
336 clientSlotStatusInd [14] ClientSlotStatusInd,
337 bankSlotStatusInd [15] BankSlotStatusInd,
338 ...
339}
340
341RsproPDU ::= SEQUENCE {
Harald Welte293478c2018-09-24 14:49:41 +0200342 version [0] INTEGER(0..32),
Harald Welte3aa901d2018-08-13 18:32:36 +0200343 tag [1] OperationTag,
344 msg [2] RsproPDUchoice
345}
346
347END