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_CONNECTION_H 17 #define AUTH_CONNECTION_H 18 19 #include "auth_common.h" 20 #include "auth_interface.h" 21 #include "auth_connection_struct.h" 22 #include "softbus_conn_interface.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif 29 30 int32_t AuthConnInit(const AuthConnListener *listener); 31 void AuthConnDeinit(void); 32 33 int32_t ConnectAuthDevice(uint32_t requestId, const AuthConnInfo *connInfo, ConnSideType sideType); 34 void UpdateAuthDevicePriority(uint64_t connId); 35 void DisconnectAuthDevice(uint64_t *connId); 36 int32_t PostAuthData(uint64_t connId, bool toServer, const AuthDataHead *head, const uint8_t *data); 37 38 ConnSideType GetConnSideType(uint64_t connId); 39 bool CheckActiveAuthConnection(const AuthConnInfo *connInfo); 40 41 const char *GetConnTypeStr(uint64_t connId); 42 uint32_t GetConnId(uint64_t connId); 43 int32_t GetConnType(uint64_t connId); 44 int32_t GetFd(uint64_t connId); 45 uint64_t GenConnId(int32_t connType, int32_t id); 46 void UpdateFd(uint64_t *connId, int32_t id); 47 48 uint32_t GetAuthDataSize(uint32_t len); 49 int32_t PackAuthData(const AuthDataHead *head, const uint8_t *data, uint8_t *buf, uint32_t size); 50 const uint8_t *UnpackAuthData(const uint8_t *data, uint32_t len, AuthDataHead *head); 51 int32_t GetConnInfoByConnectionId(uint32_t connectionId, AuthConnInfo *connInfo); 52 53 void HandleRepeatDeviceIdDataDelay(uint64_t connId, const AuthConnInfo *connInfo, bool fromServer, 54 const AuthDataHead *head, const uint8_t *data); 55 56 #ifdef __cplusplus 57 #if __cplusplus 58 } 59 #endif 60 #endif 61 #endif /* AUTH_CONNECTION_H */ 62