mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-27 02:40:40 +00:00
!8373 bug fix: bus_center error code rectification
Merge pull request !8373 from ym/master
This commit is contained in:
commit
a52f753b05
@ -87,9 +87,10 @@ static int32_t EnableBtSubnet(LnnPhysicalSubnet *subnet)
|
||||
LNN_LOGI(LNN_BUILDER, "bt running return ok");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (GetAvailableBtMac(macStr, sizeof(macStr)) != SOFTBUS_OK) {
|
||||
int32_t ret = GetAvailableBtMac(macStr, sizeof(macStr));
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get available bt mac fail");
|
||||
return SOFTBUS_ERR;
|
||||
return ret;
|
||||
}
|
||||
char *anonyMac = NULL;
|
||||
Anonymize(macStr, &anonyMac);
|
||||
@ -105,7 +106,7 @@ static int32_t DisableBrSubnet(LnnPhysicalSubnet *subnet)
|
||||
};
|
||||
|
||||
if (subnet->status != LNN_SUBNET_RUNNING) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SUBNET_STATUS_ERR;
|
||||
}
|
||||
LNN_LOGI(LNN_BUILDER, "br subnet is disable, start leave br network");
|
||||
int32_t ret = LnnRequestLeaveByAddrType(addrType, CONNECTION_ADDR_MAX);
|
||||
@ -124,7 +125,7 @@ static int32_t DisableBleSubnet(LnnPhysicalSubnet *subnet)
|
||||
};
|
||||
|
||||
if (subnet->status != LNN_SUBNET_RUNNING) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SUBNET_STATUS_ERR;
|
||||
}
|
||||
LNN_LOGI(LNN_BUILDER, "ble subnet is disable, start leave ble network");
|
||||
ret = LnnRequestLeaveByAddrType(addrType, CONNECTION_ADDR_MAX);
|
||||
@ -186,7 +187,7 @@ static void OnBtNetifStatusChanged(LnnPhysicalSubnet *subnet, void *status)
|
||||
event = GetBtStatusChangedEvent(btState);
|
||||
}
|
||||
|
||||
int32_t ret = SOFTBUS_ERR;
|
||||
int32_t ret = SOFTBUS_NETWORK_NETIF_STATUS_CHANGED;
|
||||
LnnNetIfType type;
|
||||
LnnGetNetIfTypeByName(subnet->ifName, &type);
|
||||
switch (event) {
|
||||
@ -318,11 +319,11 @@ int32_t LnnInitBtProtocol(struct LnnProtocolManager *self)
|
||||
(void)self;
|
||||
if (LnnRegisterEventHandler(LNN_EVENT_BT_STATE_CHANGED, BtStateChangedEvtHandler) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "register bt state change event handler failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR;
|
||||
}
|
||||
if (LnnRegisterEventHandler(LNN_EVENT_BT_ACL_STATE_CHANGED, BtAclStateChangedEvtHandler) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "register bt acl state change event handler failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -338,7 +339,7 @@ int32_t LnnEnableBtProtocol(struct LnnProtocolManager *self, LnnNetIfMgr *netifM
|
||||
LnnPhysicalSubnet *manager = CreateBtSubnetManager(self, netifMgr->ifName);
|
||||
if (manager == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "create bt subnet mgr fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_CREATE_SUBNET_MANAGER_FAILED;
|
||||
}
|
||||
|
||||
int ret = LnnRegistPhysicalSubnet(manager);
|
||||
|
@ -63,19 +63,19 @@ static int32_t GetWifiServiceIpAddr(const char *ifName, char *ip, uint32_t size)
|
||||
{
|
||||
if (ifName == NULL || ip == NULL || size == 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "invalid parameter");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (strcmp(ifName, WLAN_IFNAME) != 0) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
if (GetWlanIpv4Addr(ip, size) != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
if (strnlen(ip, size) == 0 || strnlen(ip, size) == size) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
if (strcmp(ip, LNN_LOOPBACK_IP) == 0 || strcmp(ip, "") == 0 || strcmp(ip, "0.0.0.0") == 0) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -83,12 +83,12 @@ static int32_t GetWifiServiceIpAddr(const char *ifName, char *ip, uint32_t size)
|
||||
static int32_t GetIpAddrFromNetlink(const char *ifName, char *ip, uint32_t size)
|
||||
{
|
||||
if (GetNetworkIpByIfName(ifName, ip, NULL, size) != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
|
||||
if (strcmp(ip, LNN_LOOPBACK_IP) == 0 || strcmp(ip, "") == 0 || strcmp(ip, "0.0.0.0") == 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "invalid ip addr");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -132,12 +132,12 @@ static int32_t GetAvailableIpAddr(const char *ifName, char *ip, uint32_t size)
|
||||
if (--retryTime > 0 && LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), RetryGetAvailableIpAddr,
|
||||
NULL, GET_IP_INTERVAL_TIME) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "LnnAsyncCallbackDelayHelper get available ip fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
if (retryTime <= 0) {
|
||||
retryTime = GET_IP_RETRY_TIMES;
|
||||
}
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_IP_ADDR_FAILED;
|
||||
}
|
||||
|
||||
static int32_t OpenAuthPort(void)
|
||||
@ -152,12 +152,12 @@ static int32_t OpenAuthPort(void)
|
||||
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_WLAN_IP, localIp, MAX_ADDR_LEN) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get local ip failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
|
||||
}
|
||||
int32_t port = AuthStartListening(AUTH_LINK_TYPE_WIFI, localIp, authPort);
|
||||
if (port < 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "AuthStartListening failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PORT;
|
||||
}
|
||||
char *anonyIp = NULL;
|
||||
Anonymize(localIp, &anonyIp);
|
||||
@ -195,12 +195,12 @@ static int32_t OpenSessionPort(void)
|
||||
};
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_WLAN_IP, info.socketOption.addr, sizeof(info.socketOption.addr)) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get local ip failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
|
||||
}
|
||||
port = TransTdcStartSessionListener(DIRECT_CHANNEL_SERVER_WIFI, &info);
|
||||
if (port < 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "open session server failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PORT;
|
||||
}
|
||||
if (sessionPort == 0) {
|
||||
return LnnSetLocalNumInfo(NUM_KEY_SESSION_PORT, port);
|
||||
@ -270,13 +270,13 @@ static int32_t OpenIpLink(void)
|
||||
int32_t ret = OpenAuthPort();
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "OpenAuthPort fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_PORT_PROCESS_FAILED;
|
||||
}
|
||||
ret = OpenSessionPort();
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "OpenSessionPort fail");
|
||||
CloseAuthPort();
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_PORT_PROCESS_FAILED;
|
||||
}
|
||||
OpenProxyPort();
|
||||
return SOFTBUS_OK;
|
||||
@ -294,11 +294,11 @@ static int32_t GetLocalIpInfo(char *ipAddr, uint32_t ipAddrLen, char *ifName, ui
|
||||
{
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_WLAN_IP, ipAddr, ipAddrLen) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get local ip error");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
|
||||
}
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_NET_IF_NAME, ifName, ifNameLen) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get local ifName error");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -306,11 +306,11 @@ static int32_t GetLocalIpInfo(char *ipAddr, uint32_t ipAddrLen, char *ifName, ui
|
||||
static int32_t SetLocalIpInfo(const char *ipAddr, const char *ifName)
|
||||
{
|
||||
if (LnnSetLocalStrInfo(STRING_KEY_WLAN_IP, ipAddr) != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_NODE_INFO_ERR;
|
||||
}
|
||||
if (LnnSetLocalStrInfo(STRING_KEY_NET_IF_NAME, ifName) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "set local ifName error");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_NODE_INFO_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -346,12 +346,12 @@ static int32_t ReleaseMainPort(const char *ifName)
|
||||
}
|
||||
if (strcmp(ifName, oldMainIf) != 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "if is not main port! ifName=%{public}s", ifName);
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_CMP_FAIL;
|
||||
}
|
||||
} while (false);
|
||||
if (SetLocalIpInfo(LNN_LOOPBACK_IP, LNN_LOOPBACK_IFNAME) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "set local ip info failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_NODE_INFO_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -360,25 +360,25 @@ static int32_t RequestMainPort(const char *ifName, const char *address)
|
||||
{
|
||||
if (strcmp(ifName, LNN_LOOPBACK_IFNAME) == 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "loopback ifName not allowed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_CMP_FAIL;
|
||||
}
|
||||
if (strcmp(address, LNN_LOOPBACK_IP) == 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "loopback ip not allowed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_CMP_FAIL;
|
||||
}
|
||||
LNN_LOGI(LNN_BUILDER, "get local ifName begin");
|
||||
char oldMainIf[NET_IF_NAME_LEN] = {0};
|
||||
if (LnnGetLocalStrInfo(STRING_KEY_NET_IF_NAME, oldMainIf, sizeof(oldMainIf)) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "get local ifName error");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_GET_NODE_INFO_ERR;
|
||||
}
|
||||
LNN_LOGD(LNN_BUILDER, "get local ifName end");
|
||||
if (strcmp(oldMainIf, ifName) != 0 && strcmp(oldMainIf, LNN_LOOPBACK_IFNAME) != 0) {
|
||||
LNN_LOGE(LNN_BUILDER, "Only 1 local subnet is allowed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_CMP_FAIL;
|
||||
}
|
||||
if (SetLocalIpInfo(address, ifName) != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_NODE_INFO_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -394,7 +394,7 @@ static int32_t EnableIpSubnet(LnnPhysicalSubnet *subnet)
|
||||
}
|
||||
if (RequestMainPort(subnet->ifName, address)) {
|
||||
LNN_LOGE(LNN_BUILDER, "request main port failed! ifName=%{public}s", subnet->ifName);
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_PORT_PROCESS_FAILED;
|
||||
}
|
||||
LNN_LOGI(LNN_BUILDER, "open ip link and start discovery");
|
||||
if (OpenIpLink() != SOFTBUS_OK) {
|
||||
@ -538,7 +538,7 @@ static void OnIpNetifStatusChanged(LnnPhysicalSubnet *subnet, void *status)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t ret = SOFTBUS_ERR;
|
||||
int32_t ret = SOFTBUS_NETWORK_NETIF_STATUS_CHANGED;
|
||||
switch (event) {
|
||||
case IP_SUBNET_MANAGER_EVENT_IF_READY: {
|
||||
ret = EnableIpSubnet(subnet);
|
||||
@ -681,11 +681,11 @@ int32_t LnnInitIpProtocol(struct LnnProtocolManager *self)
|
||||
int32_t ret = SOFTBUS_OK;
|
||||
if (LnnRegisterEventHandler(LNN_EVENT_IP_ADDR_CHANGED, IpAddrChangeEventHandler) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "register ip addr change event handler failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR;
|
||||
}
|
||||
if (SetLocalIpInfo(LNN_LOOPBACK_IP, LNN_LOOPBACK_IFNAME) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "init local ip as loopback failed!");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_NODE_INFO_ERR;
|
||||
}
|
||||
DiscLinkStatusChanged(LINK_STATUS_DOWN, COAP);
|
||||
g_heartbeatEnable = IsEnableSoftBusHeartbeat();
|
||||
@ -698,12 +698,12 @@ int32_t LnnEnableIpProtocol(struct LnnProtocolManager *self, LnnNetIfMgr *netifM
|
||||
(void)self;
|
||||
if (netifMgr == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "netif mgr is null");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
LnnPhysicalSubnet *manager = CreateIpSubnetManager(self, netifMgr->ifName);
|
||||
if (manager == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "malloc subnet mgr fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
int ret = LnnRegistPhysicalSubnet(manager);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
|
@ -119,11 +119,11 @@ static int32_t RegistNetIfMgr(LnnNetIfNameType type, LnnNetIfManagerBuilder buil
|
||||
{
|
||||
if (type >= LNN_MAX_NUM_TYPE) {
|
||||
LNN_LOGE(LNN_BUILDER, "type too big");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (g_netifBuilders[type] != NULL && g_netifBuilders[type] != builder) {
|
||||
LNN_LOGE(LNN_BUILDER, "type already registed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_ALREADY_EXISTED;
|
||||
}
|
||||
g_netifBuilders[type] = builder;
|
||||
return SOFTBUS_OK;
|
||||
@ -182,25 +182,25 @@ static int32_t SetIfNameDefaultVal(void)
|
||||
LnnNetIfMgr *netIfMgr = NetifMgrFactory(LNN_ETH_TYPE, LNN_DEFAULT_IF_NAME_ETH);
|
||||
if (netIfMgr == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "add default ETH port failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED;
|
||||
}
|
||||
ListTailInsert(&g_netIfNameList, &netIfMgr->node);
|
||||
netIfMgr = NetifMgrFactory(LNN_WLAN_TYPE, LNN_DEFAULT_IF_NAME_WLAN);
|
||||
if (netIfMgr == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "add default ETH port failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED;
|
||||
}
|
||||
ListTailInsert(&g_netIfNameList, &netIfMgr->node);
|
||||
netIfMgr = NetifMgrFactory(LNN_BR_TYPE, LNN_DEFAULT_IF_NAME_BR);
|
||||
if (netIfMgr == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "add default BR netIfMgr failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED;
|
||||
}
|
||||
ListTailInsert(&g_netIfNameList, &netIfMgr->node);
|
||||
netIfMgr = NetifMgrFactory(LNN_BLE_TYPE, LNN_DEFAULT_IF_NAME_BLE);
|
||||
if (netIfMgr == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "add default BLE netIfMgr failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED;
|
||||
}
|
||||
ListTailInsert(&g_netIfNameList, &netIfMgr->node);
|
||||
return SOFTBUS_OK;
|
||||
@ -213,7 +213,7 @@ static int32_t LnnInitManagerByConfig(void)
|
||||
LNN_LOGE(LNN_BUILDER, "get lnn net ifName fail, use default value");
|
||||
if (SetIfNameDefaultVal() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "default value set fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -375,7 +375,7 @@ int32_t UnregistProtocol(LnnProtocolManager *protocolMgr)
|
||||
}
|
||||
}
|
||||
LNN_LOGE(LNN_BUILDER, "no such protocol!");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
bool LnnVisitNetif(VisitNetifCallback callback, void *data)
|
||||
@ -685,7 +685,7 @@ int32_t LnnInitNetworkManager(void)
|
||||
ProtocolType type = 0;
|
||||
if (!LnnVisitProtocol(GetAllProtocols, &type)) {
|
||||
LNN_LOGE(LNN_BUILDER, "Get all protocol failed");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_MANAGER_INIT_FAILED;
|
||||
}
|
||||
LNN_LOGI(LNN_BUILDER, "set supported protocol type. type=%{public}u", type);
|
||||
ret = LnnSetLocalNum64Info(NUM_KEY_TRANS_PROTOCOLS, (int64_t)type);
|
||||
@ -809,7 +809,7 @@ int32_t LnnGetNetIfTypeByName(const char *ifName, LnnNetIfType *type)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_NOT_FOUND;
|
||||
}
|
||||
|
||||
int32_t LnnGetAddrTypeByIfName(const char *ifName, ConnectionAddrType *type)
|
||||
@ -837,7 +837,7 @@ int32_t LnnGetAddrTypeByIfName(const char *ifName, ConnectionAddrType *type)
|
||||
*type = CONNECTION_ADDR_BLE;
|
||||
break;
|
||||
default:
|
||||
ret = SOFTBUS_ERR;
|
||||
ret = SOFTBUS_NETWORK_NOT_SUPPORT;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -91,14 +91,14 @@ static int32_t DoRegistSubnet(LnnPhysicalSubnet *subnet)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
LNN_LOGE(LNN_BUILDER, "subnet list is full");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_NETWORK_SUBNET_LIST_FULL;
|
||||
}
|
||||
|
||||
int32_t LnnRegistPhysicalSubnet(LnnPhysicalSubnet *subnet)
|
||||
{
|
||||
if (subnet == NULL || subnet->protocol == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "protocol of subnet is required");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
int32_t ret = SOFTBUS_OK;
|
||||
LNN_LOGI(LNN_BUILDER, "get g_physicalSubnetsLock start, currTime=%{public}" PRIu64, SoftBusGetSysTimeMs());
|
||||
|
@ -648,6 +648,13 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_NETWORK_GET_SERVICE_NUM_ZERO,
|
||||
SOFTBUS_NETWORK_GET_CLIENT_PROXY_NULL,
|
||||
SOFTBUS_NETWORK_STOP_REFRESH_LNN_FAILED,
|
||||
SOFTBUS_NETWORK_SET_DEFAULT_VAL_FAILED,
|
||||
SOFTBUS_NETWORK_GET_IP_ADDR_FAILED,
|
||||
SOFTBUS_NETWORK_PORT_PROCESS_FAILED,
|
||||
SOFTBUS_NETWORK_NETIF_STATUS_CHANGED,
|
||||
SOFTBUS_NETWORK_SUBNET_LIST_FULL,
|
||||
SOFTBUS_NETWORK_SUBNET_STATUS_ERR,
|
||||
SOFTBUS_NETWORK_CREATE_SUBNET_MANAGER_FAILED,
|
||||
|
||||
/* errno begin: -((203 << 21) | (4 << 16) | (1 << 12) | 0x0FFF) */
|
||||
SOFTBUS_LANE_ERR_BASE = SOFTBUS_SUB_ERRNO(LNN_SUB_MODULE_CODE, LNN_LANE_MODULE_CODE),
|
||||
|
@ -69,10 +69,10 @@ void LNNBtNetworkImplMockTest::TearDown()
|
||||
HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_001, TestSize.Level1)
|
||||
{
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(btMock, LnnRegisterEventHandler(_, _)).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(btMock, LnnRegisterEventHandler(_, _)).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int32_t ret = LnnInitBtProtocol(nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = LnnInitBtProtocol(nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
}
|
||||
@ -87,8 +87,10 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_002, TestSize.Level1
|
||||
{
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(ledgerMock, LnnGetNetworkIdByBtMac).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveSpecific).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetNetworkIdByBtMac)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveSpecific)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
LnnMonitorBtAclStateChangedEvent btEvent1 = {
|
||||
.basic.event = LNN_EVENT_BT_ACL_STATE_CHANGED,
|
||||
.status = (uint8_t)SOFTBUS_BR_ACL_CONNECTED,
|
||||
@ -144,7 +146,8 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(btMock, LnnGetNetIfTypeByName).WillRepeatedly(LnnBtNetworkImplInterfaceMock::
|
||||
ActionOfLnnGetNetIfTypeByNameBr);
|
||||
EXPECT_CALL(btMock, LnnRegistPhysicalSubnet).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, LnnRegistPhysicalSubnet)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
LnnProtocolManager self = {0};
|
||||
LnnNetIfMgr netifMgr = {
|
||||
.ifName = "name",
|
||||
@ -152,7 +155,7 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
int32_t ret = LnnEnableBtProtocol(&self, nullptr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
|
||||
ret = LnnEnableBtProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = LnnEnableBtProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
}
|
||||
@ -166,7 +169,8 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_005, TestSize.Level1)
|
||||
{
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveByAddrType).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveByAddrType)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
LnnPhysicalSubnet *subnet = reinterpret_cast<LnnPhysicalSubnet *>(SoftBusMalloc(sizeof(LnnPhysicalSubnet)));
|
||||
memset_s(subnet, sizeof(LnnPhysicalSubnet), 0, sizeof(LnnPhysicalSubnet));
|
||||
subnet->status = LNN_SUBNET_IDLE;
|
||||
@ -192,7 +196,8 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_006, TestSize.Level1
|
||||
.status = LNN_SUBNET_RUNNING,
|
||||
};
|
||||
EXPECT_CALL(btMock, SoftBusGetBtState).WillRepeatedly(Return(BLE_DISABLE));
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveByAddrType).WillOnce(Return(SOFTBUS_OK)).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(btMock, LnnRequestLeaveByAddrType)
|
||||
.WillOnce(Return(SOFTBUS_OK)).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
OnBtNetifStatusChanged(nullptr, nullptr);
|
||||
|
||||
EXPECT_CALL(btMock, LnnGetNetIfTypeByName).WillOnce(LnnBtNetworkImplInterfaceMock::
|
||||
@ -224,17 +229,19 @@ HWTEST_F(LNNBtNetworkImplMockTest, LNN_BT_NETWORK_IMPL_TEST_007, TestSize.Level1
|
||||
{
|
||||
char macStr[] = "123456789";
|
||||
NiceMock<LnnBtNetworkImplInterfaceMock> btMock;
|
||||
EXPECT_CALL(btMock, SoftBusGetBtMacAddr).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, ConvertBtMacToStr).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, SoftBusGetBtMacAddr)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(btMock, ConvertBtMacToStr)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
|
||||
int32_t ret = GetAvailableBtMac(macStr, NETWORK_ID_BUF_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_INVALID_PARAM);
|
||||
|
||||
ret = GetAvailableBtMac(macStr, BT_MAC_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
|
||||
ret = GetAvailableBtMac(macStr, BT_MAC_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
|
||||
ret = GetAvailableBtMac(macStr, BT_MAC_LEN);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
|
@ -47,11 +47,11 @@ int32_t LnnIpNetworkImplInterfaceMock::ActionOfGetNetworkIpByIfName(
|
||||
{
|
||||
if (ifName == nullptr || netmask == nullptr || len == 0) {
|
||||
LNN_LOGI(LNN_TEST, "invalid para");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (memcpy_s(ip, strlen("127.0.0.2") + 1, "127.0.0.2", strlen("127.0.0.2") + 1) != EOK) {
|
||||
LNN_LOGI(LNN_TEST, "memcpy networkId fail");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
@ -87,27 +87,28 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_001, TestSize.Level1
|
||||
ret = LnnGetIpListenerModule(LNN_LISTENER_MODE_AUTH);
|
||||
EXPECT_TRUE(ret == UNUSE_BUTT);
|
||||
|
||||
EXPECT_CALL(ipMock, LnnRegistPhysicalSubnet).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, LnnRegistPhysicalSubnet)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
|
||||
memset_s(&self, sizeof(LnnProtocolManager), 0, sizeof(LnnProtocolManager));
|
||||
memset_s(&netifMgr, sizeof(LnnNetIfMgr), 0, sizeof(LnnNetIfMgr));
|
||||
strcpy_s(netifMgr.ifName, sizeof("name"), "name");
|
||||
int32_t res = LnnEnableIpProtocol(nullptr, nullptr);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
EXPECT_NE(res, SOFTBUS_OK);
|
||||
res = LnnEnableIpProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
EXPECT_NE(res, SOFTBUS_OK);
|
||||
res = LnnEnableIpProtocol(&self, &netifMgr);
|
||||
EXPECT_TRUE(res == SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(ipMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(ipMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
|
||||
res = LnnInitIpProtocol(&self);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
EXPECT_NE(res, SOFTBUS_OK);
|
||||
res = LnnInitIpProtocol(&self);
|
||||
EXPECT_TRUE(res == SOFTBUS_ERR);
|
||||
EXPECT_NE(res, SOFTBUS_OK);
|
||||
res = LnnInitIpProtocol(&self);
|
||||
EXPECT_TRUE(res == SOFTBUS_OK);
|
||||
|
||||
@ -164,9 +165,10 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_003, TestSize.Level1
|
||||
{
|
||||
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ipMock, GetNetworkIpByIfName).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, GetNetworkIpByIfName)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int32_t ret = GetAvailableIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP1), SIZE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = GetAvailableIpAddr(IFNAME_TEST1, const_cast<char *>(WLAN_IP2), SIZE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
|
||||
@ -196,29 +198,32 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
{
|
||||
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(LnnNetLedgertInterfaceMock::ActionOfLnnGetLocalStrInfo2);
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int32_t ret = RequestMainPort("lo", "127.0.0.1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = RequestMainPort("lol", "127.0.0.1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = RequestMainPort("lol", "127.0.0.2");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = RequestMainPort("lol", "127.0.0.2");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = RequestMainPort("deviceName", "127.0.0.2");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = RequestMainPort("deviceName", "127.0.0.2");
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, AuthStartListening).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, AuthStartListening)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
ret = OpenAuthPort();
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = OpenAuthPort();
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = OpenAuthPort();
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
ret = OpenIpLink();
|
||||
@ -236,7 +241,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_004, TestSize.Level1
|
||||
.status = LNN_SUBNET_RUNNING,
|
||||
};
|
||||
ret = EnableIpSubnet(&subnet);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
}
|
||||
/*
|
||||
* @tc.name: LNN_IP_NETWORK_IMPL_TEST_005
|
||||
@ -248,24 +253,28 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_005, TestSize.Level1
|
||||
{
|
||||
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(LnnNetLedgertInterfaceMock::ActionOfLnnGetLocalStrInfo2);
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalStrInfo)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int32_t ret = ReleaseMainPort("deviceName");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = ReleaseMainPort("deviceName1");
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
ret = ReleaseMainPort("deviceName");
|
||||
EXPECT_TRUE(ret == SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(ipMock, LnnGetAddrTypeByIfName).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, LnnRequestLeaveByAddrType).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, LnnGetAddrTypeByIfName)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, LnnRequestLeaveByAddrType)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
LeaveOldIpNetwork(nullptr);
|
||||
LeaveOldIpNetwork(nullptr);
|
||||
LeaveOldIpNetwork(nullptr);
|
||||
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, ConnStopLocalListening).WillOnce(Return(SOFTBUS_ERR)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, ConnStopLocalListening)
|
||||
.WillOnce(Return(SOFTBUS_INVALID_PARAM)).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
CloseProxyPort();
|
||||
CloseProxyPort();
|
||||
|
||||
@ -326,7 +335,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_008, TestSize.Level1
|
||||
NiceMock<LnnIpNetworkImplInterfaceMock> ipMock;
|
||||
EXPECT_CALL(ipMock, GetWlanIpv4Addr).WillRepeatedly(Return(!SOFTBUS_OK));
|
||||
ret = GetWifiServiceIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP0), SIZE);
|
||||
EXPECT_TRUE(ret == SOFTBUS_ERR);
|
||||
EXPECT_NE(ret, SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(ipMock, GetWlanIpv4Addr).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
ret = GetWifiServiceIpAddr(IFNAME_TEST0, const_cast<char *>(WLAN_IP0), SIZE);
|
||||
@ -352,7 +361,7 @@ HWTEST_F(LNNIpNetworkImplMockTest, LNN_IP_NETWORK_IMPL_TEST_009, TestSize.Level1
|
||||
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ipMock, ConnStartLocalListening).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(ipMock, ConnStartLocalListening).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
OpenProxyPort();
|
||||
|
||||
LnnPhysicalSubnet subnet = {
|
||||
|
@ -88,7 +88,7 @@ int32_t LnnInitBtProtocolOk(LnnProtocolManager *self)
|
||||
int32_t LnnInitBtProtocolErr(LnnProtocolManager *self)
|
||||
{
|
||||
(void)self;
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t LnnEnableBtProtocol(LnnProtocolManager *self, LnnNetIfMgr *netifMgr)
|
||||
@ -115,14 +115,14 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_001, TestSize.Level
|
||||
NiceMock<LnnNetworkManagerInterfaceMock> managerMock;
|
||||
NiceMock<LnnAuthtInterfaceMock> authMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, RegistIPProtocolManager).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(managerMock, RegistIPProtocolManager).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(authMock, RegGroupChangeListener).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(authMock, RegGroupChangeListener).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, LnnInitPhysicalSubnetManager).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(managerMock, LnnInitPhysicalSubnetManager).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalNum64Info).WillOnce(Return(SOFTBUS_ERR)).
|
||||
EXPECT_CALL(ledgerMock, LnnSetLocalNum64Info).WillOnce(Return(SOFTBUS_INVALID_PARAM)).
|
||||
WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
int32_t ret = LnnInitNetworkManager();
|
||||
@ -134,7 +134,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_001, TestSize.Level
|
||||
ret = LnnInitNetworkManager();
|
||||
EXPECT_TRUE(ret!= SOFTBUS_OK);
|
||||
ret = LnnInitNetworkManager();
|
||||
EXPECT_TRUE(ret != SOFTBUS_ERR);
|
||||
EXPECT_EQ(ret, SOFTBUS_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -238,7 +238,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_004, TestSize.Level
|
||||
NiceMock<LnnNetworkManagerInterfaceMock> managerMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(true));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
bool ret = LnnIsAutoNetWorkingEnabled();
|
||||
EXPECT_TRUE(ret == true);
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
@ -249,7 +249,7 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_NETWORK_MANAGER_TEST_004, TestSize.Level
|
||||
int32_t res = LnnInitManagerByConfig();
|
||||
EXPECT_TRUE(res != SOFTBUS_OK);
|
||||
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
res = LnnInitManagerByConfig();
|
||||
EXPECT_TRUE(res == SOFTBUS_OK);
|
||||
|
||||
@ -404,10 +404,10 @@ HWTEST_F(LNNNetworkManagerMockTest, SAVE_BRNETWORK_DEVICE_TEST_001, TestSize.Lev
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
(void)SaveBrNetworkDevices();
|
||||
EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
(void)SaveBrNetworkDevices();
|
||||
EXPECT_CALL(ledgerMock, LnnGetAllOnlineNodeInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetRemoteNodeInfoById).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(ledgerMock, LnnGetRemoteNodeInfoById).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
(void)SaveBrNetworkDevices();
|
||||
EXPECT_CALL(ledgerMock, LnnGetRemoteNodeInfoById).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnHasDiscoveryType).WillRepeatedly(Return(false));
|
||||
@ -500,34 +500,34 @@ HWTEST_F(LNNNetworkManagerMockTest, REGIST_NETIFMGR_TEST_001, TestSize.Level1)
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStopPublish).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL));
|
||||
(void)RestartCoapDiscovery();
|
||||
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStopPublish).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL));
|
||||
EXPECT_CALL(managerMock, LnnStopDiscovery).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStartDiscovery).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
(void)RestartCoapDiscovery();
|
||||
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStopPublish).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnStartPublish).WillRepeatedly(Return(SOFTBUS_DISCOVER_COAP_START_PUBLISH_FAIL));
|
||||
EXPECT_CALL(managerMock, LnnStopDiscovery).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, LnnStartDiscovery).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnStartDiscovery).WillRepeatedly(Return(SOFTBUS_DISCOVER_COAP_START_DISCOVER_FAIL));
|
||||
(void)RestartCoapDiscovery();
|
||||
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
@ -547,23 +547,23 @@ HWTEST_F(LNNNetworkManagerMockTest, CONVERT_TO_NET_IF_TYPE_001, TestSize.Level1)
|
||||
NiceMock<LnnNetworkManagerInterfaceMock> managerMock;
|
||||
NiceMock<LnnNetLedgertInterfaceMock> ledgerMock;
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
(void)RestartCoapDiscovery();
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
(void)RestartCoapDiscovery();
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
(void)RestartCoapDiscovery();
|
||||
EXPECT_CALL(ledgerMock, IsActiveOsAccountUnlocked).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, SoftbusGetConfig).WillRepeatedly(Return(SOFTBUS_INVALID_PARAM));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalStrInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(ledgerMock, LnnGetLocalNumInfo).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
EXPECT_CALL(managerMock, DiscLinkStatusChanged).WillRepeatedly(Return());
|
||||
@ -592,22 +592,23 @@ HWTEST_F(LNNNetworkManagerMockTest, LNN_REGISTER_EVENT_001, TestSize.Level1)
|
||||
EXPECT_CALL(managerMock, LnnOnOhosAccountLogout).WillRepeatedly(Return());
|
||||
(void)OnGroupDeleted(groupId, groupType);
|
||||
int32_t ret = SOFTBUS_OK;
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_INVALID_PARAM));
|
||||
ret = LnnRegisterEvent();
|
||||
EXPECT_EQ(ret, SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR);
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_ERR));
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler)
|
||||
.WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_INVALID_PARAM));
|
||||
ret = LnnRegisterEvent();
|
||||
EXPECT_EQ(ret, SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR);
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_OK)).
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_ERR));
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_INVALID_PARAM));
|
||||
ret = LnnRegisterEvent();
|
||||
EXPECT_EQ(ret, SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR);
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_OK)).
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_ERR));
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_INVALID_PARAM));
|
||||
ret = LnnRegisterEvent();
|
||||
EXPECT_EQ(ret, SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR);
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_OK)).
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_ERR));
|
||||
WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_OK)).WillOnce(Return(SOFTBUS_INVALID_PARAM));
|
||||
ret = LnnRegisterEvent();
|
||||
EXPECT_EQ(ret, SOFTBUS_NETWORK_REG_EVENT_HANDLER_ERR);
|
||||
EXPECT_CALL(managerMock, LnnRegisterEventHandler).WillRepeatedly(Return(SOFTBUS_OK));
|
||||
|
Loading…
Reference in New Issue
Block a user