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), |
| 92 | |
| 93 | -- no card is present in given slot |
| 94 | cardNotPresent (100), |
| 95 | -- card is present but unresponsive in given slot |
| 96 | cardUnresponsive (101), |
| 97 | -- unrecoverable transmission errors detected |
| 98 | cardTransmissionError (102), |
| 99 | ... |
| 100 | } |
| 101 | |
| 102 | -- Slot number within a SIM bank or a client. |
| 103 | SlotNumber ::= INTEGER(0..1023) |
| 104 | |
| 105 | -- Slot identity on client (modem) side |
| 106 | ClientSlot ::= SEQUENCE { |
| 107 | clientId ClientId, |
| 108 | slotNr SlotNumber, |
| 109 | ... |
| 110 | } |
| 111 | |
| 112 | -- Slot identity on SIM bank side |
| 113 | BankSlot ::= SEQUENCE { |
| 114 | bankId BankId, |
| 115 | slotNr SlotNumber, |
| 116 | ... |
| 117 | } |
| 118 | |
| 119 | ATR ::= OCTET STRING (SIZE (1..55)) |
| 120 | |
| 121 | -- flags related to a TPDU in either of the two directions |
| 122 | TpduFlags ::= SEQUENCE { |
| 123 | -- indicates a TPDU header is present in this message |
| 124 | tpduHeaderPresent BOOLEAN, |
| 125 | -- indicates last part of transmission in this direction |
| 126 | finalPart BOOLEAN, |
| 127 | -- indicates a PB is present and we should continue with TX |
| 128 | procByteContinueTx BOOLEAN, |
| 129 | -- indicates a PB is present and we should continue with RX |
| 130 | procByteContinueRx BOOLEAN, |
| 131 | ... |
| 132 | } |
| 133 | |
| 134 | --- physical state of a given slot |
| 135 | SlotPhysStatus ::= SEQUENCE { |
| 136 | -- is RST activated by the modem? |
| 137 | resetActive [0] BOOLEAN, |
| 138 | -- is VCC applied by the modem? |
| 139 | vccPresent [1] BOOLEAN OPTIONAL, |
| 140 | -- is CLK applied by the modem? |
| 141 | clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this |
| 142 | -- is card presence signalled to the modem? |
| 143 | cardPresent [3] BOOLEAN OPTIONAL, |
| 144 | ... |
| 145 | } |
| 146 | |
| 147 | ---------------------------------------------------------------------- |
| 148 | -- Messages |
| 149 | ---------------------------------------------------------------------- |
| 150 | |
| 151 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 152 | -- BANKD->SERVER: SIM Bank connects to central server |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 153 | ConnectBankReq ::= SEQUENCE { |
| 154 | -- identity of the bank that is connecting to the server |
| 155 | identity ComponentIdentity, |
| 156 | -- bank number, pre-configured on bank side |
| 157 | bankId BankId, |
| 158 | numberOfSlots SlotNumber, |
| 159 | ... |
| 160 | } |
| 161 | ConnectBankRes ::= SEQUENCE { |
| 162 | -- identity of the server to which the bank is connecting |
| 163 | identity ComponentIdentity, |
| 164 | result ResultCode, |
| 165 | ... |
| 166 | } |
| 167 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 168 | -- CLIENT->SERVER or CLIENT->BANKD |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 169 | ConnectClientReq ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 170 | -- identity of the client that is connecting to the server/bankd |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 171 | identity ComponentIdentity, |
Harald Welte | f1d7016 | 2018-10-11 12:56:00 +0200 | [diff] [blame] | 172 | 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] | 173 | ... |
| 174 | } |
| 175 | ConnectClientRes ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 176 | -- identity of the bankd/server to which the client is connecting |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 177 | identity ComponentIdentity, |
| 178 | result ResultCode, |
| 179 | ... |
| 180 | } |
| 181 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 182 | -- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 183 | CreateMappingReq ::= SEQUENCE { |
| 184 | client ClientSlot, |
| 185 | bank BankSlot, |
| 186 | ... |
| 187 | } |
| 188 | CreateMappingRes ::= SEQUENCE { |
| 189 | result ResultCode, |
| 190 | ... |
| 191 | } |
| 192 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 193 | -- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 194 | RemoveMappingReq ::= SEQUENCE { |
| 195 | client ClientSlot, |
| 196 | bank BankSlot, |
| 197 | ... |
| 198 | } |
| 199 | RemoveMappingRes ::= SEQUENCE { |
| 200 | result ResultCode, |
| 201 | ... |
| 202 | } |
| 203 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 204 | -- SERVER->CLIENT: set configuration (client ID and BANK IP/Port) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 205 | ConfigClientReq ::= SEQUENCE { |
| 206 | -- server-allocated assignment of a client ID |
Harald Welte | 371d026 | 2018-08-16 15:23:58 +0200 | [diff] [blame] | 207 | clientSlot ClientSlot, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 208 | -- bank to which the client shall connect |
| 209 | bankd IpPort, |
| 210 | ... |
| 211 | } |
| 212 | ConfigClientRes ::= SEQUENCE { |
| 213 | result ResultCode, |
| 214 | ... |
| 215 | } |
| 216 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 217 | -- 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] | 218 | SetAtrReq ::= SEQUENCE { |
| 219 | slot ClientSlot, |
| 220 | atr ATR, |
| 221 | ... |
| 222 | } |
| 223 | SetAtrRes ::= SEQUENCE { |
| 224 | result ResultCode, |
| 225 | ... |
| 226 | } |
| 227 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 228 | -- CLIENT->BANKD: TPDU in Modem -> Card direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 229 | TpduModemToCard ::= SEQUENCE { |
| 230 | -- we include fully-qualified bank and client slots for easier debugging |
| 231 | fromClientSlot ClientSlot, |
| 232 | toBankSlot BankSlot, |
| 233 | flags TpduFlags, |
| 234 | data OCTET STRING, |
| 235 | ... |
| 236 | } |
| 237 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 238 | -- BANKD->CLIENT: TPDU in Card -> Modem direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 239 | TpduCardToModem ::= SEQUENCE { |
| 240 | -- we include fully-qualified bank and client slots for easier debugging |
| 241 | fromBankSlot BankSlot, |
| 242 | toClientSlot ClientSlot, |
| 243 | flags TpduFlags, |
| 244 | data OCTET STRING, |
| 245 | ... |
| 246 | } |
| 247 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 248 | -- CLIENT->BANKD: indciation about the current status of a client (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 249 | ClientSlotStatusInd ::= SEQUENCE { |
| 250 | fromClientSlot ClientSlot, |
| 251 | toBankSlot BankSlot, |
| 252 | slotPhysStatus SlotPhysStatus, |
| 253 | ... |
| 254 | } |
| 255 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 256 | -- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 257 | BankSlotStatusInd ::= SEQUENCE { |
| 258 | fromBankSlot BankSlot, |
| 259 | toClientSlot ClientSlot, |
| 260 | slotPhysStatus SlotPhysStatus, |
| 261 | ... |
| 262 | } |
| 263 | |
| 264 | ---------------------------------------------------------------------- |
| 265 | -- PDU |
| 266 | ---------------------------------------------------------------------- |
| 267 | |
| 268 | RsproPDUchoice ::= CHOICE { |
| 269 | -- configuration + management |
| 270 | connectBankReq [0] ConnectBankReq, |
| 271 | connectBankRes [1] ConnectBankRes, |
| 272 | connectClientReq [2] ConnectClientReq, |
| 273 | connectClientRes [3] ConnectClientRes, |
| 274 | createMappingReq [4] CreateMappingReq, |
| 275 | createMappingRes [5] CreateMappingRes, |
| 276 | removeMappingReq [6] RemoveMappingReq, |
| 277 | removeMappingRes [7] RemoveMappingRes, |
| 278 | configClientReq [8] ConfigClientReq, |
| 279 | configClientRes [9] ConfigClientRes, |
| 280 | -- APDUs etc. |
| 281 | setAtrReq [10] SetAtrReq, |
| 282 | setAtrRes [11] SetAtrRes, |
| 283 | tpduModemToCard [12] TpduModemToCard, |
| 284 | tpduCardToModem [13] TpduCardToModem, |
| 285 | clientSlotStatusInd [14] ClientSlotStatusInd, |
| 286 | bankSlotStatusInd [15] BankSlotStatusInd, |
| 287 | ... |
| 288 | } |
| 289 | |
| 290 | RsproPDU ::= SEQUENCE { |
Harald Welte | 293478c | 2018-09-24 14:49:41 +0200 | [diff] [blame] | 291 | version [0] INTEGER(0..32), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 292 | tag [1] OperationTag, |
| 293 | msg [2] RsproPDUchoice |
| 294 | } |
| 295 | |
| 296 | END |