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 LNN_P2P_INFO_H 17 #define LNN_P2P_INFO_H 18 19 #include <stdint.h> 20 21 #include "common_list.h" 22 #include "lnn_node_info.h" 23 #include "softbus_common.h" 24 #include "softbus_json_utils.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 #define MSG_FLAG_REQUEST 0 31 #define MES_FLAG_REPLY 1 32 33 typedef struct { 34 char networkId[NETWORK_ID_BUF_LEN]; 35 char ptk[PTK_DEFAULT_LEN]; 36 ListNode node; 37 } PtkSyncInfo; 38 39 typedef struct { 40 char udid[UDID_BUF_LEN]; 41 char uuid[UUID_BUF_LEN]; 42 uint64_t createTime; 43 uint64_t endTime; 44 char ptk[PTK_DEFAULT_LEN]; 45 ListNode node; 46 } LocalPtkList; 47 48 typedef struct { 49 uint32_t connId; 50 char ptk[PTK_DEFAULT_LEN]; 51 ListNode node; 52 } LocalMetaList; 53 54 int32_t LnnInitP2p(void); 55 void LnnDeinitP2p(void); 56 int32_t LnnInitLocalP2pInfo(NodeInfo *info); 57 int32_t LnnSyncP2pInfo(void); 58 int32_t LnnSyncWifiDirectAddr(void); 59 int32_t LnnInitWifiDirect(void); 60 void LnnDeinitWifiDirect(void); 61 int32_t LnnInitPtk(void); 62 void LnnDeinitPtk(void); 63 int32_t LnnGetLocalPtkByUdid(const char *udid, char *localPtk, uint32_t len); 64 int32_t LnnGetLocalPtkByUuid(const char *uuid, char *localPtk, uint32_t len); 65 int32_t LnnGetLocalDefaultPtkByUuid(const char *uuid, char *localPtk, uint32_t len); 66 int32_t LnnGetRemoteDefaultPtkByUuid(const char *uuid, char *remotePtk, uint32_t len); 67 void LnnLoadPtkInfo(void); 68 int32_t LnnSyncPtk(char *networkId); 69 int32_t UpdateLocalPtkIfValid(char *udid); 70 int32_t LnnSetLocalPtkConn(char *udid); 71 int32_t LnnGenerateLocalPtk(char *udid, char *uuid); 72 int32_t LnnGenerateMetaPtk(uint32_t connId); 73 int32_t LnnGetMetaPtk(uint32_t connId, char *metaPtk, uint32_t len); 74 int32_t LnnDeleteMetaPtk(uint32_t connectionId); 75 int32_t UpdatePtkByAuth(char *networkId, AuthHandle authHandle); 76 77 #ifdef __cplusplus 78 } 79 #endif 80 81 #endif // LNN_P2P_INFO_H