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> |
| 4 | ---------------------------------------------------------------------- |
| 5 | |
| 6 | RSPRO {} DEFINITIONS |
| 7 | |
| 8 | IMPLICIT TAGS |
| 9 | |
| 10 | ::= |
| 11 | |
| 12 | BEGIN |
| 13 | |
| 14 | EXPORTS |
| 15 | RsproPDU |
| 16 | ; |
| 17 | |
| 18 | ---------------------------------------------------------------------- |
| 19 | -- Elementary Data Types |
| 20 | ---------------------------------------------------------------------- |
| 21 | |
| 22 | -- Some random ID the requestor can chose and which the client echos back in a response. |
| 23 | -- This allows multiple outstanding commands in flight and matching of responses to requests. |
| 24 | OperationTag ::= INTEGER(0..2147483647) |
| 25 | |
| 26 | -- Unique identifier of a given SIM bank |
| 27 | BankId ::= INTEGER(0..1023) |
| 28 | |
| 29 | -- Unique identifier of a given client (modem) |
| 30 | ClientId ::= INTEGER(0..1023) |
| 31 | |
| 32 | ComponentType ::= ENUMERATED { |
| 33 | -- client: Modems / Phones |
| 34 | remsimClient (0), |
| 35 | -- server: Coordination |
| 36 | remsimServer (1), |
| 37 | -- bank daemon: SIM cards |
| 38 | remsimBankd (2) |
| 39 | } |
| 40 | ComponentName ::= IA5String (SIZE (1..32)) |
| 41 | ComponentIdentity ::= SEQUENCE { |
| 42 | type ComponentType, |
| 43 | name ComponentName, |
| 44 | software [0] ComponentName, |
| 45 | swVersion [1] ComponentName, |
| 46 | hwManufacturer [2] ComponentName OPTIONAL, |
| 47 | hwModel [3] ComponentName OPTIONAL, |
| 48 | hwSerialNr [4] ComponentName OPTIONAL, |
| 49 | hwVersion [5] ComponentName OPTIONAL, |
| 50 | fwVersion [6] ComponentName OPTIONAL, |
| 51 | ... |
| 52 | } |
| 53 | |
| 54 | -- IP address / port details |
| 55 | Ipv4Address ::= OCTET STRING (SIZE (4)) |
| 56 | Ipv6Address ::= OCTET STRING (SIZE (16)) |
| 57 | IpAddress ::= CHOICE { |
| 58 | ipv4 [0] Ipv4Address, |
| 59 | ipv6 [1] Ipv6Address |
| 60 | } |
| 61 | PortNumber ::= INTEGER (0..65535) |
| 62 | IpPort ::= SEQUENCE { |
| 63 | ip IpAddress, |
| 64 | port PortNumber |
| 65 | } |
| 66 | |
| 67 | -- Result of a given operation |
| 68 | ResultCode ::= ENUMERATED { |
| 69 | ok (0), |
| 70 | -- client / bank / slot ID not accepted |
| 71 | illegalClientId (1), |
| 72 | illegalBankId (2), |
| 73 | illegalSlotId (3), |
| 74 | |
| 75 | -- no card is present in given slot |
| 76 | cardNotPresent (100), |
| 77 | -- card is present but unresponsive in given slot |
| 78 | cardUnresponsive (101), |
| 79 | -- unrecoverable transmission errors detected |
| 80 | cardTransmissionError (102), |
| 81 | ... |
| 82 | } |
| 83 | |
| 84 | -- Slot number within a SIM bank or a client. |
| 85 | SlotNumber ::= INTEGER(0..1023) |
| 86 | |
| 87 | -- Slot identity on client (modem) side |
| 88 | ClientSlot ::= SEQUENCE { |
| 89 | clientId ClientId, |
| 90 | slotNr SlotNumber, |
| 91 | ... |
| 92 | } |
| 93 | |
| 94 | -- Slot identity on SIM bank side |
| 95 | BankSlot ::= SEQUENCE { |
| 96 | bankId BankId, |
| 97 | slotNr SlotNumber, |
| 98 | ... |
| 99 | } |
| 100 | |
| 101 | ATR ::= OCTET STRING (SIZE (1..55)) |
| 102 | |
| 103 | -- flags related to a TPDU in either of the two directions |
| 104 | TpduFlags ::= SEQUENCE { |
| 105 | -- indicates a TPDU header is present in this message |
| 106 | tpduHeaderPresent BOOLEAN, |
| 107 | -- indicates last part of transmission in this direction |
| 108 | finalPart BOOLEAN, |
| 109 | -- indicates a PB is present and we should continue with TX |
| 110 | procByteContinueTx BOOLEAN, |
| 111 | -- indicates a PB is present and we should continue with RX |
| 112 | procByteContinueRx BOOLEAN, |
| 113 | ... |
| 114 | } |
| 115 | |
| 116 | --- physical state of a given slot |
| 117 | SlotPhysStatus ::= SEQUENCE { |
| 118 | -- is RST activated by the modem? |
| 119 | resetActive [0] BOOLEAN, |
| 120 | -- is VCC applied by the modem? |
| 121 | vccPresent [1] BOOLEAN OPTIONAL, |
| 122 | -- is CLK applied by the modem? |
| 123 | clkActive [2] BOOLEAN OPTIONAL, -- not all hardware supports this |
| 124 | -- is card presence signalled to the modem? |
| 125 | cardPresent [3] BOOLEAN OPTIONAL, |
| 126 | ... |
| 127 | } |
| 128 | |
| 129 | ---------------------------------------------------------------------- |
| 130 | -- Messages |
| 131 | ---------------------------------------------------------------------- |
| 132 | |
| 133 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 134 | -- BANKD->SERVER: SIM Bank connects to central server |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 135 | ConnectBankReq ::= SEQUENCE { |
| 136 | -- identity of the bank that is connecting to the server |
| 137 | identity ComponentIdentity, |
| 138 | -- bank number, pre-configured on bank side |
| 139 | bankId BankId, |
| 140 | numberOfSlots SlotNumber, |
| 141 | ... |
| 142 | } |
| 143 | ConnectBankRes ::= SEQUENCE { |
| 144 | -- identity of the server to which the bank is connecting |
| 145 | identity ComponentIdentity, |
| 146 | result ResultCode, |
| 147 | ... |
| 148 | } |
| 149 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 150 | -- CLIENT->SERVER or CLIENT->BANKD |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 151 | ConnectClientReq ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 152 | -- identity of the client that is connecting to the server/bankd |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 153 | identity ComponentIdentity, |
Harald Welte | f1d7016 | 2018-10-11 12:56:00 +0200 | [diff] [blame] | 154 | 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] | 155 | ... |
| 156 | } |
| 157 | ConnectClientRes ::= SEQUENCE { |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 158 | -- identity of the bankd/server to which the client is connecting |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 159 | identity ComponentIdentity, |
| 160 | result ResultCode, |
| 161 | ... |
| 162 | } |
| 163 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 164 | -- SERVER->BANKD: create a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 165 | CreateMappingReq ::= SEQUENCE { |
| 166 | client ClientSlot, |
| 167 | bank BankSlot, |
| 168 | ... |
| 169 | } |
| 170 | CreateMappingRes ::= SEQUENCE { |
| 171 | result ResultCode, |
| 172 | ... |
| 173 | } |
| 174 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 175 | -- SERVER->BANKD: remove a mapping between a given Bank:Slot <-> Client:Slot |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 176 | RemoveMappingReq ::= SEQUENCE { |
| 177 | client ClientSlot, |
| 178 | bank BankSlot, |
| 179 | ... |
| 180 | } |
| 181 | RemoveMappingRes ::= SEQUENCE { |
| 182 | result ResultCode, |
| 183 | ... |
| 184 | } |
| 185 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 186 | -- SERVER->CLIENT: set configuration (client ID and BANK IP/Port) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 187 | ConfigClientReq ::= SEQUENCE { |
| 188 | -- server-allocated assignment of a client ID |
Harald Welte | 371d026 | 2018-08-16 15:23:58 +0200 | [diff] [blame] | 189 | clientSlot ClientSlot, |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 190 | -- bank to which the client shall connect |
| 191 | bankd IpPort, |
| 192 | ... |
| 193 | } |
| 194 | ConfigClientRes ::= SEQUENCE { |
| 195 | result ResultCode, |
| 196 | ... |
| 197 | } |
| 198 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 199 | -- 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] | 200 | SetAtrReq ::= SEQUENCE { |
| 201 | slot ClientSlot, |
| 202 | atr ATR, |
| 203 | ... |
| 204 | } |
| 205 | SetAtrRes ::= SEQUENCE { |
| 206 | result ResultCode, |
| 207 | ... |
| 208 | } |
| 209 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 210 | -- CLIENT->BANKD: TPDU in Modem -> Card direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 211 | TpduModemToCard ::= SEQUENCE { |
| 212 | -- we include fully-qualified bank and client slots for easier debugging |
| 213 | fromClientSlot ClientSlot, |
| 214 | toBankSlot BankSlot, |
| 215 | flags TpduFlags, |
| 216 | data OCTET STRING, |
| 217 | ... |
| 218 | } |
| 219 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 220 | -- BANKD->CLIENT: TPDU in Card -> Modem direction |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 221 | TpduCardToModem ::= SEQUENCE { |
| 222 | -- we include fully-qualified bank and client slots for easier debugging |
| 223 | fromBankSlot BankSlot, |
| 224 | toClientSlot ClientSlot, |
| 225 | flags TpduFlags, |
| 226 | data OCTET STRING, |
| 227 | ... |
| 228 | } |
| 229 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 230 | -- CLIENT->BANKD: indciation about the current status of a client (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 231 | ClientSlotStatusInd ::= SEQUENCE { |
| 232 | fromClientSlot ClientSlot, |
| 233 | toBankSlot BankSlot, |
| 234 | slotPhysStatus SlotPhysStatus, |
| 235 | ... |
| 236 | } |
| 237 | |
Harald Welte | f0614df | 2018-08-16 14:45:23 +0200 | [diff] [blame] | 238 | -- BANKD->CLIENT: indciation about the current status of a bank (modem side) |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 239 | BankSlotStatusInd ::= SEQUENCE { |
| 240 | fromBankSlot BankSlot, |
| 241 | toClientSlot ClientSlot, |
| 242 | slotPhysStatus SlotPhysStatus, |
| 243 | ... |
| 244 | } |
| 245 | |
| 246 | ---------------------------------------------------------------------- |
| 247 | -- PDU |
| 248 | ---------------------------------------------------------------------- |
| 249 | |
| 250 | RsproPDUchoice ::= CHOICE { |
| 251 | -- configuration + management |
| 252 | connectBankReq [0] ConnectBankReq, |
| 253 | connectBankRes [1] ConnectBankRes, |
| 254 | connectClientReq [2] ConnectClientReq, |
| 255 | connectClientRes [3] ConnectClientRes, |
| 256 | createMappingReq [4] CreateMappingReq, |
| 257 | createMappingRes [5] CreateMappingRes, |
| 258 | removeMappingReq [6] RemoveMappingReq, |
| 259 | removeMappingRes [7] RemoveMappingRes, |
| 260 | configClientReq [8] ConfigClientReq, |
| 261 | configClientRes [9] ConfigClientRes, |
| 262 | -- APDUs etc. |
| 263 | setAtrReq [10] SetAtrReq, |
| 264 | setAtrRes [11] SetAtrRes, |
| 265 | tpduModemToCard [12] TpduModemToCard, |
| 266 | tpduCardToModem [13] TpduCardToModem, |
| 267 | clientSlotStatusInd [14] ClientSlotStatusInd, |
| 268 | bankSlotStatusInd [15] BankSlotStatusInd, |
| 269 | ... |
| 270 | } |
| 271 | |
| 272 | RsproPDU ::= SEQUENCE { |
Harald Welte | 293478c | 2018-09-24 14:49:41 +0200 | [diff] [blame] | 273 | version [0] INTEGER(0..32), |
Harald Welte | 3aa901d | 2018-08-13 18:32:36 +0200 | [diff] [blame] | 274 | tag [1] OperationTag, |
| 275 | msg [2] RsproPDUchoice |
| 276 | } |
| 277 | |
| 278 | END |