mirror of
https://github.com/openharmony/security_deviceauth.git
synced 2026-07-18 14:44:51 -04:00
fix: 解决Werror编译中,int和int32_t不兼容的问题
close #I4QWQF Signed-off-by: SimonLi <likailong@huawei.com>
This commit is contained in:
@@ -211,7 +211,7 @@ int32_t GetByteFromJson(const CJson *jsonObj, const char *key, uint8_t *byte, ui
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int *value)
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int32_t *value)
|
||||
{
|
||||
if (jsonObj == NULL || key == NULL || value == NULL) {
|
||||
return CLIB_ERR_NULL_PTR;
|
||||
|
||||
@@ -81,7 +81,7 @@ const char *GetStringFromJson(const CJson *jsonObj, const char *key);
|
||||
* This function will convert the hex string to byte, and then put it in param--byte in the form of byte.
|
||||
*/
|
||||
int32_t GetByteFromJson(const CJson *jsonObj, const char *key, uint8_t *byte, uint32_t len);
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int *value);
|
||||
int32_t GetIntFromJson(const CJson *jsonObj, const char *key, int32_t *value);
|
||||
int32_t GetInt64FromJson(const CJson *jsonObj, const char *key, int64_t *value);
|
||||
int32_t GetBoolFromJson(const CJson *jsonObj, const char *key, bool *value);
|
||||
char *GetStringValue(const CJson *item);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
typedef struct SubTaskBaseT {
|
||||
int (*getTaskType)(const struct SubTaskBaseT *);
|
||||
void (*destroyTask)(struct SubTaskBaseT *);
|
||||
int (*process)(struct SubTaskBaseT *, const CJson *in, CJson *out, int *status);
|
||||
int (*process)(struct SubTaskBaseT *, const CJson *in, CJson *out, int32_t *status);
|
||||
VersionStruct curVersion;
|
||||
} SubTaskBase;
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
typedef struct DasAuthModuleT {
|
||||
AuthModuleBase moduleBase;
|
||||
int (*registerLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int (*unregisterLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int (*deletePeerAuthInfo)(const char *, const char *, Uint8Buff *, int);
|
||||
int32_t (*registerLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int32_t (*unregisterLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int32_t (*deletePeerAuthInfo)(const char *, const char *, Uint8Buff *, int);
|
||||
} DasAuthModule;
|
||||
|
||||
bool IsDasSupported(void);
|
||||
|
||||
@@ -27,11 +27,11 @@ typedef struct TaskT {
|
||||
int taskId;
|
||||
VersionInfo versionInfo;
|
||||
void(*destroyTask)(struct TaskT *);
|
||||
int(*processTask)(struct TaskT *, const CJson *in, CJson *out, int *status);
|
||||
int(*processTask)(struct TaskT *, const CJson *in, CJson *out, int32_t *status);
|
||||
SubTaskVec vec;
|
||||
} Task;
|
||||
|
||||
Task *CreateTaskT(int *taskId, const CJson *in, CJson *out);
|
||||
Task *CreateTaskT(int32_t *taskId, const CJson *in, CJson *out);
|
||||
|
||||
int32_t InitDasProtocolEntities(void);
|
||||
void DestroyDasProtocolEntities(void);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
typedef struct TokenManagerT {
|
||||
int (*registerLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int (*unregisterLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int (*deletePeerAuthInfo)(const char *, const char *, Uint8Buff *, int);
|
||||
int32_t (*unregisterLocalIdentity)(const char *, const char *, Uint8Buff *, int);
|
||||
int32_t (*deletePeerAuthInfo)(const char *, const char *, Uint8Buff *, int);
|
||||
int (*computeAndSavePsk)(const PakeParams *);
|
||||
} TokenManager;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ typedef enum {
|
||||
} VersionAgreementStatus;
|
||||
|
||||
typedef struct VersionInfoT {
|
||||
int opCode;
|
||||
int32_t opCode;
|
||||
VersionAgreementStatus versionStatus;
|
||||
VersionStruct minVersion;
|
||||
VersionStruct curVersion;
|
||||
@@ -57,4 +57,4 @@ ProtocolType GetPrototolType(VersionStruct *curVersion, OperationCode opCode);
|
||||
PakeAlgType GetSupportedPakeAlg(VersionStruct *curVersion, ProtocolType protocolType);
|
||||
bool IsSupportedPsk(VersionStruct *curVersion);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -42,12 +42,12 @@ typedef struct IsoParamsT {
|
||||
IsoBaseParams baseParams;
|
||||
|
||||
Uint8Buff seed;
|
||||
int selfUserType;
|
||||
int peerUserType;
|
||||
int32_t selfUserType;
|
||||
int32_t peerUserType;
|
||||
char *packageName;
|
||||
char *serviceType;
|
||||
char *pinCodeString;
|
||||
int opCode;
|
||||
int32_t opCode;
|
||||
uint32_t keyLen;
|
||||
bool isClient;
|
||||
} IsoParams;
|
||||
@@ -55,7 +55,7 @@ typedef struct IsoParamsT {
|
||||
typedef struct SymBaseCurTaskT {
|
||||
CurTaskType (*getCurTaskType)(void);
|
||||
void (*destroyTask)(struct SymBaseCurTaskT *);
|
||||
int(*process)(struct SymBaseCurTaskT *, IsoParams *params, const CJson *in, CJson *out, int *status);
|
||||
int(*process)(struct SymBaseCurTaskT *, IsoParams *params, const CJson *in, CJson *out, int32_t *status);
|
||||
int taskStatus;
|
||||
} SymBaseCurTask;
|
||||
|
||||
|
||||
+1
-1
@@ -23,6 +23,6 @@ typedef struct {
|
||||
uint8_t challenge[CHALLENGE_SIZE];
|
||||
} IsoClientBindExchangeTask;
|
||||
|
||||
SymBaseCurTask *CreateClientBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status);
|
||||
SymBaseCurTask *CreateClientBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ typedef struct {
|
||||
SymBaseCurTask taskBase;
|
||||
} IsoClientUnbindExchangeTask;
|
||||
|
||||
SymBaseCurTask *CreateClientUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status);
|
||||
SymBaseCurTask *CreateClientUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ typedef struct {
|
||||
SymBaseCurTask taskBase;
|
||||
} IsoServerBindExchangeTask;
|
||||
|
||||
SymBaseCurTask *CreateServerBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status);
|
||||
SymBaseCurTask *CreateServerBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status);
|
||||
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -22,6 +22,6 @@ typedef struct {
|
||||
SymBaseCurTask taskBase;
|
||||
} IsoServerUnbindExchangeTask;
|
||||
|
||||
SymBaseCurTask *CreateServerUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status);
|
||||
SymBaseCurTask *CreateServerUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@ typedef struct PakeParamsT {
|
||||
bool isPskSupported;
|
||||
Uint8Buff returnKey;
|
||||
Uint8Buff nonce;
|
||||
int opCode;
|
||||
int32_t opCode;
|
||||
int32_t userType;
|
||||
int32_t userTypePeer;
|
||||
char *packageName;
|
||||
|
||||
@@ -46,8 +46,8 @@ static int32_t DeleteDasPeerAuthInfo(const char *pkgName, const char *serviceTyp
|
||||
|
||||
bool IsDasMsgNeedIgnore(const CJson *in)
|
||||
{
|
||||
uint32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, (int *)&message) != HC_SUCCESS) {
|
||||
int32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, &message) != HC_SUCCESS) {
|
||||
LOGD("There is no message code."); // There is no message code in the client's createTask request params
|
||||
return false;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ bool IsDasMsgNeedIgnore(const CJson *in)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int CreateDasTask(int *taskId, const CJson *in, CJson *out)
|
||||
static int CreateDasTask(int32_t *taskId, const CJson *in, CJson *out)
|
||||
{
|
||||
if (taskId == NULL || in == NULL || out == NULL) {
|
||||
LOGE("Params is null.");
|
||||
@@ -94,7 +94,7 @@ static void DestroyDasModule(AuthModuleBase *module)
|
||||
}
|
||||
}
|
||||
|
||||
static int ProcessDasTask(int taskId, const CJson* in, CJson* out, int *status)
|
||||
static int ProcessDasTask(int32_t taskId, const CJson* in, CJson* out, int32_t *status)
|
||||
{
|
||||
if (status == NULL || in == NULL || out == NULL) {
|
||||
LOGE("Params is null.");
|
||||
|
||||
@@ -104,8 +104,8 @@ void DasSendErrMsgToSelf(CJson *out, int errCode)
|
||||
|
||||
uint32_t ProtocolMessageIn(const CJson *in)
|
||||
{
|
||||
uint32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, (int *)&message) != 0) {
|
||||
int32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, &message) != 0) {
|
||||
return INVALID_MESSAGE;
|
||||
}
|
||||
if (message == ERR_MESSAGE) {
|
||||
@@ -438,7 +438,7 @@ int32_t GetAndCheckKeyLenOnServer(const CJson *in, uint32_t *keyLen)
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
uint32_t tmpKeyLen = 0;
|
||||
if (GetIntFromJson(payload, FIELD_KEY_LENGTH, (int *)&tmpKeyLen) != HC_SUCCESS) {
|
||||
if (GetIntFromJson(payload, FIELD_KEY_LENGTH, (int32_t *)&tmpKeyLen) != HC_SUCCESS) {
|
||||
LOGE("Get tmpKeyLen from payload failed.");
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ static void DestroyTaskT(Task *task)
|
||||
HcFree(task);
|
||||
}
|
||||
|
||||
static int ProcessMultiTask(Task *task, const CJson *in, CJson *out, int *status)
|
||||
static int ProcessMultiTask(Task *task, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint32_t index;
|
||||
@@ -175,7 +175,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int NegotiateAndProcessTask(Task *task, const CJson *in, CJson *out, int *status)
|
||||
static int NegotiateAndProcessTask(Task *task, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
VersionStruct curVersionPeer = { 0, 0, 0 };
|
||||
VersionStruct minVersionPeer = { 0, 0, 0 };
|
||||
@@ -224,7 +224,7 @@ static int NegotiateAndProcessTask(Task *task, const CJson *in, CJson *out, int
|
||||
|
||||
static bool IsPeerErrMessage(const CJson *in, int32_t *res)
|
||||
{
|
||||
int message = 0;
|
||||
int32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, &message) != HC_SUCCESS) {
|
||||
LOGD("There is no message code.");
|
||||
return false;
|
||||
@@ -239,9 +239,9 @@ static bool IsPeerErrMessage(const CJson *in, int32_t *res)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int ProcessTaskT(Task *task, const CJson *in, CJson *out, int *status)
|
||||
static int ProcessTaskT(Task *task, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
int32_t res;
|
||||
if (IsPeerErrMessage(in, &res)) {
|
||||
LOGE("Receive error message from peer, errCode: %x.", res);
|
||||
DasSendErrMsgToSelf(out, HC_ERR_PEER_ERROR);
|
||||
@@ -351,7 +351,7 @@ static int CreateSingleSubTask(Task *task, const CJson *in)
|
||||
return HC_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
Task *CreateTaskT(int *taskId, const CJson *in, CJson *out)
|
||||
Task *CreateTaskT(int32_t *taskId, const CJson *in, CJson *out)
|
||||
{
|
||||
int res;
|
||||
Task *task = NULL;
|
||||
|
||||
@@ -44,7 +44,7 @@ static void DestroyIsoClientTask(struct SubTaskBaseT *task)
|
||||
HcFree(innerTask);
|
||||
}
|
||||
|
||||
static int CreateNextTask(IsoClientTask *realTask, const CJson *in, CJson *out, int *status)
|
||||
static int CreateNextTask(IsoClientTask *realTask, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res = HC_SUCCESS;
|
||||
switch (realTask->params.opCode) {
|
||||
@@ -90,7 +90,7 @@ static int CreateNextTask(IsoClientTask *realTask, const CJson *in, CJson *out,
|
||||
return res;
|
||||
}
|
||||
|
||||
static int Process(struct SubTaskBaseT *task, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SubTaskBaseT *task, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoClientTask *realTask = (IsoClientTask *)task;
|
||||
if (realTask->curTask == NULL) {
|
||||
|
||||
+5
-5
@@ -77,7 +77,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int IsoClientStart(SymBaseCurTask *task, IsoParams *params, CJson *out, int *status)
|
||||
static int IsoClientStart(SymBaseCurTask *task, IsoParams *params, CJson *out, int32_t *status)
|
||||
{
|
||||
if (task->taskStatus != TASK_STATUS_BEGIN) {
|
||||
LOGI("The message is repeated, ignore it, status: %d", task->taskStatus);
|
||||
@@ -149,7 +149,7 @@ static int ParseServerStartMessage(IsoParams *params, const CJson *in, Uint8Buff
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
static int CalculateTokenClient(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int CalculateTokenClient(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
if (task->taskStatus < TASK_STATUS_SERVER_RES_TOKEN) {
|
||||
@@ -199,7 +199,7 @@ static int CalculateTokenClient(SymBaseCurTask *task, IsoParams *params, const C
|
||||
return res;
|
||||
}
|
||||
|
||||
static int GenerateSessionKey(SymBaseCurTask *task, IsoParams *params, const CJson *in, int *status)
|
||||
static int GenerateSessionKey(SymBaseCurTask *task, IsoParams *params, const CJson *in, int32_t *status)
|
||||
{
|
||||
if (task->taskStatus < TASK_STATUS_GEN_SESSION_KEY) {
|
||||
LOGE("Invalid taskStatus: %d", task->taskStatus);
|
||||
@@ -238,7 +238,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint32_t step = ProtocolMessageIn(in);
|
||||
@@ -285,4 +285,4 @@ SymBaseCurTask *CreateProtocolClientTask(void)
|
||||
task->taskBase.process = Process;
|
||||
task->taskBase.getCurTaskType = GetTaskType;
|
||||
return (SymBaseCurTask *)task;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -72,7 +72,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int IsoServerStart(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int IsoServerStart(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
if (task->taskStatus != TASK_STATUS_BEGIN) {
|
||||
LOGI("The message is repeated, ignore it, status: %d", task->taskStatus);
|
||||
@@ -151,7 +151,8 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int CalTokenAndGenSessionKey(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int CalTokenAndGenSessionKey(SymBaseCurTask *task, IsoParams *params, const CJson *in, CJson *out,
|
||||
int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint8_t *peerToken = NULL;
|
||||
@@ -207,7 +208,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint32_t step = ProtocolMessageIn(in);
|
||||
@@ -249,4 +250,4 @@ SymBaseCurTask *CreateProtocolServerTask()
|
||||
task->taskBase.process = Process;
|
||||
task->taskBase.getCurTaskType = GetTaskType;
|
||||
return (SymBaseCurTask *)task;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ static void DestroyIsoServerTask(struct SubTaskBaseT *task)
|
||||
HcFree(innerTask);
|
||||
}
|
||||
|
||||
static int CreateNextTask(IsoServerTask *realTask, const CJson *in, CJson *out, int *status)
|
||||
static int CreateNextTask(IsoServerTask *realTask, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int message = 0;
|
||||
int32_t message = 0;
|
||||
if (GetIntFromJson(in, FIELD_MESSAGE, &message) != 0) {
|
||||
LOGE("Get message code failed.");
|
||||
return HC_ERR_JSON_GET;
|
||||
@@ -97,7 +97,7 @@ static int CreateNextTask(IsoServerTask *realTask, const CJson *in, CJson *out,
|
||||
return res;
|
||||
}
|
||||
|
||||
static int Process(struct SubTaskBaseT *task, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SubTaskBaseT *task, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoServerTask *realTask = (IsoServerTask *)task;
|
||||
if (realTask->curTask != NULL) {
|
||||
|
||||
@@ -437,7 +437,7 @@ static int32_t GetKeyLength(IsoParams *params, const CJson *in)
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
if (GetIntFromJson(in, FIELD_KEY_LENGTH, (int *)&(params->keyLen)) != 0) {
|
||||
if (GetIntFromJson(in, FIELD_KEY_LENGTH, (int32_t *)&(params->keyLen)) != 0) {
|
||||
LOGD("Get key length failed, use default.");
|
||||
params->keyLen = DEFAULT_RETURN_KEY_LENGTH;
|
||||
}
|
||||
@@ -616,4 +616,4 @@ ERR:
|
||||
HcFree(random);
|
||||
HcFree(input);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -121,7 +121,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoClientBindExchangeTask *realTask = (IsoClientBindExchangeTask *)task;
|
||||
if (realTask->taskBase.taskStatus < TASK_TYPE_BEGIN) {
|
||||
@@ -135,7 +135,7 @@ static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
int res;
|
||||
int message = 0;
|
||||
int32_t message = 0;
|
||||
res = GetIntFromJson(in, FIELD_MESSAGE, &message);
|
||||
if (res != 0 || message != ISO_SERVER_BIND_EXCHANGE_RET) {
|
||||
return HC_ERR_BAD_MESSAGE;
|
||||
@@ -192,7 +192,8 @@ static int ClientBindAesEncrypt(IsoClientBindExchangeTask *task, const IsoParams
|
||||
return res;
|
||||
}
|
||||
|
||||
static int ClientBindExchangeStart(const IsoParams *params, IsoClientBindExchangeTask *task, CJson *out, int *status)
|
||||
static int ClientBindExchangeStart(const IsoParams *params, IsoClientBindExchangeTask *task, CJson *out,
|
||||
int32_t *status)
|
||||
{
|
||||
uint8_t *nonce = NULL;
|
||||
uint8_t *encData = NULL;
|
||||
@@ -232,7 +233,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
SymBaseCurTask *CreateClientBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
SymBaseCurTask *CreateClientBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
(void)in;
|
||||
IsoClientBindExchangeTask *task = (IsoClientBindExchangeTask *)HcMalloc(sizeof(IsoClientBindExchangeTask), 0);
|
||||
|
||||
+5
-5
@@ -33,7 +33,7 @@ static void DestroyClientUnbindExchangeTask(struct SymBaseCurTaskT *task)
|
||||
HcFree(task);
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoClientUnbindExchangeTask *realTask = (IsoClientUnbindExchangeTask *)task;
|
||||
if (realTask->taskBase.taskStatus < TASK_TYPE_BEGIN) {
|
||||
@@ -48,7 +48,7 @@ static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson
|
||||
}
|
||||
int res;
|
||||
uint8_t *keyAlias = NULL;
|
||||
int message = 0;
|
||||
int32_t message = 0;
|
||||
res = GetIntFromJson(in, FIELD_MESSAGE, &message);
|
||||
if (res != 0 || message != ISO_SERVER_UNBIND_EXCHANGE_RET) {
|
||||
return HC_ERR_BAD_MESSAGE;
|
||||
@@ -167,7 +167,7 @@ ERR:
|
||||
|
||||
|
||||
static int ClientUnbindExchangeStart(const IsoParams *params, IsoClientUnbindExchangeTask *task, CJson *out,
|
||||
int *status)
|
||||
int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint8_t *nonce = NULL;
|
||||
@@ -196,7 +196,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
SymBaseCurTask *CreateClientUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
SymBaseCurTask *CreateClientUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
(void)in;
|
||||
IsoClientUnbindExchangeTask *task = (IsoClientUnbindExchangeTask *)HcMalloc(sizeof(IsoClientUnbindExchangeTask), 0);
|
||||
@@ -212,4 +212,4 @@ SymBaseCurTask *CreateClientUnbindExchangeTask(IsoParams *params, const CJson *i
|
||||
return NULL;
|
||||
}
|
||||
return (SymBaseCurTask *)task;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -37,7 +37,7 @@ void DestroyServerBindExchangeTask(struct SymBaseCurTaskT *task)
|
||||
HcFree(task);
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoServerBindExchangeTask *realTask = (IsoServerBindExchangeTask *)task;
|
||||
if (realTask->taskBase.taskStatus < TASK_TYPE_BEGIN) {
|
||||
@@ -51,7 +51,7 @@ static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
int res;
|
||||
int message = 0;
|
||||
int32_t message = 0;
|
||||
res = GetIntFromJson(in, FIELD_MESSAGE, &message);
|
||||
if (res != 0 || message != ISO_CLIENT_BIND_EXCHANGE_CONFIRM) {
|
||||
return HC_ERR_BAD_MESSAGE;
|
||||
@@ -219,7 +219,7 @@ ERR:
|
||||
}
|
||||
|
||||
static int ServerBindExchangeStart(const IsoParams *params, IsoServerBindExchangeTask *task,
|
||||
const CJson *in, CJson *out, int *status)
|
||||
const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res;
|
||||
uint8_t *challenge = (uint8_t *)HcMalloc(CHALLENGE_SIZE, 0);
|
||||
@@ -244,7 +244,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
SymBaseCurTask *CreateServerBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
SymBaseCurTask *CreateServerBindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
IsoServerBindExchangeTask *task = (IsoServerBindExchangeTask *)HcMalloc(sizeof(IsoServerBindExchangeTask), 0);
|
||||
if (task == NULL) {
|
||||
@@ -259,4 +259,4 @@ SymBaseCurTask *CreateServerBindExchangeTask(IsoParams *params, const CJson *in,
|
||||
return NULL;
|
||||
}
|
||||
return (SymBaseCurTask *)task;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -35,7 +35,7 @@ static void DestroyServerUnbindExchangeTask(struct SymBaseCurTaskT *task)
|
||||
HcFree(task);
|
||||
}
|
||||
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
static int Process(struct SymBaseCurTaskT *task, IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
(void)task;
|
||||
(void)params;
|
||||
@@ -52,7 +52,7 @@ static int CheckRemoveInfo(const Uint8Buff *removeInfoBuf, const IsoParams *para
|
||||
LOGE("Get remove info json failed");
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
int userType = 0;
|
||||
int32_t userType = 0;
|
||||
uint8_t *peerAuthId = NULL;
|
||||
int res = GetIntFromJson(removeInfoJson, FIELD_RMV_TYPE, &userType);
|
||||
if (res != HC_SUCCESS) {
|
||||
@@ -157,7 +157,7 @@ ERR:
|
||||
}
|
||||
|
||||
static int ServerUnbindExchangeStart(IsoParams *param, IsoServerUnbindExchangeTask *task,
|
||||
const CJson *in, CJson *out, int *status)
|
||||
const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
int res = DecryptRemoveInfo(param, in);
|
||||
if (res != 0) {
|
||||
@@ -176,7 +176,7 @@ ERR:
|
||||
return res;
|
||||
}
|
||||
|
||||
SymBaseCurTask *CreateServerUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int *status)
|
||||
SymBaseCurTask *CreateServerUnbindExchangeTask(IsoParams *params, const CJson *in, CJson *out, int32_t *status)
|
||||
{
|
||||
(void)in;
|
||||
IsoServerUnbindExchangeTask *task = (IsoServerUnbindExchangeTask *)HcMalloc(sizeof(IsoServerUnbindExchangeTask), 0);
|
||||
@@ -192,4 +192,4 @@ SymBaseCurTask *CreateServerUnbindExchangeTask(IsoParams *params, const CJson *i
|
||||
return NULL;
|
||||
}
|
||||
return (SymBaseCurTask *)task;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ extern "C" {
|
||||
|
||||
typedef struct AuthModuleBaseT {
|
||||
int moduleType;
|
||||
int (*createTask)(int *, const CJson *in, CJson *out);
|
||||
int (*processTask)(int, const CJson *in, CJson *out, int *status);
|
||||
int (*createTask)(int32_t *, const CJson *in, CJson *out);
|
||||
int (*processTask)(int32_t, const CJson *in, CJson *out, int32_t *status);
|
||||
void (*destroyTask)(int);
|
||||
void (*destroyModule)(struct AuthModuleBaseT *module);
|
||||
} AuthModuleBase;
|
||||
@@ -34,8 +34,8 @@ typedef struct AuthModuleBaseT {
|
||||
int32_t InitModules(void);
|
||||
void DestroyModules(void);
|
||||
|
||||
int32_t CreateTask(int *taskId, const CJson *in, CJson *out, int moduleType);
|
||||
int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int *status, int moduleType);
|
||||
int32_t CreateTask(int32_t *taskId, const CJson *in, CJson *out, int moduleType);
|
||||
int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, int moduleType);
|
||||
void DestroyTask(int taskId, int moduleType);
|
||||
int32_t CheckMsgRepeatability(const CJson *in, int moduleType);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "json_utils.h"
|
||||
|
||||
typedef struct SessionT {
|
||||
int (*process)(struct SessionT *, CJson *);
|
||||
int32_t (*process)(struct SessionT *, CJson *);
|
||||
void (*destroy)(struct SessionT *);
|
||||
const DeviceAuthCallback *callback;
|
||||
int type;
|
||||
|
||||
@@ -146,7 +146,7 @@ int32_t DeletePeerAuthInfo(const char *pkgName, const char *serviceType, Uint8Bu
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int *status, int moduleType)
|
||||
int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int32_t *status, int moduleType)
|
||||
{
|
||||
if (in == NULL || out == NULL || status == NULL) {
|
||||
LOGE("Params is null.");
|
||||
@@ -175,7 +175,7 @@ int32_t ProcessTask(int taskId, const CJson *in, CJson *out, int *status, int mo
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t CreateTask(int *taskId, const CJson *in, CJson *out, int moduleType)
|
||||
int32_t CreateTask(int32_t *taskId, const CJson *in, CJson *out, int moduleType)
|
||||
{
|
||||
if (in == NULL || out == NULL || taskId == NULL) {
|
||||
LOGE("Params is null.");
|
||||
|
||||
@@ -24,7 +24,7 @@ DECLARE_HC_VECTOR(ParamsVec, void*)
|
||||
|
||||
typedef struct {
|
||||
Session base;
|
||||
int curTaskId;
|
||||
int32_t curTaskId;
|
||||
ParamsVec paramsList;
|
||||
uint32_t currentIndex;
|
||||
} AuthSession;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
typedef struct AuthSessionLiteT {
|
||||
Session base;
|
||||
int curTaskId;
|
||||
int32_t curTaskId;
|
||||
CJson *authParams;
|
||||
} AuthSessionLite;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "json_utils.h"
|
||||
#include "session_common.h"
|
||||
|
||||
static int ProcessClientAuthSession(Session *session, CJson *in);
|
||||
static int32_t ProcessClientAuthSession(Session *session, CJson *in);
|
||||
|
||||
int32_t CheckInputAuthParams(const CJson *authParam)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ static int32_t StartClientAuthTask(AuthSession *session)
|
||||
int32_t CheckClientGroupAuthMsg(AuthSession *session, const CJson *in)
|
||||
{
|
||||
int32_t groupErrMsg = 0;
|
||||
if (GetIntFromJson(in, FIELD_GROUP_ERROR_MSG, (int *)&groupErrMsg) != HC_SUCCESS) {
|
||||
if (GetIntFromJson(in, FIELD_GROUP_ERROR_MSG, &groupErrMsg) != HC_SUCCESS) {
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
CJson *outData = CreateJson();
|
||||
@@ -202,4 +202,4 @@ Session *CreateClientAuthSession(CJson *param, const DeviceAuthCallback *callbac
|
||||
}
|
||||
LOGD("End create client authSession.");
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "hc_types.h"
|
||||
#include "session_common.h"
|
||||
|
||||
static int ProcessServerAuthSession(Session *session, CJson *in);
|
||||
static int32_t ProcessServerAuthSession(Session *session, CJson *in);
|
||||
|
||||
static int32_t CombineServerParams(const CJson *confirmationJson, CJson *dataFromClient)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static int32_t AddAuthParamByRequest(CJson *dataFromClient, const DeviceAuthCall
|
||||
LOGE("Failed to create json from string!");
|
||||
return HC_ERR_JSON_FAIL;
|
||||
}
|
||||
int serverConfirm = REQUEST_ACCEPTED;
|
||||
int32_t serverConfirm = REQUEST_ACCEPTED;
|
||||
(void)GetIntFromJson(confirmationJson, FIELD_CONFIRMATION, &serverConfirm);
|
||||
if ((uint32_t)serverConfirm == REQUEST_REJECTED) {
|
||||
LOGE("Server reject to response.");
|
||||
@@ -184,14 +184,14 @@ static int32_t StartServerAuthTask(AuthSession *session, const CJson *receivedDa
|
||||
static int32_t CheckServerGroupAuthMsg(const CJson *in, const CJson *paramInSession, const DeviceAuthCallback *callback)
|
||||
{
|
||||
int32_t groupErrMsg = 0;
|
||||
if (GetIntFromJson(in, FIELD_GROUP_ERROR_MSG, (int *)&groupErrMsg) != HC_SUCCESS) {
|
||||
if (GetIntFromJson(in, FIELD_GROUP_ERROR_MSG, &groupErrMsg) != HC_SUCCESS) {
|
||||
return HC_SUCCESS;
|
||||
}
|
||||
InformLocalAuthError(paramInSession, callback);
|
||||
return HC_ERR_PEER_ERROR;
|
||||
}
|
||||
|
||||
static int ProcessServerAuthSession(Session *session, CJson *in)
|
||||
static int32_t ProcessServerAuthSession(Session *session, CJson *in)
|
||||
{
|
||||
LOGI("Begin process server authSession.");
|
||||
if ((session == NULL) || (in == NULL)) {
|
||||
@@ -278,4 +278,4 @@ Session *CreateServerAuthSession(CJson *param, const DeviceAuthCallback *callbac
|
||||
return NULL;
|
||||
}
|
||||
return (Session *)session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ int32_t ConvertGroupIdToJsonStr(const char *groupId, char **returnJsonStr);
|
||||
int32_t GenerateBindSuccessData(const char *peerAuthId, const char *groupId, char **returnDataStr);
|
||||
int32_t GenerateUnbindSuccessData(const char *peerAuthId, const char *groupId, char **returnDataStr);
|
||||
|
||||
int32_t GetGroupTypeFromDb(const char *groupId, int *returnGroupType);
|
||||
int32_t GetGroupTypeFromDb(const char *groupId, int32_t *returnGroupType);
|
||||
int32_t GetUserIdHashFromJson(const CJson *jsonParams, char **userIdHash);
|
||||
int32_t GetGroupIdFromJson(const CJson *jsonParams, const char **groupId);
|
||||
int32_t GetAppIdFromJson(const CJson *jsonParams, const char **appId);
|
||||
|
||||
@@ -301,7 +301,7 @@ bool IsGroupVisibilityValid(int groupVisibility)
|
||||
|
||||
int32_t CheckUserTypeIfExist(const CJson *jsonParams)
|
||||
{
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_USER_TYPE, &userType);
|
||||
if (!IsUserTypeValid(userType)) {
|
||||
LOGE("The input userType is invalid! [UserType]: %d", userType);
|
||||
@@ -312,7 +312,7 @@ int32_t CheckUserTypeIfExist(const CJson *jsonParams)
|
||||
|
||||
int32_t CheckGroupVisibilityIfExist(const CJson *jsonParams)
|
||||
{
|
||||
int groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
int32_t groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_GROUP_VISIBILITY, &groupVisibility);
|
||||
if (!IsGroupVisibilityValid(groupVisibility)) {
|
||||
LOGE("The input groupVisibility is invalid! [GroupVisibility]: %d", groupVisibility);
|
||||
@@ -323,7 +323,7 @@ int32_t CheckGroupVisibilityIfExist(const CJson *jsonParams)
|
||||
|
||||
int32_t CheckExpireTimeIfExist(const CJson *jsonParams)
|
||||
{
|
||||
int expireTime = DEFAULT_EXPIRE_TIME;
|
||||
int32_t expireTime = DEFAULT_EXPIRE_TIME;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_EXPIRE_TIME, &expireTime);
|
||||
if (!IsExpireTimeValid(expireTime)) {
|
||||
LOGE("Invalid group expire time! [ExpireTime]: %d", expireTime);
|
||||
@@ -368,7 +368,7 @@ int32_t AddGroupTypeToParams(int groupType, GroupInfo *groupParams)
|
||||
int32_t AddGroupVisibilityOrDefault(const CJson *jsonParams, GroupInfo *groupParams)
|
||||
{
|
||||
/* Currently, only the public group and private group can be created. */
|
||||
int groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
int32_t groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_GROUP_VISIBILITY, &groupVisibility);
|
||||
groupParams->visibility = groupVisibility;
|
||||
return HC_SUCCESS;
|
||||
@@ -376,7 +376,7 @@ int32_t AddGroupVisibilityOrDefault(const CJson *jsonParams, GroupInfo *groupPar
|
||||
|
||||
int32_t AddExpireTimeOrDefault(const CJson *jsonParams, GroupInfo *groupParams)
|
||||
{
|
||||
int expireTime = DEFAULT_EXPIRE_TIME;
|
||||
int32_t expireTime = DEFAULT_EXPIRE_TIME;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_EXPIRE_TIME, &expireTime);
|
||||
groupParams->expireTime = expireTime;
|
||||
return HC_SUCCESS;
|
||||
@@ -433,7 +433,7 @@ int32_t AddAuthIdToParamsOrDefault(const CJson *jsonParams, DeviceInfo *devParam
|
||||
|
||||
int32_t AddUserTypeToParamsOrDefault(const CJson *jsonParams, DeviceInfo *devParams)
|
||||
{
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_USER_TYPE, &userType);
|
||||
devParams->devType = userType;
|
||||
return HC_SUCCESS;
|
||||
@@ -687,7 +687,7 @@ int32_t ProcessKeyPair(int action, const CJson *jsonParams, const char *groupId)
|
||||
}
|
||||
authId = udid;
|
||||
}
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_USER_TYPE, &userType);
|
||||
Uint8Buff authIdBuff = { 0, 0 };
|
||||
authIdBuff.length = HcStrlen(authId);
|
||||
@@ -715,7 +715,7 @@ int32_t ProcessKeyPair(int action, const CJson *jsonParams, const char *groupId)
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t GetGroupTypeFromDb(const char *groupId, int *returnGroupType)
|
||||
int32_t GetGroupTypeFromDb(const char *groupId, int32_t *returnGroupType)
|
||||
{
|
||||
if ((groupId == NULL) || (returnGroupType == NULL)) {
|
||||
LOGE("The input parameters contains NULL value!");
|
||||
@@ -824,4 +824,4 @@ int32_t GetHashResult(const uint8_t *info, uint32_t infoLen, char *hash, uint32_
|
||||
HcFree(infoHash.val);
|
||||
HcFree(message.val);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,7 +637,7 @@ static int32_t AddMemberToGroup(int64_t requestId, CJson *jsonParams, const Devi
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
int32_t result;
|
||||
int operationCode = MEMBER_INVITE;
|
||||
int32_t operationCode = MEMBER_INVITE;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_OPERATION_CODE, &operationCode);
|
||||
result = CheckClientStatus(operationCode, jsonParams);
|
||||
if (result != HC_SUCCESS) {
|
||||
@@ -678,7 +678,7 @@ static int32_t ProcessData(int64_t requestId, CJson *jsonParams, const DeviceAut
|
||||
LOGE("The input parameters contains NULL value!");
|
||||
return HC_ERR_INVALID_PARAMS;
|
||||
}
|
||||
int operationCode = MEMBER_INVITE;
|
||||
int32_t operationCode = MEMBER_INVITE;
|
||||
(void)(GetIntFromJson(jsonParams, FIELD_GROUP_OP, &operationCode));
|
||||
int32_t result = CheckServerStatusIfNotInvite(operationCode, jsonParams);
|
||||
if (result != HC_SUCCESS) {
|
||||
|
||||
@@ -145,7 +145,7 @@ static int32_t PrepareClient(const CJson *jsonParams, BindSession *session)
|
||||
|
||||
Session *CreateClientBindSession(CJson *jsonParams, const DeviceAuthCallback *callback)
|
||||
{
|
||||
int opCode = MEMBER_INVITE;
|
||||
int32_t opCode = MEMBER_INVITE;
|
||||
if (GetIntFromJson(jsonParams, FIELD_OPERATION_CODE, &opCode) != HC_SUCCESS) {
|
||||
LOGE("Failed to get opCode from json!");
|
||||
return NULL;
|
||||
@@ -183,4 +183,4 @@ Session *CreateClientBindSession(CJson *jsonParams, const DeviceAuthCallback *ca
|
||||
return NULL;
|
||||
}
|
||||
return (Session *)session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ static int32_t AddGroupAndDevInfoToParams(const BindSession *session, CJson *mod
|
||||
LOGE("Failed to get authId from params!");
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
if (GetIntFromJson(session->params, FIELD_USER_TYPE, &userType) != HC_SUCCESS) {
|
||||
LOGE("Failed to get userType from params!");
|
||||
return HC_ERR_JSON_GET;
|
||||
@@ -243,7 +243,7 @@ static int32_t AddPeerAuthIdToParams(BindSession *session, CJson *moduleParams)
|
||||
|
||||
static int32_t AddPeerUserTypeToParams(BindSession *session, CJson *moduleParams)
|
||||
{
|
||||
int peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
if (GetIntFromJson(session->params, FIELD_PEER_USER_TYPE, &peerUserType) != HC_SUCCESS) {
|
||||
LOGE("Failed to get peerUserType from params!");
|
||||
return HC_ERR_JSON_GET;
|
||||
@@ -269,7 +269,7 @@ static int32_t AddPeerAuthIdAndUserTypeToParamsIfNeed(BindSession *session, CJso
|
||||
|
||||
static int32_t TryAddPeerUserTypeToParams(const CJson *jsonParams, BindSession *session)
|
||||
{
|
||||
int peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
if (GetIntFromJson(jsonParams, FIELD_PEER_USER_TYPE, &peerUserType) == HC_SUCCESS) {
|
||||
if (AddIntToJson(session->params, FIELD_PEER_USER_TYPE, peerUserType) != HC_SUCCESS) {
|
||||
LOGE("Failed to add peerUserType to params!");
|
||||
@@ -412,7 +412,7 @@ static int32_t AddGroupTypeIfValid(const CJson *jsonParams, CJson *params)
|
||||
|
||||
static int32_t AddGroupVisibilityIfValidOrDefault(const CJson *jsonParams, CJson *params)
|
||||
{
|
||||
int groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
int32_t groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_GROUP_VISIBILITY, &groupVisibility);
|
||||
if (!IsGroupVisibilityValid(groupVisibility)) {
|
||||
LOGE("The input groupVisibility is invalid!");
|
||||
@@ -427,7 +427,7 @@ static int32_t AddGroupVisibilityIfValidOrDefault(const CJson *jsonParams, CJson
|
||||
|
||||
static int32_t AddExpireTimeIfValidOrDefault(const CJson *jsonParams, CJson *params)
|
||||
{
|
||||
int expireTime = DEFAULT_EXPIRE_TIME;
|
||||
int32_t expireTime = DEFAULT_EXPIRE_TIME;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_EXPIRE_TIME, &expireTime);
|
||||
if (!IsExpireTimeValid(expireTime)) {
|
||||
LOGE("The input expireTime is invalid!");
|
||||
@@ -472,7 +472,7 @@ static int32_t CheckAuthIdAndUserTypeValid(int userType, const char *groupId, co
|
||||
|
||||
static int32_t AddAuthIdAndUserTypeIfValidOrDefault(const char *groupId, const CJson *jsonParams, CJson *params)
|
||||
{
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_USER_TYPE, &userType);
|
||||
if (!IsUserTypeValid(userType)) {
|
||||
LOGE("The input userType is invalid!");
|
||||
@@ -516,7 +516,7 @@ static int32_t AddUdid(CJson *params)
|
||||
|
||||
static int32_t AddUserTypeIfValidOrDefault(const CJson *jsonParams, CJson *params)
|
||||
{
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_USER_TYPE, &userType);
|
||||
if (!IsUserTypeValid(userType)) {
|
||||
LOGE("The input userType is invalid!");
|
||||
@@ -802,7 +802,7 @@ static int32_t SetGroupType(const CJson *params, GroupInfo *groupParams)
|
||||
|
||||
static int32_t SetGroupVisibility(const CJson *params, GroupInfo *groupParams)
|
||||
{
|
||||
int groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
int32_t groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
(void)GetIntFromJson(params, FIELD_GROUP_VISIBILITY, &groupVisibility);
|
||||
groupParams->visibility = groupVisibility;
|
||||
return HC_SUCCESS;
|
||||
@@ -810,7 +810,7 @@ static int32_t SetGroupVisibility(const CJson *params, GroupInfo *groupParams)
|
||||
|
||||
static int32_t SetGroupExpireTime(const CJson *params, GroupInfo *groupParams)
|
||||
{
|
||||
int expireTime = DEFAULT_EXPIRE_TIME;
|
||||
int32_t expireTime = DEFAULT_EXPIRE_TIME;
|
||||
(void)GetIntFromJson(params, FIELD_EXPIRE_TIME, &expireTime);
|
||||
groupParams->expireTime = expireTime;
|
||||
return HC_SUCCESS;
|
||||
@@ -830,7 +830,7 @@ static int32_t ForceDeletePeerKey(CJson *params)
|
||||
LOGE("Failed to get groupId from params!");
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
int peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(params, FIELD_PEER_USER_TYPE, &peerUserType);
|
||||
Uint8Buff peerAuthIdBuff = {
|
||||
.val = (uint8_t *)peerAuthId,
|
||||
@@ -925,7 +925,7 @@ static int32_t AddGroupAndLocalDevIfNotExist(const char *groupId, const BindSess
|
||||
LOGI("No authId is found. The default value is udid!");
|
||||
authId = udid;
|
||||
}
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(session->params, FIELD_USER_TYPE, &userType);
|
||||
return AddTrustDevToDatabase(authId, udid, groupId, userType);
|
||||
}
|
||||
@@ -943,7 +943,7 @@ static int32_t AddPeerDevToGroup(const char *peerAuthId, const char *peerUdid,
|
||||
}
|
||||
LOGI("Delete the original data successfully! RequestId: %" PRId64, session->reqId);
|
||||
}
|
||||
int peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t peerUserType = DEVICE_TYPE_ACCESSORY;
|
||||
(void)GetIntFromJson(session->params, FIELD_PEER_USER_TYPE, &peerUserType);
|
||||
int32_t result = AddTrustDevToDatabase(peerAuthId, peerUdid, groupId, peerUserType);
|
||||
if (result != HC_SUCCESS) {
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
|
||||
static int32_t AddRecvModuleDataToParams(CJson *jsonParams, CJson *moduleParams)
|
||||
{
|
||||
int message = ERR_MESSAGE;
|
||||
int32_t message = ERR_MESSAGE;
|
||||
if (GetIntFromJson(jsonParams, FIELD_MESSAGE, &message) != HC_SUCCESS) {
|
||||
LOGE("Failed to get message from in!");
|
||||
return HC_ERR_JSON_GET;
|
||||
}
|
||||
int authForm = ERR_AUTH_FORM;
|
||||
int32_t authForm = ERR_AUTH_FORM;
|
||||
(void)GetIntFromJson(jsonParams, FIELD_AUTH_FORM, &authForm);
|
||||
CJson *payload = GetObjFromJson(jsonParams, FIELD_PAYLOAD);
|
||||
if (payload == NULL) {
|
||||
@@ -227,7 +227,7 @@ static int32_t AddAuthIdIfExist(const CJson *returnData, CJson *jsonParams)
|
||||
|
||||
static int32_t AddUserTypeIfExistAndValid(const CJson *returnData, CJson *jsonParams)
|
||||
{
|
||||
int userType = DEVICE_TYPE_ACCESSORY;
|
||||
int32_t userType = DEVICE_TYPE_ACCESSORY;
|
||||
if (GetIntFromJson(returnData, FIELD_USER_TYPE, &userType) == HC_SUCCESS) {
|
||||
if (!IsUserTypeValid(userType)) {
|
||||
LOGE("The input userType is invalid!");
|
||||
@@ -243,7 +243,7 @@ static int32_t AddUserTypeIfExistAndValid(const CJson *returnData, CJson *jsonPa
|
||||
|
||||
static int32_t AddGroupVisibilityIfExistAndValid(const CJson *returnData, CJson *jsonParams)
|
||||
{
|
||||
int groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
int32_t groupVisibility = GROUP_VISIBILITY_PUBLIC;
|
||||
if (GetIntFromJson(returnData, FIELD_GROUP_VISIBILITY, &groupVisibility) == HC_SUCCESS) {
|
||||
if (!IsGroupVisibilityValid(groupVisibility)) {
|
||||
LOGE("The input groupVisibility invalid!");
|
||||
@@ -259,7 +259,7 @@ static int32_t AddGroupVisibilityIfExistAndValid(const CJson *returnData, CJson
|
||||
|
||||
static int32_t AddExpireTimeIfExistAndValid(const CJson *returnData, CJson *jsonParams)
|
||||
{
|
||||
int expireTime = DEFAULT_EXPIRE_TIME;
|
||||
int32_t expireTime = DEFAULT_EXPIRE_TIME;
|
||||
if (GetIntFromJson(returnData, FIELD_EXPIRE_TIME, &expireTime) == HC_SUCCESS) {
|
||||
if (!IsExpireTimeValid(expireTime)) {
|
||||
LOGE("The input expireTime invalid!");
|
||||
@@ -444,7 +444,7 @@ static int32_t HandleRequest(CJson *jsonParams, BindSession *session, bool *isNe
|
||||
|
||||
Session *CreateServerBindSession(CJson *jsonParams, const DeviceAuthCallback *callback)
|
||||
{
|
||||
int opCode = MEMBER_INVITE;
|
||||
int32_t opCode = MEMBER_INVITE;
|
||||
if (GetIntFromJson(jsonParams, FIELD_GROUP_OP, &opCode) != HC_SUCCESS) {
|
||||
LOGE("Failed to get opCode from jsonParams!");
|
||||
return NULL;
|
||||
@@ -469,4 +469,4 @@ Session *CreateServerBindSession(CJson *jsonParams, const DeviceAuthCallback *ca
|
||||
return NULL;
|
||||
}
|
||||
return (Session *)session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ int32_t SendBindSessionData(const BindSession *session, const CJson *sendData)
|
||||
|
||||
int32_t CreateAndProcessModule(BindSession *session, const CJson *in, CJson *out)
|
||||
{
|
||||
int status = 0;
|
||||
int32_t status = 0;
|
||||
LOGI("Start to create and process module task! [ModuleType]: %d", session->moduleType);
|
||||
int32_t res = CreateTask(&(session->curTaskId), in, out, session->moduleType);
|
||||
if (res != HC_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user