Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 1 | ---------------------------------------------------------------------- |
| 2 | -- RSPRO - Remote SIM Protocol, part of Osmocom Remote SIM Suite |
| 3 | -- (C) 2018 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 3dcdd20 | 2019-03-09 13:06:46 +0100 | [diff] [blame] | 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 | -- |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 18 | ---------------------------------------------------------------------- |
| 19 | |
| 20 | RSPRO {} DEFINITIONS |
| 21 | |
| 22 | IMPLICIT TAGS |
| 23 | |
| 24 | ::= |
| 25 | |
| 26 | BEGIN |
| 27 | |
| 28 | EXPORTS |
| 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. |
| 38 | OperationTag ::= INTEGER(0..2147483647) |
| 39 | |
| 40 | -- Unique identifier of a given SIM bank |
| 41 | BankId ::= INTEGER(0..1023) |
| 42 | |
| 43 | -- Unique identifier of a given client (modem) |
| 44 | ClientId ::= INTEGER(0..1023) |
| 45 | |
| 46 | ComponentType ::= ENUMERATED { |
| 47 | -- client: Modems / Phones |
| 48 | remsimClient (0), |
| 49 | -- server: Coordination |
| 50 | remsimServer (1), |
| 51 | -- bank daemon: SIM cards |
| 52 | remsimBankd (2) |
| 53 | } |
| 54 | ComponentName ::= IA5String (SIZE (1..32)) |
| 55 | ComponentIdentity ::= 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 |
| 69 | Ipv4Address ::= OCTET STRING (SIZE (4)) |
| 70 | Ipv6Address ::= OCTET STRING (SIZE (16)) |
| 71 | IpAddress ::= CHOICE { |
| 72 | ipv4 [0] Ipv4Address, |
| 73 | ipv6 [1] Ipv6Address |
| 74 | } |
| 75 | PortNumber ::= INTEGER (0..65535) |
| 76 | IpPort ::= SEQUENCE { |
| 77 | ip IpAddress, |
| 78 | port PortNumber |
| 79 | } |
| 80 | |
| 81 | -- Result of a given operation |
| 82 | ResultCode ::= ENUMERATED { |
| 83 | ok (0), |
| 84 | -- client / bank / slot ID not accepted |
| 85 | illegalClientId (1), |
| 86 | illegalBankId (2), |
| 87 | illegalSlotId (3), |
Harald Welte | 71752dd | 2019-03-09 15:07:01 +0100 | [diff] [blame] | 88 | unsupportedProtocolVersion (4), |
| 89 | unknownSlotmap (5), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 90 | |
| 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 Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 100 | ErrorCode ::= 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 | |
| 109 | ErrorString ::= IA5String (SIZE (1..255)) |
| 110 | |
| 111 | ErrorSeverity ::= ENUMERATED { |
| 112 | minor (1), |
| 113 | major (2), |
| 114 | fatal (3), |
| 115 | ... |
| 116 | } |
| 117 | |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 118 | -- Slot number within a SIM bank or a client. |
| 119 | SlotNumber ::= INTEGER(0..1023) |
| 120 | |
| 121 | -- Slot identity on client (modem) side |
| 122 | ClientSlot ::= SEQUENCE { |
| 123 | clientId ClientId, |
| 124 | slotNr SlotNumber, |
| 125 | ... |
| 126 | } |
| 127 | |
| 128 | -- Slot identity on SIM bank side |
| 129 | BankSlot ::= SEQUENCE { |
| 130 | bankId BankId, |
| 131 | slotNr SlotNumber, |
| 132 | ... |
| 133 | } |
| 134 | |
| 135 | ATR ::= OCTET STRING (SIZE (1..55)) |
| 136 | |
| 137 | -- flags related to a TPDU in either of the two directions |
| 138 | TpduFlags ::= 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 |
| 151 | SlotPhysStatus ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 168 | -- BANKD->SERVER: SIM Bank connects to central server |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 169 | ConnectBankReq ::= 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 | } |
| 177 | ConnectBankRes ::= SEQUENCE { |
| 178 | -- identity of the server to which the bank is connecting |
| 179 | identity ComponentIdentity, |
| 180 | result ResultCode, |
| 181 | ... |
| 182 | } |
| 183 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 184 | -- CLIENT->SERVER or CLIENT->BANKD |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 185 | ConnectClientReq ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 186 | -- identity of the client that is connecting to the server/bankd |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 187 | identity ComponentIdentity, |
Harald Welte | f1d7016 | 2018-10-11 12:56:00 +0200 | [diff] [blame] | 188 | clientSlot ClientSlot OPTIONAL, -- mandatory for CL->BANKD; CL->SERVER: old identity, if any |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 189 | ... |
| 190 | } |
| 191 | ConnectClientRes ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 192 | -- identity of the bankd/server to which the client is connecting |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 193 | identity ComponentIdentity, |
| 194 | result ResultCode, |
| 195 | ... |
| 196 | } |
| 197 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 198 | -- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 199 | CreateMappingReq ::= SEQUENCE { |
| 200 | client ClientSlot, |
| 201 | bank BankSlot, |
| 202 | ... |
| 203 | } |
| 204 | CreateMappingRes ::= SEQUENCE { |
| 205 | result ResultCode, |
| 206 | ... |
| 207 | } |
| 208 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 209 | -- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 210 | RemoveMappingReq ::= SEQUENCE { |
| 211 | client ClientSlot, |
| 212 | bank BankSlot, |
| 213 | ... |
| 214 | } |
| 215 | RemoveMappingRes ::= SEQUENCE { |
| 216 | result ResultCode, |
| 217 | ... |
| 218 | } |
| 219 | |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 220 | -- SERVER->CLIENT: set Client ID |
| 221 | ConfigClientIdReq ::= SEQUENCE { |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 222 | -- server-allocated assignment of a client ID |
Harald Welte | 371d026 | 2018-08-16 15:23:58 +0200 | [diff] [blame] | 223 | clientSlot ClientSlot, |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 224 | ... |
| 225 | } |
| 226 | ConfigClientIdRes ::= SEQUENCE { |
| 227 | result ResultCode, |
| 228 | ... |
| 229 | } |
| 230 | |
| 231 | -- SERVER->CLIENT: set BankId/Slot and IP/Port |
| 232 | ConfigClientBankReq ::= SEQUENCE { |
| 233 | -- server-allocated assignment of a client ID |
| 234 | bankSlot BankSlot, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 235 | -- bank to which the client shall connect |
| 236 | bankd IpPort, |
| 237 | ... |
| 238 | } |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 239 | ConfigClientBankRes ::= SEQUENCE { |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 240 | result ResultCode, |
| 241 | ... |
| 242 | } |
| 243 | |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 244 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 245 | -- BANKD->CLIENT: configure the ATR which the card emulator (client) shall send to the modem |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 246 | SetAtrReq ::= SEQUENCE { |
| 247 | slot ClientSlot, |
| 248 | atr ATR, |
| 249 | ... |
| 250 | } |
| 251 | SetAtrRes ::= SEQUENCE { |
| 252 | result ResultCode, |
| 253 | ... |
| 254 | } |
| 255 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 256 | -- CLIENT->BANKD: TPDU in Modem -> Card direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 257 | TpduModemToCard ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 266 | -- BANKD->CLIENT: TPDU in Card -> Modem direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 267 | TpduCardToModem ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 276 | -- CLIENT->BANKD: indciation about the current status of a client (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 277 | ClientSlotStatusInd ::= SEQUENCE { |
| 278 | fromClientSlot ClientSlot, |
| 279 | toBankSlot BankSlot, |
| 280 | slotPhysStatus SlotPhysStatus, |
| 281 | ... |
| 282 | } |
| 283 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 284 | -- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 285 | BankSlotStatusInd ::= SEQUENCE { |
| 286 | fromBankSlot BankSlot, |
| 287 | toClientSlot ClientSlot, |
| 288 | slotPhysStatus SlotPhysStatus, |
| 289 | ... |
| 290 | } |
| 291 | |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 292 | -- *->SERVER: indication about some kind of error |
| 293 | ErrorInd ::= 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 Welte | 3f96632 | 2019-12-04 19:09:58 +0100 | [diff] [blame] | 307 | -- SERVER->*: request reset of all state on peer side |
| 308 | ResetStateReq ::= SEQUENCE { |
| 309 | ... |
| 310 | } |
| 311 | |
| 312 | -- *->SERVER: confirm reset of all state on peer side |
| 313 | ResetStateRes ::= SEQUENCE { |
| 314 | result ResultCode, |
| 315 | ... |
| 316 | } |
| 317 | |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 318 | |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 319 | ---------------------------------------------------------------------- |
| 320 | -- PDU |
| 321 | ---------------------------------------------------------------------- |
| 322 | |
| 323 | RsproPDUchoice ::= 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 Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 333 | configClientIdReq [8] ConfigClientIdReq, |
| 334 | configClientIdRes [9] ConfigClientIdRes, |
| 335 | configClientBankReq [17] ConfigClientBankReq, |
| 336 | configClientBankRes [18] ConfigClientBankRes, |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 337 | errorInd [16] ErrorInd, |
Harald Welte | 3f96632 | 2019-12-04 19:09:58 +0100 | [diff] [blame] | 338 | resetStateReq [19] ResetStateReq, |
| 339 | resetStateRes [20] ResetStateRes, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 340 | -- 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 | |
| 350 | RsproPDU ::= SEQUENCE { |
Harald Welte | 293478c | 2018-09-24 14:49:41 +0200 | [diff] [blame] | 351 | version [0] INTEGER(0..32), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 352 | tag [1] OperationTag, |
| 353 | msg [2] RsproPDUchoice |
| 354 | } |
| 355 | |
| 356 | END |