• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 AUTH_REQUEST_H
17 #define AUTH_REQUEST_H
18 
19 #include "auth_interface.h"
20 
21 #ifdef __cplusplus
22 #if __cplusplus
23 extern "C" {
24 #endif
25 #endif
26 
27 typedef enum {
28     REQUEST_TYPE_VERIFY = 0,
29     REQUEST_TYPE_RECONNECT,
30     REQUEST_TYPE_CONNECT,
31 } RequestType;
32 
33 typedef struct {
34     uint32_t requestId;
35     AuthConnInfo connInfo;
36     AuthVerifyCallback verifyCb;
37     AuthVerifyModule module;
38     int64_t authId;
39     int64_t traceId;
40     AuthConnCallback connCb;
41     RequestType type;
42     ListNode node;
43     uint64_t addTime;
44     bool isFastAuth;
45     DeviceKeyId deviceKeyId;
46     ForceJoinInfo forceJoinInfo;
47     uint16_t deviceTypeId;
48 } AuthRequest;
49 
50 bool CheckVerifyCallback(const AuthVerifyCallback *verifyCb);
51 bool CheckAuthConnCallback(const AuthConnCallback *connCb);
52 
53 /* Note: return wait list num, 0 means add fail. */
54 uint32_t AddAuthRequest(const AuthRequest *request);
55 int32_t GetAuthRequest(uint32_t requestId, AuthRequest *request);
56 int32_t FindAuthRequestByConnInfo(const AuthConnInfo *connInfo, AuthRequest *request);
57 int32_t GetAuthRequestNoLock(uint32_t requestId, AuthRequest *request);
58 int32_t FindAndDelAuthRequestByConnInfo(uint32_t requestId, const AuthConnInfo *connInfo);
59 void DelAuthRequest(uint32_t requestId);
60 void ClearAuthRequest(void);
61 
62 void PerformVerifyCallback(uint32_t requestId, int32_t result, AuthHandle authHandle, const NodeInfo *info);
63 void PerformAuthConnCallback(uint32_t requestId, int32_t result, int64_t authId);
64 
65 #ifdef __cplusplus
66 #if __cplusplus
67 }
68 #endif
69 #endif
70 #endif /* AUTH_REQUEST_H */
71