• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_PRE_LINK_H
17 #define AUTH_PRE_LINK_H
18 
19 #include <stdatomic.h>
20 #include <stdbool.h>
21 #include <stdint.h>
22 #include "common_list.h"
23 #include "softbus_common.h"
24 #include "auth_attest_interface_struct.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct {
31     char uuid[UUID_BUF_LEN];
32     ConnectionAddr connAddr;
33     int32_t fd;
34     uint32_t requestId;
35     ListNode node;
36 } AuthPreLinkNode;
37 
38 typedef struct {
39     bool isValid;
40     _Atomic int isParallelGen;
41     int32_t requestId;
42     SoftbusCertChain *softbusCertChain;
43     ListNode node;
44 } AuthGenCertNode;
45 
46 int32_t InitAuthPreLinkList(void);
47 bool IsAuthPreLinkNodeExist(uint32_t requestId);
48 bool AuthPreLinkCheckNeedPtk(uint32_t requestId, const char *uuid);
49 int32_t AddToAuthPreLinkList(uint32_t requestId, int32_t fd, ConnectionAddr *connAddr);
50 int32_t FindAuthPreLinkNodeById(uint32_t requestId, AuthPreLinkNode *reuseNode);
51 int32_t FindAuthPreLinkNodeByUuid(const char *uuid, AuthPreLinkNode *reuseNode);
52 int32_t UpdateAuthPreLinkUuidById(uint32_t requestId, char *uuid);
53 void DelAuthPreLinkById(uint32_t requestId);
54 void DelAuthPreLinkByUuid(char *uuid);
55 void DeinitAuthPreLinkList(void);
56 
57 int32_t InitAuthGenCertParallelList(void);
58 int32_t AddAuthGenCertParaNode(int32_t requestId);
59 int32_t UpdateAuthGenCertParaNode(int32_t requestId, bool isValid, SoftbusCertChain *softbusCertChain);
60 int32_t FindAndWaitAuthGenCertParaNodeById(int32_t requestId, AuthGenCertNode **genCertParaNode);
61 void DelAuthGenCertParaNodeById(int32_t requestId);
62 void DeinitAuthGenCertParallelList(void);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 #endif /* AUTH_PRE_LINK_H */