mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-23 16:59:54 +00:00
solve some mem leak and list iterator problems
Signed-off-by: jeosif <liubao6@huawei.com> Change-Id: I9c1053d19d7c9564af4af1083918e2a1e37f5eeb
This commit is contained in:
parent
3b7cddc2de
commit
8b4e687db1
@ -174,7 +174,8 @@ The main code directory structure of DSoftBus is as follows:
|
||||
#define EVENT_NODE_STATE_ONLINE 0x1
|
||||
#define EVENT_NODE_STATE_OFFLINE 0x02
|
||||
#define EVENT_NODE_STATE_INFO_CHANGED 0x04
|
||||
#define EVENT_NODE_STATE_MASK 0x07
|
||||
#define EVENT_NODE_STATUS_CHANGED 0x08
|
||||
#define EVENT_NODE_STATE_MASK 0x15
|
||||
|
||||
// Device information
|
||||
typedef struct {
|
||||
@ -189,6 +190,7 @@ The main code directory structure of DSoftBus is as follows:
|
||||
void (*onNodeOnline)(NodeBasicInfo *info); // Called when the device gets online.
|
||||
void (*onNodeOffline)(NodeBasicInfo *info); // Called when the device gets offline.
|
||||
void (*onNodeBasicInfoChanged)(NodeBasicInfoType type, NodeBasicInfo *info); // Called when the device information changes.
|
||||
void (*onNodeStatusChanged)(NodeStatusType type, NodeStatus *status); // Called when the device status changed.
|
||||
} INodeStateCb;
|
||||
|
||||
// Register the callback for device state events.
|
||||
|
@ -175,7 +175,8 @@
|
||||
#define EVENT_NODE_STATE_ONLINE 0x1
|
||||
#define EVENT_NODE_STATE_OFFLINE 0x02
|
||||
#define EVENT_NODE_STATE_INFO_CHANGED 0x04
|
||||
#define EVENT_NODE_STATE_MASK 0x07
|
||||
#define EVENT_NODE_STATUS_CHANGED 0x08
|
||||
#define EVENT_NODE_STATE_MASK 0x15
|
||||
|
||||
// 节点信息
|
||||
typedef struct {
|
||||
@ -190,6 +191,7 @@
|
||||
void (*onNodeOnline)(NodeBasicInfo *info); // 节点上线事件回调
|
||||
void (*onNodeOffline)(NodeBasicInfo *info); // 节点下线事件回调
|
||||
void (*onNodeBasicInfoChanged)(NodeBasicInfoType type, NodeBasicInfo *info); // 节点信息变化事件回调
|
||||
void (*onNodeStatusChanged)(NodeStatusType type, NodeStatus *status); // 设备运行状态变化事件回调
|
||||
} INodeStateCb;
|
||||
|
||||
// 注册节点状态事件回调
|
||||
|
@ -208,7 +208,7 @@ int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len)
|
||||
|
||||
int32_t SoftBusGenerateSessionKey(char *key, uint32_t len)
|
||||
{
|
||||
if (SoftBusGenerateRandomArray((unsigned char*)key, len) != SOFTBUS_OK) {
|
||||
if (SoftBusGenerateRandomArray((unsigned char *)key, len) != SOFTBUS_OK) {
|
||||
HILOG_ERROR(SOFTBUS_HILOG_ID, "generate sessionKey error.");
|
||||
return SOFTBUS_ENCRYPT_ERR;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ int32_t SoftBusGenerateRandomArray(unsigned char *randStr, uint32_t len)
|
||||
|
||||
int32_t SoftBusGenerateSessionKey(char *key, uint32_t len)
|
||||
{
|
||||
if (SoftBusGenerateRandomArray((unsigned char*)key, len) != SOFTBUS_OK) {
|
||||
if (SoftBusGenerateRandomArray((unsigned char *)key, len) != SOFTBUS_OK) {
|
||||
HILOG_ERROR(SOFTBUS_HILOG_ID, "generate sessionKey error.");
|
||||
return SOFTBUS_ENCRYPT_ERR;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ NO_SANITIZE("cfi") void SoftbusConfigAdapterInit(const ConfigSetProc *sets)
|
||||
{
|
||||
int32_t val;
|
||||
val = MAX_BYTES_LENGTH;
|
||||
sets->SetConfig(SOFTBUS_INT_MAX_BYTES_LENGTH, (unsigned char*)&val, sizeof(val));
|
||||
sets->SetConfig(SOFTBUS_INT_MAX_BYTES_LENGTH, (unsigned char *)&val, sizeof(val));
|
||||
val = 0x1;
|
||||
sets->SetConfig(SOFTBUS_INT_AUTH_ABILITY_COLLECTION, (unsigned char*)&val, sizeof(val));
|
||||
sets->SetConfig(SOFTBUS_INT_AUTH_ABILITY_COLLECTION, (unsigned char *)&val, sizeof(val));
|
||||
}
|
@ -176,7 +176,8 @@ NO_SANITIZE("cfi") void UnregisterLaneIdListener(const ILaneIdStateListener *lis
|
||||
return;
|
||||
}
|
||||
LaneIdListenerNode *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_laneListenerList.list, LaneIdListenerNode, node) {
|
||||
LaneIdListenerNode *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_laneListenerList.list, LaneIdListenerNode, node) {
|
||||
if (memcmp(&item->listener, listener, sizeof(ILaneIdStateListener)) == 0) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item);
|
||||
|
@ -166,6 +166,7 @@ NO_SANITIZE("cfi") void LnnLanePendingDeinit(void)
|
||||
ConnRequestItem *item = NULL;
|
||||
while (!IsListEmpty(&g_pendingList->list)) {
|
||||
item = LIST_ENTRY(GET_LIST_HEAD(&g_pendingList->list), ConnRequestItem, node);
|
||||
ListDelete(&item->node);
|
||||
(void)SoftBusCondDestroy(&item->cond);
|
||||
SoftBusFree(item);
|
||||
}
|
||||
|
@ -91,11 +91,12 @@ static void AddLaneIdNode(uint32_t laneId, LaneModel *laneModel)
|
||||
|
||||
static void DeleteLaneIdNode(uint32_t laneId, LaneModel *laneModel)
|
||||
{
|
||||
LaneIdInfo *infoNode = NULL;
|
||||
LIST_FOR_EACH_ENTRY(infoNode, &laneModel->laneIdList, LaneIdInfo, node) {
|
||||
if (infoNode->laneId == laneId) {
|
||||
ListDelete(&infoNode->node);
|
||||
SoftBusFree(infoNode);
|
||||
LaneIdInfo *item = NULL;
|
||||
LaneIdInfo *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &laneModel->laneIdList, LaneIdInfo, node) {
|
||||
if (item->laneId == laneId) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item);
|
||||
laneModel->ref--;
|
||||
return;
|
||||
}
|
||||
|
@ -50,12 +50,12 @@ static int32_t GetWlanLinkedFrequency(void)
|
||||
static bool GetNetCap(const char *networkId, int32_t *local, int32_t *remote)
|
||||
{
|
||||
int32_t ret = LnnGetLocalNumInfo(NUM_KEY_NET_CAP, local);
|
||||
if (ret < 0 || *local < 0) {
|
||||
if (ret != SOFTBUS_OK || *local < 0) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "LnnGetLocalNumInfo err, ret = %d, local = %d", ret, *local);
|
||||
return false;
|
||||
}
|
||||
ret = LnnGetRemoteNumInfo(networkId, NUM_KEY_NET_CAP, remote);
|
||||
if (ret < 0 || *remote < 0) {
|
||||
if (ret != SOFTBUS_OK || *remote < 0) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "LnnGetRemoteNumInfo err, ret = %d, remote = %d", ret, *remote);
|
||||
return false;
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ static void LinkSuccess(uint32_t laneId, const LaneLinkInfo *linkInfo)
|
||||
{
|
||||
if (linkInfo == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "linkSuccess param invalid");
|
||||
return;
|
||||
}
|
||||
LaneLinkInfo *linkParam = (LaneLinkInfo *)SoftBusCalloc(sizeof(LaneLinkInfo));
|
||||
if (linkParam == NULL) {
|
||||
@ -140,7 +141,8 @@ static void DeleteLaneLinkNode(uint32_t laneId)
|
||||
return;
|
||||
}
|
||||
LaneLinkNodeInfo *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_multiLinkList, LaneLinkNodeInfo, node) {
|
||||
LaneLinkNodeInfo *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_multiLinkList, LaneLinkNodeInfo, node) {
|
||||
if (item->laneId == laneId) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item->linkList);
|
||||
@ -207,11 +209,12 @@ static void DeleteRequestNode(uint32_t laneId)
|
||||
if (Lock() != SOFTBUS_OK) {
|
||||
return;
|
||||
}
|
||||
TransReqInfo *infoNode = NULL;
|
||||
LIST_FOR_EACH_ENTRY(infoNode, &g_requestList->list, TransReqInfo, node) {
|
||||
if (infoNode->laneId == laneId) {
|
||||
ListDelete(&infoNode->node);
|
||||
SoftBusFree(infoNode);
|
||||
TransReqInfo *item = NULL;
|
||||
TransReqInfo *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_requestList->list, TransReqInfo, node) {
|
||||
if (item->laneId == laneId) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item);
|
||||
g_requestList->cnt--;
|
||||
break;
|
||||
}
|
||||
@ -281,15 +284,16 @@ static int32_t Free(uint32_t laneId)
|
||||
if (Lock() != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
TransReqInfo *infoNode = NULL;
|
||||
LIST_FOR_EACH_ENTRY(infoNode, &g_requestList->list, TransReqInfo, node) {
|
||||
if (infoNode->laneId == laneId) {
|
||||
ListDelete(&infoNode->node);
|
||||
TransReqInfo *item = NULL;
|
||||
TransReqInfo *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_requestList->list, TransReqInfo, node) {
|
||||
if (item->laneId == laneId) {
|
||||
ListDelete(&item->node);
|
||||
g_requestList->cnt--;
|
||||
Unlock();
|
||||
DestroyLink(laneId, infoNode->type, infoNode->info.pid, infoNode->p2pMac, infoNode->info.networkId);
|
||||
UnbindLaneId(laneId, infoNode);
|
||||
SoftBusFree(infoNode);
|
||||
DestroyLink(laneId, item->type, item->info.pid, item->p2pMac, item->info.networkId);
|
||||
UnbindLaneId(laneId, item);
|
||||
SoftBusFree(item);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
@ -392,10 +396,12 @@ NO_SANITIZE("cfi") static void NotifyLaneAllocFail(uint32_t laneId, int32_t reas
|
||||
return;
|
||||
}
|
||||
TransReqInfo *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_requestList->list, TransReqInfo, node) {
|
||||
TransReqInfo *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_requestList->list, TransReqInfo, node) {
|
||||
if (item->laneId == laneId) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item);
|
||||
g_requestList->cnt--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -168,8 +168,9 @@ static int32_t TryUpdateStartTimeSyncReq(TimeSyncReqInfo *info, const StartTimeS
|
||||
static void RemoveStartTimeSyncReq(const TimeSyncReqInfo *info, const char *pkgName)
|
||||
{
|
||||
StartTimeSyncReq *item = NULL;
|
||||
StartTimeSyncReq *next = NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &info->startReqList, StartTimeSyncReq, node) {
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &info->startReqList, StartTimeSyncReq, node) {
|
||||
if (strcmp(pkgName, item->pkgName) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -54,11 +54,6 @@
|
||||
#define JSON_KEY_MASTER_WEIGHT "MasterWeight"
|
||||
#define NOT_TRUSTED_DEVICE_MSG_DELAY 5000
|
||||
|
||||
typedef enum {
|
||||
LNN_MSG_ID_ELECT,
|
||||
LNN_MSG_ID_MAX
|
||||
} LnnMsgType;
|
||||
|
||||
typedef enum {
|
||||
MSG_TYPE_JOIN_LNN = 0,
|
||||
MSG_TYPE_DISCOVERY_DEVICE,
|
||||
@ -174,7 +169,7 @@ static void NetBuilderConfigInit(void)
|
||||
g_netBuilder.maxConnCount = DEFAULT_MAX_LNN_CONNECTION_COUNT;
|
||||
}
|
||||
if (SoftbusGetConfig(SOFTBUS_INT_LNN_MAX_CONCURRENT_NUM,
|
||||
(unsigned char *)&g_netBuilder.maxConcurrentCount, sizeof(g_netBuilder.maxConnCount)) != SOFTBUS_OK) {
|
||||
(unsigned char *)&g_netBuilder.maxConcurrentCount, sizeof(g_netBuilder.maxConcurrentCount)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "get lnn max conncurent count fail, use default value");
|
||||
g_netBuilder.maxConcurrentCount = 0;
|
||||
}
|
||||
@ -493,8 +488,9 @@ static int32_t PostJoinRequestToMetaNode(MetaJoinRequestNode *metaJoinNode, cons
|
||||
static void TryRemovePendingJoinRequest(void)
|
||||
{
|
||||
PendingJoinRequestNode *item = NULL;
|
||||
PendingJoinRequestNode *next = NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_netBuilder.pendingList, PendingJoinRequestNode, node) {
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_netBuilder.pendingList, PendingJoinRequestNode, node) {
|
||||
if (NeedPendingJoinRequest()) {
|
||||
return;
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ NO_SANITIZE("cfi") int32_t LnnInitTopoManager(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
if (SoftbusGetConfig(SOFTBUS_BOOL_SUPPORT_TOPO, (unsigned char*)&g_topoTable.isSupportTopo,
|
||||
if (SoftbusGetConfig(SOFTBUS_BOOL_SUPPORT_TOPO, (unsigned char *)&g_topoTable.isSupportTopo,
|
||||
sizeof(g_topoTable.isSupportTopo)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "Cannot get isSupportTopo from config file");
|
||||
g_topoTable.isSupportTopo = true;
|
||||
|
@ -50,7 +50,7 @@ NO_SANITIZE("cfi") uint32_t LnnGetNetCapabilty(void)
|
||||
uint32_t configValue;
|
||||
|
||||
if (SoftbusGetConfig(SOFTBUS_INT_LNN_SUPPORT_CAPABILITY,
|
||||
(unsigned char*)&configValue, sizeof(configValue)) != SOFTBUS_OK) {
|
||||
(unsigned char *)&configValue, sizeof(configValue)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "get lnn capbility fail, use default value");
|
||||
configValue = DEFAUTL_LNN_CAPBILITY;
|
||||
}
|
||||
|
@ -46,9 +46,10 @@ static bool CheckMetaNodeConfigInfo(const MetaNodeConfigInfo *info)
|
||||
static MetaNodeStorageInfo *FindMetaNodeStorageInfo(const char *id, bool isUdid)
|
||||
{
|
||||
MetaNodeStorageInfo *item = NULL;
|
||||
MetaNodeStorageInfo *next = NULL;
|
||||
const char *itemId = NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_metaNodeList->list, MetaNodeStorageInfo, node) {
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_metaNodeList->list, MetaNodeStorageInfo, node) {
|
||||
itemId = isUdid ? item->info.configInfo.udid : item->info.metaNodeId;
|
||||
if (strncmp(itemId, id, strlen(id)) == 0) {
|
||||
return item;
|
||||
@ -183,7 +184,9 @@ NO_SANITIZE("cfi") int32_t LnnGetAllMetaNodeInfo(MetaNodeInfo *infos, int32_t *i
|
||||
|
||||
NO_SANITIZE("cfi") int32_t LnnInitMetaNodeLedger(void)
|
||||
{
|
||||
g_metaNodeList = CreateSoftBusList();
|
||||
if (g_metaNodeList == NULL) {
|
||||
g_metaNodeList = CreateSoftBusList();
|
||||
}
|
||||
if (g_metaNodeList == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "create meta node list failed");
|
||||
return SOFTBUS_ERR;
|
||||
@ -194,8 +197,22 @@ NO_SANITIZE("cfi") int32_t LnnInitMetaNodeLedger(void)
|
||||
|
||||
NO_SANITIZE("cfi") void LnnDeinitMetaNodeLedger(void)
|
||||
{
|
||||
if (g_metaNodeList != NULL) {
|
||||
DestroySoftBusList(g_metaNodeList);
|
||||
g_metaNodeList = NULL;
|
||||
if (g_metaNodeList == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MetaNodeStorageInfo *item = NULL;
|
||||
MetaNodeStorageInfo *next = NULL;
|
||||
if (SoftBusMutexLock(&g_metaNodeList->lock) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "lock failed");
|
||||
return;
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_metaNodeList->list, MetaNodeStorageInfo, node) {
|
||||
ListDelete(&item->node);
|
||||
g_metaNodeList->cnt--;
|
||||
SoftBusFree(item);
|
||||
}
|
||||
(void)SoftBusMutexUnlock(&g_metaNodeList->lock);
|
||||
DestroySoftBusList(g_metaNodeList);
|
||||
g_metaNodeList = NULL;
|
||||
}
|
@ -49,10 +49,12 @@ NO_SANITIZE("cfi") static int32_t PostMessageToHandler(SoftBusMessage *msg)
|
||||
{
|
||||
if (g_notifyHandler.looper == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "NotifyHandler not initialized.");
|
||||
FreeMessage(msg);
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
if (g_notifyHandler.looper->PostMessage == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "invalid looper.");
|
||||
FreeMessage(msg);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
g_notifyHandler.looper->PostMessage(g_notifyHandler.looper, msg);
|
||||
@ -154,8 +156,7 @@ static bool IsRepeatEventHandler(LnnEventType event, LnnEventHandler handler)
|
||||
{
|
||||
LnnEventHandlerItem *item = NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_eventCtrl.handlers[event], LnnEventHandlerItem, node)
|
||||
{
|
||||
LIST_FOR_EACH_ENTRY(item, &g_eventCtrl.handlers[event], LnnEventHandlerItem, node) {
|
||||
if (item->handler == handler) {
|
||||
return true;
|
||||
}
|
||||
@ -183,8 +184,7 @@ static void NotifyEvent(const LnnEventBasicInfo *info)
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "lock failed in notify event");
|
||||
return;
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY(item, &g_eventCtrl.handlers[info->event], LnnEventHandlerItem, node)
|
||||
{
|
||||
LIST_FOR_EACH_ENTRY(item, &g_eventCtrl.handlers[info->event], LnnEventHandlerItem, node) {
|
||||
item->handler(info);
|
||||
}
|
||||
(void)SoftBusMutexUnlock(&g_eventCtrl.lock);
|
||||
@ -437,6 +437,7 @@ NO_SANITIZE("cfi") int32_t LnnRegisterEventHandler(LnnEventType event, LnnEventH
|
||||
NO_SANITIZE("cfi") void LnnUnregisterEventHandler(LnnEventType event, LnnEventHandler handler)
|
||||
{
|
||||
LnnEventHandlerItem *item = NULL;
|
||||
LnnEventHandlerItem *next = NULL;
|
||||
|
||||
if (event == LNN_EVENT_TYPE_MAX || handler == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "invalid event handler params");
|
||||
@ -446,8 +447,7 @@ NO_SANITIZE("cfi") void LnnUnregisterEventHandler(LnnEventType event, LnnEventHa
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "hold lock failed in unregister event handler");
|
||||
return;
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY(item, &g_eventCtrl.handlers[event], LnnEventHandlerItem, node)
|
||||
{
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_eventCtrl.handlers[event], LnnEventHandlerItem, node) {
|
||||
if (item->handler == handler) {
|
||||
ListDelete(&item->node);
|
||||
SoftBusFree(item);
|
||||
|
@ -98,7 +98,7 @@ static LnnLocalConfigInit g_lnnLocalConfigInit = {
|
||||
static void ReadDelayConfig(void)
|
||||
{
|
||||
if (SoftbusGetConfig(SOFTBUS_INT_LNN_UDID_INIT_DELAY_LEN,
|
||||
(unsigned char*)&g_lnnLocalConfigInit.delayLen, sizeof(g_lnnLocalConfigInit.delayLen)) != SOFTBUS_OK) {
|
||||
(unsigned char *)&g_lnnLocalConfigInit.delayLen, sizeof(g_lnnLocalConfigInit.delayLen)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "get lnn delay init len fail, use default value");
|
||||
g_lnnLocalConfigInit.delayLen = DEFAULT_DELAY_LEN;
|
||||
}
|
||||
|
@ -162,132 +162,132 @@ static DiscConfigItem g_discConfig = {
|
||||
ConfigVal g_configItems[SOFTBUS_CONFIG_TYPE_MAX] = {
|
||||
{
|
||||
SOFTBUS_INT_MAX_BYTES_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxBytesLen),
|
||||
(unsigned char *)&(g_tranConfig.maxBytesLen),
|
||||
sizeof(g_tranConfig.maxBytesLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_MAX_MESSAGE_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxMessageLen),
|
||||
(unsigned char *)&(g_tranConfig.maxMessageLen),
|
||||
sizeof(g_tranConfig.maxMessageLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_BR_MAX_DATA_LENGTH,
|
||||
(unsigned char*)&(g_config.connBrMaxDataLen),
|
||||
(unsigned char *)&(g_config.connBrMaxDataLen),
|
||||
sizeof(g_config.connBrMaxDataLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_RFCOM_SEND_MAX_LEN,
|
||||
(unsigned char*)&(g_config.connRfcomSendMaxLen),
|
||||
(unsigned char *)&(g_config.connRfcomSendMaxLen),
|
||||
sizeof(g_config.connRfcomSendMaxLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_BR_RECEIVE_MAX_LEN,
|
||||
(unsigned char*)&(g_config.connBrRecvMaxLen),
|
||||
(unsigned char *)&(g_config.connBrRecvMaxLen),
|
||||
sizeof(g_config.connBrRecvMaxLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_TCP_MAX_LENGTH,
|
||||
(unsigned char*)&(g_config.connTcpMaxLen),
|
||||
(unsigned char *)&(g_config.connTcpMaxLen),
|
||||
sizeof(g_config.connTcpMaxLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_TCP_MAX_CONN_NUM,
|
||||
(unsigned char*)&(g_config.connTcpMaxConnNum),
|
||||
(unsigned char *)&(g_config.connTcpMaxConnNum),
|
||||
sizeof(g_config.connTcpMaxConnNum)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_CONN_TCP_TIME_OUT,
|
||||
(unsigned char*)&(g_config.connTcpTimeOut),
|
||||
(unsigned char *)&(g_config.connTcpTimeOut),
|
||||
sizeof(g_config.connTcpTimeOut)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_MAX_NODE_STATE_CB_CNT,
|
||||
(unsigned char*)&(g_config.maxNodeStateCbCnt),
|
||||
(unsigned char *)&(g_config.maxNodeStateCbCnt),
|
||||
sizeof(g_config.maxNodeStateCbCnt)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_MAX_LNN_CONNECTION_CNT,
|
||||
(unsigned char*)&(g_config.maxLnnConnCnt),
|
||||
(unsigned char *)&(g_config.maxLnnConnCnt),
|
||||
sizeof(g_config.maxLnnConnCnt)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_LNN_SUPPORT_CAPABILITY,
|
||||
(unsigned char*)&(g_config.maxLnnSupportCap),
|
||||
(unsigned char *)&(g_config.maxLnnSupportCap),
|
||||
sizeof(g_config.maxLnnSupportCap)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_AUTH_ABILITY_COLLECTION,
|
||||
(unsigned char*)&(g_config.authAbilityConn),
|
||||
(unsigned char *)&(g_config.authAbilityConn),
|
||||
sizeof(g_config.authAbilityConn)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_ADAPTER_LOG_LEVEL,
|
||||
(unsigned char*)&(g_config.adapterLogLevel),
|
||||
(unsigned char *)&(g_config.adapterLogLevel),
|
||||
sizeof(g_config.adapterLogLevel)
|
||||
},
|
||||
{
|
||||
SOFTBUS_STR_STORAGE_DIRECTORY,
|
||||
(unsigned char*)(g_config.storageDir),
|
||||
(unsigned char *)(g_config.storageDir),
|
||||
sizeof(g_config.storageDir)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_SUPPORT_TCP_PROXY,
|
||||
(unsigned char*)&(g_tranConfig.isSupportTcpProxy),
|
||||
(unsigned char *)&(g_tranConfig.isSupportTcpProxy),
|
||||
sizeof(g_tranConfig.isSupportTcpProxy)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_SUPPORT_SELECT_INTERVAL,
|
||||
(unsigned char*)&(g_tranConfig.selectInterval),
|
||||
(unsigned char *)&(g_tranConfig.selectInterval),
|
||||
sizeof(g_tranConfig.selectInterval)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_LNN_UDID_INIT_DELAY_LEN,
|
||||
(unsigned char*)&(g_config.lnnUdidInitDelayLen),
|
||||
(unsigned char *)&(g_config.lnnUdidInitDelayLen),
|
||||
sizeof(g_config.lnnUdidInitDelayLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_STR_LNN_NET_IF_NAME,
|
||||
(unsigned char*)&(g_config.lnnNetIfName),
|
||||
(unsigned char *)&(g_config.lnnNetIfName),
|
||||
sizeof(g_config.lnnNetIfName)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_LNN_MAX_CONCURRENT_NUM,
|
||||
(unsigned char*)&(g_config.lnnMaxConcurentNum),
|
||||
(unsigned char *)&(g_config.lnnMaxConcurentNum),
|
||||
sizeof(g_config.lnnMaxConcurentNum)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_AUTH_MAX_BYTES_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxAuthBytesLen),
|
||||
(unsigned char *)&(g_tranConfig.maxAuthBytesLen),
|
||||
sizeof(g_tranConfig.maxAuthBytesLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_AUTH_MAX_MESSAGE_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxAuthMessageLen),
|
||||
(unsigned char *)&(g_tranConfig.maxAuthMessageLen),
|
||||
sizeof(g_tranConfig.maxAuthMessageLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_AUTO_NETWORKING_SWITCH,
|
||||
(unsigned char*)&(g_config.lnnAutoNetworkingSwitch),
|
||||
(unsigned char *)&(g_config.lnnAutoNetworkingSwitch),
|
||||
sizeof(g_config.lnnAutoNetworkingSwitch)
|
||||
},
|
||||
{
|
||||
SOFTBUS_BOOL_SUPPORT_TOPO,
|
||||
(unsigned char*)&(g_config.isSupportTopo),
|
||||
(unsigned char *)&(g_config.isSupportTopo),
|
||||
sizeof(g_config.isSupportTopo)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_DISC_FREQ,
|
||||
(unsigned char*)(g_discConfig.discFreq),
|
||||
(unsigned char *)(g_discConfig.discFreq),
|
||||
sizeof(g_discConfig.discFreq)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_PROXY_MAX_BYTES_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxProxyBytesLen),
|
||||
(unsigned char *)&(g_tranConfig.maxProxyBytesLen),
|
||||
sizeof(g_tranConfig.maxProxyBytesLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_PROXY_MAX_MESSAGE_LENGTH,
|
||||
(unsigned char*)&(g_tranConfig.maxProxyMessageLen),
|
||||
(unsigned char *)&(g_tranConfig.maxProxyMessageLen),
|
||||
sizeof(g_tranConfig.maxProxyMessageLen)
|
||||
},
|
||||
|
||||
|
@ -96,7 +96,7 @@ extern "C" {
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define EVENT_NODE_STATUS_CHANGED 0x05
|
||||
#define EVENT_NODE_STATUS_CHANGED 0x08
|
||||
|
||||
/**
|
||||
* @brief Indicates mask bits for {@link INodeStateCb.events}.
|
||||
@ -104,7 +104,7 @@ extern "C" {
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define EVENT_NODE_STATE_MASK 0x07
|
||||
#define EVENT_NODE_STATE_MASK 0x15
|
||||
|
||||
/**
|
||||
* @brief The maximum length of meta node bypass info {@link MetaNodeConfigInfo.bypassInfo}.
|
||||
@ -122,6 +122,14 @@ extern "C" {
|
||||
*/
|
||||
#define CALLER_ID_MAX_LEN 128
|
||||
|
||||
/**
|
||||
* @brief Indicates the maximum length of the custom user data.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
#define USER_DATA_MAX_LEN 256
|
||||
|
||||
/**
|
||||
* @brief The maximum of meta node {@link MetaNodeConfigInfo.bypassInfo}.
|
||||
*
|
||||
@ -138,14 +146,14 @@ extern "C" {
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
NODE_KEY_UDID = 0, /**< UDID in string format*/
|
||||
NODE_KEY_UUID, /**< UUID in string format */
|
||||
NODE_KEY_UDID = 0, /**< UDID in string format*/
|
||||
NODE_KEY_UUID, /**< UUID in string format */
|
||||
NODE_KEY_MASTER_UDID, /**< UDID of master node in string format */
|
||||
NODE_KEY_BR_MAC, /**< BR MAC in string format */
|
||||
NODE_KEY_IP_ADDRESS, /**< IP address in string format */
|
||||
NODE_KEY_DEV_NAME, /**< Device name in string format */
|
||||
NODE_KEY_NETWORK_CAPABILITY, /**< Network capability in number format */
|
||||
NODE_KEY_NETWORK_TYPE, /**< Network type in number format */
|
||||
NODE_KEY_BR_MAC, /**< BR MAC in string format */
|
||||
NODE_KEY_IP_ADDRESS, /**< IP address in string format */
|
||||
NODE_KEY_DEV_NAME, /**< Device name in string format */
|
||||
NODE_KEY_NETWORK_CAPABILITY, /**< Network capability in number format */
|
||||
NODE_KEY_NETWORK_TYPE, /**< Network type in number format */
|
||||
NODE_KEY_BLE_OFFLINE_CODE, /**< Ble offlinecode in string format */
|
||||
NODE_KEY_DATA_CHANGE_FLAG,
|
||||
} NodeDeviceInfoKey;
|
||||
@ -254,7 +262,7 @@ typedef struct {
|
||||
uint16_t authStatus;
|
||||
uint16_t dataBaseStatus;
|
||||
uint16_t meshType;
|
||||
uint16_t reserved[NODE_STATUS_MAX_NUM-3];
|
||||
uint16_t reserved[NODE_STATUS_MAX_NUM - 3];
|
||||
} NodeStatus;
|
||||
|
||||
/**
|
||||
@ -264,10 +272,10 @@ typedef struct {
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef enum {
|
||||
TYPE_AUTH_STATUS = 2, /**< certify status change */
|
||||
TYPE_AUTH_STATUS = 2, /**< certify status change */
|
||||
TYPE_DATABASE_STATUS = 3, /**< database change */
|
||||
TYPE_MESH_TYPE = 4, /**< lnn mesh typechange */
|
||||
TYPE_STATUS_MAX = 5, /**< max num */
|
||||
TYPE_MESH_TYPE = 4, /**< lnn mesh typechange */
|
||||
TYPE_STATUS_MAX = 5, /**< max num */
|
||||
} NodeStatusType;
|
||||
|
||||
/**
|
||||
@ -401,7 +409,7 @@ typedef struct {
|
||||
* @brief Called when the running status of a device changes.
|
||||
*
|
||||
* @param type Indicates the device type. For details, see {@link NodeStatusType}.
|
||||
* @param info Indicates the pointer to the new status of the device.
|
||||
* @param status Indicates the pointer to the new status of the device.
|
||||
* For details, see {@link NodeStatus}.
|
||||
*
|
||||
* @since 1.0
|
||||
@ -488,8 +496,8 @@ typedef enum {
|
||||
* @version 1.0
|
||||
*/
|
||||
typedef struct {
|
||||
CustomType type; /**< user type */
|
||||
uint8_t data[256]; /**< user data */
|
||||
CustomType type; /**< user type */
|
||||
uint8_t data[USER_DATA_MAX_LEN]; /**< user data */
|
||||
} CustomData;
|
||||
|
||||
/**
|
||||
@ -599,8 +607,10 @@ int32_t JoinMetaNode(const char *pkgName, ConnectionAddr *target, CustomData *cu
|
||||
int32_t LeaveLNN(const char *pkgName, const char *networkId, OnLeaveLNNResult cb);
|
||||
|
||||
/**
|
||||
* @brief Removes the current device from the LNN.
|
||||
* @brief Removes the current device from the MetaNode.
|
||||
*
|
||||
* @param pkgName Indicates the pointer to the caller ID, for example, the package name.
|
||||
* For the same caller, the value of this parameter must be the same for all functions.
|
||||
* @param networkId Indicates the pointer to the network ID that is returned
|
||||
* after the device is added to the LNN via {@link JoinMetaNode}.
|
||||
* @param cb Indicates the callback for the result. If you set this parameter to <b>NULL</b>,
|
||||
|
@ -398,7 +398,7 @@ void BusCenterClientDeinit(void)
|
||||
int BusCenterClientInit(void)
|
||||
{
|
||||
if (SoftbusGetConfig(SOFTBUS_INT_MAX_NODE_STATE_CB_CNT,
|
||||
(unsigned char*)&g_maxNodeStateCbCount, sizeof(g_maxNodeStateCbCount)) != SOFTBUS_OK) {
|
||||
(unsigned char *)&g_maxNodeStateCbCount, sizeof(g_maxNodeStateCbCount)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "Cannot get NodeStateCbCount from config file");
|
||||
g_maxNodeStateCbCount = DEFAULT_NODE_STATE_CB_CNT;
|
||||
}
|
||||
|
@ -60,6 +60,10 @@ static bool IsValidNodeStateCb(INodeStateCb *callback)
|
||||
callback->onNodeBasicInfoChanged == NULL) {
|
||||
return false;
|
||||
}
|
||||
if ((callback->events & EVENT_NODE_STATUS_CHANGED) != 0 &&
|
||||
callback->onNodeStatusChanged == NULL) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user