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 | |
| 104 | -- Slot number within a SIM bank or a client. |
| 105 | SlotNumber ::= INTEGER(0..1023) |
| 106 | |
| 107 | -- Slot identity on client (modem) side |
| 108 | ClientSlot ::= SEQUENCE { |
| 109 | clientId ClientId, |
| 110 | slotNr SlotNumber, |
| 111 | ... |
| 112 | } |
| 113 | |
| 114 | -- Slot identity on SIM bank side |
| 115 | BankSlot ::= SEQUENCE { |
| 116 | bankId BankId, |
| 117 | slotNr SlotNumber, |
| 118 | ... |
| 119 | } |
| 120 | |
| 121 | ATR ::= OCTET STRING (SIZE (1..55)) |
| 122 | |
| 123 | -- flags related to a TPDU in either of the two directions |
| 124 | TpduFlags ::= 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 |
| 137 | SlotPhysStatus ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 154 | -- BANKD->SERVER: SIM Bank connects to central server |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 155 | ConnectBankReq ::= 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 | } |
| 163 | ConnectBankRes ::= SEQUENCE { |
| 164 | -- identity of the server to which the bank is connecting |
| 165 | identity ComponentIdentity, |
| 166 | result ResultCode, |
| 167 | ... |
| 168 | } |
| 169 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 170 | -- CLIENT->SERVER or CLIENT->BANKD |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 171 | ConnectClientReq ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 172 | -- identity of the client that is connecting to the server/bankd |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 173 | identity ComponentIdentity, |
Harald Welte | f1d7016 | 2018-10-11 12:56:00 +0200 | [diff] [blame] | 174 | 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] | 175 | ... |
| 176 | } |
| 177 | ConnectClientRes ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 178 | -- identity of the bankd/server to which the client is connecting |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 179 | identity ComponentIdentity, |
| 180 | result ResultCode, |
| 181 | ... |
| 182 | } |
| 183 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 184 | -- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 185 | CreateMappingReq ::= SEQUENCE { |
| 186 | client ClientSlot, |
| 187 | bank BankSlot, |
| 188 | ... |
| 189 | } |
| 190 | CreateMappingRes ::= SEQUENCE { |
| 191 | result ResultCode, |
| 192 | ... |
| 193 | } |
| 194 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 195 | -- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 196 | RemoveMappingReq ::= SEQUENCE { |
| 197 | client ClientSlot, |
| 198 | bank BankSlot, |
| 199 | ... |
| 200 | } |
| 201 | RemoveMappingRes ::= SEQUENCE { |
| 202 | result ResultCode, |
| 203 | ... |
| 204 | } |
| 205 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 206 | -- SERVER->CLIENT: set configuration (client ID and BANK IP/Port) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 207 | ConfigClientReq ::= SEQUENCE { |
| 208 | -- server-allocated assignment of a client ID |
Harald Welte | 371d026 | 2018-08-16 15:23:58 +0200 | [diff] [blame] | 209 | clientSlot ClientSlot, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 210 | -- bank to which the client shall connect |
| 211 | bankd IpPort, |
| 212 | ... |
| 213 | } |
| 214 | ConfigClientRes ::= SEQUENCE { |
| 215 | result ResultCode, |
| 216 | ... |
| 217 | } |
| 218 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 219 | -- 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] | 220 | SetAtrReq ::= SEQUENCE { |
| 221 | slot ClientSlot, |
| 222 | atr ATR, |
| 223 | ... |
| 224 | } |
| 225 | SetAtrRes ::= SEQUENCE { |
| 226 | result ResultCode, |
| 227 | ... |
| 228 | } |
| 229 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 230 | -- CLIENT->BANKD: TPDU in Modem -> Card direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 231 | TpduModemToCard ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 240 | -- BANKD->CLIENT: TPDU in Card -> Modem direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 241 | TpduCardToModem ::= 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 Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 250 | -- CLIENT->BANKD: indciation about the current status of a client (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 251 | ClientSlotStatusInd ::= SEQUENCE { |
| 252 | fromClientSlot ClientSlot, |
| 253 | toBankSlot BankSlot, |
| 254 | slotPhysStatus SlotPhysStatus, |
| 255 | ... |
| 256 | } |
| 257 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 258 | -- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 259 | BankSlotStatusInd ::= SEQUENCE { |
| 260 | fromBankSlot BankSlot, |
| 261 | toClientSlot ClientSlot, |
| 262 | slotPhysStatus SlotPhysStatus, |
| 263 | ... |
| 264 | } |
| 265 | |
| 266 | ---------------------------------------------------------------------- |
| 267 | -- PDU |
| 268 | ---------------------------------------------------------------------- |
| 269 | |
| 270 | RsproPDUchoice ::= 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 | |
| 292 | RsproPDU ::= SEQUENCE { |
Harald Welte | 293478c | 2018-09-24 14:49:41 +0200 | [diff] [blame] | 293 | version [0] INTEGER(0..32), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 294 | tag [1] OperationTag, |
| 295 | msg [2] RsproPDUchoice |
| 296 | } |
| 297 | |
| 298 | END |