1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_RIL_VENDOR_SIM_DEFS_H 17 #define OHOS_RIL_VENDOR_SIM_DEFS_H 18 19 #include <stddef.h> 20 21 #include "hril_public_struct.h" 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /** 28 * @brief Defines the SIM data request information. 29 * 30 * Form 3GPP TS 27.007 V4.3.0 (2001-12) 8.18, + CRSM 31 */ 32 typedef struct { 33 /** 34 * Command passed on by the MT to the SIM; refer 3GPP TS 51.011 [28] 35 * 176 READ BINARY 36 * 178 READ RECORD 37 * 192 GET RESPONSE 38 * 214 UPDATE BINARY 39 * 220 UPDATE RECORD 40 * 242 STATUS 41 * 203 RETRIEVE DATA 42 * 219 SET DATA 43 */ 44 int32_t command; 45 /** 46 * This is the identifier of an elementary datafile on SIM. 47 * Mandatory for every command except STATUS. 48 */ 49 int32_t fileid; 50 /** 51 * Parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 52 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. 53 */ 54 int32_t p1; 55 /** 56 * Parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 57 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. 58 */ 59 int32_t p2; 60 /** 61 * Parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 62 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. 63 */ 64 int32_t p3; 65 /** 66 * Information which shall be written to the SIM (hexadecimal character format; refer +CSCS). 67 */ 68 char *data; 69 /** 70 * Contains the path of an elementary file on the SIM/UICC in hexadecimal format 71 * as defined in ETSI TS 102 221 [60] (e.g. "7F205F70" in SIM and UICC case). 72 * The <pathid> shall only be used in the mode "select by path from MF" 73 * as defined in ETSI TS 102 221 [60]. 74 */ 75 char *pathid; 76 /** 77 * PIN2 78 */ 79 char *pin2; 80 } HRilSimIO; 81 82 /** 83 * @brief Defines the response to the SIM data request. 84 * 85 * Form TS 27.007.8.18 +CRSM 86 */ 87 typedef struct { 88 /** 89 * Information from the SIM about the execution of the actual command. 90 * These parameters are delivered to the TE in both cases, 91 * on successful or failed execution of the command. 92 */ 93 int32_t sw1; 94 /** 95 * Information from the SIM about the execution of the actual command. 96 * These parameters are delivered to the TE in both cases, 97 * on successful or failed execution of the command. 98 */ 99 int32_t sw2; 100 /** 101 * Response of a successful completion of the command previously issued 102 * (hexadecimal character format; refer +CSCS). STATUS and GET RESPONSE return data, 103 * which gives information about the current elementary datafield.This information 104 * includes the type of file and its size (refer 3GPP TS 51.011 [28]). After READ BINARY, 105 * READ RECORD or RETRIEVE DATA command the requested data will be returned. 106 * <response> is not returned after a successful UPDATE BINARY, 107 * UPDATE RECORD or SET DATA command 108 */ 109 char *response; 110 } HRilSimIOResponse; 111 112 /** 113 * @brief Defines the response to the request for enabling the logical channel of the APDU. 114 */ 115 typedef struct { 116 /** 117 * Information from the SIM about the execution of the actual command. 118 * These parameters are delivered to the TE in both cases, 119 * on successful or failed execution of the command. 120 */ 121 int32_t sw1; 122 /** 123 * Information from the SIM about the execution of the actual command. 124 * These parameters are delivered to the TE in both cases, 125 * on successful or failed execution of the command. 126 */ 127 int32_t sw2; 128 /** 129 * ID of the opened logical channel 130 */ 131 int32_t channelId; 132 /** 133 * Response information 134 */ 135 char *response; 136 } HRilOpenLogicalChannelResponse; 137 138 /** 139 * @brief Defines the SIM card status information. 140 */ 141 typedef struct { 142 /** 143 * SIM card index 144 */ 145 int32_t index; 146 /** 147 * SIM card type: 148 */ 149 HRilSimType simType; 150 /** 151 * SIM card status: 152 */ 153 HRilSimState simState; 154 } HRilCardState; 155 156 /** 157 * @brief Defines the lock status information. 158 */ 159 typedef struct { 160 /** 161 * Query result. For details, see {@link RilErrType}. 162 */ 163 int32_t result; 164 /** 165 * Number of remaining attempts 166 */ 167 int32_t remain; 168 } HRilLockStatus; 169 170 /** 171 * @brief Defines the SIM card lock information. 172 * 173 * From 3GPP TS 27.007 7.4 174 */ 175 typedef struct { 176 /** 177 * ("SC","AO","OI","OX","AI","IR","AB","AG","AC","FD","PN","PU","PP") 178 */ 179 char *fac; 180 /** 181 * 0 unlock 182 * 1 lock 183 * 2 query status 184 */ 185 int32_t mode; 186 /** 187 * 0 not active 188 * 1 active 189 */ 190 int32_t status; 191 /** 192 * Shall be the same as password specified for the facility 193 * from the MT user interface or with command Change Password +CPWD 194 */ 195 char *passwd; 196 /** 197 * Is a sum of integers each representing a class of information (default 7 - voice, data and 198 * fax): 1 voice (telephony) 2 data (refers to all bearer services; with <mode>=2 this may refer 199 * only to some bearer service if TA does not support values 16, 32, 64 and 128) 4 fax (facsimile 200 * services) 8 short message service 16 data circuit sync 32 data circuit async 64 201 * dedicated packet access 128 dedicated PAD access 202 */ 203 int32_t classx; 204 } HRilSimClock; 205 206 /** 207 * @brief Defines the SIM card password information. 208 * 209 * From 3GPP TS 27.007 7.5 210 */ 211 typedef struct { 212 /** 213 * ("SC","AO","OI","OX","AI","IR","AB","AG","AC","FD","PN","PU","PP") 214 */ 215 char *fac; 216 /** 217 * <oldPassword> shall be the same as password specified for the facility from the MT 218 * user interface or with command Change Password +CPWD and <newPassword> is the new 219 * password 220 */ 221 char *oldPassword; 222 char *newPassword; 223 /** 224 * Maximum length of the password for the facility 225 */ 226 int32_t passwordLength; 227 } HRilSimPassword; 228 229 /** 230 * @brief Defines the maximum number of SIM password attempts. 231 */ 232 typedef struct { 233 char *code; 234 /** 235 * Number of remaining password attempts 236 */ 237 int32_t times; 238 /** 239 * Number of remaining PUK attempts 240 */ 241 int32_t pukTimes; 242 /** 243 * Number of remaining PIN attempts 244 */ 245 int32_t pinTimes; 246 /** 247 * Number of remaining PUK2 attempts 248 */ 249 int32_t puk2Times; 250 /** 251 * Number of remaining PIN2 attempts 252 */ 253 int32_t pin2Times; 254 } HRilPinInputTimes; 255 256 /** 257 * @brief Enumerates radio protocol phases. 258 */ 259 typedef struct { 260 /** 261 * Session ID 262 */ 263 int32_t sessionId; 264 /** 265 * Radio protocol parameters. 266 */ 267 HRilRadioProtocolPhase phase; 268 /** 269 * Radio protocol technology: 270 */ 271 int32_t technology; 272 /** 273 * Modem ID, corresponding to slotId at the bottom layer 274 */ 275 int32_t modemId; 276 /** 277 * Radio protocol status. 278 */ 279 HRilRadioProtocolStatus status; 280 } HRilRadioProtocol; 281 282 /** 283 * @brief Defines the APDU data transmission request information. 284 */ 285 typedef struct { 286 /** 287 * Channel ID 288 */ 289 int32_t channelId; 290 /** 291 * APDU instruction type. For details, see ETSI 102 221 [55]. 292 */ 293 int32_t type; 294 /** 295 * APDU instruction. For details, see ETSI 102 221 [55]. 296 */ 297 int32_t instruction; 298 /** 299 * Command parameter 1 of the SIM data request. For details, see 3GPP TS 51.011[28]. 300 */ 301 int32_t p1; 302 /** 303 * Command parameter 2 of the SIM data request. For details, see 3GPP TS 51.011[28]. 304 */ 305 int32_t p2; 306 /** 307 * Command parameter 3 of the SIM data request. For details, see 3GPP TS 51.011[28]. 308 * If p3 is a negative value, a 4-byte APDU is sent to the SIM card. 309 */ 310 int32_t p3; 311 /** 312 * Data to be transmitted 313 */ 314 char *data; 315 } HRilApduSimIO; 316 317 /** 318 * @brief Defines the SIM card authentication request information. 319 */ 320 typedef struct { 321 /** 322 * Request SN 323 */ 324 int32_t serial; 325 /** 326 * App ID 327 */ 328 char *aid; 329 /** 330 * Authentication data 331 */ 332 char *data; 333 } HRilSimAuthenticationRequestInfo; 334 335 typedef struct { 336 void (*GetSimStatus)(const ReqDataInfo *requestInfo); 337 void (*GetSimIO)(const ReqDataInfo *requestInfo, const HRilSimIO *data, size_t dataLen); 338 void (*GetSimImsi)(const ReqDataInfo *requestInfo); 339 void (*GetSimLockStatus)(const ReqDataInfo *requestInfo, const HRilSimClock *data, size_t dataLen); 340 void (*SetSimLock)(const ReqDataInfo *requestInfo, const HRilSimClock *data, size_t dataLen); 341 void (*ChangeSimPassword)(const ReqDataInfo *requestInfo, const HRilSimPassword *data, size_t dataLen); 342 void (*UnlockPin)(const ReqDataInfo *requestInfo, const char *pin); 343 void (*UnlockPuk)(const ReqDataInfo *requestInfo, const char *puk, const char *pin); 344 void (*GetSimPinInputTimes)(const ReqDataInfo *requestInfo); 345 void (*UnlockPin2)(const ReqDataInfo *requestInfo, const char *pin2); 346 void (*UnlockPuk2)(const ReqDataInfo *requestInfo, const char *puk2, const char *pin2); 347 void (*GetSimPin2InputTimes)(const ReqDataInfo *requestInfo); 348 void (*SetActiveSim)(const ReqDataInfo *requestInfo, int32_t index, int32_t enable); 349 void (*SimStkSendTerminalResponse)(const ReqDataInfo *requestInfo, const char *strCmd); 350 void (*SimStkSendEnvelope)(const ReqDataInfo *requestInfo, const char *strCmd); 351 void (*SimStkSendEnvelopeResponseContainStatus)(const ReqDataInfo *requestInfo, const char *strCmd); 352 void (*SimStkSendCallSetupRequestResult)(const ReqDataInfo *requestInfo, int32_t accept); 353 void (*SimStkIsReady)(const ReqDataInfo *requestInfo); 354 void (*GetRadioProtocol)(const ReqDataInfo *requestInfo); 355 void (*SetRadioProtocol)(const ReqDataInfo *requestInfo, const HRilRadioProtocol *data); 356 void (*SimOpenLogicalChannel)(const ReqDataInfo *requestInfo, const char *appID, int32_t p2); 357 void (*SimCloseLogicalChannel)(const ReqDataInfo *requestInfo, int32_t channelId); 358 void (*SimTransmitApduLogicalChannel)(const ReqDataInfo *requestInfo, HRilApduSimIO *data, size_t dataLen); 359 void (*SimTransmitApduBasicChannel)(const ReqDataInfo *requestInfo, HRilApduSimIO *data, size_t dataLen); 360 void (*SimAuthentication)(const ReqDataInfo *requestInfo, HRilSimAuthenticationRequestInfo *data, size_t dataLen); 361 void (*UnlockSimLock)(const ReqDataInfo *requestInfo, int32_t lockType, const char *password); 362 } HRilSimReq; 363 #ifdef __cplusplus 364 } 365 #endif 366 #endif // OHOS_RIL_VENDOR_SIM_DEFS_H 367