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 | -- |
| 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 Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 22 | ---------------------------------------------------------------------- |
| 23 | |
| 24 | RSPRO {} DEFINITIONS |
| 25 | |
| 26 | IMPLICIT TAGS |
| 27 | |
| 28 | ::= |
| 29 | |
| 30 | BEGIN |
| 31 | |
| 32 | EXPORTS |
| 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. |
| 42 | OperationTag ::= INTEGER(0..2147483647) |
| 43 | |
| 44 | -- Unique identifier of a given SIM bank |
| 45 | BankId ::= INTEGER(0..1023) |
| 46 | |
| 47 | -- Unique identifier of a given client (modem) |
| 48 | ClientId ::= INTEGER(0..1023) |
| 49 | |
| 50 | ComponentType ::= ENUMERATED { |
| 51 | -- client: Modems / Phones |
| 52 | remsimClient (0), |
| 53 | -- server: Coordination |
| 54 | remsimServer (1), |
| 55 | -- bank daemon: SIM cards |
| 56 | remsimBankd (2) |
| 57 | } |
| 58 | ComponentName ::= IA5String (SIZE (1..32)) |
| 59 | ComponentIdentity ::= 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 |
| 73 | Ipv4Address ::= OCTET STRING (SIZE (4)) |
| 74 | Ipv6Address ::= OCTET STRING (SIZE (16)) |
| 75 | IpAddress ::= CHOICE { |
| 76 | ipv4 [0] Ipv4Address, |
| 77 | ipv6 [1] Ipv6Address |
| 78 | } |
| 79 | PortNumber ::= INTEGER (0..65535) |
| 80 | IpPort ::= SEQUENCE { |
| 81 | ip IpAddress, |
| 82 | port PortNumber |
| 83 | } |
| 84 | |
| 85 | -- Result of a given operation |
| 86 | ResultCode ::= ENUMERATED { |
| 87 | ok (0), |
| 88 | -- client / bank / slot ID not accepted |
| 89 | illegalClientId (1), |
| 90 | illegalBankId (2), |
| 91 | illegalSlotId (3), |
Harald Welte | 71752dd | 2019-03-09 15:07:01 +0100 | [diff] [blame] | 92 | unsupportedProtocolVersion (4), |
| 93 | unknownSlotmap (5), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 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 | |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 104 | ErrorCode ::= 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 | |
| 113 | ErrorString ::= IA5String (SIZE (1..255)) |
| 114 | |
| 115 | ErrorSeverity ::= ENUMERATED { |
| 116 | minor (1), |
| 117 | major (2), |
| 118 | fatal (3), |
| 119 | ... |
| 120 | } |
| 121 | |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 122 | -- Slot number within a SIM bank or a client. |
| 123 | SlotNumber ::= INTEGER(0..1023) |
| 124 | |
| 125 | -- Slot identity on client (modem) side |
| 126 | ClientSlot ::= SEQUENCE { |
| 127 | clientId ClientId, |
| 128 | slotNr SlotNumber, |
| 129 | ... |
| 130 | } |
| 131 | |
| 132 | -- Slot identity on SIM bank side |
| 133 | BankSlot ::= SEQUENCE { |
| 134 | bankId BankId, |
| 135 | slotNr SlotNumber, |
| 136 | ... |
| 137 | } |
| 138 | |
| 139 | ATR ::= OCTET STRING (SIZE (1..55)) |
| 140 | |
| 141 | -- flags related to a TPDU in either of the two directions |
| 142 | TpduFlags ::= 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 |
| 155 | SlotPhysStatus ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 172 | -- BANKD->SERVER: SIM Bank connects to central server |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 173 | ConnectBankReq ::= 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 | } |
| 181 | ConnectBankRes ::= SEQUENCE { |
| 182 | -- identity of the server to which the bank is connecting |
| 183 | identity ComponentIdentity, |
| 184 | result ResultCode, |
| 185 | ... |
| 186 | } |
| 187 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 188 | -- CLIENT->SERVER or CLIENT->BANKD |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 189 | ConnectClientReq ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 190 | -- identity of the client that is connecting to the server/bankd |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 191 | identity ComponentIdentity, |
Harald Welte | f1d7016 | 2018-10-11 12:56:00 +0200 | [diff] [blame] | 192 | 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] | 193 | ... |
| 194 | } |
| 195 | ConnectClientRes ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 196 | -- identity of the bankd/server to which the client is connecting |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 197 | identity ComponentIdentity, |
| 198 | result ResultCode, |
| 199 | ... |
| 200 | } |
| 201 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 202 | -- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 203 | CreateMappingReq ::= SEQUENCE { |
| 204 | client ClientSlot, |
| 205 | bank BankSlot, |
| 206 | ... |
| 207 | } |
| 208 | CreateMappingRes ::= SEQUENCE { |
| 209 | result ResultCode, |
| 210 | ... |
| 211 | } |
| 212 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 213 | -- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 214 | RemoveMappingReq ::= SEQUENCE { |
| 215 | client ClientSlot, |
| 216 | bank BankSlot, |
| 217 | ... |
| 218 | } |
| 219 | RemoveMappingRes ::= SEQUENCE { |
| 220 | result ResultCode, |
| 221 | ... |
| 222 | } |
| 223 | |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 224 | -- SERVER->CLIENT: set Client ID |
| 225 | ConfigClientIdReq ::= SEQUENCE { |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 226 | -- server-allocated assignment of a client ID |
Harald Welte | 371d026 | 2018-08-16 15:23:58 +0200 | [diff] [blame] | 227 | clientSlot ClientSlot, |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 228 | ... |
| 229 | } |
| 230 | ConfigClientIdRes ::= SEQUENCE { |
| 231 | result ResultCode, |
| 232 | ... |
| 233 | } |
| 234 | |
| 235 | -- SERVER->CLIENT: set BankId/Slot and IP/Port |
| 236 | ConfigClientBankReq ::= SEQUENCE { |
| 237 | -- server-allocated assignment of a client ID |
| 238 | bankSlot BankSlot, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 239 | -- bank to which the client shall connect |
| 240 | bankd IpPort, |
| 241 | ... |
| 242 | } |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 243 | ConfigClientBankRes ::= SEQUENCE { |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 244 | result ResultCode, |
| 245 | ... |
| 246 | } |
| 247 | |
Harald Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 248 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 249 | -- 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] | 250 | SetAtrReq ::= SEQUENCE { |
| 251 | slot ClientSlot, |
| 252 | atr ATR, |
| 253 | ... |
| 254 | } |
| 255 | SetAtrRes ::= SEQUENCE { |
| 256 | result ResultCode, |
| 257 | ... |
| 258 | } |
| 259 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 260 | -- CLIENT->BANKD: TPDU in Modem -> Card direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 261 | TpduModemToCard ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 270 | -- BANKD->CLIENT: TPDU in Card -> Modem direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 271 | TpduCardToModem ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 280 | -- CLIENT->BANKD: indciation about the current status of a client (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 281 | ClientSlotStatusInd ::= SEQUENCE { |
| 282 | fromClientSlot ClientSlot, |
| 283 | toBankSlot BankSlot, |
| 284 | slotPhysStatus SlotPhysStatus, |
| 285 | ... |
| 286 | } |
| 287 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 288 | -- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 289 | BankSlotStatusInd ::= SEQUENCE { |
| 290 | fromBankSlot BankSlot, |
| 291 | toClientSlot ClientSlot, |
| 292 | slotPhysStatus SlotPhysStatus, |
| 293 | ... |
| 294 | } |
| 295 | |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 296 | -- *->SERVER: indication about some kind of error |
| 297 | ErrorInd ::= 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 Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 312 | ---------------------------------------------------------------------- |
| 313 | -- PDU |
| 314 | ---------------------------------------------------------------------- |
| 315 | |
| 316 | RsproPDUchoice ::= 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 Welte | d571a3e | 2019-03-11 22:09:50 +0100 | [diff] [blame] | 326 | configClientIdReq [8] ConfigClientIdReq, |
| 327 | configClientIdRes [9] ConfigClientIdRes, |
| 328 | configClientBankReq [17] ConfigClientBankReq, |
| 329 | configClientBankRes [18] ConfigClientBankRes, |
Harald Welte | 769ab7d | 2019-03-09 15:10:36 +0100 | [diff] [blame] | 330 | errorInd [16] ErrorInd, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 331 | -- 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 | |
| 341 | RsproPDU ::= SEQUENCE { |
Harald Welte | 293478c | 2018-09-24 14:49:41 +0200 | [diff] [blame] | 342 | version [0] INTEGER(0..32), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 343 | tag [1] OperationTag, |
| 344 | msg [2] RsproPDUchoice |
| 345 | } |
| 346 | |
| 347 | END |