• 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 } AuthRequest;
46 
47 bool CheckVerifyCallback(const AuthVerifyCallback *verifyCb);
48 bool CheckAuthConnCallback(const AuthConnCallback *connCb);
49 
50 /* Note: return wait list num, 0 means add fail. */
51 uint32_t AddAuthRequest(const AuthRequest *request);
52 int32_t GetAuthRequest(uint32_t requestId, AuthRequest *request);
53 int32_t FindAuthRequestByConnInfo(const AuthConnInfo *connInfo, AuthRequest *request);
54 int32_t GetAuthRequestNoLock(uint32_t requestId, AuthRequest *request);
55 int32_t FindAndDelAuthRequestByConnInfo(uint32_t requestId, const AuthConnInfo *connInfo);
56 void DelAuthRequest(uint32_t requestId);
57 void ClearAuthRequest(void);
58 
59 void PerformVerifyCallback(uint32_t requestId, int32_t result, AuthHandle authHandle, const NodeInfo *info);
60 void PerformAuthConnCallback(uint32_t requestId, int32_t result, int64_t authId);
61 
62 #ifdef __cplusplus
63 #if __cplusplus
64 }
65 #endif
66 #endif
67 #endif /* AUTH_REQUEST_H */
68