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 /* Form 3GPP TS 27.007 V4.3.0 (2001-12) 8.18, + CRSM */ 28 typedef struct { 29 int32_t command; /* command passed on by the MT to the SIM; refer 3GPP TS 51.011 [28] 30 * 176 READ BINARY 31 * 178 READ RECORD 32 * 192 GET RESPONSE 33 * 214 UPDATE BINARY 34 * 220 UPDATE RECORD 35 * 242 STATUS 36 * 203 RETRIEVE DATA 37 * 219 SET DATA 38 */ 39 int32_t fileid; /* this is the identifier of an elementary datafile on SIM. 40 * Mandatory for every command except STATUS. */ 41 int32_t p1; /* parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 42 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. */ 43 int32_t p2; /* parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 44 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. */ 45 int32_t p3; /* parameters passed on by the MT to the SIM. These parameters are mandatory for every command, 46 * except GET RESPONSE and STATUS. The values are described in 3GPP TS 51.011 [28]. */ 47 char *data; /* information which shall be written to the SIM (hexadecimal character format; refer +CSCS). */ 48 char *pathid; /* contains the path of an elementary file on the SIM/UICC in hexadecimal format 49 * as defined in ETSI TS 102 221 [60] (e.g. "7F205F70" in SIM and UICC case). 50 * The <pathid> shall only be used in the mode "select by path from MF" 51 * as defined in ETSI TS 102 221 [60]. */ 52 char *pin2; 53 } HRilSimIO; 54 55 /* Form TS 27.007.8.18 +CRSM */ 56 typedef struct { 57 int32_t sw1; /* information from the SIM about the execution of the actual command. 58 * These parameters are delivered to the TE in both cases, 59 * on successful or failed execution of the command. */ 60 int32_t sw2; /* information from the SIM about the execution of the actual command. 61 * These parameters are delivered to the TE in both cases, 62 * on successful or failed execution of the command. */ 63 char *response; /* response of a successful completion of the command previously issued 64 * (hexadecimal character format; refer +CSCS). STATUS and GET RESPONSE return data, 65 * which gives information about the current elementary datafield.This information 66 * includes the type of file and its size (refer 3GPP TS 51.011 [28]). After READ BINARY, 67 * READ RECORD or RETRIEVE DATA command the requested data will be returned. 68 * <response> is not returned after a successful UPDATE BINARY, 69 * UPDATE RECORD or SET DATA command */ 70 } HRilSimIOResponse; 71 72 typedef struct { 73 int32_t sw1; /* information from the SIM about the execution of the actual command. 74 * These parameters are delivered to the TE in both cases, 75 * on successful or failed execution of the command. */ 76 int32_t sw2; /* information from the SIM about the execution of the actual command. 77 * These parameters are delivered to the TE in both cases, 78 * on successful or failed execution of the command. */ 79 int32_t channelId; 80 char *response; 81 } HRilOpenLogicalChannelResponse; 82 83 typedef struct { 84 int32_t index; /* sim index */ 85 HRilSimType simType; 86 HRilSimState simState; 87 } HRilCardState; 88 89 typedef struct { 90 int32_t result; 91 int32_t remain; 92 } HRilLockStatus; 93 94 /* From 3GPP TS 27.007 7.4 */ 95 typedef struct { 96 char *fac; /* ("SC","AO","OI","OX","AI","IR","AB","AG","AC","FD","PN","PU","PP") */ 97 int32_t mode; /* 0 unlock 98 * 1 lock 99 * 2 query status */ 100 int32_t status; /* 0 not active 101 * 1 active */ 102 char *passwd; /* shall be the same as password specified for the facility 103 * from the MT user interface or with command Change Password +CPWD */ 104 int32_t classx; /* is a sum of integers each representing a class of information (default 7 - voice, data and 105 * fax): 1 voice (telephony) 2 data (refers to all bearer services; with <mode>=2 this may refer 106 * only to some bearer service if TA does not support values 16, 32, 64 and 128) 4 fax (facsimile 107 * services) 8 short message service 16 data circuit sync 32 data circuit async 64 108 * dedicated packet access 128 dedicated PAD access */ 109 } HRilSimClock; 110 111 /* From 3GPP TS 27.007 7.5 */ 112 typedef struct { 113 char *fac; /* ("SC","AO","OI","OX","AI","IR","AB","AG","AC","FD","PN","PU","PP") */ 114 char *oldPassword; /* <oldPassword> shall be the same as password specified for the facility from the MT 115 * user interface or with command Change Password +CPWD and <newPassword> is the new 116 * password; maximum length of password can be determined with <passwordLength> */ 117 char *newPassword; 118 int32_t passwordLength; /* maximum length of the password for the facility */ 119 } HRilSimPassword; 120 121 typedef struct { 122 char *code; 123 int32_t times; 124 int32_t pukTimes; 125 int32_t pinTimes; 126 int32_t puk2Times; 127 int32_t pin2Times; 128 } HRilPinInputTimes; 129 130 typedef struct { 131 int32_t sessionId; 132 HRilRadioProtocolPhase phase; 133 int32_t technology; 134 int32_t modemId; 135 HRilRadioProtocolStatus status; 136 } HRilRadioProtocol; 137 138 typedef struct { 139 int32_t channelId; 140 int32_t type; 141 int32_t instruction; 142 int32_t p1; 143 int32_t p2; 144 int32_t p3; 145 char *data; 146 } HRilApduSimIO; 147 148 typedef struct { 149 int32_t serial; 150 char *aid; 151 char *data; 152 } HRilSimAuthenticationRequestInfo; 153 154 typedef struct { 155 void (*GetSimStatus)(const ReqDataInfo *requestInfo); 156 void (*GetSimIO)(const ReqDataInfo *requestInfo, const HRilSimIO *data, size_t dataLen); 157 void (*GetSimImsi)(const ReqDataInfo *requestInfo); 158 void (*GetSimLockStatus)(const ReqDataInfo *requestInfo, const HRilSimClock *data, size_t dataLen); 159 void (*SetSimLock)(const ReqDataInfo *requestInfo, const HRilSimClock *data, size_t dataLen); 160 void (*ChangeSimPassword)(const ReqDataInfo *requestInfo, const HRilSimPassword *data, size_t dataLen); 161 void (*UnlockPin)(const ReqDataInfo *requestInfo, const char *pin); 162 void (*UnlockPuk)(const ReqDataInfo *requestInfo, const char *puk, const char *pin); 163 void (*GetSimPinInputTimes)(const ReqDataInfo *requestInfo); 164 void (*UnlockPin2)(const ReqDataInfo *requestInfo, const char *pin2); 165 void (*UnlockPuk2)(const ReqDataInfo *requestInfo, const char *puk2, const char *pin2); 166 void (*GetSimPin2InputTimes)(const ReqDataInfo *requestInfo); 167 void (*SetActiveSim)(const ReqDataInfo *requestInfo, int32_t index, int32_t enable); 168 void (*SimStkSendTerminalResponse)(const ReqDataInfo *requestInfo, const char *strCmd); 169 void (*SimStkSendEnvelope)(const ReqDataInfo *requestInfo, const char *strCmd); 170 void (*SimStkSendCallSetupRequestResult)(const ReqDataInfo *requestInfo, int32_t accept); 171 void (*SimStkIsReady)(const ReqDataInfo *requestInfo); 172 void (*GetRadioProtocol)(const ReqDataInfo *requestInfo); 173 void (*SetRadioProtocol)(const ReqDataInfo *requestInfo, const HRilRadioProtocol *data); 174 void (*SimOpenLogicalChannel)(const ReqDataInfo *requestInfo, const char *appID, int32_t p2); 175 void (*SimCloseLogicalChannel)(const ReqDataInfo *requestInfo, int32_t channelId); 176 void (*SimTransmitApduLogicalChannel)(const ReqDataInfo *requestInfo, HRilApduSimIO *data, size_t dataLen); 177 void (*SimTransmitApduBasicChannel)(const ReqDataInfo *requestInfo, HRilApduSimIO *data, size_t dataLen); 178 void (*SimAuthentication)(const ReqDataInfo *requestInfo, HRilSimAuthenticationRequestInfo *data, size_t dataLen); 179 void (*UnlockSimLock)(const ReqDataInfo *requestInfo, int32_t lockType, const char *password); 180 } HRilSimReq; 181 #ifdef __cplusplus 182 } 183 #endif 184 #endif // OHOS_RIL_VENDOR_SIM_DEFS_H 185