• 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_COMMON_H
17 #define AUTH_COMMON_H
18 
19 #include "auth_interface.h"
20 #include "softbus_common.h"
21 #include "softbus_conn_interface.h"
22 #include "softbus_error_code.h"
23 #include "softbus_utils.h"
24 #include "auth_common_struct.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif
30 #endif
31 
32 int32_t PostAuthEvent(EventType event, EventHandler handler,
33     const void *obj, uint32_t size, uint64_t delayMs);
34 int32_t RemoveAuthEvent(EventType event, RemoveCompareFunc func, void *param);
35 
36 /* Auth Lock */
37 bool RequireAuthLock(void);
38 void ReleaseAuthLock(void);
39 
40 /* auth config */
41 bool GetConfigSupportAsServer(void);
42 
43 /* auth capacity */
44 uint32_t GetAuthCapacity(void);
45 
46 /* Common Functions */
47 uint8_t *DupMemBuffer(const uint8_t *buf, uint32_t size);
48 int64_t GenSeq(bool isServer);
49 uint64_t GetCurrentTimeMs(void);
50 const char *GetAuthSideStr(bool isServer);
51 bool CompareConnInfo(const AuthConnInfo *info1, const AuthConnInfo *info2, bool cmpShortHash);
52 int32_t ConvertToConnectOption(const AuthConnInfo *connInfo, ConnectOption *option);
53 int32_t ConvertToAuthConnInfo(const ConnectionInfo *info, AuthConnInfo *connInfo);
54 int32_t ConvertToAuthInfoForSle(const ConnectionInfo *info, AuthConnInfo *connInfo);
55 int32_t GetPeerUdidByNetworkId(const char *networkId, char *udid, uint32_t len);
56 int32_t GetIsExchangeUdidByNetworkId(const char *networkId, bool *isExchangeUdid);
57 DiscoveryType ConvertToDiscoveryType(AuthLinkType type);
58 AuthLinkType ConvertToAuthLinkType(DiscoveryType type);
59 bool CheckAuthConnInfoType(const AuthConnInfo *connInfo);
60 void PrintAuthConnInfo(const AuthConnInfo *connInfo);
61 
62 int32_t AuthCommonInit(void);
63 void AuthCommonDeinit(void);
64 
65 #ifdef __cplusplus
66 #if __cplusplus
67 }
68 #endif
69 #endif
70 #endif /* AUTH_COMMON_H */
71