-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
RSPRO.asn
359 lines (315 loc) · 9 KB
/
RSPRO.asn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
----------------------------------------------------------------------
-- RSPRO - Remote SIM Protocol, part of Osmocom Remote SIM Suite
-- (C) 2018 by Harald Welte <[email protected]>
-- All Rights Reserved
--
-- SPDX-License-Identifier: GPL-2.0+
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
----------------------------------------------------------------------
RSPRO {} DEFINITIONS
IMPLICIT TAGS
::=
BEGIN
EXPORTS
RsproPDU
;
----------------------------------------------------------------------
-- Elementary Data Types
----------------------------------------------------------------------
-- Some random ID the requestor can chose and which the client echos back in a response.
-- This allows multiple outstanding commands in flight and matching of responses to requests.
OperationTag ::= INTEGER(0..2147483647)
-- Unique identifier of a given SIM bank
BankId ::= INTEGER(0..1023)
-- Unique identifier of a given client (modem)
ClientId ::= INTEGER(0..1023)
ComponentType ::= ENUMERATED {
-- client: Modems / Phones
remsimClient (0),
-- server: Coordination
remsimServer (1),
-- bank daemon: SIM cards
remsimBankd (2)
}
ComponentName ::= IA5String (SIZE (1..32))
ComponentIdentity ::= SEQUENCE {
type ComponentType,
name ComponentName,
software [0] ComponentName,
swVersion [1] ComponentName,
hwManufacturer [2] ComponentName OPTIONAL,
hwModel [3] ComponentName OPTIONAL,
hwSerialNr [4] ComponentName OPTIONAL,
hwVersion [5] ComponentName OPTIONAL,
fwVersion [6] ComponentName OPTIONAL,
...
}
-- IP address / port details
Ipv4Address ::= OCTET STRING (SIZE (4))
Ipv6Address ::= OCTET STRING (SIZE (16))
IpAddress ::= CHOICE {
ipv4 [0] Ipv4Address,
ipv6 [1] Ipv6Address
}
PortNumber ::= INTEGER (0..65535)
IpPort ::= SEQUENCE {
ip IpAddress,
port PortNumber
}
-- Result of a given operation
ResultCode ::= ENUMERATED {
ok (0),
-- client / bank / slot ID not accepted
illegalClientId (1),
illegalBankId (2),
illegalSlotId (3),
unsupportedProtocolVersion (4),
unknownSlotmap (5),
identityInUse (6),
-- no card is present in given slot
cardNotPresent (100),
-- card is present but unresponsive in given slot
cardUnresponsive (101),
-- unrecoverable transmission errors detected
cardTransmissionError (102),
...
}
ErrorCode ::= ENUMERATED {
-- Bankd or Server has received connection form unknown client (no mapping)
unknownClientConnected (1),
-- unexpected disconnect (typically bankd reports client disconnect)
unexpectedDisconnect (2),
unexpectedProtocolVersion (3),
...
}
ErrorString ::= IA5String (SIZE (1..255))
ErrorSeverity ::= ENUMERATED {
minor (1),
major (2),
fatal (3),
...
}
-- Slot number within a SIM bank or a client.
SlotNumber ::= INTEGER(0..1023)
-- Slot identity on client (modem) side
ClientSlot ::= SEQUENCE {
clientId ClientId,
slotNr SlotNumber,
...
}
-- Slot identity on SIM bank side
BankSlot ::= SEQUENCE {
bankId BankId,
slotNr SlotNumber,
...
}
ATR ::= OCTET STRING (SIZE (1..55))
-- flags related to a TPDU in either of the two directions
TpduFlags ::= SEQUENCE {
-- indicates a TPDU header is present in this message
tpduHeaderPresent BOOLEAN,
-- indicates last part of transmission in this direction
finalPart BOOLEAN,
-- indicates a PB is present and we should continue with TX
procByteContinueTx BOOLEAN,
-- indicates a PB is present and we should continue with RX
procByteContinueRx BOOLEAN,
...
}
--- physical state of a given slot
SlotPhysStatus ::= SEQUENCE {
-- is RST activated by the modem?
resetActive [0] BOOLEAN,
-- is VCC applied by the modem?
vccPresent [1] BOOLEAN OPTIONAL,
-- is CLK applied by the modem?
clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this
-- is card presence signalled to the modem?
cardPresent [3] BOOLEAN OPTIONAL,
...
}
----------------------------------------------------------------------
-- Messages
----------------------------------------------------------------------
-- BANKD->SERVER: SIM Bank connects to central server
ConnectBankReq ::= SEQUENCE {
-- identity of the bank that is connecting to the server
identity ComponentIdentity,
-- bank number, pre-configured on bank side
bankId BankId,
numberOfSlots SlotNumber,
-- IP/Port to which this bankd has bound and is listening for clients
bound IpPort OPTIONAL,
...
}
ConnectBankRes ::= SEQUENCE {
-- identity of the server to which the bank is connecting
identity ComponentIdentity,
result ResultCode,
...
}
-- CLIENT->SERVER or CLIENT->BANKD
ConnectClientReq ::= SEQUENCE {
-- identity of the client that is connecting to the server/bankd
identity ComponentIdentity,
clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any
...
}
ConnectClientRes ::= SEQUENCE {
-- identity of the bankd/server to which the client is connecting
identity ComponentIdentity,
result ResultCode,
...
}
-- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot
CreateMappingReq ::= SEQUENCE {
client ClientSlot,
bank BankSlot,
...
}
CreateMappingRes ::= SEQUENCE {
result ResultCode,
...
}
-- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot
RemoveMappingReq ::= SEQUENCE {
client ClientSlot,
bank BankSlot,
...
}
RemoveMappingRes ::= SEQUENCE {
result ResultCode,
...
}
-- SERVER->CLIENT: set Client ID
ConfigClientIdReq ::= SEQUENCE {
-- server-allocated assignment of a client ID
clientSlot ClientSlot,
...
}
ConfigClientIdRes ::= SEQUENCE {
result ResultCode,
...
}
-- SERVER->CLIENT: set BankId/Slot and IP/Port
ConfigClientBankReq ::= SEQUENCE {
-- server-allocated assignment of a client ID
bankSlot BankSlot,
-- bank to which the client shall connect
bankd IpPort,
...
}
ConfigClientBankRes ::= SEQUENCE {
result ResultCode,
...
}
-- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem
SetAtrReq ::= SEQUENCE {
slot ClientSlot,
atr ATR,
...
}
SetAtrRes ::= SEQUENCE {
result ResultCode,
...
}
-- CLIENT->BANKD: TPDU in Modem -> Card direction
TpduModemToCard ::= SEQUENCE {
-- we include fully-qualified bank and client slots for easier debugging
fromClientSlot ClientSlot,
toBankSlot BankSlot,
flags TpduFlags,
data OCTET STRING,
...
}
-- BANKD->CLIENT: TPDU in Card -> Modem direction
TpduCardToModem ::= SEQUENCE {
-- we include fully-qualified bank and client slots for easier debugging
fromBankSlot BankSlot,
toClientSlot ClientSlot,
flags TpduFlags,
data OCTET STRING,
...
}
-- CLIENT->BANKD: indciation about the current status of a client (modem side)
ClientSlotStatusInd ::= SEQUENCE {
fromClientSlot ClientSlot,
toBankSlot BankSlot,
slotPhysStatus SlotPhysStatus,
...
}
-- BANKD->CLIENT: indciation about the current status of a bank (modem side)
BankSlotStatusInd ::= SEQUENCE {
fromBankSlot BankSlot,
toClientSlot ClientSlot,
slotPhysStatus SlotPhysStatus,
...
}
-- *->SERVER: indication about some kind of error
ErrorInd ::= SEQUENCE {
-- whoever is detecting + sending us the error
sender ComponentType,
severity ErrorSeverity,
code ErrorCode,
-- any bank-side slot that's affected
bankSlot [0] BankSlot OPTIONAL,
-- any client-side slot that's affected
clientSlot [1] ClientSlot OPTIONAL,
-- any additional textual information
errorString [2] ErrorString OPTIONAL,
...
}
-- SERVER->*: request reset of all state on peer side
ResetStateReq ::= SEQUENCE {
...
}
-- *->SERVER: confirm reset of all state on peer side
ResetStateRes ::= SEQUENCE {
result ResultCode,
...
}
----------------------------------------------------------------------
-- PDU
----------------------------------------------------------------------
RsproPDUchoice ::= CHOICE {
-- configuration + management
connectBankReq [0] ConnectBankReq,
connectBankRes [1] ConnectBankRes,
connectClientReq [2] ConnectClientReq,
connectClientRes [3] ConnectClientRes,
createMappingReq [4] CreateMappingReq,
createMappingRes [5] CreateMappingRes,
removeMappingReq [6] RemoveMappingReq,
removeMappingRes [7] RemoveMappingRes,
configClientIdReq [8] ConfigClientIdReq,
configClientIdRes [9] ConfigClientIdRes,
configClientBankReq [17] ConfigClientBankReq,
configClientBankRes [18] ConfigClientBankRes,
errorInd [16] ErrorInd,
resetStateReq [19] ResetStateReq,
resetStateRes [20] ResetStateRes,
-- APDUs etc.
setAtrReq [10] SetAtrReq,
setAtrRes [11] SetAtrRes,
tpduModemToCard [12] TpduModemToCard,
tpduCardToModem [13] TpduCardToModem,
clientSlotStatusInd [14] ClientSlotStatusInd,
bankSlotStatusInd [15] BankSlotStatusInd,
...
}
RsproPDU ::= SEQUENCE {
version [0] INTEGER(0..32),
tag [1] OperationTag,
msg [2] RsproPDUchoice
}
END