blob: ce290033945ff02a2f3a68c19ebd26b14da0ec3e [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--
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--
22----------------------------------------------------------------------
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),
92 unsupportedProtocolVersion (4),
93 unknownSlotmap (5),
94
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
104ErrorCode ::= 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
122-- 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
172-- BANKD->SERVER: SIM Bank connects to central server
173ConnectBankReq ::= 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 -- IP/Port to which this bankd has bound and is listening for clients
180 bound IpPort OPTIONAL,
181 ...
182}
183ConnectBankRes ::= SEQUENCE {
184 -- identity of the server to which the bank is connecting
185 identity ComponentIdentity,
186 result ResultCode,
187 ...
188}
189
190-- CLIENT->SERVER or CLIENT->BANKD
191ConnectClientReq ::= SEQUENCE {
192 -- identity of the client that is connecting to the server/bankd
193 identity ComponentIdentity,
194 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
195 ...
196}
197ConnectClientRes ::= SEQUENCE {
198 -- identity of the bankd/server to which the client is connecting
199 identity ComponentIdentity,
200 result ResultCode,
201 ...
202}
203
204-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
205CreateMappingReq ::= SEQUENCE {
206 client ClientSlot,
207 bank BankSlot,
208 ...
209}
210CreateMappingRes ::= SEQUENCE {
211 result ResultCode,
212 ...
213}
214
215-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
216RemoveMappingReq ::= SEQUENCE {
217 client ClientSlot,
218 bank BankSlot,
219 ...
220}
221RemoveMappingRes ::= SEQUENCE {
222 result ResultCode,
223 ...
224}
225
226-- SERVER->CLIENT: set Client ID
227ConfigClientIdReq ::= SEQUENCE {
228 -- server-allocated assignment of a client ID
229 clientSlot ClientSlot,
230 ...
231}
232ConfigClientIdRes ::= SEQUENCE {
233 result ResultCode,
234 ...
235}
236
237-- SERVER->CLIENT: set BankId/Slot and IP/Port
238ConfigClientBankReq ::= SEQUENCE {
239 -- server-allocated assignment of a client ID
240 bankSlot BankSlot,
241 -- bank to which the client shall connect
242 bankd IpPort,
243 ...
244}
245ConfigClientBankRes ::= SEQUENCE {
246 result ResultCode,
247 ...
248}
249
250
251-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
252SetAtrReq ::= SEQUENCE {
253 slot ClientSlot,
254 atr ATR,
255 ...
256}
257SetAtrRes ::= SEQUENCE {
258 result ResultCode,
259 ...
260}
261
262-- CLIENT->BANKD: TPDU in Modem -> Card direction
263TpduModemToCard ::= SEQUENCE {
264 -- we include fully-qualified bank and client slots for easier debugging
265 fromClientSlot ClientSlot,
266 toBankSlot BankSlot,
267 flags TpduFlags,
268 data OCTET STRING,
269 ...
270}
271
272-- BANKD->CLIENT: TPDU in Card -> Modem direction
273TpduCardToModem ::= SEQUENCE {
274 -- we include fully-qualified bank and client slots for easier debugging
275 fromBankSlot BankSlot,
276 toClientSlot ClientSlot,
277 flags TpduFlags,
278 data OCTET STRING,
279 ...
280}
281
282-- CLIENT->BANKD: indciation about the current status of a client (modem side)
283ClientSlotStatusInd ::= SEQUENCE {
284 fromClientSlot ClientSlot,
285 toBankSlot BankSlot,
286 slotPhysStatus SlotPhysStatus,
287 ...
288}
289
290-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
291BankSlotStatusInd ::= SEQUENCE {
292 fromBankSlot BankSlot,
293 toClientSlot ClientSlot,
294 slotPhysStatus SlotPhysStatus,
295 ...
296}
297
298-- *->SERVER: indication about some kind of error
299ErrorInd ::= SEQUENCE {
300 -- whoever is detecting + sending us the error
301 sender ComponentType,
302 severity ErrorSeverity,
303 code ErrorCode,
304 -- any bank-side slot that's affected
305 bankSlot [0] BankSlot OPTIONAL,
306 -- any client-side slot that's affected
307 clientSlot [1] ClientSlot OPTIONAL,
308 -- any additional textual information
309 errorString [2] ErrorString OPTIONAL,
310 ...
311}
312
Harald Welteeb172b32019-12-04 20:54:15 +0100313-- SERVER->*: request reset of all state on peer side
314ResetStateReq ::= SEQUENCE {
315 ...
316}
317
318-- *->SERVER: confirm reset of all state on peer side
319ResetStateRes ::= SEQUENCE {
320 result ResultCode,
321 ...
322}
323
Harald Weltefaa42922019-03-04 18:31:11 +0100324
325----------------------------------------------------------------------
326-- PDU
327----------------------------------------------------------------------
328
329RsproPDUchoice ::= CHOICE {
330 -- configuration + management
331 connectBankReq [0] ConnectBankReq,
332 connectBankRes [1] ConnectBankRes,
333 connectClientReq [2] ConnectClientReq,
334 connectClientRes [3] ConnectClientRes,
335 createMappingReq [4] CreateMappingReq,
336 createMappingRes [5] CreateMappingRes,
337 removeMappingReq [6] RemoveMappingReq,
338 removeMappingRes [7] RemoveMappingRes,
339 configClientIdReq [8] ConfigClientIdReq,
340 configClientIdRes [9] ConfigClientIdRes,
341 configClientBankReq [17] ConfigClientBankReq,
342 configClientBankRes [18] ConfigClientBankRes,
343 errorInd [16] ErrorInd,
Harald Welteeb172b32019-12-04 20:54:15 +0100344 resetStateReq [19] ResetStateReq,
345 resetStateRes [20] ResetStateRes,
Harald Weltefaa42922019-03-04 18:31:11 +0100346 -- APDUs etc.
347 setAtrReq [10] SetAtrReq,
348 setAtrRes [11] SetAtrRes,
349 tpduModemToCard [12] TpduModemToCard,
350 tpduCardToModem [13] TpduCardToModem,
351 clientSlotStatusInd [14] ClientSlotStatusInd,
352 bankSlotStatusInd [15] BankSlotStatusInd,
353 ...
354}
355
356RsproPDU ::= SEQUENCE {
357 version [0] INTEGER(0..32),
358 tag [1] OperationTag,
359 msg [2] RsproPDUchoice
360}
361
362END