1 /* 2 * Copyright (c) 2021-2024 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 BUS_CENTER_MANAGER_H 17 #define BUS_CENTER_MANAGER_H 18 19 #include <stdint.h> 20 21 #include "bus_center_info_key.h" 22 #include "data_level.h" 23 #include "disc_manager.h" 24 #include "softbus_bus_center.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 typedef enum { 31 LNN_MESSAGE_LANE = 1, 32 LNN_BYTES_LANE, 33 LNN_FILE_LANE, 34 LNN_STREAM_LANE, 35 LNN_LANE_PROPERTY_BUTT, 36 } LnnLaneProperty; 37 38 typedef union { 39 IServerDiscInnerCallback serverCb; 40 DiscInnerCallback innerCb; 41 } InnerCallback; 42 43 int32_t LnnPublishService(const char *pkgName, const PublishInfo *info, bool isInnerRequest); 44 int32_t LnnUnPublishService(const char *pkgName, int32_t publishId, bool isInnerRequest); 45 int32_t LnnStartDiscDevice(const char *pkgName, const SubscribeInfo *info, const InnerCallback *cb, 46 bool isInnerRequest); 47 int32_t LnnStopDiscDevice(const char *pkgName, int32_t subscribeId, bool isInnerRequest); 48 49 int32_t LnnGetRemoteStrInfo(const char *networkId, InfoKey key, char *info, uint32_t len); 50 int32_t LnnGetRemoteBoolInfo(const char *networkId, InfoKey key, bool *info); 51 int32_t LnnGetRemoteBoolInfoIgnoreOnline(const char *networkId, InfoKey key, bool *info); 52 int32_t LnnGetRemoteNumInfo(const char *networkId, InfoKey key, int32_t *info); 53 int32_t LnnGetRemoteNumU32Info(const char *networkId, InfoKey key, uint32_t *info); 54 int32_t LnnGetRemoteNumU64Info(const char *networkId, InfoKey key, uint64_t *info); 55 int32_t LnnGetRemoteNum16Info(const char *networkId, InfoKey key, int16_t *info); 56 int32_t LnnGetRemoteByteInfo(const char *networkId, InfoKey key, uint8_t *info, uint32_t len); 57 int32_t LnnSetLocalStrInfo(InfoKey key, const char *info); 58 int32_t LnnSetLocalNumInfo(InfoKey key, int32_t info); 59 int32_t LnnGetLocalStrInfo(InfoKey key, char *info, uint32_t len); 60 int32_t LnnGetLocalNumInfo(InfoKey key, int32_t *info); 61 int32_t LnnGetLocalNum64Info(InfoKey key, int64_t *info); 62 int32_t LnnGetLocalNumU64Info(InfoKey key, uint64_t *info); 63 int32_t LnnSetLocalNum64Info(InfoKey key, int64_t info); 64 int32_t LnnGetLocalNum16Info(InfoKey key, int16_t *info); 65 int32_t LnnSetLocalNum16Info(InfoKey key, int16_t info); 66 int32_t LnnGetLocalNumU16Info(InfoKey key, uint16_t *info); 67 int32_t LnnSetLocalNumU16Info(InfoKey key, uint16_t info); 68 int32_t LnnGetLocalNumU32Info(InfoKey key, uint32_t *info); 69 int32_t LnnSetLocalNumU32Info(InfoKey key, uint32_t info); 70 int32_t LnnSetLocalByteInfo(InfoKey key, const uint8_t *info, uint32_t len); 71 int32_t LnnGetLocalByteInfo(InfoKey key, uint8_t *info, uint32_t len); 72 int32_t LnnGetLocalBoolInfo(InfoKey key, bool *info, uint32_t len); 73 bool LnnIsLSANode(const NodeBasicInfo *info); 74 int32_t LnnGetAllOnlineNodeInfo(NodeBasicInfo **info, int32_t *infoNum); 75 int32_t LnnGetAllOnlineAndMetaNodeInfo(NodeBasicInfo **info, int32_t *infoNum); 76 int32_t LnnGetAllOnlineNodeNum(int32_t *nodeNum); 77 int32_t LnnGetLocalDeviceInfo(NodeBasicInfo *info); 78 int32_t LnnGetNodeKeyInfo(const char *networkId, int key, uint8_t *info, uint32_t infoLen); 79 int32_t LnnSetNodeDataChangeFlag(const char *networkId, uint16_t dataChangeFlag); 80 int32_t LnnSetDataLevel(const DataLevel *dataLevel, bool *isSwitchLevelChanged); 81 int32_t LnnGetNodeKeyInfoLen(int32_t key); 82 int32_t LnnGetNetworkIdByUuid(const char *uuid, char *buf, uint32_t len); 83 int32_t LnnGetNetworkIdByUdid(const char *udid, char *buf, uint32_t len); 84 int32_t LnnGetNetworkIdByBtMac(const char *btMac, char *buf, uint32_t len); 85 int32_t LnnGetNetworkIdByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *buf, uint32_t len); 86 int32_t LnnGetConnSubFeatureByUdidHashStr(const char *udidHashStr, uint64_t *connSubFeature); 87 int32_t LnnSetLocalUnifiedName(const char *unifiedName); 88 bool LnnIsMasterNode(void); 89 void SoftBusDumpBusCenterPrintInfo(int fd, NodeBasicInfo *nodeInfo); 90 91 int32_t LnnServerJoin(ConnectionAddr *addr, const char *pkgName); 92 int32_t LnnServerLeave(const char *networkId, const char *pkgName); 93 94 int32_t BusCenterServerInit(void); 95 void BusCenterServerDeinit(void); 96 97 int32_t LnnSyncP2pInfo(void); 98 int32_t LnnInitLnnLooper(void); 99 void LnnDeinitLnnLooper(void); 100 101 #ifdef __cplusplus 102 } 103 #endif 104 #endif // BUS_CENTER_MANAGER_H