blob: 1214f911b2329f9979e158fb9a552eddf8e9b890 [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
104-- Slot number within a SIM bank or a client.
105SlotNumber ::= INTEGER(0..1023)
106
107-- Slot identity on client (modem) side
108ClientSlot ::= SEQUENCE {
109 clientId ClientId,
110 slotNr SlotNumber,
111 ...
112}
113
114-- Slot identity on SIM bank side
115BankSlot ::= SEQUENCE {
116 bankId BankId,
117 slotNr SlotNumber,
118 ...
119}
120
121ATR ::= OCTET STRING (SIZE (1..55))
122
123-- flags related to a TPDU in either of the two directions
124TpduFlags ::= SEQUENCE {
125 -- indicates a TPDU header is present in this message
126 tpduHeaderPresent BOOLEAN,
127 -- indicates last part of transmission in this direction
128 finalPart BOOLEAN,
129 -- indicates a PB is present and we should continue with TX
130 procByteContinueTx BOOLEAN,
131 -- indicates a PB is present and we should continue with RX
132 procByteContinueRx BOOLEAN,
133 ...
134}
135
136--- physical state of a given slot
137SlotPhysStatus ::= SEQUENCE {
138 -- is RST activated by the modem?
139 resetActive [0] BOOLEAN,
140 -- is VCC applied by the modem?
141 vccPresent [1] BOOLEAN OPTIONAL,
142 -- is CLK applied by the modem?
143 clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
144 -- is card presence signalled to the modem?
145 cardPresent [3] BOOLEAN OPTIONAL,
146 ...
147}
148
149----------------------------------------------------------------------
150-- Messages
151----------------------------------------------------------------------
152
153
Harald Weltef0614df2018-08-16 14:45:23 +0200154-- BANKD->SERVER: SIM Bank connects to central server
Harald Welte3aa901d2018-08-13 18:32:36 +0200155ConnectBankReq ::= SEQUENCE {
156 -- identity of the bank that is connecting to the server
157 identity ComponentIdentity,
158 -- bank number, pre-configured on bank side
159 bankId BankId,
160 numberOfSlots SlotNumber,
161 ...
162}
163ConnectBankRes ::= SEQUENCE {
164 -- identity of the server to which the bank is connecting
165 identity ComponentIdentity,
166 result ResultCode,
167 ...
168}
169
Harald Weltef0614df2018-08-16 14:45:23 +0200170-- CLIENT->SERVER or CLIENT->BANKD
Harald Welte3aa901d2018-08-13 18:32:36 +0200171ConnectClientReq ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200172 -- identity of the client that is connecting to the server/bankd
Harald Welte3aa901d2018-08-13 18:32:36 +0200173 identity ComponentIdentity,
Harald Weltef1d70162018-10-11 12:56:00 +0200174 clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
Harald Welte3aa901d2018-08-13 18:32:36 +0200175 ...
176}
177ConnectClientRes ::= SEQUENCE {
Harald Weltef0614df2018-08-16 14:45:23 +0200178 -- identity of the bankd/server to which the client is connecting
Harald Welte3aa901d2018-08-13 18:32:36 +0200179 identity ComponentIdentity,
180 result ResultCode,
181 ...
182}
183
Harald Weltef0614df2018-08-16 14:45:23 +0200184-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200185CreateMappingReq ::= SEQUENCE {
186 client ClientSlot,
187 bank BankSlot,
188 ...
189}
190CreateMappingRes ::= SEQUENCE {
191 result ResultCode,
192 ...
193}
194
Harald Weltef0614df2018-08-16 14:45:23 +0200195-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
Harald Welte3aa901d2018-08-13 18:32:36 +0200196RemoveMappingReq ::= SEQUENCE {
197 client ClientSlot,
198 bank BankSlot,
199 ...
200}
201RemoveMappingRes ::= SEQUENCE {
202 result ResultCode,
203 ...
204}
205
Harald Weltef0614df2018-08-16 14:45:23 +0200206-- SERVER->CLIENT: set configuration (client ID and BANK IP/Port)
Harald Welte3aa901d2018-08-13 18:32:36 +0200207ConfigClientReq ::= SEQUENCE {
208 -- server-allocated assignment of a client ID
Harald Welte371d0262018-08-16 15:23:58 +0200209 clientSlot ClientSlot,
Harald Welte3aa901d2018-08-13 18:32:36 +0200210 -- bank to which the client shall connect
211 bankd IpPort,
212 ...
213}
214ConfigClientRes ::= SEQUENCE {
215 result ResultCode,
216 ...
217}
218
Harald Weltef0614df2018-08-16 14:45:23 +0200219-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
Harald Welte3aa901d2018-08-13 18:32:36 +0200220SetAtrReq ::= SEQUENCE {
221 slot ClientSlot,
222 atr ATR,
223 ...
224}
225SetAtrRes ::= SEQUENCE {
226 result ResultCode,
227 ...
228}
229
Harald Weltef0614df2018-08-16 14:45:23 +0200230-- CLIENT->BANKD: TPDU in Modem -> Card direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200231TpduModemToCard ::= SEQUENCE {
232 -- we include fully-qualified bank and client slots for easier debugging
233 fromClientSlot ClientSlot,
234 toBankSlot BankSlot,
235 flags TpduFlags,
236 data OCTET STRING,
237 ...
238}
239
Harald Weltef0614df2018-08-16 14:45:23 +0200240-- BANKD->CLIENT: TPDU in Card -> Modem direction
Harald Welte3aa901d2018-08-13 18:32:36 +0200241TpduCardToModem ::= SEQUENCE {
242 -- we include fully-qualified bank and client slots for easier debugging
243 fromBankSlot BankSlot,
244 toClientSlot ClientSlot,
245 flags TpduFlags,
246 data OCTET STRING,
247 ...
248}
249
Harald Weltef0614df2018-08-16 14:45:23 +0200250-- CLIENT->BANKD: indciation about the current status of a client (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200251ClientSlotStatusInd ::= SEQUENCE {
252 fromClientSlot ClientSlot,
253 toBankSlot BankSlot,
254 slotPhysStatus SlotPhysStatus,
255 ...
256}
257
Harald Weltef0614df2018-08-16 14:45:23 +0200258-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
Harald Welte3aa901d2018-08-13 18:32:36 +0200259BankSlotStatusInd ::= SEQUENCE {
260 fromBankSlot BankSlot,
261 toClientSlot ClientSlot,
262 slotPhysStatus SlotPhysStatus,
263 ...
264}
265
266----------------------------------------------------------------------
267-- PDU
268----------------------------------------------------------------------
269
270RsproPDUchoice ::= CHOICE {
271 -- configuration + management
272 connectBankReq [0] ConnectBankReq,
273 connectBankRes [1] ConnectBankRes,
274 connectClientReq [2] ConnectClientReq,
275 connectClientRes [3] ConnectClientRes,
276 createMappingReq [4] CreateMappingReq,
277 createMappingRes [5] CreateMappingRes,
278 removeMappingReq [6] RemoveMappingReq,
279 removeMappingRes [7] RemoveMappingRes,
280 configClientReq [8] ConfigClientReq,
281 configClientRes [9] ConfigClientRes,
282 -- APDUs etc.
283 setAtrReq [10] SetAtrReq,
284 setAtrRes [11] SetAtrRes,
285 tpduModemToCard [12] TpduModemToCard,
286 tpduCardToModem [13] TpduCardToModem,
287 clientSlotStatusInd [14] ClientSlotStatusInd,
288 bankSlotStatusInd [15] BankSlotStatusInd,
289 ...
290}
291
292RsproPDU ::= SEQUENCE {
Harald Welte293478c2018-09-24 14:49:41 +0200293 version [0] INTEGER(0..32),
Harald Welte3aa901d2018-08-13 18:32:36 +0200294 tag [1] OperationTag,
295 msg [2] RsproPDUchoice
296}
297
298END