mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2024-11-27 02:40:40 +00:00
Merge branch 'master' of gitee.com:openharmony/communication_dsoftbus into master
Signed-off-by: 咚咚 <zhanghaodong12@huawei.com>
This commit is contained in:
commit
23bdf2419e
@ -57,8 +57,8 @@ if (defined(ohos_lite)) {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
"init:libbegetutil",
|
||||
"json:nlohmann_json_static",
|
||||
]
|
||||
public_external_deps = [ "json:nlohmann_json_static" ]
|
||||
if (board_name == "hispark_pegasus") {
|
||||
include_dirs +=
|
||||
[ "$hispark_pegasus_sdk_path/third_party/lwip_sack/include" ]
|
||||
@ -183,7 +183,7 @@ if (defined(ohos_lite)) {
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
external_deps += [ "json:nlohmann_json_static" ]
|
||||
public_external_deps = [ "json:nlohmann_json_static" ]
|
||||
|
||||
if (dsoftbus_feature_encrypt == 0) {
|
||||
sources += [
|
||||
@ -259,7 +259,10 @@ if (defined(ohos_lite)) {
|
||||
"$dsoftbus_dfx_path/event:softbus_dfx_event",
|
||||
"$dsoftbus_dfx_path/log:softbus_dfx_log",
|
||||
]
|
||||
public_external_deps = [ "bounds_checking_function:libsec_shared" ]
|
||||
public_external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"json:nlohmann_json_static",
|
||||
]
|
||||
|
||||
ble_enhanced_impl =
|
||||
"dsoftbus_enhance/adapter/common/range/softbus_adapter_range.c"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "lnn_ohos_account.h"
|
||||
#include "softbus_error_code.h"
|
||||
#include "parameter.h"
|
||||
#include "lnn_settingdata_event_monitor.h"
|
||||
|
||||
#define BOOTEVENT_ACCOUNT_READY "bootevent.account.ready"
|
||||
|
||||
@ -32,6 +33,7 @@ static void ProcessBootEvent(void *para)
|
||||
(void)para;
|
||||
LNN_LOGI(LNN_EVENT, "start process account ready event");
|
||||
LnnUpdateOhosAccount(true);
|
||||
LnnInitDeviceNameMonitorImpl();
|
||||
if (LnnIsDefaultOhosAccount() && !IsAuthHasTrustedRelation()) {
|
||||
LNN_LOGE(LNN_EVENT, "not trusted releation, heartbeat(HB) process start later");
|
||||
return;
|
||||
|
@ -103,7 +103,9 @@ static int32_t RtNetlinkTalk(struct nlmsghdr *nlMsgHdr, struct nlmsghdr *answer,
|
||||
}
|
||||
|
||||
while (true) {
|
||||
LNN_LOGI(LNN_BUILDER, "SoftBusSocketRecv begin");
|
||||
status = SoftBusSocketRecv(fd, answer, maxlen, 0);
|
||||
LNN_LOGI(LNN_BUILDER, "SoftBusSocketRecv end");
|
||||
if (status < 0) {
|
||||
if (status == SOFTBUS_ADAPTER_SOCKET_EINTR || status == SOFTBUS_ADAPTER_SOCKET_EAGAIN) {
|
||||
continue;
|
||||
|
@ -36,7 +36,7 @@ int32_t BtStatusToSoftBus(BtStatus btStatus);
|
||||
void SoftbusAdvParamToBt(const SoftbusBroadcastParam *src, BleAdvParams *dst);
|
||||
void BtScanResultToSoftbus(const BtScanResultData *src, SoftBusBcScanResult *dst);
|
||||
void SoftbusFilterToBt(BleScanNativeFilter *nativeFilter, const SoftBusBcScanFilter *filter, uint8_t filterSize);
|
||||
void SoftbusSetManufactureData(BleScanNativeFilter *nativeFilter, uint8_t filterSize);
|
||||
void SoftbusSetManufactureFilter(BleScanNativeFilter *nativeFilter, uint8_t filterSize);
|
||||
void FreeBtFilter(BleScanNativeFilter *nativeFilter, int32_t filterSize);
|
||||
void DumpBleScanFilter(BleScanNativeFilter *nativeFilter, int32_t filterSize);
|
||||
int GetBtScanMode(uint16_t scanInterval, uint16_t scanWindow);
|
||||
@ -44,6 +44,8 @@ uint8_t *AssembleAdvData(const SoftbusBroadcastData *data, uint16_t *dataLen);
|
||||
uint8_t *AssembleRspData(const SoftbusBroadcastPayload *data, uint16_t *dataLen);
|
||||
int32_t ParseScanResult(const uint8_t *advData, uint8_t advLen, SoftBusBcScanResult *dst);
|
||||
|
||||
void DumpSoftbusAdapterData(const char *description, uint8_t *data, uint16_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -476,6 +476,7 @@ static int32_t StartBleAdv(int32_t advId, int *btAdvId, const SoftbusBroadcastPa
|
||||
return SOFTBUS_BC_ADAPTER_ASSEMBLE_FAIL;
|
||||
}
|
||||
}
|
||||
DumpSoftbusAdapterData("mgr pkg:", advRawData.advData, advRawData.advDataLen);
|
||||
int ret = BleStartAdvEx(btAdvId, advRawData, advParam);
|
||||
SoftBusFree(advRawData.advData);
|
||||
SoftBusFree(advRawData.rspData);
|
||||
@ -766,7 +767,7 @@ static bool SoftbusSetLpParam(LpServerType type,
|
||||
return false;
|
||||
}
|
||||
if (type == SOFTBUS_HEARTBEAT_TYPE) {
|
||||
SoftbusSetManufactureData(lpParam.filter, scanParam->filterSize);
|
||||
SoftbusSetManufactureFilter(lpParam.filter, scanParam->filterSize);
|
||||
}
|
||||
SoftbusFilterToBt(lpParam.filter, scanParam->filter, scanParam->filterSize);
|
||||
lpParam.filterSize = (unsigned int)scanParam->filterSize;
|
||||
|
@ -280,11 +280,12 @@ void SoftbusFilterToBt(BleScanNativeFilter *nativeFilter, const SoftBusBcScanFil
|
||||
}
|
||||
}
|
||||
|
||||
void SoftbusSetManufactureData(BleScanNativeFilter *nativeFilter, uint8_t filterSize)
|
||||
void SoftbusSetManufactureFilter(BleScanNativeFilter *nativeFilter, uint8_t filterSize)
|
||||
{
|
||||
while (filterSize-- > 0) {
|
||||
uint8_t *manufactureData = (uint8_t *)SoftBusCalloc(MANUFACTURE_DATA_LEN);
|
||||
if (manufactureData == NULL) {
|
||||
DISC_LOGW(DISC_BLE_ADAPTER, "malloc manufacture data failed");
|
||||
return;
|
||||
}
|
||||
manufactureData[0] = MANUFACTURE_DATA_UUID_LOW & BC_BYTE_MASK;
|
||||
@ -292,6 +293,7 @@ void SoftbusSetManufactureData(BleScanNativeFilter *nativeFilter, uint8_t filter
|
||||
uint8_t *manufactureMask = (uint8_t *)SoftBusCalloc(MANUFACTURE_DATA_LEN);
|
||||
if (manufactureMask == NULL) {
|
||||
SoftBusFree(manufactureData);
|
||||
DISC_LOGW(DISC_BLE_ADAPTER, "malloc manufacture mask failed");
|
||||
return;
|
||||
}
|
||||
manufactureMask[0] = BC_BYTE_MASK;
|
||||
@ -491,3 +493,19 @@ int32_t ParseScanResult(const uint8_t *advData, uint8_t advLen, SoftBusBcScanRes
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
void DumpSoftbusAdapterData(const char *description, uint8_t *data, uint16_t len)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_LOGE(description != NULL, DISC_BLE_ADAPTER, "data is null!");
|
||||
DISC_CHECK_AND_RETURN_LOGE(len != 0, DISC_BLE_ADAPTER, "len is 0!");
|
||||
DISC_CHECK_AND_RETURN_LOGE(data != NULL, DISC_BLE_ADAPTER, "data is null!");
|
||||
|
||||
int32_t hexLen = HEXIFY_LEN(len);
|
||||
char *softbusData = (char *)SoftBusCalloc(sizeof(char) * hexLen);
|
||||
DISC_CHECK_AND_RETURN_LOGE(softbusData != NULL, DISC_BLE_ADAPTER, "malloc failed!");
|
||||
|
||||
(void)ConvertBytesToHexString(softbusData, hexLen, data, len);
|
||||
DISC_LOGI(DISC_BLE_ADAPTER, "description=%{public}s, softbusData=%{public}s", description, softbusData);
|
||||
|
||||
SoftBusFree(softbusData);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ int32_t SoftBusGenerateHmacHash(
|
||||
if (outBufLen != SHA256_MAC_LEN) {
|
||||
COMM_LOGE(COMM_ADAPTER, "outBufLen is invalid length for hash.");
|
||||
(void)memset_s(tempOutputData, sizeof(tempOutputData), 0, sizeof(tempOutputData));
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_HMAC_ERR;
|
||||
}
|
||||
if (memcpy_s(hash, hashLen, tempOutputData, outBufLen) != EOK) {
|
||||
COMM_LOGE(COMM_ADAPTER, "hash result memcpy_s failed.");
|
||||
@ -168,7 +168,7 @@ static int32_t GenerateIvAndSessionKey(const EncryptKey *randomKey, EncryptKey *
|
||||
(void)memset_s(cipherKey->iv, cipherKey->ivLen, 0, cipherKey->ivLen);
|
||||
SoftBusFree(cipherKey->key);
|
||||
SoftBusFree(cipherKey->iv);
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_GENERATE_KEY_FAIL;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -190,7 +190,7 @@ int32_t SoftBusAesCfbRootEncrypt(const AesInputData *inData, const EncryptKey *r
|
||||
if (GenerateIvAndSessionKey(randomKey, rootKey, &cipherKey) != SOFTBUS_OK) {
|
||||
COMM_LOGE(COMM_ADAPTER, "GenerateIvAndSessionKey failed!");
|
||||
SoftBusFree(encryptData.data);
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_GENERATE_KEY_FAIL;
|
||||
}
|
||||
if (OpensslAesCfbEncrypt(&cipherKey, inData, encMode, &encryptData) != SOFTBUS_OK) {
|
||||
COMM_LOGE(COMM_ADAPTER, "OpensslAesCfb encrypt or decrypt by root key failed.");
|
||||
@ -283,12 +283,12 @@ static int32_t GcmOpensslEvpInit(EVP_CIPHER_CTX **ctx, uint32_t keyLen, int32_t
|
||||
EVP_CIPHER *cipher = GetSslGcmAlgorithmByKeyLen(keyLen);
|
||||
if (cipher == NULL) {
|
||||
COMM_LOGE(COMM_ADAPTER, "GetSslGcmAlgorithmByKeyLen failed.");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
*ctx = EVP_CIPHER_CTX_new();
|
||||
if (*ctx == NULL) {
|
||||
COMM_LOGE(COMM_ADAPTER, "EVP_CIPHER_CTX_new failed.");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
EVP_CIPHER_CTX_set_padding(*ctx, OPENSSL_EVP_PADDING_FUNC_CLOSE);
|
||||
if (encMode == ENCRYPT_MODE) {
|
||||
@ -310,7 +310,7 @@ static int32_t GcmOpensslEvpInit(EVP_CIPHER_CTX **ctx, uint32_t keyLen, int32_t
|
||||
COMM_LOGE(COMM_ADAPTER, "EVP_CIPHER_CTX_ctrl failed.");
|
||||
EVP_CIPHER_CTX_free(*ctx);
|
||||
*ctx = NULL;
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_GCM_SET_IV_FAIL;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -325,7 +325,7 @@ static int32_t OpensslAesGcmEncrypt(
|
||||
}
|
||||
EVP_CIPHER_CTX *ctx = NULL;
|
||||
int32_t ret = GcmOpensslEvpInit(&ctx, cipherKey->keyLen, ENCRYPT_MODE);
|
||||
COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, SOFTBUS_ERR, COMM_ADAPTER, "GcmOpensslEvpInit failed.");
|
||||
COMM_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, SOFTBUS_ENCRYPT_ERR, COMM_ADAPTER, "GcmOpensslEvpInit failed.");
|
||||
if (EVP_EncryptInit_ex(ctx, NULL, NULL, cipherKey->key, cipherKey->iv) != 1) {
|
||||
COMM_LOGE(COMM_ADAPTER, "EVP_EncryptInit_ex failed.");
|
||||
goto EXIT;
|
||||
@ -379,7 +379,7 @@ static int32_t OpensslAesGcmDecrypt(
|
||||
EVP_CIPHER_CTX *ctx = NULL;
|
||||
if (GcmOpensslEvpInit(&ctx, cipherKey->keyLen, DECRYPT_MODE) != SOFTBUS_OK) {
|
||||
COMM_LOGE(COMM_ADAPTER, "GcmOpensslEvpInit failed.");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_DECRYPT_ERR;
|
||||
}
|
||||
if (EVP_DecryptInit_ex(ctx, NULL, NULL, cipherKey->key, cipherKey->iv) != 1) {
|
||||
COMM_LOGE(COMM_ADAPTER, "EVP_DecryptInit_ex failed.");
|
||||
|
36
bundle.json
36
bundle.json
@ -122,38 +122,10 @@
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
"//foundation/communication/dsoftbus/tests/adapter:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/adapter:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/adapter:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/adapter:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/authentication:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/authentication:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/broadcast:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/broadcast:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/bus_center:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/bus_center:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/common:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/common:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/connection:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/connection:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/discovery:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/discovery:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/frame:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/core/transmission:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/core/transmission:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/bus_center:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/bus_center:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/discovery:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/discovery:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/transmission:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/transmission:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/bus_center:benchmarktest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/discovery:benchmarktest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/transmission:benchmarktest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/transmission:integration_test",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/frame/common:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/frame/standard:unittest",
|
||||
"//foundation/communication/dsoftbus/tests/sdk/frame:fuzztest"
|
||||
"//foundation/communication/dsoftbus/tests:benchmarktest",
|
||||
"//foundation/communication/dsoftbus/tests:fuzztest",
|
||||
"//foundation/communication/dsoftbus/tests:integration_test",
|
||||
"//foundation/communication/dsoftbus/tests:unittest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "anonymizer.h"
|
||||
#include "lnn_log.h"
|
||||
#include "lnn_ohos_account_adapter.h"
|
||||
#include "ohos_account_kits.h"
|
||||
@ -44,7 +45,10 @@ int32_t GetOsAccountId(char *id, uint32_t idLen, uint32_t *len)
|
||||
}
|
||||
|
||||
*len = accountInfo.second.name_.length();
|
||||
LNN_LOGI(LNN_STATE, "uid=%{public}s, len=%{public}d", accountInfo.second.name_.c_str(), *len);
|
||||
char *anonyUid = nullptr;
|
||||
Anonymize(accountInfo.second.name_.c_str(), &anonyUid);
|
||||
LNN_LOGI(LNN_STATE, "uid=%{public}s, len=%{public}d", AnonymizeWrapper(anonyUid), *len);
|
||||
AnonymizeFree(anonyUid);
|
||||
|
||||
if (memcmp(DEFAULT_ACCOUNT_NAME, accountInfo.second.name_.c_str(), *len) == 0) {
|
||||
LNN_LOGE(LNN_STATE, "not login account");
|
||||
@ -74,8 +78,10 @@ int32_t GetCurrentAccount(int64_t *account)
|
||||
LNN_LOGE(LNN_STATE, "accountInfo name_ is empty");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
LNN_LOGI(LNN_STATE, "name_=%{public}s", accountInfo.second.name_.c_str());
|
||||
char *anonyUid = nullptr;
|
||||
Anonymize(accountInfo.second.name_.c_str(), &anonyUid);
|
||||
LNN_LOGI(LNN_STATE, "name_=%{public}s", AnonymizeWrapper(anonyUid));
|
||||
AnonymizeFree(anonyUid);
|
||||
if (memcmp(DEFAULT_ACCOUNT_NAME, accountInfo.second.name_.c_str(),
|
||||
accountInfo.second.name_.length()) == 0) {
|
||||
LNN_LOGE(LNN_STATE, "not login account");
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "softbus_errcode.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "uri.h"
|
||||
#include "lnn_ohos_account_adapter.h"
|
||||
|
||||
static LnnDeviceNameHandler g_eventHandler = nullptr;
|
||||
|
||||
@ -37,10 +38,13 @@ namespace OHOS {
|
||||
namespace BusCenter {
|
||||
static const std::string SETTINGS_DATA_BASE_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/SETTINGSDATA?Proxy=true";
|
||||
static const std::string SETTINGS_DATA_SECURE_URI =
|
||||
"datashare:///com.ohos.settingsdata/entry/settingsdata/USER_SETTINGSDATA_SECURE_";
|
||||
static constexpr const char *SETTINGS_DATA_EXT_URI = "datashare:///com.ohos.settingsdata.DataAbility";
|
||||
static constexpr const char *SETTINGS_DATA_FIELD_KEYWORD = "KEYWORD";
|
||||
static constexpr const char *SETTINGS_DATA_FIELD_VALUE = "VALUE";
|
||||
static constexpr const char *PREDICATES_STRING = "settings.general.device_name";
|
||||
static constexpr const char *USER_DEFINED_STRING = "settings.general.user_defined_device_name";
|
||||
static const uint32_t SOFTBUS_SA_ID = 4700;
|
||||
|
||||
class LnnSettingDataEventMonitor : public AAFwk::DataAbilityObserverStub {
|
||||
@ -72,35 +76,25 @@ std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelperInstance(void)
|
||||
return DataShare::DataShareHelper::Creator(remoteObject, SETTINGS_DATA_BASE_URI, SETTINGS_DATA_EXT_URI);
|
||||
}
|
||||
|
||||
static int32_t GetDeviceNameFromDataShareHelper(char *deviceName, uint32_t len)
|
||||
static int32_t GetDeviceNameFromDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> &dataShareHelper,
|
||||
std::shared_ptr<Uri> &uri, const char *key, char *deviceName, uint32_t len)
|
||||
{
|
||||
auto dataShareHelper = OHOS::BusCenter::CreateDataShareHelperInstance();
|
||||
if (dataShareHelper == nullptr) {
|
||||
LNN_LOGE(LNN_STATE, "CreateDataShareHelperInstance fail.");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
LNN_LOGI(LNN_STATE, "GetDeviceNameFromDataShareHelper enter.");
|
||||
int32_t numRows = 0;
|
||||
std::string val;
|
||||
|
||||
std::shared_ptr<Uri> uri = std::make_shared<Uri>(SETTINGS_DATA_BASE_URI + "&key=" + PREDICATES_STRING);
|
||||
std::vector<std::string> columns;
|
||||
columns.emplace_back(SETTINGS_DATA_FIELD_VALUE);
|
||||
DataShare::DataSharePredicates predicates;
|
||||
predicates.EqualTo(SETTINGS_DATA_FIELD_KEYWORD, PREDICATES_STRING);
|
||||
predicates.EqualTo(SETTINGS_DATA_FIELD_KEYWORD, key);
|
||||
|
||||
auto resultSet = dataShareHelper->Query(*uri, predicates, columns);
|
||||
if (resultSet == nullptr) {
|
||||
LNN_LOGE(LNN_STATE, "GetDeviceNameFromDataShareHelper query fail.");
|
||||
dataShareHelper->Release();
|
||||
LNN_LOGE(LNN_STATE, "query fail.");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
resultSet->GetRowCount(numRows);
|
||||
if (numRows <= 0) {
|
||||
LNN_LOGE(LNN_STATE, "GetDeviceNameFromDataShareHelper row zero.");
|
||||
LNN_LOGE(LNN_STATE, "row zero.");
|
||||
resultSet->Close();
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
@ -110,21 +104,40 @@ static int32_t GetDeviceNameFromDataShareHelper(char *deviceName, uint32_t len)
|
||||
if (resultSet->GetString(columnIndex, val) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_STATE, "GetString val fail");
|
||||
resultSet->Close();
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (strncpy_s(deviceName, len, val.c_str(), strlen(val.c_str())) != EOK) {
|
||||
LNN_LOGE(LNN_STATE, "strncpy_s fail.");
|
||||
resultSet->Close();
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
LNN_LOGI(LNN_STATE, "GetDeviceNameFromDataShareHelper, deviceName=%{public}s.", deviceName);
|
||||
LNN_LOGI(LNN_STATE, "deviceName=%{public}s.", deviceName);
|
||||
resultSet->Close();
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t GetDefaultDeviceName(std::shared_ptr<DataShare::DataShareHelper> &dataShareHelper,
|
||||
char *deviceName, uint32_t len)
|
||||
{
|
||||
std::shared_ptr<Uri> uri = std::make_shared<Uri>(SETTINGS_DATA_BASE_URI + "&key=" + PREDICATES_STRING);
|
||||
LNN_LOGI(LNN_STATE, "get default deviceName");
|
||||
return GetDeviceNameFromDataShareHelper(dataShareHelper, uri, PREDICATES_STRING, deviceName, len);
|
||||
}
|
||||
|
||||
static int32_t GetUserDefinedDeviceName(std::shared_ptr<DataShare::DataShareHelper> &dataShareHelper,
|
||||
char *deviceName, uint32_t len)
|
||||
{
|
||||
int32_t osAccountId = GetActiveOsAccountIds();
|
||||
if (osAccountId == SOFTBUS_ERR) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
std::string accountIdStr = std::to_string(osAccountId);
|
||||
std::shared_ptr<Uri> uri = std::make_shared<Uri>(SETTINGS_DATA_SECURE_URI + accountIdStr + "?Proxy=true&key=" +
|
||||
USER_DEFINED_STRING);
|
||||
LNN_LOGI(LNN_STATE, "get user defined deviceName, accountIdStr=%{public}s", accountIdStr.c_str());
|
||||
return GetDeviceNameFromDataShareHelper(dataShareHelper, uri, USER_DEFINED_STRING, deviceName, len);
|
||||
}
|
||||
|
||||
static void RegisterNameMonitorHelper(void)
|
||||
{
|
||||
auto dataShareHelper = OHOS::BusCenter::CreateDataShareHelperInstance();
|
||||
@ -135,6 +148,15 @@ static void RegisterNameMonitorHelper(void)
|
||||
auto uri = std::make_shared<Uri>(SETTINGS_DATA_BASE_URI + "&key=" + PREDICATES_STRING);
|
||||
sptr<LnnSettingDataEventMonitor> settingDataObserver = std::make_unique<LnnSettingDataEventMonitor>().release();
|
||||
dataShareHelper->RegisterObserver(*uri, settingDataObserver);
|
||||
|
||||
int32_t osAccountId = GetActiveOsAccountIds();
|
||||
if (osAccountId == SOFTBUS_ERR) {
|
||||
return;
|
||||
}
|
||||
std::string accountIdStr = std::to_string(osAccountId);
|
||||
uri = std::make_shared<Uri>(SETTINGS_DATA_SECURE_URI + accountIdStr + "?Proxy=true&key=" + USER_DEFINED_STRING);
|
||||
dataShareHelper->RegisterObserver(*uri, settingDataObserver);
|
||||
|
||||
dataShareHelper->Release();
|
||||
LNN_LOGI(LNN_STATE, "success");
|
||||
}
|
||||
@ -147,11 +169,27 @@ int32_t LnnGetSettingDeviceName(char *deviceName, uint32_t len)
|
||||
LNN_LOGE(LNN_STATE, "invalid para");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (OHOS::BusCenter::GetDeviceNameFromDataShareHelper(deviceName, len) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_STATE, "GetDeviceNameFromDataShareHelper fail");
|
||||
return SOFTBUS_ERR;
|
||||
auto dataShareHelper = OHOS::BusCenter::CreateDataShareHelperInstance();
|
||||
if (dataShareHelper == nullptr) {
|
||||
LNN_LOGE(LNN_STATE, "CreateDataShareHelperInstance fail.");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
|
||||
int32_t ret = OHOS::BusCenter::GetUserDefinedDeviceName(dataShareHelper, deviceName, len);
|
||||
if (ret == SOFTBUS_NO_INIT) {
|
||||
LNN_LOGI(LNN_STATE, "account not ready, try again");
|
||||
dataShareHelper->Release();
|
||||
return ret;
|
||||
}
|
||||
if (ret == SOFTBUS_OK) {
|
||||
LNN_LOGI(LNN_STATE, "get user defined deviceName=%{public}s", deviceName);
|
||||
dataShareHelper->Release();
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ret = OHOS::BusCenter::GetDefaultDeviceName(dataShareHelper, deviceName, len);
|
||||
LNN_LOGI(LNN_STATE, "get default deviceName=%{public}s, ret=%{public}d", deviceName, ret);
|
||||
dataShareHelper->Release();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t LnnInitGetDeviceName(LnnDeviceNameHandler handler)
|
||||
|
@ -215,7 +215,7 @@ static int32_t EncryptByPublicKey(const uint8_t *src, uint32_t srcLen, const RSA
|
||||
if ((BN_num_bits(modNum) > OPENSSL_RSA_MAX_MODULUS_BITS) || (BN_ucmp(modNum, exp) <= 0) ||
|
||||
((BN_num_bits(modNum) > OPENSSL_RSA_SMALL_MODULUS_BITS) && (BN_num_bits(exp) > OPENSSL_RSA_MAX_PUBEXP_BITS))) {
|
||||
COMM_LOGE(COMM_UTILS, "invalid param rsa.");
|
||||
return SOFTBUS_ERR;
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
do {
|
||||
ctx = GetRsaBigNum(modNum, &base, &result, &buf, &bufNum);
|
||||
|
@ -86,6 +86,7 @@ void DelAuthManager(AuthManager *auth, int32_t type);
|
||||
void DelDupAuthManager(AuthManager *auth);
|
||||
void RemoveAuthManagerByAuthId(AuthHandle authHandle);
|
||||
int32_t AuthDeviceGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo);
|
||||
int32_t AuthDeviceGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo);
|
||||
int32_t AuthDeviceGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo);
|
||||
int32_t AuthDeviceGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo);
|
||||
/*check whether AUTH device is exist or not*/
|
||||
|
@ -184,6 +184,7 @@ int32_t AuthOpenConn(const AuthConnInfo *info, uint32_t requestId, const AuthCon
|
||||
int32_t AuthPostTransData(AuthHandle authHandle, const AuthTransData *dataInfo);
|
||||
void AuthCloseConn(AuthHandle authHandle);
|
||||
int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
|
||||
int32_t AuthGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo, bool isMeta);
|
||||
int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
|
||||
int32_t AuthGetHmlConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta);
|
||||
int32_t AuthGetLatestAuthSeqList(const char *udid, int64_t *seqList, uint32_t num);
|
||||
|
@ -29,11 +29,12 @@
|
||||
#include "softbus_def.h"
|
||||
#include "wifi_direct_manager.h"
|
||||
|
||||
#define AUTH_CONN_DATA_HEAD_SIZE 24
|
||||
#define AUTH_CONN_CONNECT_TIMEOUT_MS 11000
|
||||
#define AUTH_REPEAT_DEVICE_ID_HANDLE_DELAY 1000
|
||||
#define AUTH_CONN_MAX_RETRY_TIMES 1
|
||||
#define AUTH_CONN_RETRY_DELAY_MILLIS 3000
|
||||
#define AUTH_CONN_DATA_HEAD_SIZE 24
|
||||
#define AUTH_ENHANCE_P2P_CONNECT_TIMEOUT_MS 4500
|
||||
#define AUTH_CONN_CONNECT_TIMEOUT_MS 11000
|
||||
#define AUTH_REPEAT_DEVICE_ID_HANDLE_DELAY 1000
|
||||
#define AUTH_CONN_MAX_RETRY_TIMES 1
|
||||
#define AUTH_CONN_RETRY_DELAY_MILLIS 3000
|
||||
|
||||
typedef struct {
|
||||
uint32_t requestId;
|
||||
@ -271,10 +272,15 @@ static void HandleConnConnectTimeout(const void *para)
|
||||
NotifyClientConnected(requestId, 0, SOFTBUS_AUTH_CONN_TIMEOUT, NULL);
|
||||
}
|
||||
|
||||
static void PostConnConnectTimeout(uint32_t requestId)
|
||||
static void PostConnConnectTimeout(uint32_t requestId, AuthLinkType type)
|
||||
{
|
||||
PostAuthEvent(
|
||||
EVENT_CONNECT_TIMEOUT, HandleConnConnectTimeout, &requestId, sizeof(requestId), AUTH_CONN_CONNECT_TIMEOUT_MS);
|
||||
if (type == AUTH_LINK_TYPE_ENHANCED_P2P) {
|
||||
PostAuthEvent(EVENT_CONNECT_TIMEOUT, HandleConnConnectTimeout, &requestId, sizeof(requestId),
|
||||
AUTH_ENHANCE_P2P_CONNECT_TIMEOUT_MS);
|
||||
} else {
|
||||
PostAuthEvent(EVENT_CONNECT_TIMEOUT, HandleConnConnectTimeout, &requestId, sizeof(requestId),
|
||||
AUTH_CONN_CONNECT_TIMEOUT_MS);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t RemoveFunc(const void *obj, void *param)
|
||||
@ -610,7 +616,7 @@ int32_t ConnectAuthDevice(uint32_t requestId, const AuthConnInfo *connInfo, Conn
|
||||
CHECK_NULL_PTR_RETURN_VALUE(connInfo, SOFTBUS_INVALID_PARAM);
|
||||
AUTH_LOGI(AUTH_CONN, "requestId=%{public}u, connType=%{public}d, sideType=%{public}d", requestId,
|
||||
connInfo->type, sideType);
|
||||
PostConnConnectTimeout(requestId);
|
||||
PostConnConnectTimeout(requestId, connInfo->type);
|
||||
int32_t ret = 0;
|
||||
switch (connInfo->type) {
|
||||
case AUTH_LINK_TYPE_WIFI: {
|
||||
|
@ -307,6 +307,14 @@ int32_t AuthGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isM
|
||||
return AuthDeviceGetPreferConnInfo(uuid, connInfo);
|
||||
}
|
||||
|
||||
int32_t AuthGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo, bool isMeta)
|
||||
{
|
||||
if (isMeta) {
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
return AuthDeviceGetConnInfoByType(uuid, type, connInfo);
|
||||
}
|
||||
|
||||
int32_t AuthGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo, bool isMeta)
|
||||
{
|
||||
if (isMeta) {
|
||||
|
@ -1671,6 +1671,27 @@ int32_t AuthDeviceGetPreferConnInfo(const char *uuid, AuthConnInfo *connInfo)
|
||||
return TryGetBrConnInfo(uuid, connInfo);
|
||||
}
|
||||
|
||||
int32_t AuthDeviceGetConnInfoByType(const char *uuid, AuthLinkType type, AuthConnInfo *connInfo)
|
||||
{
|
||||
if (uuid == NULL || uuid[0] == '\0' || connInfo == NULL) {
|
||||
AUTH_LOGE(AUTH_CONN, "invalid uuid or connInfo");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (GetAuthConnInfoByUuid(uuid, type, connInfo) != SOFTBUS_OK) {
|
||||
if (type == AUTH_LINK_TYPE_BR) {
|
||||
return TryGetBrConnInfo(uuid, connInfo);
|
||||
}
|
||||
return SOFTBUS_AUTH_NOT_FOUND;
|
||||
}
|
||||
if (type == AUTH_LINK_TYPE_BLE) {
|
||||
if (!CheckActiveAuthConnection(connInfo)) {
|
||||
AUTH_LOGI(AUTH_CONN, "auth ble connection not active");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t AuthDeviceGetP2pConnInfo(const char *uuid, AuthConnInfo *connInfo)
|
||||
{
|
||||
if (uuid == NULL || uuid[0] == '\0' || connInfo == NULL) {
|
||||
|
@ -633,6 +633,27 @@ static void SyncDevIdStateEnter(FsmStateMachine *fsm)
|
||||
SoftbusHitraceStop();
|
||||
}
|
||||
|
||||
static void SaveLastAuthSeq(const unsigned char *udidHash, int64_t authSeq)
|
||||
{
|
||||
AUTH_LOGI(AUTH_FSM, "save auth seq.authSeq=%{public}" PRId64, authSeq);
|
||||
char hashStr[SHORT_UDID_HASH_HEX_LEN + 1] = {0};
|
||||
if (ConvertBytesToHexString(hashStr, SHORT_UDID_HASH_HEX_LEN + 1,
|
||||
udidHash, SHORT_UDID_HASH_HEX_LEN / HEXIFY_UNIT_LEN) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "convert udidhash to hexstr fail.");
|
||||
return;
|
||||
}
|
||||
NodeInfo deviceInfo;
|
||||
(void)memset_s(&deviceInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
if (LnnRetrieveDeviceInfo(hashStr, &deviceInfo) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "no this device info.");
|
||||
return;
|
||||
}
|
||||
deviceInfo.lastAuthSeq = authSeq;
|
||||
if (LnnSaveRemoteDeviceInfo(&deviceInfo) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "save device info fail.");
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t RecoveryNormalizedDeviceKey(AuthFsm *authFsm)
|
||||
{
|
||||
if (authFsm->info.normalizedKey == NULL) {
|
||||
@ -653,6 +674,9 @@ static int32_t RecoveryNormalizedDeviceKey(AuthFsm *authFsm)
|
||||
}
|
||||
AuthUpdateNormalizeKeyIndex(udidShortHash, authFsm->info.normalizedIndex, authFsm->info.connInfo.type,
|
||||
authFsm->info.normalizedKey, authFsm->info.isServer);
|
||||
if (authFsm->info.connInfo.type == AUTH_LINK_TYPE_BLE) {
|
||||
SaveLastAuthSeq(hash, authFsm->authSeq);
|
||||
}
|
||||
ret = AuthSessionSaveSessionKey(authFsm->authSeq, authFsm->info.normalizedKey->value,
|
||||
authFsm->info.normalizedKey->len);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_node_info.h"
|
||||
#include "lnn_settingdata_event_monitor.h"
|
||||
#include "softbus_adapter_bt_common.h"
|
||||
#include "softbus_adapter_json.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
#include "softbus_adapter_socket.h"
|
||||
@ -185,6 +186,8 @@
|
||||
#define BLE_CONNECTION_CLOSE_DELAY (10 * 1000L)
|
||||
#define BLE_MAC_AUTO_REFRESH_SWITCH 1
|
||||
|
||||
#define INVALID_BR_MAC_ADDR "00:00:00:00:00:00"
|
||||
|
||||
static void OptString(const JsonObj *json, const char * const key,
|
||||
char *target, uint32_t targetLen, const char *defaultValue)
|
||||
{
|
||||
@ -1160,13 +1163,17 @@ static void PackCommP2pInfo(JsonObj *json, const NodeInfo *info)
|
||||
(void)JSON_AddInt32ToObject(json, STA_FREQUENCY, LnnGetStaFrequency(info));
|
||||
}
|
||||
|
||||
static void AuthPrintBase64Ptk(const char *ptk)
|
||||
{
|
||||
char *anonyPtk = NULL;
|
||||
Anonymize(ptk, &anonyPtk);
|
||||
AUTH_LOGD(AUTH_FSM, "base Ptk=%{public}s", anonyPtk);
|
||||
AnonymizeFree(anonyPtk);
|
||||
}
|
||||
|
||||
static void PackWifiDirectInfo(
|
||||
const AuthConnInfo *connInfo, JsonObj *json, const NodeInfo *info, const char *remoteUuid, bool isMetaAuth)
|
||||
{
|
||||
if (json == NULL) {
|
||||
AUTH_LOGE(AUTH_FSM, "invalid param");
|
||||
return;
|
||||
}
|
||||
unsigned char encodePtk[PTK_ENCODE_LEN] = {0};
|
||||
char localPtk[PTK_DEFAULT_LEN] = {0};
|
||||
if (isMetaAuth || remoteUuid == NULL) {
|
||||
@ -1193,6 +1200,7 @@ static void PackWifiDirectInfo(
|
||||
AUTH_LOGE(AUTH_FSM, "encode ptk fail");
|
||||
return;
|
||||
}
|
||||
AuthPrintBase64Ptk((const char *)encodePtk);
|
||||
if (!JSON_AddStringToObject(json, PTK, (char *)encodePtk)) {
|
||||
AUTH_LOGE(AUTH_FSM, "add ptk string to json fail");
|
||||
return;
|
||||
@ -1230,6 +1238,21 @@ static int32_t FillBroadcastCipherKey(BroadcastCipherKey *broadcastKey, const No
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static void DumpRpaCipherKey(char *cipherKey, char *cipherIv, const char *peerIrk, const char *log)
|
||||
{
|
||||
char *anonyIrk = NULL;
|
||||
char *anonyCipherKey = NULL;
|
||||
char *anonyCipherIv = NULL;
|
||||
Anonymize(cipherKey, &anonyCipherKey);
|
||||
Anonymize(cipherIv, &anonyCipherIv);
|
||||
Anonymize(peerIrk, &anonyIrk);
|
||||
AUTH_LOGI(AUTH_FSM, "log=%{public}s, cipherKey=%{public}s, cipherIv=%{public}s, peerIrk=%{public}s", log,
|
||||
anonyCipherKey, anonyCipherIv, anonyIrk);
|
||||
AnonymizeFree(anonyCipherKey);
|
||||
AnonymizeFree(anonyCipherIv);
|
||||
AnonymizeFree(anonyIrk);
|
||||
}
|
||||
|
||||
static int32_t PackCipherRpaInfo(JsonObj *json, const NodeInfo *info)
|
||||
{
|
||||
char cipherKey[SESSION_KEY_STR_LEN] = {0};
|
||||
@ -1274,7 +1297,7 @@ static int32_t PackCipherRpaInfo(JsonObj *json, const NodeInfo *info)
|
||||
(void)memset_s(&broadcastKey, sizeof(BroadcastCipherKey), 0, sizeof(BroadcastCipherKey));
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
AUTH_LOGI(AUTH_FSM, "update broadcast cipher key success!");
|
||||
DumpRpaCipherKey(cipherKey, cipherIv, peerIrk, "pack broadcast cipher key");
|
||||
(void)memset_s(&broadcastKey, sizeof(BroadcastCipherKey), 0, sizeof(BroadcastCipherKey));
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -1314,7 +1337,7 @@ static void UnpackCipherRpaInfo(const JsonObj *json, NodeInfo *info)
|
||||
AUTH_LOGE(AUTH_FSM, "convert publicAddress to bytes fail.");
|
||||
break;
|
||||
}
|
||||
AUTH_LOGI(AUTH_FSM, "unpack cipher and rpa info success!");
|
||||
DumpRpaCipherKey(cipherKey, cipherIv, peerIrk, "unpack broadcast cipher key");
|
||||
} while (0);
|
||||
(void)memset_s(cipherKey, SESSION_KEY_STR_LEN, 0, SESSION_KEY_STR_LEN);
|
||||
(void)memset_s(cipherIv, BROADCAST_IV_STR_LEN, 0, BROADCAST_IV_STR_LEN);
|
||||
@ -1413,7 +1436,39 @@ static int32_t PackCommon(JsonObj *json, const NodeInfo *info, SoftBusVersion ve
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static void UnpackWifiDirectInfo(const JsonObj *json, NodeInfo *info)
|
||||
static void UnpackMetaPtk(char *remoteMetaPtk, char *decodePtk)
|
||||
{
|
||||
size_t len = 0;
|
||||
if (SoftBusBase64Decode((unsigned char *)remoteMetaPtk, PTK_DEFAULT_LEN, &len,
|
||||
(const unsigned char *)decodePtk, strlen((char *)decodePtk)) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode remote meta ptk fail");
|
||||
return;
|
||||
}
|
||||
LnnDumpRemotePtk(NULL, remoteMetaPtk, "unpack meta wifi direct info");
|
||||
if (len != PTK_DEFAULT_LEN) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode data len error");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void UnpackPtk(char *remotePtk, char *decodePtk)
|
||||
{
|
||||
size_t len = 0;
|
||||
if (SoftBusBase64Decode((unsigned char *)remotePtk, PTK_DEFAULT_LEN, &len,
|
||||
(const unsigned char *)decodePtk, strlen((char *)decodePtk)) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode remote ptk fail");
|
||||
return;
|
||||
}
|
||||
LnnDumpRemotePtk(NULL, remotePtk, "unpack wifi direct info");
|
||||
if (len != PTK_DEFAULT_LEN) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode data len error");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void UnpackWifiDirectInfo(const JsonObj *json, NodeInfo *info, bool isMetaAuth)
|
||||
{
|
||||
char staticCap[STATIC_CAP_STR_LEN] = {0};
|
||||
if (!JSON_GetInt32FromOject(json, STATIC_CAP_LENGTH, &info->staticCapLen)) {
|
||||
@ -1430,20 +1485,15 @@ static void UnpackWifiDirectInfo(const JsonObj *json, NodeInfo *info)
|
||||
return;
|
||||
}
|
||||
char encodePtk[PTK_ENCODE_LEN] = {0};
|
||||
size_t len = 0;
|
||||
if (!JSON_GetStringFromOject(json, PTK, encodePtk, PTK_ENCODE_LEN)) {
|
||||
AUTH_LOGE(AUTH_FSM, "get encode ptk fail");
|
||||
return;
|
||||
}
|
||||
if (SoftBusBase64Decode((unsigned char *)info->remotePtk, PTK_DEFAULT_LEN,
|
||||
&len, (const unsigned char *)encodePtk, strlen((char *)encodePtk)) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode static cap fail");
|
||||
return;
|
||||
}
|
||||
LnnDumpRemotePtk(NULL, info->remotePtk, "unpack wifi direct info");
|
||||
if (len != PTK_DEFAULT_LEN) {
|
||||
AUTH_LOGE(AUTH_FSM, "decode data len error");
|
||||
return;
|
||||
AuthPrintBase64Ptk((const char *)encodePtk);
|
||||
if (isMetaAuth) {
|
||||
UnpackMetaPtk(info->remoteMetaPtk, encodePtk);
|
||||
} else {
|
||||
UnpackPtk(info->remotePtk, encodePtk);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1853,6 +1903,45 @@ static int32_t UnpackCertificateInfo(JsonObj *json, NodeInfo *nodeInfo, const Au
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static void UpdateLocalNetBrMac(void)
|
||||
{
|
||||
NodeInfo info;
|
||||
if (memset_s(&info, sizeof(NodeInfo), 0, sizeof(NodeInfo)) != EOK) {
|
||||
AUTH_LOGE(AUTH_FSM, "memset_s fail");
|
||||
return;
|
||||
}
|
||||
if (LnnGetLocalNodeInfoSafe(&info) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "get local node info fail");
|
||||
return;
|
||||
}
|
||||
const char *brMacTemp = LnnGetBtMac(&info);
|
||||
int32_t lenBrMac = strlen(brMacTemp);
|
||||
if ((lenBrMac == 0 || (strncmp(brMacTemp, INVALID_BR_MAC_ADDR, BT_MAC_LEN) == 0)) &&
|
||||
SoftBusGetBtState() == BLE_ENABLE) {
|
||||
char brMac[BT_MAC_LEN] = {0};
|
||||
SoftBusBtAddr mac = {0};
|
||||
int32_t ret = 0;
|
||||
ret = SoftBusGetBtMacAddr(&mac);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "get bt mac addr fail, do not update local brmac");
|
||||
return;
|
||||
}
|
||||
ret = ConvertBtMacToStr(brMac, BT_MAC_LEN, mac.addr, sizeof(mac.addr));
|
||||
if (ret != SOFTBUS_OK || strlen(brMac) == 0) {
|
||||
AUTH_LOGE(AUTH_FSM, "convert bt mac to str fail, do not update local brmac");
|
||||
return;
|
||||
}
|
||||
if (LnnSetLocalStrInfo(STRING_KEY_BT_MAC, brMac) != SOFTBUS_OK) {
|
||||
AUTH_LOGE(AUTH_FSM, "set local brmac fail, do not update local brmac");
|
||||
return;
|
||||
}
|
||||
char *anonyMac = NULL;
|
||||
Anonymize(brMac, &anonyMac);
|
||||
AUTH_LOGI(AUTH_FSM, "update local brmac=%{public}s", anonyMac);
|
||||
AnonymizeFree(anonyMac);
|
||||
}
|
||||
}
|
||||
|
||||
char *PackDeviceInfoMessage(const AuthConnInfo *connInfo, SoftBusVersion version, bool isMetaAuth,
|
||||
const char *remoteUuid, const AuthSessionInfo *info)
|
||||
{
|
||||
@ -1862,6 +1951,7 @@ char *PackDeviceInfoMessage(const AuthConnInfo *connInfo, SoftBusVersion version
|
||||
return NULL;
|
||||
}
|
||||
AUTH_LOGI(AUTH_FSM, "connType=%{public}d", connInfo->type);
|
||||
UpdateLocalNetBrMac();
|
||||
const NodeInfo *nodeInfo = LnnGetLocalNodeInfo();
|
||||
if (nodeInfo == NULL) {
|
||||
AUTH_LOGE(AUTH_FSM, "local info is null");
|
||||
@ -1949,7 +2039,7 @@ int32_t UnpackDeviceInfoMessage(const DevInfoData *devInfo, NodeInfo *nodeInfo,
|
||||
} else {
|
||||
ret = UnpackBt(json, nodeInfo, devInfo->version, isMetaAuth);
|
||||
}
|
||||
UnpackWifiDirectInfo(json, nodeInfo);
|
||||
UnpackWifiDirectInfo(json, nodeInfo, isMetaAuth);
|
||||
if (UnpackCertificateInfo(json, nodeInfo, info) != SOFTBUS_OK) {
|
||||
JSON_Delete(json);
|
||||
return SOFTBUS_ERR;
|
||||
|
@ -53,6 +53,7 @@ int32_t LnnIpcNotifyLeaveResult(const char *networkId, int32_t retCode);
|
||||
int32_t LnnIpcNotifyOnlineState(bool isOnline, void *info, uint32_t infoTypeLen);
|
||||
int32_t LnnIpcNotifyBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type);
|
||||
int32_t LnnIpcLocalNetworkIdChanged(void);
|
||||
int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg);
|
||||
int32_t LnnIpcNotifyTimeSyncResult(
|
||||
const char *pkgName, int32_t pid, const void *info, uint32_t infoTypeLen, int32_t retCode);
|
||||
|
||||
|
@ -182,6 +182,12 @@ int32_t LnnIpcLocalNetworkIdChanged(void)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg)
|
||||
{
|
||||
LNN_LOGI(LNN_EVENT, "not implement");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
|
||||
uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
|
@ -436,6 +436,12 @@ int32_t LnnIpcLocalNetworkIdChanged(void)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg)
|
||||
{
|
||||
LNN_LOGI(LNN_EVENT, "not implement");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
|
||||
uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
|
@ -39,6 +39,7 @@ int32_t ClientOnLeaveLNNResult(const char *pkgName, int32_t pid, const char *net
|
||||
int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoTypeLen);
|
||||
int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t type);
|
||||
int32_t ClinetOnLocalNetworkIdChanged(void);
|
||||
int32_t ClinetNotifyDeviceNotTrusted(const char *msg);
|
||||
int32_t ClientOnTimeSyncResult(
|
||||
const char *pkgName, int32_t pid, const void *info, uint32_t infoTypeLen, int32_t retCode);
|
||||
int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t pid, int32_t publishId, int32_t reason);
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
int32_t OnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info, uint32_t infoTypeLen) override;
|
||||
int32_t OnNodeBasicInfoChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override;
|
||||
int32_t OnLocalNetworkIdChanged(const char *pkgName) override;
|
||||
int32_t OnNodeDeviceNotTrusted(const char *pkgName, const char *msg) override;
|
||||
int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) override;
|
||||
void OnPublishLNNResult(int32_t publishId, int32_t reason) override;
|
||||
void OnRefreshLNNResult(int32_t refreshId, int32_t reason) override;
|
||||
|
@ -95,6 +95,21 @@ int32_t ClinetOnLocalNetworkIdChanged()
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t ClinetNotifyDeviceNotTrusted(const char *msg)
|
||||
{
|
||||
std::multimap<std::string, sptr<IRemoteObject>> proxyMap;
|
||||
SoftbusClientInfoManager::GetInstance().GetSoftbusClientProxyMap(proxyMap);
|
||||
for (auto proxy : proxyMap) {
|
||||
const char *dmPkgName = "ohos.distributedhardware.devicemanager";
|
||||
if (strcmp(dmPkgName, proxy.first.c_str()) != 0) {
|
||||
continue;
|
||||
}
|
||||
sptr<BusCenterClientProxy> clientProxy = new (std::nothrow) BusCenterClientProxy(proxy.second);
|
||||
clientProxy->OnNodeDeviceNotTrusted(proxy.first.c_str(), msg);
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t ClientOnTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
|
||||
uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
|
@ -368,6 +368,39 @@ int32_t BusCenterClientProxy::OnLocalNetworkIdChanged(const char *pkgName)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t BusCenterClientProxy::OnNodeDeviceNotTrusted(const char *pkgName, const char *msg)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
LNN_LOGE(LNN_EVENT, "remote is nullptr");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
if (pkgName == nullptr|| msg == nullptr) {
|
||||
LNN_LOGE(LNN_EVENT, "invalid parameters");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
LNN_LOGE(LNN_EVENT, "write InterfaceToken failed!");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
if (!data.WriteCString(pkgName)) {
|
||||
LNN_LOGE(LNN_EVENT, "write pkgName failed");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
if (!data.WriteCString(msg)) {
|
||||
LNN_LOGE(LNN_EVENT, "write msg failed");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option = { MessageOption::TF_ASYNC };
|
||||
if (remote->SendRequest(CLIENT_ON_NODE_DEVICE_NOT_TRUST, data, reply, option) != 0) {
|
||||
LNN_LOGE(LNN_EVENT, "send request failed");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t BusCenterClientProxy::OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
|
@ -491,6 +491,11 @@ int32_t LnnIpcLocalNetworkIdChanged(void)
|
||||
return ClinetOnLocalNetworkIdChanged();
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyDeviceNotTrusted(const char *msg)
|
||||
{
|
||||
return ClinetNotifyDeviceNotTrusted(msg);
|
||||
}
|
||||
|
||||
int32_t LnnIpcNotifyTimeSyncResult(const char *pkgName, int32_t pid, const void *info,
|
||||
uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
|
@ -32,6 +32,7 @@ extern "C" {
|
||||
#define HB_SHORT_ACCOUNT_HASH_LEN 2
|
||||
#define HB_FSM_NAME_LEN 32
|
||||
|
||||
#define HB_TIME_FACTOR_TWO_HUNDRED_MS (200LL)
|
||||
#define HB_TIME_FACTOR (1000LL)
|
||||
#define HB_START_DELAY_LEN (10 * HB_TIME_FACTOR)
|
||||
#define HB_CLOUD_SYNC_DELAY_LEN (13 * HB_TIME_FACTOR)
|
||||
|
@ -593,6 +593,10 @@ static void HbScreenLockChangeEventHandler(const LnnEventBasicInfo *info)
|
||||
LnnAsyncCallbackDelayHelper(GetLooper(LOOP_TYPE_DEFAULT), HbDelayConditionChanged, NULL,
|
||||
HbTryCloudSync() == SOFTBUS_OK ? HB_CLOUD_SYNC_DELAY_LEN : 0);
|
||||
}
|
||||
if (g_hbConditionState.screenState == SOFTBUS_SCREEN_ON &&
|
||||
g_hbConditionState.accountState != SOFTBUS_ACCOUNT_LOG_IN) {
|
||||
HbConditionChanged(false);
|
||||
}
|
||||
break;
|
||||
case SOFTBUS_SCREEN_LOCK:
|
||||
LNN_LOGI(LNN_HEART_BEAT, "HB handle SOFTBUS_SCREEN_LOCK");
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "lnn_heartbeat_strategy.h"
|
||||
#include "lnn_heartbeat_utils.h"
|
||||
#include "lnn_lane_vap_info.h"
|
||||
#include "lnn_local_net_ledger.h"
|
||||
#include "lnn_log.h"
|
||||
#include "lnn_net_builder.h"
|
||||
#include "lnn_node_info.h"
|
||||
@ -50,6 +51,8 @@
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_utils.h"
|
||||
|
||||
#define INVALID_BR_MAC_ADDR "00:00:00:00:00:00"
|
||||
|
||||
#define HB_RECV_INFO_SAVE_LEN (60 * 60 * HB_TIME_FACTOR)
|
||||
#define HB_REAUTH_TIME (10 * HB_TIME_FACTOR)
|
||||
#define HB_DFX_DELAY_TIME (7 * HB_TIME_FACTOR)
|
||||
@ -435,6 +438,19 @@ static bool IsStateVersionChanged(
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsInvalidBrmac(const char *macAddr)
|
||||
{
|
||||
if (strlen(macAddr) == 0) {
|
||||
LNN_LOGE(LNN_HEART_BEAT, "macAddr is null");
|
||||
return true;
|
||||
}
|
||||
if (strcmp(macAddr, INVALID_BR_MAC_ADDR) == 0) {
|
||||
LNN_LOGE(LNN_HEART_BEAT, "macAddr is invalid");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsNeedConnectOnLine(DeviceInfo *device, HbRespData *hbResp, ConnectOnlineReason *connectReason)
|
||||
{
|
||||
if (hbResp == NULL || hbResp->stateVersion == STATE_VERSION_INVALID) {
|
||||
@ -450,7 +466,7 @@ static bool IsNeedConnectOnLine(DeviceInfo *device, HbRespData *hbResp, ConnectO
|
||||
return true;
|
||||
}
|
||||
if (LnnRetrieveDeviceInfo(device->devId, &deviceInfo) != SOFTBUS_OK ||
|
||||
strlen(deviceInfo.connectInfo.macAddr) == 0) {
|
||||
IsInvalidBrmac(deviceInfo.connectInfo.macAddr)) {
|
||||
*connectReason = BLE_FIRST_CONNECT;
|
||||
LNN_LOGI(LNN_HEART_BEAT, "don't support ble direct online because retrieve fail, "
|
||||
"stateVersion=%{public}d->%{public}d", deviceInfo.stateVersion, (int32_t)hbResp->stateVersion);
|
||||
|
@ -329,7 +329,7 @@ static int32_t RelayHeartbeatV0Split(
|
||||
.isRelay = msgPara->isRelay,
|
||||
.isLastEnd = true,
|
||||
};
|
||||
delayTime += HB_SEND_RELAY_LEN;
|
||||
delayTime += HB_SEND_RELAY_LEN + HB_TIME_FACTOR_TWO_HUNDRED_MS;
|
||||
if (LnnPostSendEndMsgToHbFsm(hbFsm, &endData, delayTime) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_HEART_BEAT, "HB send once last end fail, hbType=%{public}d", registedHbType);
|
||||
return SOFTBUS_ERR;
|
||||
@ -341,7 +341,7 @@ static int32_t RelayHeartbeatV0Split(
|
||||
LNN_LOGE(LNN_HEART_BEAT, "HB send once first begin fail, hbType=%{public}d", registedHbType);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
delayTime += HB_SEND_RELAY_LEN;
|
||||
delayTime += HB_SEND_RELAY_LEN + HB_TIME_FACTOR_TWO_HUNDRED_MS;
|
||||
msgPara->hasScanRsp = true;
|
||||
if (LnnPostSendBeginMsgToHbFsm(hbFsm, registedHbType, wakeupFlag, msgPara, delayTime) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_HEART_BEAT, "HB send once first begin fail, hbType=%{public}d", registedHbType);
|
||||
|
@ -373,18 +373,29 @@ void LnnDumpLocalBasicInfo(void)
|
||||
char *anonyUdidHash = NULL;
|
||||
char *anonyNetworkId = NULL;
|
||||
char *anonyP2pMac = NULL;
|
||||
char *anonyUdid = NULL;
|
||||
char *anonyUuid = NULL;
|
||||
char localIp[IP_LEN] = { 0 };
|
||||
char localP2PMac[MAC_LEN] = { 0 };
|
||||
char localBtMac[BT_MAC_LEN] = { 0 };
|
||||
char localUdid[UDID_BUF_LEN] = { 0 };
|
||||
char localUuid[UUID_BUF_LEN] = { 0 };
|
||||
char udidShortHash[HB_SHORT_UDID_HASH_HEX_LEN + 1] = { 0 };
|
||||
int32_t onlineNodeNum = 0;
|
||||
NodeBasicInfo localInfo = { 0 };
|
||||
|
||||
(void)LnnGetLocalDeviceInfo(&localInfo);
|
||||
(void)LnnGetLocalStrInfo(STRING_KEY_UUID, localUuid, UUID_BUF_LEN);
|
||||
(void)LnnGetLocalStrInfo(STRING_KEY_DEV_UDID, localUdid, UDID_BUF_LEN);
|
||||
Anonymize(udidShortHash, &anonyUdidHash);
|
||||
Anonymize(localUuid, &anonyUuid);
|
||||
Anonymize(localUdid, &anonyUdid);
|
||||
Anonymize(localInfo.networkId, &anonyNetworkId);
|
||||
LNN_LOGW(LNN_HEART_BEAT, "local DeviceInfo udidShortHash=%{public}s, networkId=%{public}s", anonyUdidHash,
|
||||
anonyNetworkId);
|
||||
LNN_LOGW(LNN_HEART_BEAT,
|
||||
"local DeviceInfo, uuid=%{public}s, udid=%{public}s, udidShortHash=%{public}s, networkId=%{public}s",
|
||||
anonyUuid, anonyUdid, anonyUdidHash, anonyNetworkId);
|
||||
AnonymizeFree(anonyUuid);
|
||||
AnonymizeFree(anonyUdid);
|
||||
AnonymizeFree(anonyUdidHash);
|
||||
AnonymizeFree(anonyNetworkId);
|
||||
const char *devTypeStr = LnnConvertIdToDeviceType(localInfo.deviceTypeId);
|
||||
|
@ -35,6 +35,13 @@ extern "C" {
|
||||
#define HML_LATENCY 1500
|
||||
#define BR_REUSE_LATENCY 1000
|
||||
|
||||
typedef struct {
|
||||
uint32_t activeHml;
|
||||
int32_t passiveHml;
|
||||
int32_t rawHml;
|
||||
bool isDisableLowPower;
|
||||
} PowerControlInfo;
|
||||
|
||||
typedef struct {
|
||||
char peerNetworkId[NETWORK_ID_BUF_LEN];
|
||||
bool networkDelegate;
|
||||
@ -122,6 +129,7 @@ void LaneAddP2pAddress(const char *networkId, const char *ipAddr, uint16_t port)
|
||||
|
||||
void LaneAddP2pAddressByIp(const char *ipAddr, uint16_t port);
|
||||
void LaneUpdateP2pAddressByIp(const char *ipAddr, const char *networkId);
|
||||
void DetectDisableWifiDirectApply(void);
|
||||
|
||||
int32_t FindLaneResourceByLinkAddr(const LaneLinkInfo *info, LaneResource *resource);
|
||||
int32_t FindLaneResourceByLinkType(const char *peerUdid, LaneLinkType type, LaneResource *resource);
|
||||
|
@ -44,6 +44,8 @@ int32_t SelectAuthLane(const char *networkId, LanePreferredLinkList *request,
|
||||
|
||||
int32_t LaneCapCheck(const char *networkId, LaneLinkType linkType);
|
||||
|
||||
int32_t GetErrCodeOfLink(const char *networkId, LaneLinkType linkType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -56,7 +56,6 @@
|
||||
#define TYPE_BUF_LEN 2
|
||||
#define LANE_ID_BUF_LEN (UDID_BUF_LEN + UDID_BUF_LEN + TYPE_BUF_LEN)
|
||||
#define LANE_ID_HASH_LEN 32
|
||||
#define POWER_CONTROL_CLIENT 3
|
||||
|
||||
static bool g_enabledLowPower = false;
|
||||
|
||||
@ -240,10 +239,10 @@ static int32_t GetRemoteMacAddrByLocalIp(const char *localIp, char *macAddr, uin
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static void SetWifiDirectLinkInfo(P2pLinkInfo *p2pInfo, WifiDirectLinkInfo *wifiDirectInfo)
|
||||
static void SetWifiDirectLinkInfo(P2pLinkInfo *p2pInfo, WifiDirectLinkInfo *wifiDirectInfo, uint32_t bandWidth)
|
||||
{
|
||||
wifiDirectInfo->linkType = LANE_HML;
|
||||
wifiDirectInfo->bandWidth = LANE_BW_160M;
|
||||
wifiDirectInfo->bandWidth = bandWidth;
|
||||
int32_t ret = GetRemoteMacAddrByLocalIp(p2pInfo->connInfo.localIp,
|
||||
wifiDirectInfo->wifiDirectMac, LNN_MAC_LEN);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
@ -252,33 +251,36 @@ static void SetWifiDirectLinkInfo(P2pLinkInfo *p2pInfo, WifiDirectLinkInfo *wifi
|
||||
}
|
||||
}
|
||||
|
||||
static void HandleDetectWifiDirectApply(bool isDisableLowPower, WifiDirectLinkInfo *wifiDirectInfo,
|
||||
int32_t activeHml, int32_t passiveHml, int32_t rawHml)
|
||||
static void SetLanePowerStatus(bool status)
|
||||
{
|
||||
if (LaneLock() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "lane lock fail");
|
||||
return;
|
||||
}
|
||||
if (isDisableLowPower) {
|
||||
DisablePowerControl(wifiDirectInfo);
|
||||
g_enabledLowPower = false;
|
||||
} else if ((activeHml == 1) && (passiveHml == 0) && (rawHml == 0) && (!g_enabledLowPower)) {
|
||||
int32_t ret = EnablePowerControl(wifiDirectInfo);
|
||||
g_enabledLowPower = true;
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "enable fail, ret=%{public}d", ret);
|
||||
g_enabledLowPower = false;
|
||||
}
|
||||
}
|
||||
g_enabledLowPower = status;
|
||||
LaneUnlock();
|
||||
}
|
||||
|
||||
static void DetectDisableWifiDirectApply(void)
|
||||
static void HandleDetectWifiDirectApply(PowerControlInfo *powerInfo, WifiDirectLinkInfo *wifiDirectInfo)
|
||||
{
|
||||
int32_t activeHml = 0;
|
||||
int32_t passiveHml = 0;
|
||||
int32_t rawHml = 0;
|
||||
bool isDisableLowPower = false;
|
||||
if (powerInfo->isDisableLowPower) {
|
||||
DisablePowerControl(wifiDirectInfo);
|
||||
SetLanePowerStatus(false);
|
||||
} else if ((powerInfo->activeHml == 1) && (powerInfo->passiveHml == 0) && (powerInfo->rawHml == 0)
|
||||
&& (!g_enabledLowPower)) {
|
||||
int32_t ret = EnablePowerControl(wifiDirectInfo);
|
||||
SetLanePowerStatus(true);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "enable fail, ret=%{public}d", ret);
|
||||
SetLanePowerStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DetectDisableWifiDirectApply(void)
|
||||
{
|
||||
PowerControlInfo powerInfo;
|
||||
(void)memset_s(&powerInfo, sizeof(powerInfo), 0, sizeof(powerInfo));
|
||||
WifiDirectLinkInfo wifiDirectInfo;
|
||||
(void)memset_s(&wifiDirectInfo, sizeof(wifiDirectInfo), 0, sizeof(wifiDirectInfo));
|
||||
if (LaneLock() != SOFTBUS_OK) {
|
||||
@ -288,41 +290,39 @@ static void DetectDisableWifiDirectApply(void)
|
||||
LaneResource *item = NULL;
|
||||
LaneResource *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_laneResource.list, LaneResource, node) {
|
||||
LNN_LOGI(LNN_LANE, "link.type=%{public}d, link.linkInfo.p2p.bw=%{public}d",
|
||||
item->link.type, item->link.linkInfo.p2p.bw);
|
||||
LNN_LOGI(LNN_LANE, "link.type=%{public}d, link.bw=%{public}d", item->link.type, item->link.linkInfo.p2p.bw);
|
||||
if (item->link.type == LANE_HML) {
|
||||
if (item->clientRef > 0) {
|
||||
activeHml++;
|
||||
powerInfo.activeHml++;
|
||||
}
|
||||
if (item->isServerSide) {
|
||||
passiveHml++;
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo);
|
||||
powerInfo.passiveHml++;
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo, item->link.linkInfo.p2p.bw);
|
||||
}
|
||||
if (item->link.linkInfo.p2p.bw == LANE_BW_160M) {
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo);
|
||||
if (item->link.linkInfo.p2p.bw == LANE_BW_160M || item->link.linkInfo.p2p.bw == LANE_BW_80P80M) {
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo, item->link.linkInfo.p2p.bw);
|
||||
}
|
||||
}
|
||||
if (activeHml == 1) {
|
||||
isDisableLowPower = true;
|
||||
break;
|
||||
}
|
||||
if (((activeHml == 0) || (passiveHml > 0) || (rawHml > 0)) && g_enabledLowPower) {
|
||||
isDisableLowPower = true;
|
||||
break;
|
||||
if (item->link.type == LANE_HML_RAW) {
|
||||
powerInfo.rawHml++;
|
||||
}
|
||||
}
|
||||
if (powerInfo.activeHml == 1) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
if (((powerInfo.activeHml == 0) || (powerInfo.passiveHml > 0) || (powerInfo.rawHml > 0)) && g_enabledLowPower) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
LaneUnlock();
|
||||
LNN_LOGI(LNN_LANE, "activeHml=%{public}d, passiveHml=%{public}d, rawHml=%{public}d", activeHml, passiveHml, rawHml);
|
||||
HandleDetectWifiDirectApply(isDisableLowPower, &wifiDirectInfo, activeHml, passiveHml, rawHml);
|
||||
LNN_LOGI(LNN_LANE, "activeHml=%{public}d, passiveHml=%{public}d, rawHml=%{public}d",
|
||||
powerInfo.activeHml, powerInfo.passiveHml, powerInfo.rawHml);
|
||||
HandleDetectWifiDirectApply(&powerInfo, &wifiDirectInfo);
|
||||
}
|
||||
|
||||
static void DetectEnableWifiDirectApply(void)
|
||||
{
|
||||
int32_t activeHml = 0;
|
||||
int32_t passiveHml = 0;
|
||||
int32_t rawHml = 0;
|
||||
uint32_t clientHml = 0;
|
||||
bool isDisableLowPower = false;
|
||||
PowerControlInfo powerInfo;
|
||||
(void)memset_s(&powerInfo, sizeof(powerInfo), 0, sizeof(powerInfo));
|
||||
WifiDirectLinkInfo wifiDirectInfo;
|
||||
(void)memset_s(&wifiDirectInfo, sizeof(wifiDirectInfo), 0, sizeof(wifiDirectInfo));
|
||||
if (LaneLock() != SOFTBUS_OK) {
|
||||
@ -332,35 +332,33 @@ static void DetectEnableWifiDirectApply(void)
|
||||
LaneResource *item = NULL;
|
||||
LaneResource *next = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, next, &g_laneResource.list, LaneResource, node) {
|
||||
LNN_LOGI(LNN_LANE, "link.type=%{public}d, link.linkInfo.p2p.bw=%{public}d",
|
||||
item->link.type, item->link.linkInfo.p2p.bw);
|
||||
LNN_LOGI(LNN_LANE, "link.type=%{public}d, link.bw=%{public}d", item->link.type, item->link.linkInfo.p2p.bw);
|
||||
if (item->link.type == LANE_HML) {
|
||||
if (item->clientRef > 0) {
|
||||
activeHml++;
|
||||
}
|
||||
if (item->clientRef > 0) {
|
||||
clientHml = item->clientRef;
|
||||
powerInfo.activeHml = item->clientRef;
|
||||
}
|
||||
if (item->isServerSide) {
|
||||
passiveHml++;
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo);
|
||||
powerInfo.passiveHml++;
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo, item->link.linkInfo.p2p.bw);
|
||||
}
|
||||
if (item->link.linkInfo.p2p.bw == LANE_BW_160M) {
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo);
|
||||
if (item->link.linkInfo.p2p.bw == LANE_BW_160M || item->link.linkInfo.p2p.bw == LANE_BW_80P80M) {
|
||||
SetWifiDirectLinkInfo(&item->link.linkInfo.p2p, &wifiDirectInfo, item->link.linkInfo.p2p.bw);
|
||||
}
|
||||
}
|
||||
if (clientHml >= POWER_CONTROL_CLIENT) {
|
||||
isDisableLowPower = true;
|
||||
break;
|
||||
}
|
||||
if (((activeHml == 0) || (passiveHml > 0) || (rawHml > 0)) && g_enabledLowPower) {
|
||||
isDisableLowPower = true;
|
||||
break;
|
||||
if (item->link.type == LANE_HML_RAW) {
|
||||
powerInfo.rawHml++;
|
||||
}
|
||||
}
|
||||
if (powerInfo.activeHml > 1) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
if (((powerInfo.activeHml == 0) || (powerInfo.passiveHml > 0) || (powerInfo.rawHml > 0)) && g_enabledLowPower) {
|
||||
powerInfo.isDisableLowPower = true;
|
||||
}
|
||||
LaneUnlock();
|
||||
LNN_LOGI(LNN_LANE, "activeHml=%{public}d, passiveHml=%{public}d, rawHml=%{public}d", activeHml, passiveHml, rawHml);
|
||||
HandleDetectWifiDirectApply(isDisableLowPower, &wifiDirectInfo, activeHml, passiveHml, rawHml);
|
||||
LNN_LOGI(LNN_LANE, "activeHml=%{public}d, passiveHml=%{public}d, rawHml=%{public}d",
|
||||
powerInfo.activeHml, powerInfo.passiveHml, powerInfo.rawHml);
|
||||
HandleDetectWifiDirectApply(&powerInfo, &wifiDirectInfo);
|
||||
}
|
||||
|
||||
static int32_t CreateNewLaneResource(const LaneLinkInfo *linkInfo, uint64_t laneId, bool isServerSide)
|
||||
|
@ -1557,12 +1557,51 @@ static void GuideChannelDetect(uint32_t authRequestId, AuthHandle authHandle)
|
||||
AuthChannelDetectSucc(laneReqId, authRequestId, authHandle);
|
||||
}
|
||||
|
||||
static int32_t GetPreferAuthByType(const char *networkId, AuthLinkType type, AuthConnInfo *connInfo, bool isMetaAuth)
|
||||
{
|
||||
char uuid[UDID_BUF_LEN] = {0};
|
||||
if (LnnGetRemoteStrInfo(networkId, STRING_KEY_UUID, uuid, sizeof(uuid)) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get peer uuid fail");
|
||||
return SOFTBUS_LANE_GET_LEDGER_INFO_ERR;
|
||||
}
|
||||
return AuthGetConnInfoByType(uuid, type, connInfo, isMetaAuth);
|
||||
}
|
||||
|
||||
static int32_t GetCurrentGuideType(uint32_t laneReqId, LaneLinkType linkType, WdGuideType *guideType)
|
||||
{
|
||||
WdGuideInfo guideInfo = {0};
|
||||
if (GetGuideInfo(laneReqId, linkType, &guideInfo) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get guide channel info fail.");
|
||||
return SOFTBUS_LANE_NOT_FOUND;
|
||||
}
|
||||
*guideType = guideInfo.guideList[guideInfo.guideIdx];
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t GetAuthConnInfo(const LinkRequest *request, uint32_t laneReqId, AuthConnInfo *connInfo, bool isMetaAuth)
|
||||
{
|
||||
WdGuideType guideType = LANE_CHANNEL_BUTT;
|
||||
int32_t ret = GetCurrentGuideType(laneReqId, request->linkType, &guideType);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "get current guide channel info fail");
|
||||
return ret;
|
||||
}
|
||||
if (!isMetaAuth && (guideType == LANE_NEW_AUTH_TRIGGER || guideType == LANE_ACTIVE_BR_NEGO ||
|
||||
guideType == LANE_NEW_AUTH_NEGO)) {
|
||||
LNN_LOGI(LNN_LANE, "current guideType=%{public}d", guideType);
|
||||
ret = GetPreferAuthByType(request->peerNetworkId, AUTH_LINK_TYPE_BR, connInfo, isMetaAuth);
|
||||
} else {
|
||||
ret = GetPreferAuth(request->peerNetworkId, connInfo, isMetaAuth);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t OpenAuthToConnP2p(const LinkRequest *request, uint32_t laneReqId, const LaneLinkCb *callback)
|
||||
{
|
||||
AuthConnInfo connInfo;
|
||||
(void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo));
|
||||
bool isMetaAuth = GetAuthType(request->peerNetworkId);
|
||||
int32_t ret = GetPreferAuth(request->peerNetworkId, &connInfo, isMetaAuth);
|
||||
int32_t ret = GetAuthConnInfo(request, laneReqId, &connInfo, isMetaAuth);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "no auth conn exist");
|
||||
return ret;
|
||||
@ -1590,7 +1629,7 @@ static int32_t OpenAuthTriggerToConn(const LinkRequest *request, uint32_t laneRe
|
||||
AuthConnInfo connInfo;
|
||||
(void)memset_s(&connInfo, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo));
|
||||
bool isMetaAuth = GetAuthType(request->peerNetworkId);
|
||||
int32_t ret = GetPreferAuth(request->peerNetworkId, &connInfo, isMetaAuth);
|
||||
int32_t ret = GetAuthConnInfo(request, laneReqId, &connInfo, isMetaAuth);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "no auth conn exist");
|
||||
return ret;
|
||||
@ -2159,7 +2198,7 @@ static int32_t LnnP2pInit(void)
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
if (SoftBusMutexInit(&g_AuthTagLock, NULL) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_INIT, "mutex init fail");
|
||||
(void)SoftBusMutexDestroy(&g_p2pLinkMutex);
|
||||
SoftBusFree(g_p2pLinkList);
|
||||
SoftBusFree(g_p2pLinkedList);
|
||||
SoftBusFree(g_guideInfoList);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "anonymizer.h"
|
||||
#include "lnn_distributed_net_ledger.h"
|
||||
#include "lnn_lane_common.h"
|
||||
#include "lnn_lane_link.h"
|
||||
#include "lnn_log.h"
|
||||
#include "lnn_node_info.h"
|
||||
#include "lnn_trans_lane.h"
|
||||
@ -407,6 +408,7 @@ static void LnnOnWifiDirectDeviceOffline(const char *peerMac, const char *peerIp
|
||||
LNN_LOGE(LNN_STATE, "get lane state notify info fail");
|
||||
return;
|
||||
}
|
||||
DetectDisableWifiDirectApply();
|
||||
if (PostLaneStateChangeMessage(LANE_STATE_LINKDOWN, laneLinkInfo.peerUdid, &laneLinkInfo) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LANE, "post laneState linkdown msg fail");
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ static void DumpPreferredLink(LaneLinkType preferredLink, uint32_t priority)
|
||||
LNN_LOGD(LNN_LANE, "priority=%{public}u, linkType=%{public}s", priority, GetLinkTypeStrng(preferredLink));
|
||||
}
|
||||
|
||||
static int32_t GetErrCodeOfLink(const char *networkId, LaneLinkType linkType)
|
||||
int32_t GetErrCodeOfLink(const char *networkId, LaneLinkType linkType)
|
||||
{
|
||||
if ((linkType == LANE_WLAN_2P4G || linkType == LANE_WLAN_5G || linkType == LANE_P2P ||
|
||||
linkType == LANE_P2P_REUSE || linkType == LANE_HML) &&
|
||||
|
@ -614,6 +614,9 @@ static int32_t SpecifiedLinkConvert(const char *networkId, LaneSpecifiedLink lin
|
||||
preferLink->linkType[resNum] = optionalLink[i];
|
||||
resNum++;
|
||||
}
|
||||
if (resNum == 0) {
|
||||
return GetErrCodeOfLink(networkId, optionalLink[0]);
|
||||
}
|
||||
preferLink->linkTypeNum = resNum;
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -1009,11 +1012,6 @@ static void NotifyLaneAllocSuccess(uint32_t laneReqId, uint64_t laneId, const La
|
||||
LNN_LOGE(LNN_LANE, "get lane reqInfo fail");
|
||||
return;
|
||||
}
|
||||
if (reqInfo.isWithQos && reqInfo.isCanceled) {
|
||||
LNN_LOGI(LNN_LANE, "lane has canceled not need notify succ, laneReqId=%{public}u", laneReqId);
|
||||
(void)Free(laneReqId);
|
||||
return;
|
||||
}
|
||||
LaneProfile profile;
|
||||
LaneConnInfo connInfo;
|
||||
(void)memset_s(&profile, sizeof(LaneProfile), 0, sizeof(LaneProfile));
|
||||
@ -1024,6 +1022,12 @@ static void NotifyLaneAllocSuccess(uint32_t laneReqId, uint64_t laneId, const La
|
||||
LNN_LOGI(LNN_LANE, "Notify laneAlloc succ, laneReqId=%{public}u, linkType=%{public}d, "
|
||||
"laneId=%{public}" PRIu64 "", laneReqId, info->type, laneId);
|
||||
if (reqInfo.isWithQos) {
|
||||
if (reqInfo.isCanceled) {
|
||||
LNN_LOGE(LNN_LANE, "lane has canceled only notify fail, laneReqId=%{public}u", laneReqId);
|
||||
reqInfo.listener.onLaneAllocFail(laneReqId, SOFTBUS_LANE_SUCC_AFTER_CANCELED);
|
||||
(void)Free(laneReqId);
|
||||
return;
|
||||
}
|
||||
connInfo.laneId = laneId;
|
||||
reqInfo.listener.onLaneAllocSuccess(laneReqId, &connInfo);
|
||||
} else {
|
||||
@ -1042,10 +1046,7 @@ static void NotifyLaneAllocFail(uint32_t laneReqId, int32_t reason)
|
||||
return;
|
||||
}
|
||||
if (reqInfo.isWithQos && reqInfo.isCanceled) {
|
||||
LNN_LOGI(LNN_LANE, "lane has canceled not need notify fail, laneReqId=%{public}u", laneReqId);
|
||||
DeleteRequestNode(laneReqId);
|
||||
FreeLaneReqId(laneReqId);
|
||||
return;
|
||||
LNN_LOGE(LNN_LANE, "lane has canceled only notify fail, laneReqId=%{public}u", laneReqId);
|
||||
}
|
||||
LNN_LOGE(LNN_LANE, "Notify laneAlloc fail, laneReqId=%{public}u, reason=%{public}d", laneReqId, reason);
|
||||
if (reqInfo.isWithQos) {
|
||||
|
@ -90,6 +90,7 @@ extern "C" {
|
||||
#define DEVICE_INFO_JSON_KEY_TIMESTAMP_BEGIN "JSON_KEY_TIMESTAMP_BEGIN"
|
||||
#define DEVICE_INFO_JSON_KEY_CURRENT_INDEX "JSON_KEY_CURRENT_INDEX"
|
||||
#define DEVICE_INFO_TIMESTAMP "TIMESTAMP"
|
||||
#define DEVICE_INFO_LAST_AUTH_SEQ "LAST_AUTH_SEQ"
|
||||
#define IS_SUPPORT_IPV6 "IS_SUPPORT_IPV6"
|
||||
#define IS_AUTH_EXCHANGE_UDID "IS_AUTH_EXCHANGE_UDID"
|
||||
|
||||
|
@ -737,6 +737,12 @@ static void PrintSyncNodeInfo(const NodeInfo *cacheInfo)
|
||||
LNN_LOGE(LNN_BUILDER, "invalid param");
|
||||
return;
|
||||
}
|
||||
char accountId[INT64_TO_STR_MAX_LEN] = {0};
|
||||
if (!Int64ToString(cacheInfo->accountId, accountId, INT64_TO_STR_MAX_LEN)) {
|
||||
LNN_LOGE(LNN_BUILDER, "accountId to str fail");
|
||||
}
|
||||
char *anonyAccountId = NULL;
|
||||
Anonymize(accountId, &anonyAccountId);
|
||||
char *anonyP2pMac = NULL;
|
||||
Anonymize(cacheInfo->p2pInfo.p2pMac, &anonyP2pMac);
|
||||
char *anonyMacAddr = NULL;
|
||||
@ -751,7 +757,7 @@ static void PrintSyncNodeInfo(const NodeInfo *cacheInfo)
|
||||
Anonymize(cacheInfo->deviceInfo.deviceVersion, &anonyDeviceVersion);
|
||||
LNN_LOGI(LNN_BUILDER,
|
||||
"Sync NodeInfo: WIFI_VERSION=%{public}" PRId64 ", BLE_VERSION=%{public}" PRId64
|
||||
", ACCOUNT_ID=%{public}" PRId64 ", TRANSPORT_PROTOCOL=%{public}" PRIu64 ", FEATURE=%{public}" PRIu64
|
||||
", ACCOUNT_ID=%{public}s, TRANSPORT_PROTOCOL=%{public}" PRIu64 ", FEATURE=%{public}" PRIu64
|
||||
", CONN_SUB_FEATURE=%{public}" PRIu64 ", TIMESTAMP=%{public}" PRIu64 ", "
|
||||
"P2P_MAC_ADDR=%{public}s, PKG_VERSION=%{public}s, DEVICE_NAME=%{public}s, "
|
||||
"UNIFIED_DEFAULT_DEVICE_NAME=%{public}s, UNIFIED_DEVICE_NAME=%{public}s, SETTINGS_NICK_NAME=%{public}s, "
|
||||
@ -760,7 +766,7 @@ static void PrintSyncNodeInfo(const NodeInfo *cacheInfo)
|
||||
"NETWORK_ID=%{public}s, STATE_VERSION=%{public}d, BROADCAST_CIPHER_KEY=%{public}02x, "
|
||||
"BROADCAST_CIPHER_IV=%{public}02x, IRK=%{public}02x, PUB_MAC=%{public}02x, PTK=%{public}02x, "
|
||||
"DEVICE_VERSION=%{public}s",
|
||||
cacheInfo->wifiVersion, cacheInfo->bleVersion, cacheInfo->accountId, cacheInfo->supportedProtocols,
|
||||
cacheInfo->wifiVersion, cacheInfo->bleVersion, AnonymizeWrapper(anonyAccountId), cacheInfo->supportedProtocols,
|
||||
cacheInfo->feature, cacheInfo->connSubFeature, cacheInfo->updateTimestamp, anonyP2pMac, cacheInfo->pkgVersion,
|
||||
cacheInfo->deviceInfo.deviceName, cacheInfo->deviceInfo.unifiedDefaultName, cacheInfo->deviceInfo.unifiedName,
|
||||
cacheInfo->deviceInfo.nickName, cacheInfo->authCapacity, cacheInfo->deviceInfo.osType,
|
||||
@ -768,6 +774,7 @@ static void PrintSyncNodeInfo(const NodeInfo *cacheInfo)
|
||||
cacheInfo->softBusVersion, anonyUdid, anonyUuid, anonyNetworkId, cacheInfo->stateVersion,
|
||||
*cacheInfo->cipherInfo.key, *cacheInfo->cipherInfo.iv, *cacheInfo->rpaInfo.peerIrk,
|
||||
*cacheInfo->rpaInfo.publicAddress, *cacheInfo->remotePtk, anonyDeviceVersion);
|
||||
AnonymizeFree(anonyAccountId);
|
||||
AnonymizeFree(anonyP2pMac);
|
||||
AnonymizeFree(anonyMacAddr);
|
||||
AnonymizeFree(anonyUdid);
|
||||
@ -776,6 +783,48 @@ static void PrintSyncNodeInfo(const NodeInfo *cacheInfo)
|
||||
AnonymizeFree(anonyDeviceVersion);
|
||||
}
|
||||
|
||||
static int32_t LnnSaveAndUpdateDistributedNode(NodeInfo *cacheInfo)
|
||||
{
|
||||
if (cacheInfo == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "invalid param");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
NodeInfo localCacheInfo = { 0 };
|
||||
int32_t ret = LnnGetLocalCacheNodeInfo(&localCacheInfo);
|
||||
if (ret != SOFTBUS_OK || cacheInfo->accountId != localCacheInfo.accountId) {
|
||||
char accountId[INT64_TO_STR_MAX_LEN] = {0};
|
||||
char localAccountId[INT64_TO_STR_MAX_LEN] = {0};
|
||||
if (!Int64ToString(cacheInfo->accountId, accountId, INT64_TO_STR_MAX_LEN)) {
|
||||
LNN_LOGE(LNN_BUILDER, "accountId to str fail");
|
||||
}
|
||||
if (!Int64ToString(localCacheInfo.accountId, localAccountId, INT64_TO_STR_MAX_LEN)) {
|
||||
LNN_LOGE(LNN_BUILDER, "local accountId to str fail");
|
||||
}
|
||||
char *anonyAccountId = NULL;
|
||||
char *anonyLocalAccountId = NULL;
|
||||
Anonymize(accountId, &anonyAccountId);
|
||||
Anonymize(localAccountId, &anonyLocalAccountId);
|
||||
LNN_LOGE(LNN_BUILDER, "don't set, ret=%{public}d, accountId=%{public}s, local accountId=%{public}s",
|
||||
ret, AnonymizeWrapper(anonyAccountId), AnonymizeWrapper(anonyLocalAccountId));
|
||||
AnonymizeFree(anonyAccountId);
|
||||
AnonymizeFree(anonyLocalAccountId);
|
||||
return ret;
|
||||
}
|
||||
cacheInfo->localStateVersion = localCacheInfo.stateVersion;
|
||||
(void)LnnSaveRemoteDeviceInfo(cacheInfo);
|
||||
char *anonyUdid = NULL;
|
||||
Anonymize(cacheInfo->deviceInfo.deviceUdid, &anonyUdid);
|
||||
LNN_LOGI(LNN_BUILDER,
|
||||
"success. udid=%{public}s, stateVersion=%{public}d, localStateVersion=%{public}d, updateTimestamp=%{public}"
|
||||
"" PRIu64, anonyUdid, cacheInfo->stateVersion, cacheInfo->localStateVersion, cacheInfo->updateTimestamp);
|
||||
AnonymizeFree(anonyUdid);
|
||||
if (LnnUpdateDistributedNodeInfo(cacheInfo, cacheInfo->deviceInfo.deviceUdid) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "fail:Cache info sync to Ledger fail");
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnDBDataChangeSyncToCacheInner(const char *key, const char *value)
|
||||
{
|
||||
if (key == NULL || value == NULL) {
|
||||
@ -806,21 +855,8 @@ int32_t LnnDBDataChangeSyncToCacheInner(const char *key, const char *value)
|
||||
cacheInfo.updateTimestamp)) {
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
NodeInfo localCacheInfo = { 0 };
|
||||
int32_t ret = LnnGetLocalCacheNodeInfo(&localCacheInfo);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
return ret;
|
||||
}
|
||||
cacheInfo.localStateVersion = localCacheInfo.stateVersion;
|
||||
(void)LnnSaveRemoteDeviceInfo(&cacheInfo);
|
||||
char *anonyUdid = NULL;
|
||||
Anonymize(cacheInfo.deviceInfo.deviceUdid, &anonyUdid);
|
||||
LNN_LOGI(LNN_BUILDER,
|
||||
"success. udid=%{public}s, stateVersion=%{public}d, localStateVersion=%{public}d, updateTimestamp=%{public}"
|
||||
"" PRIu64, anonyUdid, cacheInfo.stateVersion, cacheInfo.localStateVersion, cacheInfo.updateTimestamp);
|
||||
AnonymizeFree(anonyUdid);
|
||||
if (LnnUpdateDistributedNodeInfo(&cacheInfo, cacheInfo.deviceInfo.deviceUdid) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "fail:Cache info sync to Ledger fail");
|
||||
if (LnnSaveAndUpdateDistributedNode(&cacheInfo) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "save and update distribute node info fail");
|
||||
(void)memset_s(&cacheInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
#define KEY_ACCOUNT "KEY_ACCOUNT"
|
||||
|
||||
static int32_t g_tryGetDevnameNums = 0;
|
||||
static bool g_isDevnameInited = false;
|
||||
|
||||
static int32_t LnnSyncDeviceName(const char *networkId)
|
||||
{
|
||||
@ -365,12 +366,10 @@ static void UpdataLocalFromSetting(void *p)
|
||||
char unifiedName[DEVICE_NAME_BUF_LEN] = {0};
|
||||
char unifiedDefaultName[DEVICE_NAME_BUF_LEN] = {0};
|
||||
char nickName[DEVICE_NAME_BUF_LEN] = {0};
|
||||
LNN_LOGD(LNN_BUILDER, "UpdateLocalFromSetting enter");
|
||||
if (LnnGetSettingDeviceName(deviceName, DEVICE_NAME_BUF_LEN) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_BUILDER, "UpdataLocalFromSetting fail");
|
||||
g_tryGetDevnameNums++;
|
||||
LNN_LOGI(LNN_BUILDER, "g_tryGetDevnameNums=%{public}d", g_tryGetDevnameNums);
|
||||
if (g_tryGetDevnameNums < MAX_TRY) {
|
||||
LNN_LOGI(LNN_BUILDER, "g_tryGetDevnameNums=%{public}d", g_tryGetDevnameNums);
|
||||
SoftBusLooper *looper = GetLooper(LOOP_TYPE_DEFAULT);
|
||||
if (looper == NULL) {
|
||||
LNN_LOGE(LNN_BUILDER, "looper is null");
|
||||
@ -404,20 +403,25 @@ static void UpdataLocalFromSetting(void *p)
|
||||
}
|
||||
}
|
||||
RegisterNameMonitor();
|
||||
g_isDevnameInited = true;
|
||||
DiscDeviceInfoChanged(TYPE_LOCAL_DEVICE_NAME);
|
||||
LnnNotifyLocalNetworkIdChanged();
|
||||
LNN_LOGI(LNN_BUILDER, "UpdateLocalFromSetting done, deviceName=%{public}s, unifiedName=%{public}s, "
|
||||
"unifiedDefaultName=%{public}s, nickName=%{public}s", deviceName, unifiedName, unifiedDefaultName, nickName);
|
||||
}
|
||||
|
||||
static void UpdateDeviceNameFromSetting(void)
|
||||
static void RegisterDeviceNameHandle(void)
|
||||
{
|
||||
LnnInitGetDeviceName(LnnHandlerGetDeviceName);
|
||||
}
|
||||
|
||||
void UpdateDeviceName(void *p)
|
||||
{
|
||||
UpdateDeviceNameFromSetting();
|
||||
if (g_isDevnameInited) {
|
||||
LNN_LOGI(LNN_BUILDER, "device name already inited");
|
||||
return;
|
||||
}
|
||||
RegisterDeviceNameHandle();
|
||||
UpdataLocalFromSetting(p);
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,6 @@ static void RetryGetAvailableIpAddr(void *para)
|
||||
static int32_t GetAvailableIpAddr(const char *ifName, char *ip, uint32_t size)
|
||||
{
|
||||
static int32_t retryTime = GET_IP_RETRY_TIMES;
|
||||
if (!LnnIsLinkReady(ifName)) {
|
||||
LNN_LOGE(LNN_BUILDER, "link not ready. ifName=%{public}s", ifName);
|
||||
}
|
||||
if (strcmp(ifName, WLAN_IFNAME) != 0) {
|
||||
retryTime = 0;
|
||||
}
|
||||
@ -124,7 +121,7 @@ static int32_t GetAvailableIpAddr(const char *ifName, char *ip, uint32_t size)
|
||||
retryTime = GET_IP_RETRY_TIMES;
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
LNN_LOGD(LNN_BUILDER, "get ip retry time=%{public}d", retryTime);
|
||||
LNN_LOGI(LNN_BUILDER, "get ip retry time=%{public}d", retryTime);
|
||||
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");
|
||||
@ -362,11 +359,13 @@ static int32_t RequestMainPort(const char *ifName, const char *address)
|
||||
LNN_LOGE(LNN_BUILDER, "loopback ip not allowed");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
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;
|
||||
}
|
||||
LNN_LOGI(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;
|
||||
@ -466,7 +465,7 @@ static void TransactIpSubnetState(LnnPhysicalSubnet *subnet, IpSubnetManagerEven
|
||||
[IP_SUBNET_MANAGER_EVENT_IF_CHANGED] = {LNN_SUBNET_RESETTING, subnet->status}
|
||||
};
|
||||
subnet->status = transactMap[event][isAccepted ? IP_EVENT_RESULT_ACCEPTED : IP_EVENT_RESULT_REJECTED];
|
||||
LNN_LOGD(LNN_BUILDER, "subnet state change. ifName=%{public}s, protocolId=%{public}u, status=%{public}d",
|
||||
LNN_LOGI(LNN_BUILDER, "subnet state change. ifName=%{public}s, protocolId=%{public}u, status=%{public}d",
|
||||
subnet->ifName, subnet->protocol->id, subnet->status);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ extern "C" {
|
||||
|
||||
int32_t LnnInitNetLedger(void);
|
||||
int32_t LnnInitNetLedgerDelay(void);
|
||||
int32_t LnnInitEventMoniterDelay(void);
|
||||
void RestoreLocalDeviceInfo(void);
|
||||
void LnnDeinitNetLedger(void);
|
||||
|
||||
|
@ -142,8 +142,6 @@ typedef struct {
|
||||
uint32_t discoveryType;
|
||||
DeviceBasicInfo deviceInfo;
|
||||
ConnectInfo connectInfo;
|
||||
int64_t authSeqNum;
|
||||
int32_t authChannelId[CONNECTION_ADDR_MAX][AUTH_SIDE_MAX];
|
||||
BssTransInfo bssTransInfo;
|
||||
bool isBleP2p; // true: this device support connect p2p via ble connection
|
||||
P2pInfo p2pInfo;
|
||||
@ -181,8 +179,11 @@ typedef struct {
|
||||
uint8_t staticCapability[STATIC_CAP_LEN];
|
||||
int32_t staticCapLen;
|
||||
char remotePtk[PTK_DEFAULT_LEN];
|
||||
char remoteMetaPtk[PTK_DEFAULT_LEN];
|
||||
int32_t deviceSecurityLevel;
|
||||
uint8_t relation[CONNECTION_ADDR_MAX];
|
||||
int64_t authSeqNum;
|
||||
int32_t authChannelId[CONNECTION_ADDR_MAX][AUTH_SIDE_MAX];
|
||||
uint64_t heartbeatTimestamp;
|
||||
uint64_t bleDirectTimestamp;
|
||||
uint64_t onlinetTimestamp;
|
||||
@ -190,6 +191,7 @@ typedef struct {
|
||||
bool isAuthExchangeUdid;
|
||||
bool isSupportIpv6;
|
||||
uint32_t stateVersionReason;
|
||||
int64_t lastAuthSeq;
|
||||
} NodeInfo;
|
||||
|
||||
const char *LnnGetDeviceUdid(const NodeInfo *info);
|
||||
|
@ -199,6 +199,11 @@ int32_t LnnInitNetLedgerDelay(void)
|
||||
LNN_LOGE(LNN_LEDGER, "delay init decision db fail");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnInitEventMoniterDelay(void)
|
||||
{
|
||||
if (LnnInitCommonEventMonitorImpl() != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "delay init LnnInitCommonEventMonitorImpl fail");
|
||||
return SOFTBUS_ERR;
|
||||
|
@ -68,6 +68,7 @@ int32_t LnnGetDLHeartbeatTimestamp(const char *networkId, uint64_t *timestamp);
|
||||
int32_t LnnGetDLOnlineTimestamp(const char *networkId, uint64_t *timestamp);
|
||||
int32_t LnnSetDLHeartbeatTimestamp(const char *networkId, const uint64_t timestamp);
|
||||
int32_t LnnGetDLBleDirectTimestamp(const char *networkId, uint64_t *timestamp);
|
||||
int32_t LnnGetDLUpdateTimestamp(const char *udid, uint64_t *timestamp);
|
||||
int32_t LnnSetDLBleDirectTimestamp(const char *networkId, uint64_t timestamp);
|
||||
int32_t LnnGetDLAuthCapacity(const char *networkId, uint32_t *authCapacity);
|
||||
bool LnnGetOnlineStateById(const char *id, IdCategory type);
|
||||
|
@ -726,22 +726,27 @@ int32_t LnnAddMetaInfo(NodeInfo *info)
|
||||
}
|
||||
oldInfo = (NodeInfo *)LnnMapGet(&map->udidMap, udid);
|
||||
if (oldInfo != NULL && strcmp(oldInfo->networkId, info->networkId) == 0) {
|
||||
MetaInfo temp = info->metaInfo;
|
||||
LNN_LOGI(LNN_LEDGER, "old capa=%{public}u new capa=%{public}u", oldInfo->netCapacity, info->netCapacity);
|
||||
oldInfo->connectInfo.sessionPort = info->connectInfo.sessionPort;
|
||||
oldInfo->connectInfo.authPort = info->connectInfo.authPort;
|
||||
oldInfo->connectInfo.proxyPort = info->connectInfo.proxyPort;
|
||||
oldInfo->netCapacity = info->netCapacity;
|
||||
if (memcpy_s(info, sizeof(NodeInfo), oldInfo, sizeof(NodeInfo)) != EOK) {
|
||||
LNN_LOGE(LNN_LEDGER, "LnnAddMetaInfo copy fail!");
|
||||
SoftBusMutexUnlock(&g_distributedNetLedger.lock);
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
if (strcpy_s(oldInfo->connectInfo.deviceIp, IP_LEN, info->connectInfo.deviceIp) != EOK) {
|
||||
LNN_LOGE(LNN_LEDGER, "strcpy ip fail!");
|
||||
SoftBusMutexUnlock(&g_distributedNetLedger.lock);
|
||||
return SOFTBUS_STRCPY_ERR;
|
||||
}
|
||||
if (strcpy_s(oldInfo->uuid, UUID_BUF_LEN, info->uuid) != EOK) {
|
||||
LNN_LOGE(LNN_LEDGER, "strcpy uuid fail!");
|
||||
SoftBusMutexUnlock(&g_distributedNetLedger.lock);
|
||||
return SOFTBUS_STRCPY_ERR;
|
||||
}
|
||||
MetaInfo temp = info->metaInfo;
|
||||
if (memcpy_s(info, sizeof(NodeInfo), oldInfo, sizeof(NodeInfo)) != EOK) {
|
||||
LNN_LOGE(LNN_LEDGER, "LnnAddMetaInfo copy fail!");
|
||||
SoftBusMutexUnlock(&g_distributedNetLedger.lock);
|
||||
return SOFTBUS_MEM_ERR;
|
||||
}
|
||||
info->metaInfo.isMetaNode = true;
|
||||
info->metaInfo.metaDiscType = info->metaInfo.metaDiscType | temp.metaDiscType;
|
||||
}
|
||||
@ -779,6 +784,7 @@ int32_t LnnDeleteMetaInfo(const char *udid, AuthLinkType type)
|
||||
info->metaInfo.isMetaNode = false;
|
||||
}
|
||||
LnnClearAuthTypeValue(&info->AuthTypeValue, ONLINE_METANODE);
|
||||
(void)memset_s(info->remoteMetaPtk, PTK_DEFAULT_LEN, 0, PTK_DEFAULT_LEN);
|
||||
int32_t ret = LnnMapSet(&map->udidMap, udid, info, sizeof(NodeInfo));
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "lnn map set failed, ret=%{public}d", ret);
|
||||
@ -1076,6 +1082,32 @@ static void TryUpdateDeviceSecurityLevel(NodeInfo *info)
|
||||
}
|
||||
}
|
||||
|
||||
static void ReversionLastAuthSeq(NodeInfo *info)
|
||||
{
|
||||
NodeInfo deviceInfo;
|
||||
(void)memset_s(&deviceInfo, sizeof(NodeInfo), 0, sizeof(NodeInfo));
|
||||
uint8_t udidHash[SHA_256_HASH_LEN] = {0};
|
||||
char hashStr[SHORT_UDID_HASH_HEX_LEN + 1] = {0};
|
||||
if (SoftBusGenerateStrHash((const unsigned char *)info->deviceInfo.deviceUdid,
|
||||
strlen(info->deviceInfo.deviceUdid), udidHash) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "generate udidhash fail");
|
||||
return;
|
||||
}
|
||||
if (ConvertBytesToHexString(hashStr, SHORT_UDID_HASH_HEX_LEN + 1, udidHash,
|
||||
SHORT_UDID_HASH_HEX_LEN / HEXIFY_UNIT_LEN) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "convert udidhash to hexstr fail");
|
||||
return;
|
||||
}
|
||||
if (LnnRetrieveDeviceInfo(hashStr, &deviceInfo) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "get deviceInfo by udidhash fail");
|
||||
return;
|
||||
}
|
||||
if (info->lastAuthSeq == 0 && deviceInfo.lastAuthSeq != 0) {
|
||||
info->lastAuthSeq = deviceInfo.lastAuthSeq;
|
||||
LNN_LOGI(LNN_LEDGER, "reversion lastAuthSeq:0->%{public}" PRId64, info->lastAuthSeq);
|
||||
}
|
||||
}
|
||||
|
||||
ReportCategory LnnAddOnlineNode(NodeInfo *info)
|
||||
{
|
||||
if (info == NULL) {
|
||||
@ -1083,7 +1115,6 @@ ReportCategory LnnAddOnlineNode(NodeInfo *info)
|
||||
}
|
||||
// judge map
|
||||
info->onlinetTimestamp = (uint64_t)LnnUpTimeMs();
|
||||
|
||||
if (LnnHasDiscoveryType(info, DISCOVERY_TYPE_BR)) {
|
||||
LNN_LOGI(LNN_LEDGER, "DiscoveryType = BR.");
|
||||
AddCnnCode(&g_distributedNetLedger.cnnCode.connectionCode, info->uuid, DISCOVERY_TYPE_BR, info->authSeqNum);
|
||||
@ -1102,6 +1133,7 @@ ReportCategory LnnAddOnlineNode(NodeInfo *info)
|
||||
LnnSetAuthTypeValue(&info->AuthTypeValue, ONLINE_HICHAIN);
|
||||
UpdateNewNodeAccountHash(info);
|
||||
TryUpdateDeviceSecurityLevel(info);
|
||||
ReversionLastAuthSeq(info);
|
||||
int32_t ret = LnnMapSet(&map->udidMap, udid, info, sizeof(NodeInfo));
|
||||
if (ret != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_LEDGER, "lnn map set failed, ret=%{public}d", ret);
|
||||
|
@ -1513,6 +1513,27 @@ int32_t LnnGetDLBleDirectTimestamp(const char *networkId, uint64_t *timestamp)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnGetDLUpdateTimestamp(const char *udid, uint64_t *timestamp)
|
||||
{
|
||||
if (udid == NULL || timestamp == NULL) {
|
||||
LNN_LOGE(LNN_LEDGER, "invalid param");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (SoftBusMutexLock(&(LnnGetDistributedNetLedger()->lock)) != 0) {
|
||||
LNN_LOGE(LNN_LEDGER, "lock mutex fail");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
NodeInfo *nodeInfo = LnnGetNodeInfoById(udid, CATEGORY_UDID);
|
||||
if (nodeInfo == NULL) {
|
||||
LNN_LOGE(LNN_LEDGER, "get info fail");
|
||||
(void)SoftBusMutexUnlock(&(LnnGetDistributedNetLedger()->lock));
|
||||
return SOFTBUS_NOT_FIND;
|
||||
}
|
||||
*timestamp = nodeInfo->updateTimestamp;
|
||||
(void)SoftBusMutexUnlock(&(LnnGetDistributedNetLedger()->lock));
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnGetDLAuthCapacity(const char *networkId, uint32_t *authCapacity)
|
||||
{
|
||||
if (SoftBusMutexLock(&(LnnGetDistributedNetLedger()->lock)) != 0) {
|
||||
|
@ -249,6 +249,7 @@ void LnnNotifyLeaveResult(const char *networkId, int32_t retCode);
|
||||
void LnnNotifyOnlineState(bool isOnline, NodeBasicInfo *info);
|
||||
void LnnNotifyBasicInfoChanged(NodeBasicInfo *info, NodeBasicInfoType type);
|
||||
void LnnNotifyLocalNetworkIdChanged(void);
|
||||
void LnnNotifyDeviceNotTrusted(const char *msg);
|
||||
void LnnNotifyMigrate(bool isOnline, NodeBasicInfo *info);
|
||||
|
||||
void LnnNotifyWlanStateChangeEvent(void *state);
|
||||
|
@ -380,6 +380,15 @@ void LnnNotifyLocalNetworkIdChanged(void)
|
||||
(void)PostNotifyMessageDelay(NOTIFY_LOCAL_NETWORKID_UPDATE, 0);
|
||||
}
|
||||
|
||||
void LnnNotifyDeviceNotTrusted(const char *msg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
LNN_LOGE(LNN_EVENT, "msg is null");
|
||||
return;
|
||||
}
|
||||
(void)LnnIpcNotifyDeviceNotTrusted(msg);
|
||||
}
|
||||
|
||||
void LnnNotifyJoinResult(ConnectionAddr *addr, const char *networkId, int32_t retCode)
|
||||
{
|
||||
if (addr == NULL) {
|
||||
|
@ -60,6 +60,7 @@ typedef int32_t (*LnnInitDelayImpl)(void);
|
||||
|
||||
typedef enum {
|
||||
INIT_LOCAL_LEDGER_DELAY_TYPE = 0,
|
||||
INIT_EVENT_MONITER_DELAY_TYPE,
|
||||
INIT_NETWORK_MANAGER_DELAY_TYPE,
|
||||
INIT_NETBUILDER_DELAY_TYPE,
|
||||
INIT_LANEHUB_DELAY_TYPE,
|
||||
@ -91,6 +92,10 @@ static LnnLocalConfigInit g_lnnLocalConfigInit = {
|
||||
.implInit = LnnInitNetLedgerDelay,
|
||||
.isInit = false,
|
||||
},
|
||||
[INIT_EVENT_MONITER_DELAY_TYPE] = {
|
||||
.implInit = LnnInitEventMoniterDelay,
|
||||
.isInit = false,
|
||||
},
|
||||
[INIT_NETWORK_MANAGER_DELAY_TYPE] = {
|
||||
.implInit = LnnInitNetworkManagerDelay,
|
||||
.isInit = false,
|
||||
|
@ -103,6 +103,7 @@ enum SoftBusFuncId {
|
||||
CLIENT_ON_JOIN_METANODE_RESULT,
|
||||
CLIENT_ON_LEAVE_RESULT,
|
||||
CLIENT_ON_LEAVE_METANODE_RESULT,
|
||||
CLIENT_ON_NODE_DEVICE_NOT_TRUST,
|
||||
CLIENT_ON_NODE_ONLINE_STATE_CHANGED,
|
||||
CLIENT_ON_NODE_BASIC_INFO_CHANGED,
|
||||
CLIENT_ON_LOCAL_NETWORK_ID_CHANGED,
|
||||
|
@ -31,6 +31,7 @@ extern "C" {
|
||||
#define DEC_MAX_NUM 10
|
||||
#define HEX_MAX_BIT_NUM 4
|
||||
#define MAX_QUERY_LEN 64
|
||||
#define INT64_TO_STR_MAX_LEN 21
|
||||
|
||||
#define TIMER_TIMEOUT 1000 // 1s
|
||||
#define BT_MAC_NO_COLON_LEN 13
|
||||
@ -90,6 +91,7 @@ int32_t ConvertBtMacToU64(const char *strMac, uint32_t strMacLen, uint64_t *u64M
|
||||
|
||||
int32_t ConvertU64MacToStr(uint64_t u64Mac, char *strMac, uint32_t strMacLen);
|
||||
|
||||
bool Int64ToString(int64_t src, char *buf, uint32_t bufLen);
|
||||
int32_t StrCmpIgnoreCase(const char *str1, const char *str2);
|
||||
|
||||
int32_t StringToUpperCase(const char *str, char *buf, int32_t size);
|
||||
|
@ -449,6 +449,18 @@ int32_t StringToLowerCase(const char *str, char *buf, int32_t size)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
bool Int64ToString(int64_t src, char *buf, uint32_t bufLen)
|
||||
{
|
||||
if (buf == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (sprintf_s(buf, bufLen, "%" PRId64"", src) < 0) {
|
||||
COMM_LOGE(COMM_UTILS, "convert int64 to str fail");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t StrCmpIgnoreCase(const char *str1, const char *str2)
|
||||
{
|
||||
if (str1 == NULL || str2 == NULL) {
|
||||
|
@ -268,7 +268,7 @@ static void FreeSendNode(SendQueueNode *node)
|
||||
|
||||
static int32_t ConnGattTransSend(ConnBleConnection *connection, const uint8_t *data, uint32_t dataLen, int32_t module)
|
||||
{
|
||||
#define BLE_SEND_PACKET_DELAY_MILLIS 10
|
||||
#define BLE_SEND_PACKET_DELAY_MILLIS 20
|
||||
const uint8_t *waitSendData = data;
|
||||
uint32_t waitSendLen = dataLen;
|
||||
uint32_t offset = 0;
|
||||
@ -306,10 +306,8 @@ static int32_t ConnGattTransSend(ConnBleConnection *connection, const uint8_t *d
|
||||
waitSendData += amount;
|
||||
waitSendLen -= amount;
|
||||
offset += amount;
|
||||
if (waitSendLen > 0) {
|
||||
// Temporarily add delay to avoid packet loss
|
||||
SoftBusSleepMs(BLE_SEND_PACKET_DELAY_MILLIS);
|
||||
}
|
||||
// Temporarily add delay to avoid packet loss
|
||||
SoftBusSleepMs(BLE_SEND_PACKET_DELAY_MILLIS);
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -569,7 +567,6 @@ uint8_t *ConnCocTransRecv(uint32_t connectionId, LimitedBuffer *buffer, int32_t
|
||||
|
||||
static int32_t ConnCocTransSend(ConnBleConnection *connection, const uint8_t *data, uint32_t dataLen, int32_t module)
|
||||
{
|
||||
#define BLE_SEND_PACKET_DELAY_MILLIS 10
|
||||
uint32_t sentLen = 0;
|
||||
while (dataLen > sentLen) {
|
||||
uint32_t amount = (uint32_t)g_flowController->apply(g_flowController, (int32_t)dataLen);
|
||||
|
@ -195,7 +195,6 @@ int32_t P2pAdapter::GetStationFrequencyWithFilter()
|
||||
{
|
||||
int32_t frequency = P2pAdapter::GetStationFrequency();
|
||||
CONN_CHECK_AND_RETURN_RET_LOGW(frequency > 0, FREQUENCY_INVALID, CONN_WIFI_DIRECT, "invalid frequency");
|
||||
|
||||
if (WifiDirectUtils::Is5GBand(frequency)) {
|
||||
std::vector<int> channelArray;
|
||||
auto ret = P2pAdapter::GetChannel5GListIntArray(channelArray);
|
||||
@ -359,10 +358,6 @@ int32_t P2pAdapter::GetGroupConfig(std::string &groupConfigString)
|
||||
int32_t P2pAdapter::GetIpAddress(std::string &ipString)
|
||||
{
|
||||
auto groupInfo = std::make_shared<WifiP2pGroupInfo>();
|
||||
if (groupInfo == nullptr) {
|
||||
CONN_LOGE(CONN_WIFI_DIRECT, "alloc failed");
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
int32_t ret = GetCurrentGroup(groupInfo.get());
|
||||
if (ret != WIFI_SUCCESS) {
|
||||
CONN_LOGE(CONN_WIFI_DIRECT, "get current group failed, error=%{public}d", ToSoftBusErrorCode(ret));
|
||||
|
@ -22,6 +22,11 @@
|
||||
#include "conn_event.h"
|
||||
|
||||
namespace OHOS::SoftBus {
|
||||
enum class ConnectCommandRetryReason {
|
||||
RETRY_FOR_NOTHING = 0,
|
||||
RETRY_FOR_PASSIVE_SWITCH_CHANNEL,
|
||||
};
|
||||
|
||||
struct ConnectInfo {
|
||||
WifiDirectConnectInfo info_;
|
||||
std::shared_ptr<NegotiateChannel> channel_;
|
||||
@ -44,7 +49,8 @@ public:
|
||||
virtual void PreferNegotiateChannel();
|
||||
void SetRetried(bool retried) { hasRetried_ = retried; }
|
||||
bool HasRetried() const { return hasRetried_; }
|
||||
|
||||
void SetRetryReason(ConnectCommandRetryReason reason) { retryReason_ = reason; }
|
||||
ConnectCommandRetryReason GetReTryReason() const { return retryReason_; }
|
||||
void OnSuccess(const WifiDirectLink &link) const;
|
||||
void OnFailure(int reason) const;
|
||||
bool IsSameCommand(const WifiDirectConnectInfo &info) const;
|
||||
@ -55,7 +61,7 @@ protected:
|
||||
WifiDirectConnectCallback callback_;
|
||||
mutable std::string remoteDeviceId_;
|
||||
bool hasRetried_ = false;
|
||||
|
||||
ConnectCommandRetryReason retryReason_ = ConnectCommandRetryReason::RETRY_FOR_NOTHING;
|
||||
private:
|
||||
static constexpr uint64_t ABANDON_CONNECT_COMMAND_PERIOD = 500;
|
||||
};
|
||||
|
@ -115,7 +115,8 @@ bool P2pV1Processor::CanAcceptNegotiateDataAtState(WifiDirectCommand &command)
|
||||
if (nc == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return nc->GetNegotiateMessage().GetLegacyP2pCommandType() != LegacyCommandType::CMD_INVALID;
|
||||
return nc->GetNegotiateMessage().GetLegacyP2pCommandType() != LegacyCommandType::CMD_INVALID &&
|
||||
nc->GetNegotiateMessage().GetLegacyP2pCommandType() != LegacyCommandType::CMD_DISCONNECT_V1_REQ;
|
||||
}
|
||||
|
||||
void P2pV1Processor::HandleCommandAfterTerminate(WifiDirectCommand &command)
|
||||
@ -1437,10 +1438,9 @@ int P2pV1Processor::ProcessConnectResponseAtWaitAuthHandShake(std::shared_ptr<Ne
|
||||
if (connectCommand_ != nullptr) {
|
||||
auto requestId = connectCommand_->GetConnectInfo().info_.requestId;
|
||||
auto pid = connectCommand_->GetConnectInfo().info_.pid;
|
||||
bool alreadyAuthHandShake = false;
|
||||
WifiDirectLink dlink {};
|
||||
auto success = LinkManager::GetInstance().ProcessIfPresent(
|
||||
remoteMac, [msg, requestId, pid, &dlink, &alreadyAuthHandShake](InnerLink &link) {
|
||||
remoteMac, [msg, requestId, pid, &dlink](InnerLink &link) {
|
||||
link.SetState(InnerLink::LinkState::CONNECTED);
|
||||
link.GenerateLink(requestId, pid, dlink, true);
|
||||
dlink.channelId = WifiDirectUtils::FrequencyToChannel(link.GetFrequency());
|
||||
|
@ -452,6 +452,19 @@ static void RegisterEnhanceManager(WifiDirectEnhanceManager *manager)
|
||||
g_enhanceManager = *manager;
|
||||
}
|
||||
|
||||
static bool IsHmlConnected()
|
||||
{
|
||||
bool ret = false;
|
||||
OHOS::SoftBus::LinkManager::GetInstance().ForEach([&] (const OHOS::SoftBus::InnerLink &innerLink) {
|
||||
if (innerLink.GetLinkType() == OHOS::SoftBus::InnerLink::LinkType::HML) {
|
||||
ret = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void NotifyPtkSyncResult(const char *remoteDeviceId, int result)
|
||||
{
|
||||
if (g_syncPtkListener == nullptr) {
|
||||
@ -493,6 +506,7 @@ static struct WifiDirectManager g_manager = {
|
||||
|
||||
.isWifiP2pEnabled = IsWifiP2pEnabled,
|
||||
.getStationFrequency = GetStationFrequency,
|
||||
.isHmlConnected = IsHmlConnected,
|
||||
|
||||
.init = Init,
|
||||
.notifyOnline = NotifyOnline,
|
||||
|
@ -63,6 +63,7 @@ struct WifiDirectManager {
|
||||
|
||||
bool (*isWifiP2pEnabled)(void);
|
||||
int (*getStationFrequency)(void);
|
||||
bool (*isHmlConnected)(void);
|
||||
|
||||
int32_t (*init)(void);
|
||||
|
||||
|
@ -155,6 +155,11 @@ static int GetStationFrequency(void)
|
||||
return SOFTBUS_NOT_IMPLEMENT;
|
||||
}
|
||||
|
||||
static bool IsHmlConnected()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static void RegisterEnhanceManager(struct WifiDirectEnhanceManager *manager)
|
||||
{
|
||||
(void)manager;
|
||||
@ -194,6 +199,7 @@ static struct WifiDirectManager g_manager = {
|
||||
|
||||
.isWifiP2pEnabled = IsWifiP2pEnabled,
|
||||
.getStationFrequency = GetStationFrequency,
|
||||
.isHmlConnected = IsHmlConnected,
|
||||
|
||||
.init = Init,
|
||||
.notifyOnline = NotifyOnline,
|
||||
|
@ -151,6 +151,13 @@ public:
|
||||
|
||||
virtual bool ProcessNextCommand(WifiDirectExecutor *executor, std::shared_ptr<WifiDirectProcessor> &processor);
|
||||
|
||||
bool CheckExecutorRunning(const std::string &remoteDeviceId)
|
||||
{
|
||||
std::lock_guard executorLock(executorLock_);
|
||||
auto iterator = executors_.find(remoteDeviceId);
|
||||
return iterator != executors_.end();
|
||||
}
|
||||
|
||||
protected:
|
||||
int ScheduleActiveCommand(const std::shared_ptr<WifiDirectCommand> &command,
|
||||
std::shared_ptr<WifiDirectExecutor> &executor);
|
||||
|
@ -28,8 +28,8 @@ ble_discovery_inc = [
|
||||
"$dsoftbus_root_path/core/discovery/ble/dispatcher/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/approach_ble/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/share_ble/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/touch_ble/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/softbus_ble/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/touch_ble/include",
|
||||
"$dsoftbus_root_path/core/discovery/ble/virtual_link_ble/include",
|
||||
"$dsoftbus_root_path/core/common/include",
|
||||
"$dsoftbus_root_path/core/common/dfx/hisysevent_adapter/include",
|
||||
@ -58,6 +58,8 @@ if (dsoftbus_feature_disc_ble && disc_enhanced) {
|
||||
ble_discovery_src += vlink_sources
|
||||
ble_discovery_inc += vlink_include_dirs
|
||||
ble_discovery_deps += vlink_deps
|
||||
} else {
|
||||
ble_discovery_src += [ "$dsoftbus_root_path/core/discovery/ble/virtual_link_ble/src/disc_virtual_link_ble_virtual.c" ]
|
||||
}
|
||||
|
||||
if (disc_enhanced) {
|
||||
@ -68,14 +70,14 @@ if (disc_enhanced) {
|
||||
import(
|
||||
"$dsoftbus_root_path/dsoftbus_enhance/core/discovery/ble/touch_ble/touch_ble.gni")
|
||||
|
||||
ble_discovery_src += share_sources + approach_sources + vlink_sources + touch_sources
|
||||
ble_discovery_inc += share_include_dirs + approach_include_dirs + vlink_include_dirs + touch_include_dirs
|
||||
ble_discovery_deps += share_deps + approach_deps + vlink_deps + touch_deps
|
||||
ble_discovery_src += share_sources + approach_sources + touch_sources
|
||||
ble_discovery_inc +=
|
||||
share_include_dirs + approach_include_dirs + touch_include_dirs
|
||||
ble_discovery_deps += share_deps + approach_deps + touch_deps
|
||||
} else {
|
||||
ble_discovery_src += [
|
||||
"$dsoftbus_root_path/core/discovery/ble/share_ble/src/disc_share_ble_virtual.c",
|
||||
"$dsoftbus_root_path/core/discovery/ble/approach_ble/src/disc_approach_ble_virtual.c",
|
||||
"$dsoftbus_root_path/core/discovery/ble/touch_ble/src/touch_ble_virtual.c",
|
||||
"$dsoftbus_root_path/core/discovery/ble/virtual_link_ble/src/disc_virtual_link_ble_virtual.c",
|
||||
"$dsoftbus_root_path/core/discovery/ble/touch_ble/src/disc_touch_ble_virtual.c",
|
||||
]
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "disc_virtual_link_ble.h"
|
||||
#include "softbus_errcode.h"
|
||||
|
||||
#define DISPATCHER_SIZE 4
|
||||
#define DISPATCHER_SIZE 5
|
||||
|
||||
static DiscoveryBleDispatcherInterface *g_dispatchers[DISPATCHER_SIZE];
|
||||
static uint32_t g_dispatcherSize = 0;
|
||||
@ -45,7 +45,7 @@ static DiscoveryFuncInterface *FindDiscoveryFuncInterface(uint32_t capability)
|
||||
static int32_t BleDispatchPublishOption(const PublishOption *option, DiscoverMode mode,
|
||||
InterfaceFuncType type)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(option != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "option is null");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(option != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "option is null");
|
||||
DiscoveryFuncInterface *interface = FindDiscoveryFuncInterface(option->capabilityBitmap[0]);
|
||||
if (interface == NULL) {
|
||||
DISC_LOGE(DISC_BLE,
|
||||
@ -68,7 +68,7 @@ static int32_t BleDispatchPublishOption(const PublishOption *option, DiscoverMod
|
||||
case UNPUBLISH_FUNC:
|
||||
return mode == DISCOVER_MODE_ACTIVE ? interface->Unpublish(option) : interface->StopScan(option);
|
||||
default:
|
||||
DISC_LOGW(DISC_BLE,
|
||||
DISC_LOGE(DISC_BLE,
|
||||
"dispatch publish action failed: unsupport type. type=%{public}d, capability=%{public}u",
|
||||
type, option->capabilityBitmap[0]);
|
||||
return SOFTBUS_DISCOVER_BLE_DISPATCHER_FAIL;
|
||||
@ -78,7 +78,7 @@ static int32_t BleDispatchPublishOption(const PublishOption *option, DiscoverMod
|
||||
static int32_t BleDispatchSubscribeOption(const SubscribeOption *option, DiscoverMode mode,
|
||||
InterfaceFuncType type)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(option != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "option is null");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(option != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "option is null");
|
||||
DiscoveryFuncInterface *interface = FindDiscoveryFuncInterface(option->capabilityBitmap[0]);
|
||||
if (interface == NULL) {
|
||||
DISC_LOGE(DISC_BLE, "dispatch subcribe action failed: no implement support capability. capability=%{public}u",
|
||||
@ -100,7 +100,7 @@ static int32_t BleDispatchSubscribeOption(const SubscribeOption *option, Discove
|
||||
case STOPDISCOVERY_FUNC:
|
||||
return mode == DISCOVER_MODE_ACTIVE ? interface->StopAdvertise(option) : interface->Unsubscribe(option);
|
||||
default:
|
||||
DISC_LOGW(DISC_BLE, "dispatch subcribe action failed: unsupport. type=%{public}d, capability=%{public}u",
|
||||
DISC_LOGE(DISC_BLE, "dispatch subcribe action failed: unsupport. type=%{public}d, capability=%{public}u",
|
||||
type, option->capabilityBitmap[0]);
|
||||
return SOFTBUS_DISCOVER_BLE_DISPATCHER_FAIL;
|
||||
}
|
||||
@ -193,11 +193,24 @@ static void DfxRecordBleInitEnd(int32_t stage, int32_t reason)
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t DiscBleInitExt(DiscInnerCallback *discInnerCb)
|
||||
{
|
||||
DiscoveryBleDispatcherInterface *touchInterface = DiscTouchBleInit(discInnerCb);
|
||||
if (touchInterface == NULL) {
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_TOUCH_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
|
||||
DISC_LOGE(DISC_INIT, "DiscTouchBleInit err");
|
||||
return SOFTBUS_DISCOVER_MANAGER_INIT_FAIL;
|
||||
}
|
||||
g_dispatchers[g_dispatcherSize++] = touchInterface;
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_TOUCH_BLE_INIT, SOFTBUS_OK);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
DiscoveryFuncInterface *DiscBleInit(DiscInnerCallback *discInnerCb)
|
||||
{
|
||||
if (discInnerCb == NULL) {
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_INIT, SOFTBUS_INVALID_PARAM);
|
||||
DISC_LOGW(DISC_INIT, "discInnerCb err");
|
||||
DISC_LOGE(DISC_INIT, "discInnerCb err");
|
||||
return NULL;
|
||||
}
|
||||
DISC_LOGI(DISC_INIT, "DiscBleFrameInit");
|
||||
@ -238,14 +251,8 @@ DiscoveryFuncInterface *DiscBleInit(DiscInnerCallback *discInnerCb)
|
||||
g_dispatchers[g_dispatcherSize++] = vlinkInterface;
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_VLINK_BLE_INIT, SOFTBUS_OK);
|
||||
|
||||
DiscoveryBleDispatcherInterface *touchInterface = DiscTouchBleInit(discInnerCb);
|
||||
if (vlinkInterface == NULL) {
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_TOUCH_BLE_INIT, SOFTBUS_DISCOVER_MANAGER_INIT_FAIL);
|
||||
DISC_LOGE(DISC_INIT, "DiscTouchBleInit err");
|
||||
return NULL;
|
||||
}
|
||||
g_dispatchers[g_dispatcherSize++] = touchInterface;
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_TOUCH_BLE_INIT, SOFTBUS_OK);
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(DiscBleInitExt(discInnerCb) == SOFTBUS_OK,
|
||||
NULL, DISC_INIT, "disc ble init ext failed");
|
||||
|
||||
DfxRecordBleInitEnd(EVENT_STAGE_INIT, SOFTBUS_OK);
|
||||
return &g_discBleFrameFuncInterface;
|
||||
|
@ -1816,8 +1816,10 @@ static void RemoveRecvMessage(uint64_t key)
|
||||
return;
|
||||
}
|
||||
|
||||
g_discBleHandler.looper->RemoveMessageCustom(g_discBleHandler.looper, &g_discBleHandler, MessageRemovePredicate,
|
||||
(void *)key);
|
||||
if (g_discBleHandler.looper && g_discBleHandler.looper->RemoveMessageCustom) {
|
||||
g_discBleHandler.looper->RemoveMessageCustom(g_discBleHandler.looper, &g_discBleHandler,
|
||||
MessageRemovePredicate, (void *)key);
|
||||
}
|
||||
if (msg->needBrMac) {
|
||||
g_recvMessageInfo.numNeedBrMac--;
|
||||
}
|
||||
@ -1833,6 +1835,10 @@ static void ClearRecvMessage(void)
|
||||
while (!IsListEmpty(head)) {
|
||||
RecvMessage *msg = LIST_ENTRY(head->next, RecvMessage, node);
|
||||
ListDelete(&msg->node);
|
||||
if (g_discBleHandler.looper && g_discBleHandler.looper->RemoveMessageCustom) {
|
||||
g_discBleHandler.looper->RemoveMessageCustom(g_discBleHandler.looper, &g_discBleHandler,
|
||||
MessageRemovePredicate, (void *)msg->key);
|
||||
}
|
||||
SoftBusFree(msg);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ static int32_t CalculateMbsTruncateSize(const char *multiByteStr, uint32_t capac
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(multiByteStrLen <= WIDE_STR_MAX_LEN, SOFTBUS_INVALID_PARAM, DISC_BLE,
|
||||
"multi byte str too long: %zu", multiByteStrLen);
|
||||
"multi byte str too long: %{public}zu", multiByteStrLen);
|
||||
|
||||
char *localeBefore = NULL;
|
||||
int32_t ret = SetLocale(&localeBefore);
|
||||
@ -420,13 +420,13 @@ static int32_t ParseRecvTlvs(DeviceWrapper *device, const uint8_t *data, uint32_
|
||||
|
||||
int32_t GetDeviceInfoFromDisAdvData(DeviceWrapper *device, const uint8_t *data, uint32_t dataLen)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(device != NULL && device->info != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(device != NULL && device->info != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE,
|
||||
"device is null");
|
||||
BroadcastReportInfo *reportInfo = (BroadcastReportInfo *)data;
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(reportInfo != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "reportInfo=NULL is invalid");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(dataLen == sizeof(BroadcastReportInfo), SOFTBUS_INVALID_PARAM, DISC_BLE,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(reportInfo != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "reportInfo=NULL is invalid");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(dataLen == sizeof(BroadcastReportInfo), SOFTBUS_INVALID_PARAM, DISC_BLE,
|
||||
"bcData.payload=NULL is invalid");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(
|
||||
reportInfo->packet.bcData.payload != NULL, SOFTBUS_INVALID_PARAM, DISC_BLE, "payload=NULL is invalid");
|
||||
uint16_t bcLen = reportInfo->packet.bcData.payloadLen;
|
||||
uint16_t rspLen = reportInfo->packet.rspData.payloadLen;
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "disc_approach_ble.h"
|
||||
#include "disc_event_manager.h"
|
||||
#include "disc_log.h"
|
||||
#include "disc_touch_ble.h"
|
||||
#include "disc_virtual_link_ble.h"
|
||||
#include "softbus_error_code.h"
|
||||
|
||||
@ -27,6 +28,9 @@ int32_t DiscEventManagerInit(void)
|
||||
ret = DiscVLinkBleEventInit();
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, DISC_INIT, "init vlink ble event failed");
|
||||
|
||||
ret = DiscTouchBleEventInit();
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, DISC_INIT, "init touch ble event failed");
|
||||
|
||||
DISC_LOGI(DISC_INIT, "disc event manager init succ");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -35,5 +39,6 @@ void DiscEventManagerDeinit(void)
|
||||
{
|
||||
DiscApproachBleEventDeinit();
|
||||
DiscVLinkBleEventDeinit();
|
||||
DiscTouchBleEventDeinit();
|
||||
}
|
||||
|
||||
|
@ -368,8 +368,8 @@ static void InnerDeviceFound(DiscInfo *infoNode, const DeviceInfo *device,
|
||||
|
||||
static void DiscOnDeviceFound(const DeviceInfo *device, const InnerDeviceInfoAddtions *additions)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_LOGW(device != NULL, DISC_CONTROL, "device is null");
|
||||
DISC_CHECK_AND_RETURN_LOGW(additions != NULL, DISC_CONTROL, "additions is null");
|
||||
DISC_CHECK_AND_RETURN_LOGE(device != NULL, DISC_CONTROL, "device is null");
|
||||
DISC_CHECK_AND_RETURN_LOGE(additions != NULL, DISC_CONTROL, "additions is null");
|
||||
|
||||
DISC_LOGD(DISC_CONTROL,
|
||||
"capabilityBitmap=%{public}d, medium=%{public}d", device->capabilityBitmap[0], additions->medium);
|
||||
@ -910,9 +910,9 @@ int32_t DiscPublish(DiscModule moduleId, const PublishInfo *info)
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(info->mode == DISCOVER_MODE_ACTIVE, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"mode is not active");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckPublishInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(CheckPublishInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForPublish(info);
|
||||
@ -932,9 +932,9 @@ int32_t DiscStartScan(DiscModule moduleId, const PublishInfo *info)
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(info->mode == DISCOVER_MODE_PASSIVE, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"mode is not passive");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckPublishInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(CheckPublishInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForPublish(info);
|
||||
@ -964,9 +964,9 @@ int32_t DiscStartAdvertise(DiscModule moduleId, const SubscribeInfo *info)
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(info->mode == DISCOVER_MODE_ACTIVE, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"mode is not active");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForSubscribe(info);
|
||||
@ -986,9 +986,9 @@ int32_t DiscSubscribe(DiscModule moduleId, const SubscribeInfo *info)
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(info->mode == DISCOVER_MODE_PASSIVE, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"mode is not passive");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForSubscribe(info);
|
||||
@ -1014,13 +1014,13 @@ int32_t DiscStopAdvertise(DiscModule moduleId, int32_t subscribeId)
|
||||
|
||||
int32_t DiscPublishService(const char *packageName, const PublishInfo *info)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(packageName != NULL && info != NULL, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(packageName != NULL && info != NULL, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(strlen(packageName) < PKG_NAME_SIZE_MAX,
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "package name too long");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckPublishInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForPublish(info);
|
||||
@ -1051,9 +1051,9 @@ int32_t DiscStartDiscovery(const char *packageName, const SubscribeInfo *info,
|
||||
SOFTBUS_INVALID_PARAM, DISC_CONTROL, "invalid package name");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(info != NULL && cb != NULL, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid parameters");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == true, SOFTBUS_DISCOVER_MANAGER_NOT_INIT, DISC_CONTROL,
|
||||
"manager is not inited");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(CheckSubscribeInfo(info) == SOFTBUS_OK, SOFTBUS_INVALID_PARAM, DISC_CONTROL,
|
||||
"invalid info");
|
||||
|
||||
DiscInfo *infoNode = CreateDiscInfoForSubscribe(info);
|
||||
@ -1221,8 +1221,8 @@ static void RemoveDiscInfoForDiscovery(const char *pkgName)
|
||||
|
||||
void DiscMgrDeathCallback(const char *pkgName)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_LOGW(pkgName != NULL, DISC_CONTROL, "pkgName is null");
|
||||
DISC_CHECK_AND_RETURN_LOGW(g_isInited == true, DISC_CONTROL, "disc manager is not inited");
|
||||
DISC_CHECK_AND_RETURN_LOGE(pkgName != NULL, DISC_CONTROL, "pkgName is null");
|
||||
DISC_CHECK_AND_RETURN_LOGE(g_isInited == true, DISC_CONTROL, "disc manager is not inited");
|
||||
|
||||
DISC_LOGD(DISC_CONTROL, "pkg is dead. pkgName=%{public}s", pkgName);
|
||||
RemoveDiscInfoForPublish(pkgName);
|
||||
@ -1231,7 +1231,7 @@ void DiscMgrDeathCallback(const char *pkgName)
|
||||
|
||||
int32_t DiscMgrInit(void)
|
||||
{
|
||||
DISC_CHECK_AND_RETURN_RET_LOGW(g_isInited == false, SOFTBUS_OK, DISC_INIT, "already inited");
|
||||
DISC_CHECK_AND_RETURN_RET_LOGE(g_isInited == false, SOFTBUS_OK, DISC_INIT, "already inited");
|
||||
|
||||
g_discMgrMediumCb.OnDeviceFound = DiscOnDeviceFound;
|
||||
|
||||
|
@ -387,9 +387,6 @@ static int32_t CancelWaitLaneState(const char *sessionName, int32_t sessionId)
|
||||
TransFreeLane(laneHandle, isQosLane, isAsync);
|
||||
}
|
||||
}
|
||||
if (!isAsync && laneHandle != INVALID_LANE_REQ_ID) {
|
||||
TransCancelLaneItemCondByLaneHandle(laneHandle, false, false, SOFTBUS_TRANS_REQUEST_LANE_TIMEOUT);
|
||||
}
|
||||
if (isAsync && laneHandle != INVALID_LANE_REQ_ID) {
|
||||
(void)TransDeleteLaneReqItemByLaneHandle(laneHandle, isAsync);
|
||||
}
|
||||
|
@ -355,15 +355,13 @@ static void BuildTransEventExtra(
|
||||
|
||||
static void CallbackOpenChannelFailed(const SessionParam *param, const AppInfo *appInfo, int32_t errCode)
|
||||
{
|
||||
if (param->isAsync) {
|
||||
ChannelMsg data = {
|
||||
.msgChannelId = param->sessionId,
|
||||
.msgChannelType = CHANNEL_TYPE_UNDEFINED,
|
||||
.msgPkgName = appInfo->myData.pkgName,
|
||||
.msgPid = appInfo->myData.pid,
|
||||
};
|
||||
(void)ClientIpcOnChannelOpenFailed(&data, errCode);
|
||||
}
|
||||
ChannelMsg data = {
|
||||
.msgChannelId = param->sessionId,
|
||||
.msgChannelType = CHANNEL_TYPE_UNDEFINED,
|
||||
.msgPkgName = appInfo->myData.pkgName,
|
||||
.msgPid = appInfo->myData.pid,
|
||||
};
|
||||
(void)ClientIpcOnChannelOpenFailed(&data, errCode);
|
||||
}
|
||||
|
||||
static int32_t CopyAsyncReqItemSessionParamIds(const SessionParam *source, SessionParam *target)
|
||||
|
@ -244,7 +244,7 @@ int32_t TransOpenChannel(const SessionParam *param, TransInfo *transInfo)
|
||||
TransBuildTransOpenChannelStartEvent(&extra, appInfo, &nodeInfo, peerRet);
|
||||
TransSetFirstTokenInfo(appInfo, &extra);
|
||||
TRANS_EVENT(EVENT_SCENE_OPEN_CHANNEL, EVENT_STAGE_OPEN_CHANNEL_START, extra);
|
||||
if (param->isAsync) {
|
||||
if (param->isQosLane) {
|
||||
uint32_t callingTokenId = TransACLGetCallingTokenID();
|
||||
ret = TransAsyncGetLaneInfo(param, &laneHandle, callingTokenId, appInfo->timeStart);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
|
@ -119,11 +119,8 @@ static bool ResetChanIsEqual(int8_t status, ProxyChannelInfo *a, ProxyChannelInf
|
||||
|
||||
int32_t TransProxyGetAppInfoType(int16_t myId, const char *identity, AppType *appType)
|
||||
{
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "fail to lock mutex!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "fail to lock mutex!");
|
||||
ProxyChannelInfo *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if ((item->myId == myId) && (strcmp(item->identity, identity) == 0)) {
|
||||
@ -138,16 +135,10 @@ int32_t TransProxyGetAppInfoType(int16_t myId, const char *identity, AppType *ap
|
||||
|
||||
static int32_t TransProxyUpdateAckInfo(ProxyChannelInfo *info)
|
||||
{
|
||||
if (g_proxyChannelList == NULL || info == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "g_proxyChannelList or item is null");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE((g_proxyChannelList != NULL && info != NULL), SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"g_proxyChannelList or item is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
ProxyChannelInfo *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if ((item->myId == info->myId) && (strncmp(item->identity, info->identity, sizeof(item->identity)) == 0)) {
|
||||
@ -177,15 +168,10 @@ static int32_t TransProxyUpdateAckInfo(ProxyChannelInfo *info)
|
||||
|
||||
int32_t TransRefreshProxyTimesNative(int32_t channelId)
|
||||
{
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "g_proxyChannelList or item is null");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
ProxyChannelInfo *item = NULL;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
@ -201,16 +187,11 @@ int32_t TransRefreshProxyTimesNative(int32_t channelId)
|
||||
|
||||
static int32_t TransProxyAddChanItem(ProxyChannelInfo *chan)
|
||||
{
|
||||
TRANS_LOGD(TRANS_CTRL, "enter.");
|
||||
if ((chan == NULL) || (g_proxyChannelList == NULL)) {
|
||||
TRANS_LOGE(TRANS_CTRL, "trans proxy add channel param nullptr!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE((g_proxyChannelList != NULL && chan != NULL), SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"trans proxy add channel param nullptr!");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
ListAdd(&(g_proxyChannelList->list), &(chan->node));
|
||||
g_proxyChannelList->cnt++;
|
||||
(void)SoftBusMutexUnlock(&g_proxyChannelList->lock);
|
||||
@ -219,15 +200,10 @@ static int32_t TransProxyAddChanItem(ProxyChannelInfo *chan)
|
||||
|
||||
int32_t TransProxySpecialUpdateChanInfo(ProxyChannelInfo *channelInfo)
|
||||
{
|
||||
if (g_proxyChannelList == NULL || channelInfo == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "g_proxyChannelList or channelInfo is NULL!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE((g_proxyChannelList != NULL && channelInfo != NULL), SOFTBUS_INVALID_PARAM,
|
||||
TRANS_CTRL, "g_proxyChannelList or channelInfo is NULL!");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
@ -258,23 +234,14 @@ int32_t TransProxySpecialUpdateChanInfo(ProxyChannelInfo *channelInfo)
|
||||
|
||||
int32_t TransProxyGetChanByChanId(int32_t chanId, ProxyChannelInfo *chan)
|
||||
{
|
||||
if (chan == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "param invalid");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE((g_proxyChannelList != NULL && chan != NULL), SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"trans proxy get channel param nullptr!");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL || chan == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "trans proxy get channel param nullptr!");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == chanId) {
|
||||
if (memcpy_s(chan, sizeof(ProxyChannelInfo), item, sizeof(ProxyChannelInfo)) != EOK) {
|
||||
@ -294,14 +261,10 @@ int32_t TransProxyGetChanByChanId(int32_t chanId, ProxyChannelInfo *chan)
|
||||
int32_t TransProxyGetChanByReqId(int32_t reqId, ProxyChannelInfo *chan)
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->reqId == reqId && item->status == PROXY_CHANNEL_STATUS_PYH_CONNECTING) {
|
||||
@ -318,14 +281,10 @@ void TransProxyDelChanByReqId(int32_t reqId, int32_t errCode)
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if ((item->reqId == reqId) &&
|
||||
@ -348,14 +307,10 @@ void TransProxyDelChanByChanId(int32_t chanlId)
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == chanlId) {
|
||||
@ -379,14 +334,10 @@ void TransProxyDelChanByChanId(int32_t chanlId)
|
||||
void TransProxyChanProcessByReqId(int32_t reqId, uint32_t connId)
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
bool isUsing = false;
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
@ -425,9 +376,8 @@ static void TransProxyCloseProxyOtherRes(int32_t channelId, const ProxyChannelIn
|
||||
static void TransProxyReleaseChannelList(ListNode *proxyChannelList, int32_t errCode)
|
||||
{
|
||||
TRANS_LOGI(TRANS_CTRL, "enter.");
|
||||
if (proxyChannelList == NULL || IsListEmpty(proxyChannelList)) {
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE((g_proxyChannelList != NULL && !IsListEmpty(proxyChannelList)), TRANS_CTRL,
|
||||
"g_proxyChannelList is null or empty");
|
||||
ProxyChannelInfo *removeNode = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(removeNode, nextNode, proxyChannelList, ProxyChannelInfo, node) {
|
||||
@ -451,14 +401,10 @@ void TransProxyDelByConnId(uint32_t connId)
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
ListNode proxyChannelList;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
ListInit(&proxyChannelList);
|
||||
LIST_FOR_EACH_ENTRY_SAFE(removeNode, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
@ -479,14 +425,10 @@ static int32_t TransProxyDelByChannelId(int32_t channelId, ProxyChannelInfo *cha
|
||||
ProxyChannelInfo *removeNode = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(removeNode, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (removeNode->channelId == channelId) {
|
||||
@ -514,14 +456,10 @@ static int32_t TransProxyResetChan(ProxyChannelInfo *chanInfo)
|
||||
ProxyChannelInfo *removeNode = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(removeNode, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (ResetChanIsEqual(removeNode->status, removeNode, chanInfo)) {
|
||||
@ -551,14 +489,10 @@ static int32_t TransProxyGetRecvMsgChanInfo(int16_t myId, int16_t peerId, ProxyC
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if ((item->myId == myId) && (item->peerId == peerId)) {
|
||||
@ -582,14 +516,10 @@ static int32_t TransProxyKeepAliveChan(ProxyChannelInfo *chanInfo)
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (ChanIsEqual(item, chanInfo)) {
|
||||
@ -614,14 +544,10 @@ int32_t TransProxyGetSendMsgChanInfo(int32_t channelId, ProxyChannelInfo *chanIn
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
@ -646,14 +572,10 @@ int32_t TransProxyGetNewChanSeq(int32_t channelId)
|
||||
ProxyChannelInfo *item = NULL;
|
||||
int32_t seq = 0;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return seq;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return seq;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, seq, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, seq, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
@ -669,20 +591,13 @@ int32_t TransProxyGetNewChanSeq(int32_t channelId)
|
||||
|
||||
int32_t TransProxyGetAuthId(int32_t channelId, AuthHandle *authHandle)
|
||||
{
|
||||
if (authHandle == NULL) {
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
authHandle != NULL, SOFTBUS_INVALID_PARAM, TRANS_CTRL, "authHandle is null");
|
||||
ProxyChannelInfo *item = NULL;
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "g_proxyChannelList is null");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
*authHandle = item->authHandle;
|
||||
@ -696,22 +611,13 @@ int32_t TransProxyGetAuthId(int32_t channelId, AuthHandle *authHandle)
|
||||
|
||||
int32_t TransProxyGetSessionKeyByChanId(int32_t channelId, char *sessionKey, uint32_t sessionKeySize)
|
||||
{
|
||||
if (sessionKey == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "invalid param");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "proxy channel list not init");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
sessionKey != NULL, SOFTBUS_INVALID_PARAM, TRANS_CTRL, "sessionKey is null");
|
||||
ProxyChannelInfo *item = NULL;
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
if (item->status == PROXY_CHANNEL_STATUS_COMPLETED) {
|
||||
@ -735,12 +641,8 @@ int32_t TransProxyGetSessionKeyByChanId(int32_t channelId, char *sessionKey, uin
|
||||
static inline void TransProxyProcessErrMsg(ProxyChannelInfo *info, int32_t errCode)
|
||||
{
|
||||
TRANS_LOGW(TRANS_CTRL, "TransProxyProcessErrMsg errCode=%{public}d", errCode);
|
||||
|
||||
if (TransProxyGetChanByChanId(info->myId, info) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "TransProxyGetChanByChanId fail");
|
||||
return;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
TransProxyGetChanByChanId(info->myId, info) == SOFTBUS_OK, TRANS_CTRL, "TransProxyGetChanByChanId fail");
|
||||
if ((info->appInfo.appType == APP_TYPE_NORMAL) || (info->appInfo.appType == APP_TYPE_AUTH)) {
|
||||
TransProxyDelChanByChanId(info->channelId);
|
||||
(void)TransProxyOpenProxyChannelFail(info->channelId, &(info->appInfo), errCode);
|
||||
@ -751,14 +653,10 @@ static int32_t TransProxyGetAppInfo(int16_t myId, AppInfo *appInfo)
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->myId == myId) {
|
||||
@ -1790,14 +1688,10 @@ void TransProxyTimerProc(void)
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
ListNode proxyProcList;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGD(TRANS_INIT, "g_proxyChannelList is null or empty");
|
||||
return;
|
||||
}
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_INIT, "lock mutex fail");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_CTRL, "lock mutex fail!");
|
||||
if (g_proxyChannelList->cnt <= 0) {
|
||||
(void)SoftBusMutexUnlock(&g_proxyChannelList->lock);
|
||||
return;
|
||||
@ -1956,15 +1850,10 @@ int32_t TransProxyManagerInit(const IServerChannelCallBack *cb)
|
||||
int32_t TransProxyGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName,
|
||||
uint16_t pkgLen, uint16_t sessionLen)
|
||||
{
|
||||
if (pkgName == NULL || sessionName == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "invalid param");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE((pkgName != NULL && sessionName != NULL), SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"invalid param");
|
||||
ProxyChannelInfo *chan = (ProxyChannelInfo *)SoftBusCalloc(sizeof(ProxyChannelInfo));
|
||||
if (chan == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "malloc err");
|
||||
return SOFTBUS_MALLOC_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(chan != NULL, SOFTBUS_MALLOC_ERR, TRANS_CTRL, "malloc err");
|
||||
int32_t ret = TransProxyGetChanByChanId(chanId, chan);
|
||||
(void)memset_s(chan->appInfo.sessionKey, sizeof(chan->appInfo.sessionKey), 0, sizeof(chan->appInfo.sessionKey));
|
||||
if (ret != SOFTBUS_OK) {
|
||||
@ -1989,16 +1878,12 @@ int32_t TransProxyGetNameByChanId(int32_t chanId, char *pkgName, char *sessionNa
|
||||
|
||||
static void TransProxyManagerDeinitInner(void)
|
||||
{
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGW(TRANS_INIT, "g_proxyChannelList is null");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
g_proxyChannelList != NULL, TRANS_INIT, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, TRANS_INIT, "lock mutex fail!");
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_INIT, "lock mutex fail!");
|
||||
return;
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
ReleaseProxyChannelId(item->channelId);
|
||||
ListDelete(&(item->node));
|
||||
@ -2022,10 +1907,8 @@ void TransProxyManagerDeinit(void)
|
||||
static void TransProxyDestroyChannelList(const ListNode *destroyList)
|
||||
{
|
||||
TRANS_LOGD(TRANS_CTRL, "enter.");
|
||||
if ((destroyList == NULL) || IsListEmpty(destroyList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
(destroyList != NULL && !IsListEmpty(destroyList)), TRANS_INIT, "destroyList is null");
|
||||
ProxyChannelInfo *destroyNode = NULL;
|
||||
ProxyChannelInfo *nextDestroyNode = NULL;
|
||||
LIST_FOR_EACH_ENTRY_SAFE(destroyNode, nextDestroyNode, destroyList, ProxyChannelInfo, node) {
|
||||
@ -2044,10 +1927,8 @@ static void TransProxyDestroyChannelList(const ListNode *destroyList)
|
||||
|
||||
void TransProxyDeathCallback(const char *pkgName, int32_t pid)
|
||||
{
|
||||
if ((pkgName == NULL) || (g_proxyChannelList == NULL)) {
|
||||
TRANS_LOGE(TRANS_CTRL, "pkgName or proxy channel list is null.");
|
||||
return;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_LOGE(
|
||||
(pkgName != NULL && g_proxyChannelList != NULL), TRANS_CTRL, "pkgName or proxy channel list is null.");
|
||||
TRANS_LOGW(TRANS_CTRL, "TransProxyDeathCallback: pkgName=%{public}s, pid=%{public}d", pkgName, pid);
|
||||
ListNode destroyList;
|
||||
ListInit(&destroyList);
|
||||
@ -2073,21 +1954,16 @@ void TransProxyDeathCallback(const char *pkgName, int32_t pid)
|
||||
|
||||
int32_t TransProxyGetAppInfoByChanId(int32_t chanId, AppInfo *appInfo)
|
||||
{
|
||||
if (appInfo == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "param invalid");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(appInfo != NULL, SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"invalid param");
|
||||
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == chanId) {
|
||||
@ -2107,18 +1983,16 @@ int32_t TransProxyGetAppInfoByChanId(int32_t chanId, AppInfo *appInfo)
|
||||
|
||||
int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId)
|
||||
{
|
||||
if (connId == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "param invalid");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (g_proxyChannelList == NULL) {
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(connId != NULL, SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"invalid param");
|
||||
|
||||
ProxyChannelInfo *item = NULL;
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail!");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
if (item->status == PROXY_CHANNEL_STATUS_COMPLETED ||
|
||||
@ -2139,10 +2013,8 @@ int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId)
|
||||
|
||||
int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt)
|
||||
{
|
||||
if (connOpt == NULL) {
|
||||
TRANS_LOGW(TRANS_CTRL, "invalid param.");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(connOpt != NULL, SOFTBUS_INVALID_PARAM, TRANS_CTRL,
|
||||
"invalid param");
|
||||
|
||||
int32_t connId = -1;
|
||||
int32_t ret = TransProxyGetConnIdByChanId(channelId, &connId);
|
||||
@ -2164,15 +2036,10 @@ int32_t TransProxySetAuthHandleByChanId(int32_t channelId, AuthHandle authHandle
|
||||
ProxyChannelInfo *item = NULL;
|
||||
ProxyChannelInfo *nextNode = NULL;
|
||||
|
||||
if (g_proxyChannelList == NULL) {
|
||||
TRANS_LOGE(TRANS_CTRL, "trans proxy get channel param nullptr.");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_proxyChannelList->lock) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "lock mutex fail.");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
g_proxyChannelList != NULL, SOFTBUS_NO_INIT, TRANS_CTRL, "g_proxyChannelList is null");
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
SoftBusMutexLock(&g_proxyChannelList->lock) == SOFTBUS_OK, SOFTBUS_LOCK_ERR, TRANS_CTRL, "lock mutex fail!");
|
||||
|
||||
LIST_FOR_EACH_ENTRY_SAFE(item, nextNode, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->channelId == channelId) {
|
||||
|
@ -82,14 +82,18 @@ static int32_t GetRemoteUdidByBtMac(const char *peerMac, char *udid, int32_t len
|
||||
char networkId[NETWORK_ID_BUF_LEN] = {0};
|
||||
char *tmpMac = NULL;
|
||||
Anonymize(peerMac, &tmpMac);
|
||||
AnonymizeFree(tmpMac);
|
||||
int32_t ret = LnnGetNetworkIdByBtMac(peerMac, networkId, sizeof(networkId));
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
ret == SOFTBUS_OK, ret, TRANS_CTRL, "LnnGetNetworkIdByBtMac fail, peerMac=%{public}s", tmpMac);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "LnnGetNetworkIdByBtMac fail, peerMac=%{public}s", tmpMac);
|
||||
AnonymizeFree(tmpMac);
|
||||
return ret;
|
||||
}
|
||||
ret = LnnGetRemoteStrInfo(networkId, STRING_KEY_DEV_UDID, udid, len);
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
ret == SOFTBUS_OK, ret, TRANS_CTRL, "LnnGetRemoteStrInfo UDID fail, peerMac=%{public}s", tmpMac);
|
||||
return SOFTBUS_OK;
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_CTRL, "LnnGetRemoteStrInfo UDID fail, peerMac=%{public}s", tmpMac);
|
||||
}
|
||||
AnonymizeFree(tmpMac);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t GetRemoteBtMacByUdidHash(const uint8_t *udidHash, uint32_t udidHashLen, char *brMac, int32_t len)
|
||||
|
@ -459,6 +459,15 @@ typedef struct {
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*onLocalNetworkIdChanged)(void);
|
||||
/**
|
||||
* @brief Called when the device is not trusted.
|
||||
*
|
||||
* @param msg Indicates the pointer to untrusted device information.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
void (*onNodeDeviceNotTrusted)(const char *msg);
|
||||
/**
|
||||
* @brief Called when the running status of a device changes.
|
||||
*
|
||||
|
@ -153,6 +153,8 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_COND_INIT_FAILED,
|
||||
SOFTBUS_GET_SYSTIME_FAILED,
|
||||
SOFTBUS_BYTE_CONVERT_FAIL,
|
||||
SOFTBUS_GENERATE_KEY_FAIL,
|
||||
SOFTBUS_GCM_SET_IV_FAIL, // set ivlen fail for aes-gcm encrypt
|
||||
|
||||
/* errno begin: -((203 << 21) | (5 << 16) | 0xFFFF) */
|
||||
SOFTBUS_TRANS_ERR_BASE = SOFTBUS_ERRNO(TRANS_SUB_MODULE_CODE),
|
||||
@ -442,6 +444,10 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_AUTH_ADD_PTK_LISTEN_ERR,
|
||||
SOFTBUS_AUTH_META_INIT_FAIL,
|
||||
SOFTBUS_AUTH_SYNC_DEVINFO_ACK_FAIL,
|
||||
SOFTBUS_CHANNEL_AUTH_INVALID_PROTOCOL,
|
||||
SOFTBUS_CHANNEL_AUTH_START_TIMEOUT,
|
||||
SOFTBUS_CHANNEL_AUTH_HANDLE_DATA_FAIL,
|
||||
SOFTBUS_CHANNEL_AUTH_PACK_DATA_FAIL,
|
||||
|
||||
/* errno begin: -((203 << 21) | (4 << 16) | 0xFFFF) */
|
||||
SOFTBUS_NETWORK_ERR_BASE = SOFTBUS_ERRNO(LNN_SUB_MODULE_CODE),
|
||||
@ -537,6 +543,7 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_LANE_WIFI_BAND_ERR,
|
||||
SOFTBUS_LANE_GET_WIFI_INFO_FAIL,
|
||||
SOFTBUS_LANE_CHANNEL_UNKNOWN,
|
||||
SOFTBUS_LANE_SUCC_AFTER_CANCELED,
|
||||
|
||||
/* errno begin: -((203 << 21) | (2 << 16) | 0xFFFF) */
|
||||
SOFTBUS_CONN_ERR_BASE = SOFTBUS_ERRNO(CONN_SUB_MODULE_CODE),
|
||||
@ -818,6 +825,7 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_CONN_NO_WIFI_CONFIG_INFO = SOFTBUS_CONN_ERR_BASE + 703,
|
||||
SOFTBUS_CONN_HV3_WAIT_CONNECTION_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 704,
|
||||
SOFTBUS_CONN_HV3_WAITING_HANDSHAKE_RESPONSE_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 705,
|
||||
SOFTBUS_CONN_HV2_SWITCHED_CONNECT_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 706,
|
||||
|
||||
/* soft bus connection mapping short range conflict error code */
|
||||
SOFTBUS_CONN_SHORT_RANGE_BASE = SOFTBUS_CONN_ERR_BASE + 1000,
|
||||
@ -854,6 +862,84 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_CONN_ACTIVE_TYPE_HML_NUM_LIMITED_CONFLICT = SOFTBUS_CONN_ERR_BASE + 1031,
|
||||
SOFTBUS_CONN_PASSIVE_TYPE_HML_NUM_LIMITED_CONFLICT = SOFTBUS_CONN_ERR_BASE + 1032,
|
||||
|
||||
/* soft bus connection legacy modules error code */
|
||||
SOFTBUS_CONN_NEARBY_CONTROL_CHANNEL_CONNECT_FAILED = SOFTBUS_CONN_ERR_BASE + 2000,
|
||||
SOFTBUS_CONN_NEARBY_CONTROL_CHANNEL_DATA_EXCEPTION = SOFTBUS_CONN_ERR_BASE + 2001,
|
||||
SOFTBUS_CONN_NEARBY_NO_AVAILABLE_DATA_CHANNEL = SOFTBUS_CONN_ERR_BASE + 2002,
|
||||
SOFTBUS_CONN_NEARBY_DEVICE_CONNECT_FAILED = SOFTBUS_CONN_ERR_BASE + 2003,
|
||||
SOFTBUS_CONN_NEARBY_DATA_SEND_FAILED = SOFTBUS_CONN_ERR_BASE + 2004,
|
||||
SOFTBUS_CONN_NEARBY_SAME_BID_BTAG = SOFTBUS_CONN_ERR_BASE + 2005,
|
||||
SOFTBUS_CONN_NEARBY_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2006,
|
||||
SOFTBUS_CONN_NEARBY_PEER_DEVICE_BUSY = SOFTBUS_CONN_ERR_BASE + 2007,
|
||||
SOFTBUS_CONN_NEARBY_LOCAL_DEVICE_BUSY = SOFTBUS_CONN_ERR_BASE + 2008,
|
||||
SOFTBUS_CONN_NEARBY_ERROR_PEER_DEVICE_IMPORT_DATA = SOFTBUS_CONN_ERR_BASE + 2009,
|
||||
SOFTBUS_CONN_NEARBY_PEER_DEVICE_HOSTSPOT_ON = SOFTBUS_CONN_ERR_BASE + 2010,
|
||||
SOFTBUS_CONN_NEARBY_LOCAL_DEVICE_HOSTSPOT_ON = SOFTBUS_CONN_ERR_BASE + 2011,
|
||||
SOFTBUS_CONN_NEARBY_PEER_SHARE_BUSY = SOFTBUS_CONN_ERR_BASE + 2012,
|
||||
SOFTBUS_CONN_NEARBY_CREATE_SOCKET_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2013,
|
||||
SOFTBUS_CONN_NEARBY_CLIENT_CONNECT_FAILED = SOFTBUS_CONN_ERR_BASE + 2014,
|
||||
SOFTBUS_CONN_NEARBY_MESSAGE_OPEN_NEARBY_SOCKET_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2015,
|
||||
SOFTBUS_CONN_NEARBY_MESSAGE_REMOTE_REJECTED = SOFTBUS_CONN_ERR_BASE + 2016,
|
||||
SOFTBUS_CONN_NEARBY_CONFLICT_REUSE_FAIL = SOFTBUS_CONN_ERR_BASE + 2017,
|
||||
SOFTBUS_CONN_NEARBY_ROLE_LOCAL_ALREADY_GC = SOFTBUS_CONN_ERR_BASE + 2018,
|
||||
SOFTBUS_CONN_NEARBY_DATACHANNEL_LOCAL_BUSY = SOFTBUS_CONN_ERR_BASE + 2019,
|
||||
SOFTBUS_CONN_LEGACY_CONFLICT_NOTIFY_DISCONENCT = SOFTBUS_CONN_ERR_BASE + 2020,
|
||||
|
||||
SOFTBUS_CONN_LEGACY_BLE_CONNECT_TIMEOUT_ERR = SOFTBUS_CONN_ERR_BASE + 2200,
|
||||
SOFTBUS_CONN_LEGACY_BLE_CONNECT_INTERNAL_ERR = SOFTBUS_CONN_ERR_BASE + 2201,
|
||||
SOFTBUS_CONN_LEGACY_BLE_INTERNAL_ERR = SOFTBUS_CONN_ERR_BASE + 2202,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_REGISTER_ERR = SOFTBUS_CONN_ERR_BASE + 2203,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_CONNECT_ERR = SOFTBUS_CONN_ERR_BASE + 2204,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_CONNECT_FAIL = SOFTBUS_CONN_ERR_BASE + 2205,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_SEARCH_SERVICE_ERR = SOFTBUS_CONN_ERR_BASE + 2206,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_SEARCH_SERVICE_FAIL = SOFTBUS_CONN_ERR_BASE + 2207,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_GET_SERVICE_ERR = SOFTBUS_CONN_ERR_BASE + 2208,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_REGISTER_NOTIFICATION_ERR = SOFTBUS_CONN_ERR_BASE + 2209,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_REGISTER_NOTIFICATION_FAIL = SOFTBUS_CONN_ERR_BASE + 2210,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_CONFIGURE_MTU_ERR = SOFTBUS_CONN_ERR_BASE + 2211,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CLIENT_CONFIGURE_MTU_FAIL = SOFTBUS_CONN_ERR_BASE + 2212,
|
||||
SOFTBUS_CONN_LEGACY_BLE_DISCONNECT_DIRECTLY_ERR = SOFTBUS_CONN_ERR_BASE + 2213,
|
||||
SOFTBUS_CONN_LEGACY_BLE_DISCONNECT_WAIT_TIMEOUT_ERR = SOFTBUS_CONN_ERR_BASE + 2214,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVER_REGISTER_CALLBACK_ERR = SOFTBUS_CONN_ERR_BASE + 2215,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVER_ADD_SERVICE_ERR = SOFTBUS_CONN_ERR_BASE + 2216,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVER_ADD_SERVICE_FAIL = SOFTBUS_CONN_ERR_BASE + 2217,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_UNKNOWN_SERVICE_ERR = SOFTBUS_CONN_ERR_BASE + 2218,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CHARACTERISTIC_ADD_ERR = SOFTBUS_CONN_ERR_BASE + 2219,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_CHARACTERISTIC_ADD_FAIL = SOFTBUS_CONN_ERR_BASE + 2220,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_DESCRIPTOR_ADD_ERR = SOFTBUS_CONN_ERR_BASE + 2221,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_HANDLE_MISMATCH_ERR = SOFTBUS_CONN_ERR_BASE + 2222,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_START_ERR = SOFTBUS_CONN_ERR_BASE + 2223,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_START_FAIL = SOFTBUS_CONN_ERR_BASE + 2224,
|
||||
SOFTBUS_CONN_LEGACY_BLE_SERVER_STATE_UNEXPECTED_ERR = SOFTBUS_CONN_ERR_BASE + 2225,
|
||||
SOFTBUS_CONN_LEGACY_BLE_SERVER_START_SERVER_TIMEOUT_ERR = SOFTBUS_CONN_ERR_BASE + 2226,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_STOP_ERR = SOFTBUS_CONN_ERR_BASE + 2227,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_STOP_FAIL = SOFTBUS_CONN_ERR_BASE + 2228,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_DELETE_ERR = SOFTBUS_CONN_ERR_BASE + 2229,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_SERVICE_DELETE_FAIL = SOFTBUS_CONN_ERR_BASE + 2230,
|
||||
SOFTBUS_CONN_LEGACY_BLE_SERVER_STOP_SERVER_TIMEOUT_ERR = SOFTBUS_CONN_ERR_BASE + 2231,
|
||||
SOFTBUS_CONN_LEGACY_BLE_CLIENT_STATE_UNEXPECTED_ERR = SOFTBUS_CONN_ERR_BASE + 2232,
|
||||
SOFTBUS_CONN_LEGACY_BLE_REPEAT_CONNECT_ERR = SOFTBUS_CONN_ERR_BASE + 2233,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_DESCRIPTOR_ADD_FAIL = SOFTBUS_CONN_ERR_BASE + 2234,
|
||||
SOFTBUS_CONN_LEGACY_BLE_UNDERLAY_UNKNOWN_DESCRIPTOR_ERR = SOFTBUS_CONN_ERR_BASE + 2235,
|
||||
|
||||
SOFTBUS_CONN_LEGACY_HML_UNDERLAY_EXCEPTION = SOFTBUS_CONN_ERR_BASE + 2400,
|
||||
SOFTBUS_CONN_LEGACY_HML_SOCKET_CONNECT_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2401,
|
||||
SOFTBUS_CONN_LEGACY_P2P_SEND_GET_GC_MAC_REQ_FAIL = SOFTBUS_CONN_ERR_BASE + 2402,
|
||||
SOFTBUS_CONN_LEGACY_P2P_CONNECT_DEVICE_FAIL = SOFTBUS_CONN_ERR_BASE + 2403,
|
||||
SOFTBUS_CONN_LEGACY_P2P_DISCONNECT_DEVICE_FAIL = SOFTBUS_CONN_ERR_BASE + 2404,
|
||||
SOFTBUS_CONN_LEGACY_P2P_REUSE_LINK_FAIL = SOFTBUS_CONN_ERR_BASE + 2405,
|
||||
SOFTBUS_CONN_LEGACY_P2P_COMMAND_SET_DATA_FAIL = SOFTBUS_CONN_ERR_BASE + 2406,
|
||||
SOFTBUS_CONN_LEGACY_P2P_SEND_COMMAND_FAIL = SOFTBUS_CONN_ERR_BASE + 2407,
|
||||
SOFTBUS_CONN_LEGACY_P2P_START_SERVER_SOCKET_FAIL = SOFTBUS_CONN_ERR_BASE + 2408,
|
||||
SOFTBUS_CONN_LEGACY_P2P_GO_SEND_CONFIG_INFO_FAIL = SOFTBUS_CONN_ERR_BASE + 2409,
|
||||
SOFTBUS_CONN_LEGACY_P2P_CREATE_GROUP_FAIL = SOFTBUS_CONN_ERR_BASE + 2410,
|
||||
SOFTBUS_CONN_LEGACY_P2P_CREATE_GROUP_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2411,
|
||||
SOFTBUS_CONN_LEGACY_P2P_CONNECT_GROUP_FAIL = SOFTBUS_CONN_ERR_BASE + 2412,
|
||||
SOFTBUS_CONN_LEGACY_P2P_CONNECT_GROUP_TIMEOUT = SOFTBUS_CONN_ERR_BASE + 2413,
|
||||
SOFTBUS_CONN_LEGACY_P2P_REMOVE_GROUP_FAIL = SOFTBUS_CONN_ERR_BASE + 2414,
|
||||
SOFTBUS_CONN_LEGACY_P2P_ADD_SEVER_TCP_CHANNEL_FAIL = SOFTBUS_CONN_ERR_BASE + 2415,
|
||||
SOFTBUS_CONN_LEGACY_P2P_NOT_AVAILABLE = SOFTBUS_CONN_ERR_BASE + 2416,
|
||||
|
||||
/* errno begin: -((203 << 21) | (1 << 16) | 0xFFFF) */
|
||||
SOFTBUS_DISCOVER_ERR_BASE = SOFTBUS_ERRNO(DISC_SUB_MODULE_CODE),
|
||||
/* errno begin: -((203 << 21) | (1 << 16) | (1 << 12) | 0x0FFF) */
|
||||
@ -947,8 +1033,6 @@ enum SoftBusErrNo {
|
||||
SOFTBUS_DISCOVER_ACTION_START_FAILED,
|
||||
SOFTBUS_DISCOVER_ACTION_STOP_FAILED,
|
||||
SOFTBUS_DISCOVER_ACTION_REPLY_FAILED,
|
||||
SOFTBUS_DISCOVER_ACTION_REPEAT_TYPE,
|
||||
SOFTBUS_DISCOVER_ACTION_HAD_PRELINK,
|
||||
|
||||
/* softbus ok */
|
||||
SOFTBUS_OK = 0,
|
||||
|
@ -261,6 +261,33 @@ typedef enum {
|
||||
OPT_LEVEL_SOFTBUS, /**< @reserved Softbus level option. */
|
||||
OPT_LEVEL_BUTT,
|
||||
} OptLevel;
|
||||
|
||||
/**
|
||||
* @brief Enumerate frame event status.
|
||||
*
|
||||
* @since 2.0
|
||||
* @version 2.0
|
||||
*/
|
||||
typedef enum {
|
||||
FRAME_UNSEND,
|
||||
FRAME_SENDING,
|
||||
FRAME_RETRING,
|
||||
FRAME_RECEIVED,
|
||||
FRAME_DROPPED,
|
||||
FRAME_UNMANAGED,
|
||||
} FrameEvtStatus;
|
||||
|
||||
typedef struct {
|
||||
int32_t seq;
|
||||
int32_t level;
|
||||
int32_t subSeqNum;
|
||||
FrameEvtStatus status;
|
||||
uint32_t interval; /**< frame sending interval */
|
||||
uint32_t queueUsage; /**< send queue percentage of use */
|
||||
uint32_t cachedFrameCnt; /**< frame count in VTP */
|
||||
} FrameEvtCbInfo;
|
||||
|
||||
typedef int (*OnFrameEvt)(int fd, const FrameEvtCbInfo *info);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,6 +59,7 @@ int32_t LnnOnLeaveResult(const char *networkId, int32_t retCode);
|
||||
int32_t LnnOnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info);
|
||||
int32_t LnnOnNodeBasicInfoChanged(const char *pkgName, void *info, int32_t type);
|
||||
int32_t LnnOnLocalNetworkIdChanged(const char *pkgName);
|
||||
int32_t LnnOnNodeDeviceNotTrusted(const char *pkgName, const char *msg);
|
||||
int32_t LnnOnTimeSyncResult(const void *info, int32_t retCode);
|
||||
void LnnOnPublishLNNResult(int32_t publishId, int32_t reason);
|
||||
void LnnOnRefreshLNNResult(int32_t refreshId, int32_t reason);
|
||||
|
@ -1212,6 +1212,39 @@ int32_t LnnOnLocalNetworkIdChanged(const char *pkgName)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnOnNodeDeviceNotTrusted(const char *pkgName, const char *msg)
|
||||
{
|
||||
NodeStateCallbackItem *item = NULL;
|
||||
ListNode dupList;
|
||||
|
||||
if (pkgName == NULL) {
|
||||
LNN_LOGE(LNN_STATE, "pkgName is null");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
if (!g_busCenterClient.isInit) {
|
||||
LNN_LOGE(LNN_STATE, "buscenter client not init");
|
||||
return SOFTBUS_NO_INIT;
|
||||
}
|
||||
|
||||
if (SoftBusMutexLock(&g_busCenterClient.lock) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_STATE, "lock local cb list in notify");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
ListInit(&dupList);
|
||||
DuplicateNodeStateCbList(&dupList);
|
||||
if (SoftBusMutexUnlock(&g_busCenterClient.lock) != SOFTBUS_OK) {
|
||||
LNN_LOGE(LNN_STATE, "unlock local cb list in notify");
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY(item, &dupList, NodeStateCallbackItem, node) {
|
||||
if (((strcmp(item->pkgName, pkgName) == 0) || (strlen(pkgName) == 0)) &&
|
||||
(item->cb.onNodeDeviceNotTrusted) != NULL) {
|
||||
item->cb.onNodeDeviceNotTrusted(msg);
|
||||
}
|
||||
}
|
||||
ClearNodeStateCbList(&dupList);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t LnnOnTimeSyncResult(const void *info, int32_t retCode)
|
||||
{
|
||||
TimeSyncCallbackItem *item = NULL;
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
|
||||
virtual int32_t OnLocalNetworkIdChanged(const char *pkgName);
|
||||
|
||||
virtual int32_t OnNodeDeviceNotTrusted(const char *pkgName, const char *msg);
|
||||
|
||||
virtual int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode);
|
||||
|
||||
virtual void OnPublishLNNResult(int32_t publishId, int32_t reason);
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
int32_t OnNodeOnlineStateChanged(const char *pkgName, bool isOnline, void *info, uint32_t infoTypeLen) override;
|
||||
int32_t OnNodeBasicInfoChanged(const char *pkgName, void *info, uint32_t infoTypeLen, int32_t type) override;
|
||||
int32_t OnLocalNetworkIdChanged(const char *pkgName) override;
|
||||
int32_t OnNodeDeviceNotTrusted(const char *pkgName, const char *msg) override;
|
||||
int32_t OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode) override;
|
||||
void OnPublishLNNResult(int32_t publishId, int32_t reason) override;
|
||||
void OnRefreshLNNResult(int32_t refreshId, int32_t reason) override;
|
||||
@ -80,6 +81,7 @@ private:
|
||||
int32_t OnNodeOnlineStateChangedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnNodeBasicInfoChangedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnLocalNetworkIdChangedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnNodeDeviceNotTrustedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnPublishLNNResultInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t OnRefreshLNNResultInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -130,6 +130,12 @@ int32_t ISoftBusClient::OnLocalNetworkIdChanged(const char *pkgName)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t ISoftBusClient::OnNodeDeviceNotTrusted(const char *pkgName, const char *msg)
|
||||
{
|
||||
COMM_LOGI(COMM_EVENT, "ipc default impl");
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t ISoftBusClient::OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
COMM_LOGI(COMM_EVENT, "ipc default impl");
|
||||
|
@ -52,6 +52,7 @@ SoftBusClientStub::SoftBusClientStub()
|
||||
memberFuncMap_[CLIENT_ON_NODE_ONLINE_STATE_CHANGED] = &SoftBusClientStub::OnNodeOnlineStateChangedInner;
|
||||
memberFuncMap_[CLIENT_ON_NODE_BASIC_INFO_CHANGED] = &SoftBusClientStub::OnNodeBasicInfoChangedInner;
|
||||
memberFuncMap_[CLIENT_ON_LOCAL_NETWORK_ID_CHANGED] = &SoftBusClientStub::OnLocalNetworkIdChangedInner;
|
||||
memberFuncMap_[CLIENT_ON_NODE_DEVICE_NOT_TRUST] = &SoftBusClientStub::OnNodeDeviceNotTrustedInner;
|
||||
memberFuncMap_[CLIENT_ON_TIME_SYNC_RESULT] = &SoftBusClientStub::OnTimeSyncResultInner;
|
||||
memberFuncMap_[CLIENT_ON_PUBLISH_LNN_RESULT] = &SoftBusClientStub::OnPublishLNNResultInner;
|
||||
memberFuncMap_[CLIENT_ON_REFRESH_LNN_RESULT] = &SoftBusClientStub::OnRefreshLNNResultInner;
|
||||
@ -552,6 +553,26 @@ int32_t SoftBusClientStub::OnLocalNetworkIdChangedInner(MessageParcel &data, Mes
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t SoftBusClientStub::OnNodeDeviceNotTrustedInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
const char *pkgName = data.ReadCString();
|
||||
if (pkgName == nullptr || strlen(pkgName) == 0) {
|
||||
COMM_LOGE(COMM_SDK, "Invalid package name, or length is zero");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
const char *msg = data.ReadCString();
|
||||
if (msg == nullptr) {
|
||||
COMM_LOGE(COMM_SDK, "OnNodeDeviceNotTrustedInner read msg failed!");
|
||||
return SOFTBUS_TRANS_PROXY_READCSTRING_FAILED;
|
||||
}
|
||||
int32_t retReply = OnNodeDeviceNotTrusted(pkgName, msg);
|
||||
if (!reply.WriteInt32(retReply)) {
|
||||
COMM_LOGE(COMM_SDK, "OnNodeDeviceNotTrustedInner write reply failed!");
|
||||
return SOFTBUS_IPC_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int32_t SoftBusClientStub::OnTimeSyncResultInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
uint32_t infoTypeLen;
|
||||
@ -695,6 +716,11 @@ int32_t SoftBusClientStub::OnLocalNetworkIdChanged(const char *pkgName)
|
||||
return LnnOnLocalNetworkIdChanged(pkgName);
|
||||
}
|
||||
|
||||
int32_t SoftBusClientStub::OnNodeDeviceNotTrusted(const char *pkgName, const char *msg)
|
||||
{
|
||||
return LnnOnNodeDeviceNotTrusted(pkgName, msg);
|
||||
}
|
||||
|
||||
int32_t SoftBusClientStub::OnTimeSyncResult(const void *info, uint32_t infoTypeLen, int32_t retCode)
|
||||
{
|
||||
(void)infoTypeLen;
|
||||
|
@ -198,6 +198,7 @@
|
||||
"ServerIpcDeactiveMetaNode";
|
||||
"LnnOnNodeBasicInfoChanged";
|
||||
"LnnOnLocalNetworkIdChanged";
|
||||
"LnnOnNodeDeviceNotTrusted";
|
||||
"OpenSessionSync";
|
||||
"ReadMaxSendMessageSize";
|
||||
"ReadSessionLinkType";
|
||||
|
@ -141,10 +141,12 @@ typedef struct {
|
||||
int32_t sessionId;
|
||||
int32_t channelId;
|
||||
ChannelType channelType;
|
||||
bool isAsync;
|
||||
void (*OnSessionClosed)(int sessionId);
|
||||
void (*OnShutdown)(int32_t socket, ShutdownReason reason);
|
||||
char sessionName[SESSION_NAME_SIZE_MAX];
|
||||
char pkgName[PKG_NAME_SIZE_MAX];
|
||||
SocketLifecycleData lifecycle;
|
||||
} DestroySessionInfo;
|
||||
|
||||
int32_t ClientAddNewSession(const char *sessionName, SessionInfo *session);
|
||||
@ -174,6 +176,8 @@ int32_t ClientGetChannelBusinessTypeBySessionId(int32_t sessionId, int32_t *busi
|
||||
|
||||
int32_t GetEncryptByChannelId(int32_t channelId, int32_t channelType, int32_t *data);
|
||||
|
||||
int32_t ClientGetSessionStateByChannelId(int32_t channelId, int32_t channelType, SessionState *sessionState);
|
||||
|
||||
int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId);
|
||||
|
||||
int32_t ClientGetSessionIsAsyncBySessionId(int32_t sessionId, bool *isAsync);
|
||||
|
@ -142,6 +142,16 @@ NO_SANITIZE("cfi")
|
||||
static int32_t TransOnBindFailed(int32_t sessionId, const ISocketListener *socketCallback, int32_t errCode)
|
||||
{
|
||||
(void)ClientHandleBindWaitTimer(sessionId, 0, TIMER_ACTION_STOP);
|
||||
bool isAsync = true;
|
||||
int32_t ret = ClientGetSessionIsAsyncBySessionId(sessionId, &isAsync);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "get is async type failed, sessionId=%{public}d, ret=%{public}d", sessionId, ret);
|
||||
return ret;
|
||||
}
|
||||
if (!isAsync) {
|
||||
(void)ClientSignalSyncBind(sessionId, errCode);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (socketCallback == NULL || socketCallback->OnError == NULL) {
|
||||
TRANS_LOGE(TRANS_SDK, "Invalid OnBind callback function");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
@ -149,7 +159,7 @@ static int32_t TransOnBindFailed(int32_t sessionId, const ISocketListener *socke
|
||||
|
||||
SocketLifecycleData lifecycle;
|
||||
(void)memset_s(&lifecycle, sizeof(SocketLifecycleData), 0, sizeof(SocketLifecycleData));
|
||||
int32_t ret = GetSocketLifecycleAndSessionNameBySessionId(sessionId, NULL, &lifecycle);
|
||||
ret = GetSocketLifecycleAndSessionNameBySessionId(sessionId, NULL, &lifecycle);
|
||||
(void)SetSessionStateBySessionId(sessionId, SESSION_STATE_INIT, 0);
|
||||
if (ret == SOFTBUS_OK && lifecycle.sessionState == SESSION_STATE_CANCELLING) {
|
||||
TRANS_LOGW(TRANS_SDK, "socket is cancelling, no need call back, socket=%{public}d, bindErrCode=%{public}d",
|
||||
@ -341,9 +351,9 @@ NO_SANITIZE("cfi") int32_t TransOnSessionOpenFailed(int32_t channelId, int32_t c
|
||||
SessionListenerAdapter sessionCallback;
|
||||
(void)memset_s(&sessionCallback, sizeof(SessionListenerAdapter), 0, sizeof(SessionListenerAdapter));
|
||||
if (channelType == CHANNEL_TYPE_UNDEFINED) {
|
||||
sessionId = channelId;
|
||||
(void)ClientSetEnableStatusBySocket(sessionId, ENABLE_STATUS_FAILED);
|
||||
// only client async bind failed call
|
||||
sessionId = channelId;
|
||||
bool tmpIsServer = false;
|
||||
ClientGetSessionCallbackAdapterById(sessionId, &sessionCallback, &tmpIsServer);
|
||||
(void)TransOnBindFailed(sessionId, &sessionCallback.socketClient, errCode);
|
||||
|
@ -737,6 +737,8 @@ int32_t ClientSetChannelBySessionId(int32_t sessionId, TransInfo *transInfo)
|
||||
}
|
||||
sessionNode->channelId = transInfo->channelId;
|
||||
sessionNode->channelType = (ChannelType)transInfo->channelType;
|
||||
TRANS_LOGI(TRANS_SDK, "Client set channel by sessionId success, sessionId=%{public}d, channelId=%{public}d, "
|
||||
"channelType=%{public}d", sessionId, sessionNode->channelId, sessionNode->channelType);
|
||||
|
||||
UnlockClientSessionServerList();
|
||||
return SOFTBUS_OK;
|
||||
@ -777,6 +779,41 @@ int32_t GetEncryptByChannelId(int32_t channelId, int32_t channelType, int32_t *d
|
||||
return SOFTBUS_TRANS_SESSION_INFO_NOT_FOUND;
|
||||
}
|
||||
|
||||
int32_t ClientGetSessionStateByChannelId(int32_t channelId, int32_t channelType, SessionState *sessionState)
|
||||
{
|
||||
if ((channelId < 0) || (sessionState == NULL)) {
|
||||
TRANS_LOGW(TRANS_SDK, "Invalid param, channelId=%{public}d, channelType=%{public}d", channelId, channelType);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t ret = LockClientSessionServerList();
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "lock failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ClientSessionServer *serverNode = NULL;
|
||||
SessionInfo *sessionNode = NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY(serverNode, &(g_clientSessionServerList->list), ClientSessionServer, node) {
|
||||
if (IsListEmpty(&serverNode->sessionList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(sessionNode, &(serverNode->sessionList), SessionInfo, node) {
|
||||
if (sessionNode->channelId == channelId && sessionNode->channelType == (ChannelType)channelType) {
|
||||
*sessionState = sessionNode->lifecycle.sessionState;
|
||||
UnlockClientSessionServerList();
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnlockClientSessionServerList();
|
||||
TRANS_LOGE(TRANS_SDK, "not found session by channelId=%{public}d", channelId);
|
||||
return SOFTBUS_TRANS_SESSION_INFO_NOT_FOUND;
|
||||
}
|
||||
|
||||
int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, int32_t *sessionId)
|
||||
{
|
||||
if ((channelId < 0) || (sessionId == NULL)) {
|
||||
|
@ -462,7 +462,7 @@ void NotifyAuthSuccess(int sessionId)
|
||||
static int32_t CheckSessionIsOpened(int32_t sessionId, bool isCancelCheck)
|
||||
{
|
||||
#define SESSION_STATUS_CHECK_MAX_NUM 100
|
||||
#define SESSION_STATUS_CANCEL_CHECK_MAX_NUM 10
|
||||
#define SESSION_STATUS_CANCEL_CHECK_MAX_NUM 5
|
||||
#define SESSION_CHECK_PERIOD 200000
|
||||
int32_t checkMaxNum = isCancelCheck ? SESSION_STATUS_CANCEL_CHECK_MAX_NUM : SESSION_STATUS_CHECK_MAX_NUM;
|
||||
int32_t i = 0;
|
||||
@ -1097,13 +1097,9 @@ int32_t ClientBind(int32_t socket, const QosTV qos[], uint32_t qosCount, const I
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_SDK, "open session failed, ret=%{public}d", ret);
|
||||
|
||||
if (!isAsync) {
|
||||
ret = ClientSetChannelBySessionId(socket, &transInfo);
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
ret == SOFTBUS_OK, ret, TRANS_SDK, "set channel by socket=%{public}d failed, ret=%{public}d", socket, ret);
|
||||
ret = CheckSessionCancelState(socket);
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
ret == SOFTBUS_OK, ret, TRANS_SDK, "check session cancel state failed, ret=%{public}d", ret);
|
||||
SetSessionStateBySessionId(socket, SESSION_STATE_OPENED, 0);
|
||||
ret = ClientWaitSyncBind(socket);
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(
|
||||
ret == SOFTBUS_OK, ret, TRANS_SDK, "ClientWaitSyncBind err, ret=%{public}d", ret);
|
||||
@ -1111,6 +1107,7 @@ int32_t ClientBind(int32_t socket, const QosTV qos[], uint32_t qosCount, const I
|
||||
ret = ClientSetSocketState(socket, maxIdleTimeout, SESSION_ROLE_CLIENT);
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(ret == SOFTBUS_OK, ret, TRANS_SDK, "set session role failed, ret=%{public}d", ret);
|
||||
if (!isAsync) {
|
||||
(void)ClientGetChannelBySessionId(socket, &(transInfo.channelId), &(transInfo.channelType), NULL);
|
||||
TRANS_LOGI(TRANS_SDK, "Bind ok: socket=%{public}d, channelId=%{public}d, channelType=%{public}d", socket,
|
||||
transInfo.channelId, transInfo.channelType);
|
||||
} else {
|
||||
@ -1176,6 +1173,10 @@ void ClientShutdown(int32_t socket, int32_t cancelReason)
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "Call sa delete socket failed: ret=%{public}d", ret);
|
||||
}
|
||||
ret = ClientSignalSyncBind(socket, 0);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "sync signal bind failed, ret=%{public}d, socket=%{public}d", ret, socket);
|
||||
}
|
||||
} else if (lifecycle.sessionState == SESSION_STATE_OPENED ||
|
||||
lifecycle.sessionState == SESSION_STATE_CALLBACK_FINISHED) {
|
||||
if (lifecycle.sessionState == SESSION_STATE_OPENED) {
|
||||
|
@ -103,6 +103,13 @@ NO_SANITIZE("cfi") DestroySessionInfo *CreateDestroySessionNode(SessionInfo *ses
|
||||
destroyNode->sessionId = sessionNode->sessionId;
|
||||
destroyNode->channelId = sessionNode->channelId;
|
||||
destroyNode->channelType = sessionNode->channelType;
|
||||
destroyNode->isAsync = sessionNode->isAsync;
|
||||
if (memcpy_s(&(destroyNode->lifecycle), sizeof(SocketLifecycleData), &(sessionNode->lifecycle),
|
||||
sizeof(SocketLifecycleData)) != EOK) {
|
||||
TRANS_LOGE(TRANS_SDK, "memcpy_s lifecycle fail.");
|
||||
SoftBusFree(destroyNode);
|
||||
return NULL;
|
||||
}
|
||||
if (memcpy_s(destroyNode->sessionName, SESSION_NAME_SIZE_MAX, server->sessionName, SESSION_NAME_SIZE_MAX) != EOK) {
|
||||
TRANS_LOGE(TRANS_SDK, "memcpy_s sessionName fail.");
|
||||
SoftBusFree(destroyNode);
|
||||
@ -136,6 +143,9 @@ NO_SANITIZE("cfi") void ClientDestroySession(const ListNode *destroyList, Shutdo
|
||||
int32_t id = destroyNode->sessionId;
|
||||
(void)ClientDeleteRecvFileList(id);
|
||||
(void)ClientTransCloseChannel(destroyNode->channelId, destroyNode->channelType);
|
||||
if ((!destroyNode->isAsync) && destroyNode->lifecycle.sessionState == SESSION_STATE_CANCELLING) {
|
||||
(void)SoftBusCondSignal(&(destroyNode->lifecycle.callbackCond));
|
||||
}
|
||||
if (destroyNode->OnSessionClosed != NULL) {
|
||||
destroyNode->OnSessionClosed(id);
|
||||
} else if (destroyNode->OnShutdown != NULL) {
|
||||
@ -653,6 +663,12 @@ void ClientCleanUpWaitTimeoutSocket(int32_t waitOutSocket[], uint32_t waitOutNum
|
||||
SessionListenerAdapter callback = { 0 };
|
||||
for (uint32_t i = 0; i < waitOutNum; ++i) {
|
||||
TRANS_LOGI(TRANS_SDK, "time out shutdown socket=%{public}d", waitOutSocket[i]);
|
||||
SessionEnableStatus enableStatus = ENABLE_STATUS_INIT;
|
||||
int32_t ret = ClientGetChannelBySessionId(waitOutSocket[i], NULL, NULL, &enableStatus);
|
||||
if (ret != SOFTBUS_OK || enableStatus == ENABLE_STATUS_SUCCESS) {
|
||||
TRANS_LOGI(TRANS_SDK, "socket has enabled, need not shutdown, socket=%{public}d", waitOutSocket[i]);
|
||||
continue;
|
||||
}
|
||||
ClientGetSessionCallbackAdapterById(waitOutSocket[i], &callback, &tmpIsServer);
|
||||
if (callback.socketClient.OnError != NULL) {
|
||||
(void)callback.socketClient.OnError(waitOutSocket[i], SOFTBUS_TRANS_STOP_BIND_BY_TIMEOUT);
|
||||
|
@ -401,7 +401,7 @@ static int32_t GetAbsFullPath(const char *fullPath, char *recvAbsPath, int32_t p
|
||||
TRANS_LOGE(TRANS_FILE, "get full abs file failed");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "dirPath=%{public}s, absFullDir=%{public}s", dirPath, absFullDir);
|
||||
TRANS_LOGI(TRANS_FILE, "dirPath=%{private}s, absFullDir=%{private}s", dirPath, absFullDir);
|
||||
fileNameLength = (int32_t)strlen(fileName);
|
||||
dirPathLength = (int32_t)strlen(absFullDir);
|
||||
if (pathSize < (fileNameLength + dirPathLength + 1)) {
|
||||
@ -409,12 +409,12 @@ static int32_t GetAbsFullPath(const char *fullPath, char *recvAbsPath, int32_t p
|
||||
dirPathLength, fileNameLength);
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "fileName=%{public}s, fileNameLen=%{public}d", fileName, fileNameLength);
|
||||
TRANS_LOGI(TRANS_FILE, "fileName=%{private}s, fileNameLen=%{public}d", fileName, fileNameLength);
|
||||
if (sprintf_s(recvAbsPath, pathSize, "%s/%s", absFullDir, fileName) < 0) {
|
||||
TRANS_LOGE(TRANS_FILE, "sprintf_s filename error");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "recvAbsPath=%{public}s", recvAbsPath);
|
||||
TRANS_LOGI(TRANS_FILE, "recvAbsPath=%{private}s", recvAbsPath);
|
||||
SoftBusFree(absFullDir);
|
||||
SoftBusFree(dirPath);
|
||||
return SOFTBUS_OK;
|
||||
|
@ -713,13 +713,13 @@ static int32_t SendSingleFile(const SendListenerInfo *sendInfo, const char *sour
|
||||
TRANS_LOGE(TRANS_FILE, "sourfile or dstfile is null");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "channelId=%{public}d, srcFile=%{public}s, dstFile=%{public}s",
|
||||
sendInfo->channelId, sourceFile, destFile);
|
||||
TRANS_LOGI(TRANS_FILE, "channelId=%{public}d, srcFile=%{private}s, dstFile=%{public}s", sendInfo->channelId,
|
||||
sourceFile, destFile);
|
||||
|
||||
int32_t ret = FileToFrameAndSendFile((SendListenerInfo *)sendInfo, sourceFile, destFile);
|
||||
ClearSendInfo((SendListenerInfo *)sendInfo);
|
||||
TRANS_LOGI(
|
||||
TRANS_FILE, "channelId=%{public}d, srcFile=%{public}s, ret=%{public}d", sendInfo->channelId, sourceFile, ret);
|
||||
TRANS_FILE, "channelId=%{public}d, srcFile=%{private}s, ret=%{public}d", sendInfo->channelId, sourceFile, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1208,7 +1208,7 @@ static int32_t GetFileInfoByStartFrame(const FileFrame *fileFrame, const FileRec
|
||||
}
|
||||
const char *rootDir = info->fileListener.rootDir;
|
||||
if (strstr(rootDir, "..") != NULL) {
|
||||
TRANS_LOGE(TRANS_FILE, "rootDir is not canonical form. rootDir=%{public}s", rootDir);
|
||||
TRANS_LOGE(TRANS_FILE, "rootDir is not canonical form. rootDir=%{private}s", rootDir);
|
||||
return SOFTBUS_FILE_ERR;
|
||||
}
|
||||
int32_t ret = UnpackFileTransStartInfo((FileFrame *)fileFrame, info, file);
|
||||
@ -1218,10 +1218,10 @@ static int32_t GetFileInfoByStartFrame(const FileFrame *fileFrame, const FileRec
|
||||
}
|
||||
char *filePath = file->filePath;
|
||||
if (!CheckDestFilePathValid(filePath)) {
|
||||
TRANS_LOGE(TRANS_FILE, "recv filePath form is wrong. filePath=%{public}s", filePath);
|
||||
TRANS_LOGE(TRANS_FILE, "recv filePath form is wrong. filePath=%{private}s", filePath);
|
||||
return SOFTBUS_FILE_ERR;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "dst filePath=%{public}s, rootDir=%{public}s", filePath, rootDir);
|
||||
TRANS_LOGI(TRANS_FILE, "dst filePath=%{private}s, rootDir=%{private}s", filePath, rootDir);
|
||||
char *fullRecvPath = GetFullRecvPath(filePath, rootDir);
|
||||
if (!IsPathValid(fullRecvPath)) {
|
||||
TRANS_LOGE(TRANS_FILE, "destFilePath is invalid");
|
||||
@ -1342,7 +1342,7 @@ static int32_t CreateFileFromFrame(int32_t sessionId, int32_t channelId, const F
|
||||
TRANS_LOGE(TRANS_FILE, "get file info by start frame fail");
|
||||
goto EXIT_ERR;
|
||||
}
|
||||
TRANS_LOGI(TRANS_FILE, "null filePath. filePath=%{public}s, seq=%{public}u", file->filePath, file->seq);
|
||||
TRANS_LOGI(TRANS_FILE, "null filePath. filePath=%{private}s, seq=%{public}u", file->filePath, file->seq);
|
||||
if (PutToRecvFileList(recipient, file) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_FILE, "put to recv files failed. sessionId=%{public}u", recipient->sessionId);
|
||||
goto EXIT_ERR;
|
||||
|
@ -34,6 +34,7 @@ typedef struct {
|
||||
SeqVerifyInfo verifyInfo;
|
||||
char sessionKey[SESSION_KEY_LENGTH];
|
||||
char myIp[IP_LEN];
|
||||
SoftBusMutex fdLock;
|
||||
SoftBusList *pendingPacketsList;
|
||||
} TcpDirectChannelDetail;
|
||||
|
||||
|
@ -150,6 +150,7 @@ void TransTdcCloseChannel(int32_t channelId)
|
||||
if (item->channelId == channelId) {
|
||||
TransTdcReleaseFd(item->detail.fd);
|
||||
ListDelete(&item->node);
|
||||
SoftBusMutexDestroy(&(item->detail.fdLock));
|
||||
SoftBusFree(item);
|
||||
item = NULL;
|
||||
(void)SoftBusMutexUnlock(&g_tcpDirectChannelInfoList->lock);
|
||||
@ -177,6 +178,11 @@ static TcpDirectChannelInfo *TransGetNewTcpChannel(const ChannelInfo *channel)
|
||||
item->channelId = channel->channelId;
|
||||
item->detail.fd = channel->fd;
|
||||
item->detail.channelType = channel->channelType;
|
||||
if (SoftBusMutexInit(&(item->detail.fdLock), NULL) != SOFTBUS_OK) {
|
||||
SoftBusFree(item);
|
||||
TRANS_LOGE(TRANS_SDK, "init fd lock failed");
|
||||
return NULL;
|
||||
}
|
||||
if (memcpy_s(item->detail.sessionKey, SESSION_KEY_LENGTH, channel->sessionKey, SESSION_KEY_LENGTH) != EOK) {
|
||||
SoftBusFree(item);
|
||||
TRANS_LOGE(TRANS_SDK, "sessionKey copy failed");
|
||||
@ -226,6 +232,7 @@ static void TransTdcDelChannelInfo(int32_t channelId)
|
||||
if (item->channelId == channelId) {
|
||||
TransTdcReleaseFd(item->detail.fd);
|
||||
ListDelete(&item->node);
|
||||
SoftBusMutexDestroy(&(item->detail.fdLock));
|
||||
SoftBusFree(item);
|
||||
item = NULL;
|
||||
(void)SoftBusMutexUnlock(&g_tcpDirectChannelInfoList->lock);
|
||||
|
@ -177,10 +177,7 @@ static int32_t TransTdcProcessPostData(const TcpDirectChannelInfo *channel, cons
|
||||
{
|
||||
uint32_t outLen = 0;
|
||||
char *buf = TransTdcPackData(channel, data, len, flags, &outLen);
|
||||
if (buf == NULL) {
|
||||
TRANS_LOGE(TRANS_SDK, "failed to pack bytes.");
|
||||
return SOFTBUS_ENCRYPT_ERR;
|
||||
}
|
||||
TRANS_CHECK_AND_RETURN_RET_LOGE(buf != NULL, SOFTBUS_ENCRYPT_ERR, TRANS_SDK, "failed to pack bytes.");
|
||||
if (outLen != len + OVERHEAD_LEN) {
|
||||
TRANS_LOGE(TRANS_SDK, "pack bytes len error, outLen=%{public}d", outLen);
|
||||
SoftBusFree(buf);
|
||||
@ -201,12 +198,26 @@ static int32_t TransTdcProcessPostData(const TcpDirectChannelInfo *channel, cons
|
||||
SoftBusFree(buf);
|
||||
return SOFTBUS_TCP_SOCKET_ERR;
|
||||
}
|
||||
TcpDirectChannelInfo info;
|
||||
(void)memset_s(&info, sizeof(TcpDirectChannelInfo), 0, sizeof(TcpDirectChannelInfo));
|
||||
if (TransTdcGetInfoById(channel->channelId, &info) == NULL) {
|
||||
TRANS_LOGE(TRANS_SDK, "get channel fd lock fail. channelId=%{public}d", channel->channelId);
|
||||
SoftBusFree(buf);
|
||||
return SOFTBUS_TRANS_TDC_CHANNEL_NOT_FOUND;
|
||||
}
|
||||
if (SoftBusMutexLock(&(info.detail.fdLock)) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "failed to lock fd. channelId=%{public}d", channel->channelId);
|
||||
SoftBusFree(buf);
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
ssize_t ret = ConnSendSocketData(channel->detail.fd, buf, outLen + DC_DATA_HEAD_SIZE, 0);
|
||||
if (ret != (ssize_t)outLen + DC_DATA_HEAD_SIZE) {
|
||||
TRANS_LOGE(TRANS_SDK, "failed to send tcp data. ret=%{public}zd", ret);
|
||||
SoftBusFree(buf);
|
||||
(void)SoftBusMutexUnlock(&(info.detail.fdLock));
|
||||
return SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT;
|
||||
}
|
||||
(void)SoftBusMutexUnlock(&(info.detail.fdLock));
|
||||
SoftBusFree(buf);
|
||||
buf = NULL;
|
||||
return SOFTBUS_OK;
|
||||
|
@ -368,24 +368,27 @@ static int32_t RleaseUdpResources(int32_t channelId)
|
||||
return ServerIpcReleaseResources(channelId);
|
||||
}
|
||||
|
||||
static int32_t CloseUdpChannel(int32_t channelId, ShutdownReason reason)
|
||||
static void NotifyCb(UdpChannel *channel, int32_t channelId, ShutdownReason reason)
|
||||
{
|
||||
UdpChannel channel;
|
||||
(void)memset_s(&channel, sizeof(UdpChannel), 0, sizeof(UdpChannel));
|
||||
TRANS_LOGI(TRANS_SDK, "close udp channelId=%{public}d.", channelId);
|
||||
if (TransGetUdpChannel(channelId, &channel) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "get udp channel by channelId=%{public}d failed.", channelId);
|
||||
return SOFTBUS_TRANS_UDP_GET_CHANNEL_FAILED;
|
||||
}
|
||||
if (channel.businessType == BUSINESS_TYPE_FILE) {
|
||||
TRANS_LOGD(TRANS_SDK, "close udp channel get file list start");
|
||||
int32_t ret = NSTACKX_DFileSessionGetFileList(channel.dfileId);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "close udp channel to get file list failed. channelId=%{public}d, ret=%{public}d",
|
||||
channelId, ret);
|
||||
if (channel != NULL && (!channel->isEnable) && g_sessionCb != NULL && g_sessionCb->OnSessionOpenFailed != NULL) {
|
||||
SessionState sessionState = SESSION_STATE_INIT;
|
||||
if (ClientGetSessionStateByChannelId(channelId, CHANNEL_TYPE_UDP, &sessionState) == SOFTBUS_OK &&
|
||||
(sessionState == SESSION_STATE_OPENED || sessionState == SESSION_STATE_CALLBACK_FINISHED)) {
|
||||
if (ClosePeerUdpChannel(channelId) != SOFTBUS_OK) {
|
||||
TRANS_LOGW(TRANS_SDK, "trans close peer udp channel failed. channelId=%{public}d", channelId);
|
||||
}
|
||||
}
|
||||
g_sessionCb->OnSessionOpenFailed(channelId, CHANNEL_TYPE_UDP, SOFTBUS_TRANS_STOP_BIND_BY_TIMEOUT);
|
||||
return;
|
||||
}
|
||||
if (g_sessionCb != NULL && g_sessionCb->OnSessionClosed != NULL) {
|
||||
g_sessionCb->OnSessionClosed(channelId, CHANNEL_TYPE_UDP, reason);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t CloseUdpChannelProc(UdpChannel *channel, int32_t channelId, ShutdownReason reason)
|
||||
{
|
||||
if (TransDeleteUdpChannel(channelId) != SOFTBUS_OK) {
|
||||
TRANS_LOGW(TRANS_SDK, "trans del udp channel failed. channelId=%{public}d", channelId);
|
||||
}
|
||||
@ -410,20 +413,41 @@ static int32_t CloseUdpChannel(int32_t channelId, ShutdownReason reason)
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t ret = TransDeleteBusinnessChannel(&channel);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "CloseUdpChannel del business channel failed. channelId=%{public}d", channelId);
|
||||
return ret;
|
||||
if (channel != NULL) {
|
||||
int32_t ret = TransDeleteBusinnessChannel(channel);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "del business channel failed. channelId=%{public}d", channelId);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (reason != SHUTDOWN_REASON_LOCAL) {
|
||||
if (g_sessionCb != NULL && g_sessionCb->OnSessionClosed != NULL) {
|
||||
g_sessionCb->OnSessionClosed(channelId, CHANNEL_TYPE_UDP, reason);
|
||||
}
|
||||
NotifyCb(channel, channelId, reason);
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t CloseUdpChannel(int32_t channelId, ShutdownReason reason)
|
||||
{
|
||||
UdpChannel channel;
|
||||
(void)memset_s(&channel, sizeof(UdpChannel), 0, sizeof(UdpChannel));
|
||||
TRANS_LOGI(TRANS_SDK, "close udp channelId=%{public}d, reason=%{public}d", channelId, reason);
|
||||
if (TransGetUdpChannel(channelId, &channel) != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "get udp channel by channelId=%{public}d failed.", channelId);
|
||||
CloseUdpChannelProc(NULL, channelId, reason);
|
||||
return SOFTBUS_TRANS_UDP_GET_CHANNEL_FAILED;
|
||||
}
|
||||
if (channel.businessType == BUSINESS_TYPE_FILE) {
|
||||
TRANS_LOGD(TRANS_SDK, "close udp channel get file list start");
|
||||
int32_t ret = NSTACKX_DFileSessionGetFileList(channel.dfileId);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
TRANS_LOGE(TRANS_SDK, "close udp channel to get file list failed. channelId=%{public}d, ret=%{public}d",
|
||||
channelId, ret);
|
||||
}
|
||||
}
|
||||
return CloseUdpChannelProc(&channel, channelId, reason);
|
||||
}
|
||||
|
||||
int32_t TransOnUdpChannelClosed(int32_t channelId, ShutdownReason reason)
|
||||
{
|
||||
return CloseUdpChannel(channelId, reason);
|
||||
|
@ -435,7 +435,7 @@ static int32_t UpdateFileRecvPath(int32_t channelId, FileListener *fileListener,
|
||||
char *absPath = realpath(rootDir, NULL);
|
||||
if (absPath == NULL) {
|
||||
TRANS_LOGE(TRANS_SDK,
|
||||
"rootDir not exist, rootDir=%{public}s, errno=%{public}d.",
|
||||
"rootDir not exist, rootDir=%{private}s, errno=%{public}d.",
|
||||
(rootDir == NULL ? "null" : rootDir), errno);
|
||||
return SOFTBUS_FILE_ERR;
|
||||
}
|
||||
@ -450,7 +450,7 @@ static int32_t UpdateFileRecvPath(int32_t channelId, FileListener *fileListener,
|
||||
|
||||
if (NSTACKX_DFileSetStoragePath(fileSession, fileListener->rootDir) != SOFTBUS_OK) {
|
||||
NSTACKX_DFileClose(fileSession);
|
||||
TRANS_LOGE(TRANS_SDK, "set storage path failed. rootDir=%{public}s", fileListener->rootDir);
|
||||
TRANS_LOGE(TRANS_SDK, "set storage path failed. rootDir=%{private}s", fileListener->rootDir);
|
||||
return SOFTBUS_FILE_ERR;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -68,6 +68,7 @@ int32_t StartVtpStreamChannelClient(int32_t channelId, const VtpStreamOpenParam
|
||||
const IStreamListener *callback);
|
||||
int32_t SendVtpStream(int32_t channelId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
|
||||
int32_t CloseVtpStreamChannel(int32_t channelId, const char *pkgName);
|
||||
int32_t SetVtpStreamMultiLayerOpt(int32_t channelId, const void *optValue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
@ -143,6 +143,25 @@ int32_t SendVtpStream(int32_t channelId, const StreamData *inData, const StreamD
|
||||
return adaptor->GetStreamManager()->Send(std::move(stream)) ? SOFTBUS_OK : SOFTBUS_TRANS_MAKE_STREAM_FAILED;
|
||||
}
|
||||
|
||||
int32_t SetVtpStreamMultiLayerOpt(int32_t channelId, const void *optValue)
|
||||
{
|
||||
if (optValue == nullptr) {
|
||||
TRANS_LOGE(TRANS_STREAM, "invalid argument optValue");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
std::shared_ptr<StreamAdaptor> adaptor = nullptr;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(g_mutex);
|
||||
auto it = g_adaptorMap.find(channelId);
|
||||
if (it == g_adaptorMap.end()) {
|
||||
TRANS_LOGE(TRANS_STREAM, "channelId %{public}u adaptor not existed!", channelId);
|
||||
return SOFTBUS_TRANS_ADAPTOR_NOT_EXISTED;
|
||||
}
|
||||
adaptor = it->second;
|
||||
}
|
||||
return adaptor->GetStreamManager()->SetMultiLayer(optValue);
|
||||
}
|
||||
|
||||
int32_t StartVtpStreamChannelServer(int32_t channelId, const VtpStreamOpenParam *param, const IStreamListener *callback)
|
||||
{
|
||||
if (channelId < 0 || param == nullptr || param->pkgName == nullptr || callback == nullptr) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -34,6 +34,8 @@ int32_t TransOnstreamChannelOpened(const ChannelInfo *channel, int32_t *streamPo
|
||||
int32_t TransCloseStreamChannel(int32_t channelId);
|
||||
|
||||
int32_t TransSendStream(int32_t channelId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
|
||||
|
||||
int32_t TransSetStreamMultiLayer(int32_t channelId, const void *optValue);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -75,6 +75,7 @@ public:
|
||||
virtual bool Send(std::unique_ptr<IStream> stream) = 0;
|
||||
|
||||
virtual bool SetOption(int type, const StreamAttr &value) = 0;
|
||||
virtual int32_t SetMultiLayer(const void *para) = 0;
|
||||
virtual StreamAttr GetOption(int type) const = 0;
|
||||
|
||||
virtual bool SetStreamListener(std::shared_ptr<IStreamSocketListener> receiver) = 0;
|
||||
@ -90,7 +91,7 @@ protected:
|
||||
static constexpr int DEFAULT_UDP_BUFFER_RCV_SIZE = 1024 * 1024;
|
||||
static constexpr int STREAM_BUFFER_THRESHOLD = 5;
|
||||
|
||||
virtual int CreateAndBindSocket(IpAndPort &local) = 0;
|
||||
virtual int CreateAndBindSocket(IpAndPort &local, bool isServer) = 0;
|
||||
virtual bool Accept() = 0;
|
||||
|
||||
virtual int EpollTimeout(int fd, int timeout) = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -64,6 +64,7 @@ public:
|
||||
virtual bool Send(std::unique_ptr<IStream>) = 0;
|
||||
|
||||
virtual bool SetOption(int type, const StreamAttr &value) = 0;
|
||||
virtual int32_t SetMultiLayer(const void *para) = 0;
|
||||
virtual StreamAttr GetOption(int type) const = 0;
|
||||
|
||||
virtual void SetStreamRecvListener(std::shared_ptr<IStreamManagerListener> recvListener) = 0;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user