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