1 /* 2 * Copyright (c) 2021 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_NET_BUILDER_H 17 #define LNN_NET_BUILDER_H 18 19 #include <stdint.h> 20 21 #include "auth_interface.h" 22 #include "lnn_sync_info_manager.h" 23 #include "softbus_bus_center.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 typedef enum { 30 NODE_TYPE_C, 31 NODE_TYPE_L 32 } NodeType; 33 34 #define JSON_KEY_NODE_CODE "NODE_CODE" 35 #define JSON_KEY_NODE_ADDR "NODE_ADDR" 36 #define JSON_KEY_NODE_PROXY_PORT "PROXY_PORT" 37 #define JSON_KEY_NODE_SESSION_PORT "SESSION_PORT" 38 39 typedef struct { 40 int32_t code; 41 char nodeAddr[SHORT_ADDRESS_MAX_LEN]; 42 int32_t proxyPort; 43 int32_t sessionPort; 44 int32_t authPort; 45 } LnnNodeAddr; 46 47 typedef struct { 48 ListNode node; 49 ConnectionAddr addr; 50 char networkId[NETWORK_ID_BUF_LEN]; 51 char pkgName[PKG_NAME_SIZE_MAX]; 52 int64_t authId; 53 int32_t callingPid; 54 uint32_t requestId; 55 uint32_t flag; 56 bool needReportFailure; 57 } MetaJoinRequestNode; 58 59 int32_t LnnInitNetBuilder(void); 60 int32_t LnnInitNetBuilderDelay(void); 61 void LnnDeinitNetBuilder(void); 62 63 int32_t LnnNotifyDiscoveryDevice(const ConnectionAddr *addr, bool isNeedConnect); 64 void LnnSyncOfflineComplete(LnnSyncInfoType type, const char *networkId, const uint8_t *msg, uint32_t len); 65 int32_t LnnRequestLeaveByAddrType(const bool *type, uint32_t typeLen); 66 int32_t LnnRequestLeaveSpecific(const char *networkId, ConnectionAddrType addrType); 67 void LnnRequestLeaveAllOnlineNodes(void); 68 int32_t LnnRequestLeaveInvalidConn(const char *oldNetworkId, ConnectionAddrType addrType, const char *newNetworkId); 69 int32_t LnnRequestCleanConnFsm(uint16_t connFsmId); 70 int32_t LnnNotifyNodeStateChanged(const ConnectionAddr *addr); 71 int32_t LnnNotifyMasterElect(const char *networkId, const char *masterUdid, int32_t masterWeight); 72 int32_t LnnNotifyAuthHandleLeaveLNN(int64_t authId); 73 int32_t LnnUpdateNodeAddr(const char *addr); 74 int32_t FindRequestIdByAddr(ConnectionAddr *connetionAddr, uint32_t *requestId); 75 NodeInfo *FindNodeInfoByRquestId(uint32_t requestId); 76 AuthVerifyCallback *LnnGetVerifyCallback(void); 77 AuthVerifyCallback *LnnGetMetaVerifyCallback(void); 78 AuthVerifyCallback *LnnGetReAuthVerifyCallback(void); 79 void SetWatchdogFlag(bool flag); 80 bool GetWatchdogFlag(void); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif