mirror of
https://gitee.com/openharmony/communication_dsoftbus
synced 2025-02-17 09:37:45 +00:00
modify MTU
Signed-off-by: bingo <wangbaoguang@huawei.com>
This commit is contained in:
parent
380104f02d
commit
4a954bc05e
@ -25,6 +25,8 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef enum {
|
||||
SOFTBUS_INT_MAX_BYTES_NEW_LENGTH, /* the default val is 4194304 */
|
||||
SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH, /* the default val is 4194304 */
|
||||
SOFTBUS_INT_MAX_BYTES_LENGTH, /* the default val is 4194304 */
|
||||
SOFTBUS_INT_MAX_MESSAGE_LENGTH, /* the default val is 4096 */
|
||||
SOFTBUS_INT_CONN_BR_MAX_DATA_LENGTH, /* the default val is 4096 */
|
||||
|
@ -41,6 +41,8 @@ extern "C" {
|
||||
|
||||
#define INVALID_SESSION_ID (-1)
|
||||
#define INVALID_CHANNEL_ID (-1)
|
||||
#define INVALID_ROUTE_TYPE (-1)
|
||||
#define INVALID_DATA_CONFIG (0)
|
||||
#define INVALID_SEQ_ID (0x7fffffff)
|
||||
|
||||
#define PKG_NAME_SIZE_MAX 65
|
||||
@ -159,6 +161,7 @@ typedef struct {
|
||||
int64_t timeStart;
|
||||
int32_t linkType;
|
||||
bool isFastData;
|
||||
uint32_t dataConfig;
|
||||
} ChannelInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -61,6 +61,8 @@
|
||||
#define DEFAULT_DISC_FREQ_SUPER_HIGH ((10 << 16) | 48)
|
||||
|
||||
#ifdef SOFTBUS_STANDARD_SYSTEM
|
||||
#define DEFAULT_NEW_BYTES_LEN (4 * 1024 * 1024)
|
||||
#define DEFAULT_NEW_MESSAGE_LEN (4 * 1024)
|
||||
#define DEFAULT_MAX_BYTES_LEN (4 * 1024 * 1024)
|
||||
#define DEFAULT_MAX_MESSAGE_LEN (4 * 1024)
|
||||
#define DEFAULT_AUTH_MAX_BYTES_LEN (40000 - 8)
|
||||
@ -69,6 +71,8 @@
|
||||
#define DEFAULT_PROXY_MAX_MESSAGE_LEN (1 * 1024)
|
||||
#define DEFAULT_IS_SUPPORT_TCP_PROXY 1
|
||||
#elif defined SOFTBUS_SMALL_SYSTEM
|
||||
#define DEFAULT_NEW_BYTES_LEN (1 * 1024 * 1024)
|
||||
#define DEFAULT_NEW_MESSAGE_LEN (4 * 1024)
|
||||
#define DEFAULT_MAX_BYTES_LEN (1 * 1024 * 1024)
|
||||
#define DEFAULT_MAX_MESSAGE_LEN (4 * 1024)
|
||||
#define DEFAULT_AUTH_MAX_BYTES_LEN (4 * 1024)
|
||||
@ -77,6 +81,8 @@
|
||||
#define DEFAULT_PROXY_MAX_MESSAGE_LEN (1 * 1024)
|
||||
#define DEFAULT_IS_SUPPORT_TCP_PROXY 1
|
||||
#else
|
||||
#define DEFAULT_NEW_BYTES_LEN (4 * 1024)
|
||||
#define DEFAULT_NEW_MESSAGE_LEN (4 * 1024)
|
||||
#define DEFAULT_MAX_BYTES_LEN (2 * 1024)
|
||||
#define DEFAULT_MAX_MESSAGE_LEN (1 * 1024)
|
||||
#define DEFAULT_AUTH_MAX_BYTES_LEN (2 * 1024)
|
||||
@ -140,6 +146,8 @@ ConfigItem g_config = {
|
||||
|
||||
typedef struct {
|
||||
int32_t isSupportTcpProxy;
|
||||
int32_t maxBytesNewLen;
|
||||
int32_t maxMessageNewLen;
|
||||
int32_t maxBytesLen;
|
||||
int32_t maxMessageLen;
|
||||
int32_t maxAuthBytesLen;
|
||||
@ -164,6 +172,16 @@ static DiscConfigItem g_discConfig = {
|
||||
};
|
||||
|
||||
ConfigVal g_configItems[SOFTBUS_CONFIG_TYPE_MAX] = {
|
||||
{
|
||||
SOFTBUS_INT_MAX_BYTES_NEW_LENGTH,
|
||||
(unsigned char *)&(g_tranConfig.maxBytesNewLen),
|
||||
sizeof(g_tranConfig.maxBytesNewLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH,
|
||||
(unsigned char *)&(g_tranConfig.maxMessageNewLen),
|
||||
sizeof(g_tranConfig.maxMessageNewLen)
|
||||
},
|
||||
{
|
||||
SOFTBUS_INT_MAX_BYTES_LENGTH,
|
||||
(unsigned char *)&(g_tranConfig.maxBytesLen),
|
||||
@ -333,6 +351,8 @@ int SoftbusGetConfig(ConfigType type, unsigned char *val, uint32_t len)
|
||||
static void SoftbusConfigSetTransDefaultVal(void)
|
||||
{
|
||||
g_tranConfig.isSupportTcpProxy = DEFAULT_IS_SUPPORT_TCP_PROXY;
|
||||
g_tranConfig.maxBytesNewLen = DEFAULT_NEW_BYTES_LEN;
|
||||
g_tranConfig.maxMessageNewLen = DEFAULT_NEW_MESSAGE_LEN;
|
||||
g_tranConfig.maxBytesLen = DEFAULT_MAX_BYTES_LEN;
|
||||
g_tranConfig.maxMessageLen = DEFAULT_MAX_MESSAGE_LEN;
|
||||
g_tranConfig.maxAuthBytesLen = DEFAULT_AUTH_MAX_BYTES_LEN;
|
||||
|
@ -82,6 +82,7 @@ typedef struct {
|
||||
char addr[IP_LEN];
|
||||
int port;
|
||||
int64_t channelId;
|
||||
uint32_t dataConfig;
|
||||
} AppInfoData;
|
||||
|
||||
typedef struct {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#define UID "UID"
|
||||
#define PID "PID"
|
||||
#define SESSION_KEY "SESSION_KEY"
|
||||
#define MTU_SIZE "MTU_SIZE"
|
||||
#define PKG_NAME "PKG_NAME"
|
||||
#define CLIENT_BUS_NAME "CLIENT_BUS_NAME"
|
||||
#define AUTH_STATE "AUTH_STATE"
|
||||
|
@ -130,7 +130,8 @@ char *PackRequest(const AppInfo *appInfo)
|
||||
!AddStringToJsonObject(json, GROUP_ID, appInfo->groupId) ||
|
||||
!AddNumberToJsonObject(json, UID, appInfo->myData.uid) ||
|
||||
!AddNumberToJsonObject(json, PID, appInfo->myData.pid) ||
|
||||
!AddStringToJsonObject(json, SESSION_KEY, (char*)encodeSessionKey)) {
|
||||
!AddStringToJsonObject(json, SESSION_KEY, (char*)encodeSessionKey) ||
|
||||
!AddNumberToJsonObject(json, MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
@ -213,6 +214,9 @@ int UnpackRequest(const cJSON *msg, AppInfo *appInfo)
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Failed to get BUS_NAME");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (!GetJsonObjectNumberItem(msg, MTU_SIZE, (int32_t *)&(appInfo->peerData.dataConfig))) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "peer dataconfig is null.");
|
||||
}
|
||||
appInfo->peerData.apiVersion = (ApiVersion)apiVersion;
|
||||
appInfo->peerData.uid = -1;
|
||||
appInfo->peerData.pid = -1;
|
||||
@ -279,6 +283,12 @@ NO_SANITIZE("cfi") char *PackReply(const AppInfo *appInfo)
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
if (!AddNumberToJsonObject(json, MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!AddNumber16ToJsonObject(json, FIRST_DATA_SIZE, appInfo->fastTransDataSize)) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Failed to add trans data size");
|
||||
return NULL;
|
||||
@ -334,7 +344,9 @@ int UnpackReply(const cJSON *msg, AppInfo *appInfo, uint16_t *fastDataSize)
|
||||
appInfo->myHandleId = -1;
|
||||
appInfo->peerHandleId = -1;
|
||||
}
|
||||
|
||||
if (!GetJsonObjectNumberItem(msg, MTU_SIZE, (int32_t *)&(appInfo->peerData.dataConfig))) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "peer dataconfig is null.");
|
||||
}
|
||||
if (apiVersion != API_V1) {
|
||||
if (!GetJsonObjectStringItem(msg, PKG_NAME, (appInfo->peerData.pkgName), PKG_NAME_SIZE_MAX) ||
|
||||
!GetJsonObjectStringItem(msg, AUTH_STATE, (appInfo->peerData.authState), AUTH_STATE_SIZE_MAX)) {
|
||||
|
@ -135,6 +135,10 @@ int32_t TransClientProxy::OnChannelOpened(const char *sessionName, const Channel
|
||||
data.WriteInt32(channel->encrypt);
|
||||
data.WriteInt32(channel->algorithm);
|
||||
data.WriteInt32(channel->crc);
|
||||
if (!data.WriteUint32(channel->dataConfig)) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "write data config failed");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "softbus_conn_interface.h"
|
||||
#include "softbus_def.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_feature_config.h"
|
||||
#include "softbus_hisysevt_transreporter.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_proxychannel_manager.h"
|
||||
@ -52,6 +53,12 @@ static int32_t g_allocProxyChannelId = MAX_FD_ID;
|
||||
static int32_t g_allocTdcChannelId = MAX_PROXY_CHANNEL_ID;
|
||||
static SoftBusMutex g_myIdLock;
|
||||
|
||||
typedef struct {
|
||||
int32_t channelType;
|
||||
int32_t businessType;
|
||||
ConfigType configType;
|
||||
} ConfigTypeMap;
|
||||
|
||||
static int32_t GenerateTdcChannelId()
|
||||
{
|
||||
int32_t channelId;
|
||||
@ -316,12 +323,48 @@ static int32_t TransOpenChannelProc(ChannelType type, AppInfo *appInfo, const Co
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static const ConfigTypeMap g_configTypeMap[] = {
|
||||
{CHANNEL_TYPE_PROXY, BUSINESS_TYPE_BYTE, SOFTBUS_INT_MAX_BYTES_NEW_LENGTH},
|
||||
{CHANNEL_TYPE_PROXY, BUSINESS_TYPE_MESSAGE, SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH},
|
||||
{CHANNEL_TYPE_TCP_DIRECT, BUSINESS_TYPE_BYTE, SOFTBUS_INT_MAX_BYTES_NEW_LENGTH},
|
||||
{CHANNEL_TYPE_TCP_DIRECT, BUSINESS_TYPE_MESSAGE, SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH},
|
||||
};
|
||||
|
||||
static int32_t FindConfigType(int32_t channelType, int32_t businessType)
|
||||
{
|
||||
for (uint32_t i = 0; i < sizeof(g_configTypeMap) / sizeof(ConfigTypeMap); i++) {
|
||||
if ((g_configTypeMap[i].channelType == channelType) && (g_configTypeMap[i].businessType == businessType)) {
|
||||
return g_configTypeMap[i].configType;
|
||||
}
|
||||
}
|
||||
return SOFTBUS_CONFIG_TYPE_MAX;
|
||||
}
|
||||
|
||||
static int TransGetLocalConfig(int32_t channelType, int32_t businessType, uint32_t len)
|
||||
{
|
||||
ConfigType configType = (ConfigType)FindConfigType(channelType, businessType);
|
||||
if (configType == SOFTBUS_CONFIG_TYPE_MAX) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Invalid channelType[%d] businessType[%d]",
|
||||
channelType, businessType);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
uint32_t maxLen;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&maxLen, sizeof(maxLen)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get fail configType[%d]", configType);
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
len = maxLen;
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "get appinfo local config[%d]", len);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi") static void FillAppInfo(AppInfo *appInfo, ConnectOption *connOpt, const SessionParam *param,
|
||||
TransInfo *transInfo, LaneConnInfo *connInfo)
|
||||
{
|
||||
transInfo->channelType = TransGetChannelType(param, connInfo);
|
||||
appInfo->linkType = connInfo->type;
|
||||
appInfo->channelType = transInfo->channelType;
|
||||
(void)TransGetLocalConfig(appInfo->channelType, appInfo->businessType, appInfo->myData.dataConfig);
|
||||
}
|
||||
|
||||
static void TransOpenChannelSetModule(int32_t channelType, ConnectOption *connOpt)
|
||||
|
@ -28,6 +28,8 @@ extern "C" {
|
||||
#define FAST_EXT_BYTE_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead) + sizeof(SessionHead))
|
||||
#define FAST_EXT_MSG_SIZE (OVERHEAD_LEN + sizeof(PacketFastHead) + sizeof(SliceFastHead))
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
int32_t TransProxyManagerInit(const IServerChannelCallBack *cb);
|
||||
void TransProxyManagerDeinit(void);
|
||||
|
||||
|
@ -41,6 +41,7 @@ typedef enum {
|
||||
#define JSON_KEY_TYPE "TYPE"
|
||||
#define JSON_KEY_IDENTITY "IDENTITY"
|
||||
#define JSON_KEY_DEVICE_ID "DEVICE_ID"
|
||||
#define JSON_KEY_MTU_SIZE "MTU_SIZE"
|
||||
#define JSON_KEY_DST_BUS_NAME "DST_BUS_NAME"
|
||||
#define JSON_KEY_SRC_BUS_NAME "SRC_BUS_NAME"
|
||||
#define JSON_KEY_HAS_PRIORITY "HAS_PRIORITY"
|
||||
|
@ -70,6 +70,7 @@ static int32_t NotifyNormalChannelOpened(int32_t channelId, const AppInfo *appIn
|
||||
info.myHandleId = appInfo->myHandleId;
|
||||
info.peerHandleId = appInfo->peerHandleId;
|
||||
info.linkType = appInfo->linkType;
|
||||
info.dataConfig = appInfo->myData.dataConfig;
|
||||
if (appInfo->appType == APP_TYPE_AUTH) {
|
||||
info.reqId = (char*)appInfo->reqId;
|
||||
}
|
||||
|
@ -56,6 +56,12 @@
|
||||
#define PROXY_CHANNEL_SERVER 1
|
||||
static SoftBusList *g_proxyChannelList = NULL;
|
||||
|
||||
typedef struct {
|
||||
int32_t channelType;
|
||||
int32_t businessType;
|
||||
ConfigType configType;
|
||||
} ConfigTypeMap;
|
||||
|
||||
static int32_t ChanIsEqual(ProxyChannelInfo *a, ProxyChannelInfo *b)
|
||||
{
|
||||
if ((a->myId == b->myId) &&
|
||||
@ -124,6 +130,7 @@ static int32_t TransProxyUpdateAckInfo(ProxyChannelInfo *info)
|
||||
item->appInfo.encrypt = info->appInfo.encrypt;
|
||||
item->appInfo.algorithm = info->appInfo.algorithm;
|
||||
item->appInfo.crc = info->appInfo.crc;
|
||||
item->appInfo.myData.dataConfig = info->appInfo.myData.dataConfig;
|
||||
item->appInfo.peerHandleId = info->appInfo.peerHandleId;
|
||||
(void)memcpy_s(&(item->appInfo.peerData), sizeof(item->appInfo.peerData),
|
||||
&(info->appInfo.peerData), sizeof(info->appInfo.peerData));
|
||||
@ -601,7 +608,7 @@ static inline void TransProxyProcessErrMsg(ProxyChannelInfo *info, int32_t errCo
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t TransProxyGetPeerDataInfo(int16_t myId, AppInfoData *peerDataInfo)
|
||||
static int32_t TransProxyGetPeerDataInfo(int16_t myId, AppInfo *appInfo)
|
||||
{
|
||||
ProxyChannelInfo *item = NULL;
|
||||
|
||||
@ -616,7 +623,9 @@ static int32_t TransProxyGetPeerDataInfo(int16_t myId, AppInfoData *peerDataInfo
|
||||
|
||||
LIST_FOR_EACH_ENTRY(item, &g_proxyChannelList->list, ProxyChannelInfo, node) {
|
||||
if (item->myId == myId) {
|
||||
(void)memcpy_s(peerDataInfo, sizeof(AppInfoData), &(item->appInfo.peerData), sizeof(item->appInfo.peerData));
|
||||
(void)memcpy_s(&(appInfo->peerData), sizeof(AppInfoData),
|
||||
&(item->appInfo.peerData), sizeof(item->appInfo.peerData));
|
||||
appInfo->businessType = item->appInfo.businessType;
|
||||
(void)SoftBusMutexUnlock(&g_proxyChannelList->lock);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
@ -625,6 +634,65 @@ static int32_t TransProxyGetPeerDataInfo(int16_t myId, AppInfoData *peerDataInfo
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
static const ConfigTypeMap g_configTypeMap[] = {
|
||||
{CHANNEL_TYPE_PROXY, BUSINESS_TYPE_BYTE, SOFTBUS_INT_MAX_BYTES_NEW_LENGTH},
|
||||
{CHANNEL_TYPE_PROXY, BUSINESS_TYPE_MESSAGE, SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH},
|
||||
};
|
||||
|
||||
static int32_t FindConfigType(int32_t channelType, int32_t businessType)
|
||||
{
|
||||
for (uint32_t i = 0; i < sizeof(g_configTypeMap) / sizeof(ConfigTypeMap); i++) {
|
||||
if ((g_configTypeMap[i].channelType == channelType) && (g_configTypeMap[i].businessType == businessType)) {
|
||||
return g_configTypeMap[i].configType;
|
||||
}
|
||||
}
|
||||
return SOFTBUS_CONFIG_TYPE_MAX;
|
||||
}
|
||||
|
||||
static int TransGetLocalConfig(int32_t channelType, int32_t businessType, uint32_t len)
|
||||
{
|
||||
ConfigType configType = (ConfigType)FindConfigType(channelType, businessType);
|
||||
if (configType == SOFTBUS_CONFIG_TYPE_MAX) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Invalid channelType[%d] businessType[%d]",
|
||||
channelType, businessType);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
uint32_t maxLen;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&maxLen, sizeof(maxLen)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get fail configType[%d]", configType);
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
len = maxLen;
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "get local config[%u]", len);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t TransProxyProcessDataConfig(AppInfo *appInfo)
|
||||
{
|
||||
if (appInfo == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "appInfo is null");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (appInfo->businessType != BUSINESS_TYPE_MESSAGE && appInfo->businessType != BUSINESS_TYPE_BYTE) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "invalid businessType[%d]", appInfo->businessType);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
appInfo->myData.dataConfig = MIN(appInfo->myData.dataConfig, appInfo->peerData.dataConfig);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "process dataConfig[%u] succ", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ConfigType configType = appInfo->businessType == BUSINESS_TYPE_BYTE ?
|
||||
SOFTBUS_INT_PROXY_MAX_BYTES_LENGTH : SOFTBUS_INT_PROXY_MAX_MESSAGE_LENGTH;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&appInfo->myData.dataConfig,
|
||||
sizeof(appInfo->myData.dataConfig)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType[%d]", configType);
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "process data config value[%d]", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi") void TransProxyProcessHandshakeAckMsg(const ProxyMessage *msg)
|
||||
{
|
||||
ProxyChannelInfo *info = (ProxyChannelInfo *)SoftBusCalloc(sizeof(ProxyChannelInfo));
|
||||
@ -634,7 +702,7 @@ NO_SANITIZE("cfi") void TransProxyProcessHandshakeAckMsg(const ProxyMessage *msg
|
||||
info->myId = msg->msgHead.myId;
|
||||
info->peerId = msg->msgHead.peerId;
|
||||
|
||||
if (TransProxyGetPeerDataInfo(info->myId, &(info->appInfo.peerData)) != SOFTBUS_OK) {
|
||||
if (TransProxyGetPeerDataInfo(info->myId, &(info->appInfo)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "fail to get peer data info");
|
||||
SoftBusFree(info);
|
||||
return;
|
||||
@ -656,6 +724,12 @@ NO_SANITIZE("cfi") void TransProxyProcessHandshakeAckMsg(const ProxyMessage *msg
|
||||
"recv Handshake ack myid %d peerid %d identity %s crc %d",
|
||||
info->myId, info->peerId, info->identity, info->appInfo.crc);
|
||||
|
||||
if (TransProxyProcessDataConfig(&info->appInfo) != SOFTBUS_OK) {
|
||||
SoftBusFree(info);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ProcessDataConfig fail");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TransProxyUpdateAckInfo(info) != SOFTBUS_OK) {
|
||||
SoftBusFree(info);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "UpdateAckInfo fail");
|
||||
@ -743,6 +817,39 @@ static void ConstructProxyChannelInfo(
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t TransProxyFillDataConfig(AppInfo *appInfo)
|
||||
{
|
||||
if (appInfo == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "appInfo is null");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (appInfo->businessType != BUSINESS_TYPE_MESSAGE && appInfo->businessType != BUSINESS_TYPE_BYTE) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "invalid businessType[%d]", appInfo->businessType);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
uint32_t localDataConfig = 0;
|
||||
if (SoftbusGetLocalConfig(CHANNEL_TYPE_PROXY, appInfo->businessType, localDataConfig) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get local config failed, businessType[%d]",
|
||||
appInfo->businessType);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
appInfo->myData.dataConfig = MIN(localDataConfig, appInfo->peerData.dataConfig);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "fill dataConfig[%u] succ", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ConfigType configType = appInfo->businessType == BUSINESS_TYPE_BYTE ?
|
||||
SOFTBUS_INT_PROXY_MAX_BYTES_LENGTH : SOFTBUS_INT_PROXY_MAX_MESSAGE_LENGTH;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&appInfo->myData.dataConfig,
|
||||
sizeof(appInfo->myData.dataConfig)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType[%d]", configType);
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "fill data config value[%d]", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t TransProxyFillChannelInfo(const ProxyMessage *msg, ProxyChannelInfo *chan)
|
||||
{
|
||||
int32_t ret = TransProxyUnpackHandshakeMsg(msg->data, chan, msg->dateLen);
|
||||
@ -778,6 +885,11 @@ static int32_t TransProxyFillChannelInfo(const ProxyMessage *msg, ProxyChannelIn
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = TransProxyFillDataConfig(&chan->appInfo);
|
||||
if (ret != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "fill dataConfig fail.");
|
||||
return ret;
|
||||
}
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,8 @@ NO_SANITIZE("cfi") char *TransProxyPackHandshakeMsg(ProxyChannelInfo *info)
|
||||
!AddStringToJsonObject(root, JSON_KEY_IDENTITY, info->identity) ||
|
||||
!AddStringToJsonObject(root, JSON_KEY_DEVICE_ID, appInfo->myData.deviceId) ||
|
||||
!AddStringToJsonObject(root, JSON_KEY_SRC_BUS_NAME, appInfo->myData.sessionName) ||
|
||||
!AddStringToJsonObject(root, JSON_KEY_DST_BUS_NAME, appInfo->peerData.sessionName)) {
|
||||
!AddStringToJsonObject(root, JSON_KEY_DST_BUS_NAME, appInfo->peerData.sessionName) ||
|
||||
!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
goto EXIT;
|
||||
}
|
||||
(void)cJSON_AddTrueToObject(root, JSON_KEY_HAS_PRIORITY);
|
||||
@ -488,6 +489,12 @@ NO_SANITIZE("cfi") char *TransProxyPackHandshakeAckMsg(ProxyChannelInfo *chan)
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
if (!AddNumberToJsonObject(root, JSON_KEY_MTU_SIZE, appInfo->myData.dataConfig)) {
|
||||
cJSON_Delete(root);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
(void)cJSON_AddTrueToObject(root, JSON_KEY_HAS_PRIORITY);
|
||||
if (appInfo->appType == APP_TYPE_NORMAL) {
|
||||
if (!AddNumberToJsonObject(root, JSON_KEY_UID, appInfo->myData.uid) ||
|
||||
@ -552,6 +559,9 @@ NO_SANITIZE("cfi") int32_t TransProxyUnpackHandshakeAckMsg(const char *msg, Prox
|
||||
cJSON_Delete(root);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (!GetJsonObjectNumberItem(root, JSON_KEY_MTU_SIZE, (int32_t *)&(appInfo->peerData.dataConfig))) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "peer dataconfig is null.");
|
||||
}
|
||||
appInfo->encrypt = APP_INFO_FILE_FEATURES_SUPPORT;
|
||||
appInfo->algorithm = APP_INFO_ALGORITHM_AES_GCM_256;
|
||||
appInfo->crc = APP_INFO_FILE_FEATURES_NO_SUPPORT;
|
||||
@ -726,6 +736,10 @@ NO_SANITIZE("cfi") int32_t TransProxyUnpackHandshakeMsg(const char *msg, ProxyCh
|
||||
cJSON_Delete(root);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
if (!GetJsonObjectNumberItem(root, JSON_KEY_MTU_SIZE, (int32_t *)&(appInfo->peerData.dataConfig))) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "peer dataconfig is null.");
|
||||
}
|
||||
|
||||
if (appInfo->appType == APP_TYPE_NORMAL) {
|
||||
if (TransProxyUnpackNormalHandshakeMsg(root, appInfo, sessionKey, BASE64KEY) != SOFTBUS_OK) {
|
||||
|
@ -26,6 +26,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
int32_t TransSrvDataListInit(void);
|
||||
void TransSrvDataListDeinit(void);
|
||||
int32_t TransSrvAddDataBufNode(int32_t channelId, int32_t fd);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "softbus_adapter_thread.h"
|
||||
#include "softbus_adapter_socket.h"
|
||||
#include "softbus_errcode.h"
|
||||
#include "softbus_feature_config.h"
|
||||
#include "softbus_hisysevt_transreporter.h"
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_message_open_channel.h"
|
||||
@ -51,6 +52,12 @@ typedef struct {
|
||||
char *w;
|
||||
} ServerDataBuf;
|
||||
|
||||
typedef struct {
|
||||
int32_t channelType;
|
||||
int32_t businessType;
|
||||
ConfigType configType;
|
||||
} ConfigTypeMap;
|
||||
|
||||
static SoftBusList *g_tcpSrvDataList = NULL;
|
||||
|
||||
static void PackTdcPacketHead(TdcPacketHead *data)
|
||||
@ -296,6 +303,7 @@ static int32_t NotifyChannelOpened(int32_t channelId)
|
||||
info.peerIp = conn.appInfo.peerData.addr;
|
||||
info.peerPort = conn.appInfo.peerData.port;
|
||||
info.linkType = conn.appInfo.linkType;
|
||||
info.dataConfig = conn.appInfo.myData.dataConfig;
|
||||
char myIp[IP_LEN] = {0};
|
||||
if (conn.serverSide) {
|
||||
if (conn.appInfo.routeType == WIFI_STA) {
|
||||
@ -407,6 +415,67 @@ static int TransTdcPostFisrtData(SessionConn *conn)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static const ConfigTypeMap g_configTypeMap[] = {
|
||||
{CHANNEL_TYPE_TCP_DIRECT, BUSINESS_TYPE_BYTE, SOFTBUS_INT_MAX_BYTES_NEW_LENGTH},
|
||||
{CHANNEL_TYPE_TCP_DIRECT, BUSINESS_TYPE_MESSAGE, SOFTBUS_INT_MAX_MESSAGE_NEW_LENGTH},
|
||||
};
|
||||
|
||||
static int32_t FindConfigType(int32_t channelType, int32_t businessType)
|
||||
{
|
||||
for (uint32_t i = 0; i < sizeof(g_configTypeMap) / sizeof(ConfigTypeMap); i++) {
|
||||
if ((g_configTypeMap[i].channelType == channelType) &&
|
||||
(g_configTypeMap[i].businessType == businessType)) {
|
||||
return g_configTypeMap[i].configType;
|
||||
}
|
||||
}
|
||||
return SOFTBUS_CONFIG_TYPE_MAX;
|
||||
}
|
||||
|
||||
static int32_t TransGetLocalConfig(int32_t channelType, int32_t businessType, uint32_t len)
|
||||
{
|
||||
ConfigType configType = (ConfigType)FindConfigType(channelType, businessType);
|
||||
if (configType == SOFTBUS_CONFIG_TYPE_MAX) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Invalid channelType: %d, businessType: %d",
|
||||
channelType, businessType);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
uint32_t maxLen;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&maxLen, sizeof(maxLen)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType: %d.", configType);
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
|
||||
len = maxLen;
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get local config = %d.", len);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t TransTdcProcessDataConfig(AppInfo *appInfo)
|
||||
{
|
||||
if (appInfo == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "appInfo is null");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (appInfo->businessType != BUSINESS_TYPE_MESSAGE && appInfo->businessType != BUSINESS_TYPE_BYTE) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "invalid businessType[%d]", appInfo->businessType);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
appInfo->myData.dataConfig = MIN(appInfo->myData.dataConfig, appInfo->peerData.dataConfig);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "process dataConfig[%u] succ", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ConfigType configType = appInfo->businessType == BUSINESS_TYPE_BYTE ?
|
||||
SOFTBUS_INT_MAX_BYTES_LENGTH : SOFTBUS_INT_MAX_MESSAGE_LENGTH;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&appInfo->myData.dataConfig,
|
||||
sizeof(appInfo->myData.dataConfig)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType[%d]", configType);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "process data config value[%d]", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t OpenDataBusReply(int32_t channelId, uint64_t seq, const cJSON *reply)
|
||||
{
|
||||
(void)seq;
|
||||
@ -432,6 +501,11 @@ static int32_t OpenDataBusReply(int32_t channelId, uint64_t seq, const cJSON *re
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
if (TransTdcProcessDataConfig(&conn.appInfo) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Trans Tdc process data config failed.");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
if (SetAppInfoById(channelId, &conn.appInfo) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "set app info by id failed.");
|
||||
return SOFTBUS_ERR;
|
||||
@ -553,6 +627,36 @@ static void NotifyFastDataRecv(SessionConn *conn, int32_t channelId)
|
||||
return;
|
||||
}
|
||||
|
||||
static int32_t TransTdcFillDataConfig(AppInfo *appInfo)
|
||||
{
|
||||
if (appInfo == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "appInfo is null");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
if (appInfo->businessType != BUSINESS_TYPE_BYTE && appInfo->businessType != BUSINESS_TYPE_MESSAGE) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "invalid businessType[%d]", appInfo->businessType);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
if (appInfo->peerData.dataConfig != 0) {
|
||||
uint32_t localDataConfig = 0;
|
||||
if (TransGetLocalConfig(CHANNEL_TYPE_TCP_DIRECT, appInfo->businessType, localDataConfig) != SOFTBUS_OK) {
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
appInfo->myData.dataConfig = MIN(appInfo->myData.dataConfig, appInfo->peerData.dataConfig);
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "fill dataConfig[%u] succ", appInfo->myData.dataConfig)
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
ConfigType configType = appInfo->businessType == BUSINESS_TYPE_BYTE ?
|
||||
SOFTBUS_INT_MAX_BYTES_LENGTH : SOFTBUS_INT_MAX_MESSAGE_LENGTH;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&appInfo->myData.dataConfig,
|
||||
sizeof(appInfo->myData.dataConfig)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType[%d]", configType);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "fill data config value[%d]", appInfo->myData.dataConfig);
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static int32_t OpenDataBusRequest(int32_t channelId, uint32_t flags, uint64_t seq, const cJSON *request)
|
||||
{
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "OpenDataBusRequest channelId=%d, seq=%d.", channelId, seq);
|
||||
@ -577,6 +681,13 @@ static int32_t OpenDataBusRequest(int32_t channelId, uint32_t flags, uint64_t se
|
||||
goto ERR_EXIT;
|
||||
}
|
||||
|
||||
if (TransTdcFillDataConfig(&conn->appInfo) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "fill data config failed.");
|
||||
errCode = SOFTBUS_INVALID_PARAM;
|
||||
errDesc = (char *)"fill data config failed";
|
||||
goto ERR_EXIT;
|
||||
}
|
||||
|
||||
if (SetAppInfoById(channelId, &conn->appInfo) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "set app info by id failed.");
|
||||
errCode = SOFTBUS_TRANS_SESSION_INFO_NOT_FOUND;
|
||||
|
@ -297,12 +297,10 @@ typedef struct {
|
||||
} QosTv;
|
||||
|
||||
typedef enum {
|
||||
/* Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_MAX_SENDBYTES_SIZE = 0,
|
||||
/* Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_MAX_SENDMESSAGE_SIZE,
|
||||
/* Value type of this option is int32_t, this option only can be get */
|
||||
SESSION_OPTION_LINK_TYPE,
|
||||
SESSION_OPTION_MAX_SENDBYTES_SIZE = 0, /**< Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_MAX_SENDMESSAGE_SIZE, /**< Value type of this option is uint32_t, this option only can be get */
|
||||
SESSION_OPTION_LINK_TYPE, /**< Value type of this option is int32_t, this option only can be get */
|
||||
SESSION_OPTION_SESSION_DATA_SIZE, /**< Value type of this option is uint32_t, this option only can be get */
|
||||
|
||||
SESSION_OPTION_BUTT,
|
||||
} SessionOption;
|
||||
|
@ -293,6 +293,10 @@ int32_t SoftBusClientStub::OnChannelOpenedInner(MessageParcel &data, MessageParc
|
||||
data.ReadInt32(channel.encrypt);
|
||||
data.ReadInt32(channel.algorithm);
|
||||
data.ReadInt32(channel.crc);
|
||||
if (!data.ReadUint32(channel.dataConfig)) {
|
||||
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OnChannelOpenedInner data config failed!");
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
int ret = OnChannelOpened(sessionName, &channel);
|
||||
bool res = reply.WriteInt32(ret);
|
||||
|
@ -164,6 +164,7 @@
|
||||
"RemoveSessionServer";
|
||||
"StopDiscovery";
|
||||
"ClientGetSessionCallbackById";
|
||||
"ClientGetDataConfigByChannelId";
|
||||
"ClientTransUdpMgrInit";
|
||||
"GetPeerUidInner";
|
||||
"TransCloseFileChannel";
|
||||
@ -191,6 +192,7 @@
|
||||
"OpenSessionSync";
|
||||
"ReadMaxSendMessageSize";
|
||||
"ReadSessionLinkType";
|
||||
"ReadSessionSendDataSize";
|
||||
"ClientTransTdcOnChannelOpened";
|
||||
".term_proc";
|
||||
"LnnOnTimeSyncResult";
|
||||
|
@ -52,6 +52,7 @@ typedef struct {
|
||||
int32_t algorithm;
|
||||
int32_t crc;
|
||||
LinkType linkType[LINK_TYPE_MAX];
|
||||
uint32_t dataConfig;
|
||||
} SessionInfo;
|
||||
|
||||
typedef struct {
|
||||
@ -106,6 +107,8 @@ int32_t ClientGetSessionIdByChannelId(int32_t channelId, int32_t channelType, in
|
||||
|
||||
int32_t ClientGetRouteTypeByChannelId(int32_t channelId, int32_t channelType, int32_t *routeType);
|
||||
|
||||
int32_t ClientGetDataConfigByChannelId(int32_t channelId, int32_t channelType, uint32_t *dataConfig);
|
||||
|
||||
int32_t ClientEnableSessionByChannelId(const ChannelInfo *channel, int32_t *sessionId);
|
||||
|
||||
int32_t ClientGetSessionCallbackById(int32_t sessionId, ISessionListener *callback);
|
||||
|
@ -26,19 +26,14 @@
|
||||
#include "softbus_log.h"
|
||||
#include "softbus_adapter_mem.h"
|
||||
|
||||
int CheckSendLen(int32_t channelType, int32_t businessType, unsigned int len)
|
||||
int CheckSendLen(int32_t channelId, int32_t channelType, unsigned int len)
|
||||
{
|
||||
ConfigType configType = (ConfigType)FindConfigType(channelType, businessType);
|
||||
if (configType == SOFTBUS_CONFIG_TYPE_MAX) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Invalid channelType: %d, businessType: %d",
|
||||
channelType, businessType);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
uint32_t maxLen;
|
||||
if (SoftbusGetConfig(configType, (unsigned char *)&maxLen, sizeof(maxLen)) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed, configType: %d.", configType);
|
||||
uint32_t dataConfig = INVALID_DATA_CONFIG;
|
||||
if (ClientGetDataConfigByChannelId(channelId, channelType, &dataConfig) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed.");
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "send data len:%u", dataConfig);
|
||||
if (len > maxLen) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "send data len[%u] over limit.", len);
|
||||
return SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT;
|
||||
@ -71,7 +66,7 @@ int SendBytes(int sessionId, const void *data, unsigned int len)
|
||||
return SOFTBUS_TRANS_SESSION_NO_ENABLE;
|
||||
}
|
||||
|
||||
if (CheckSendLen(channelType, BUSINESS_TYPE_BYTE, len) != SOFTBUS_OK) {
|
||||
if (CheckSendLen(channelId, channelType, len) != SOFTBUS_OK) {
|
||||
return SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT;
|
||||
}
|
||||
|
||||
@ -111,7 +106,7 @@ int SendMessage(int sessionId, const void *data, unsigned int len)
|
||||
return SOFTBUS_TRANS_SESSION_NO_ENABLE;
|
||||
}
|
||||
|
||||
if (CheckSendLen(channelType, BUSINESS_TYPE_MESSAGE, len) != SOFTBUS_OK) {
|
||||
if (CheckSendLen(channelId, channelType, len) != SOFTBUS_OK) {
|
||||
return SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ static int32_t AcceptSessionAsServer(const char *sessionName, const ChannelInfo
|
||||
session->fileEncrypt = channel->fileEncrypt;
|
||||
session->algorithm = channel->algorithm;
|
||||
session->crc = channel->crc;
|
||||
session->dataConfig = channel->dataConfig;
|
||||
if (strcpy_s(session->info.peerSessionName, SESSION_NAME_SIZE_MAX, channel->peerSessionName) != EOK ||
|
||||
strcpy_s(session->info.peerDeviceId, DEVICE_ID_SIZE_MAX, channel->peerDeviceId) != EOK ||
|
||||
strcpy_s(session->info.groupId, GROUP_ID_SIZE_MAX, channel->groupId) != EOK) {
|
||||
|
@ -940,6 +940,45 @@ int32_t ClientGetRouteTypeByChannelId(int32_t channelId, int32_t channelType, in
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
int32_t ClientGetDataConfigByChannelId(int32_t channelId, int32_t channelType, uint32_t *dataConfig)
|
||||
{
|
||||
if ((channelId < 0) || (dataConfig == NULL)) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "Invalid param");
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (g_clientSessionServerList == NULL) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "not init");
|
||||
return SOFTBUS_TRANS_SESSION_SERVER_NOINIT;
|
||||
}
|
||||
|
||||
ClientSessionServer *serverNode = NULL;
|
||||
SessionInfo *sessionNode = NULL;
|
||||
|
||||
if (SoftBusMutexLock(&(g_clientSessionServerList->lock)) != 0) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "lock failed");
|
||||
return SOFTBUS_LOCK_ERR;
|
||||
}
|
||||
|
||||
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) {
|
||||
*dataConfig = sessionNode->dataConfig;
|
||||
(void)SoftBusMutexUnlock(&(g_clientSessionServerList->lock));
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(void)SoftBusMutexUnlock(&(g_clientSessionServerList->lock));
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "not found dataConfig with channelId [%d]", channelId);
|
||||
return SOFTBUS_ERR;
|
||||
}
|
||||
|
||||
int32_t ClientEnableSessionByChannelId(const ChannelInfo *channel, int32_t *sessionId)
|
||||
{
|
||||
if ((channel == NULL) || (sessionId == NULL)) {
|
||||
|
@ -40,8 +40,6 @@
|
||||
#include "softbus_utils.h"
|
||||
#include "trans_server_proxy.h"
|
||||
|
||||
#define INVAILD_ROUTE_TYPE (-1)
|
||||
|
||||
typedef int (*SessionOptionRead)(int32_t channelId, int32_t type, void* value, uint32_t valueSize);
|
||||
typedef int (*SessionOptionWrite)(int32_t channelId, int32_t type, void* value, uint32_t valueSize);
|
||||
|
||||
@ -782,10 +780,28 @@ int ReadSessionLinkType(int32_t channelId, int32_t type, void* value, uint32_t v
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
int ReadSessionSendDataSize(int32_t channelId, int32_t type, void* value, uint32_t valueSize)
|
||||
{
|
||||
if (valueSize != sizeof(uint32_t)) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "value size is %d, not match", valueSize);
|
||||
return SOFTBUS_INVALID_PARAM;
|
||||
}
|
||||
|
||||
uint32_t dataConfig = INVALID_DATA_CONFIG;
|
||||
if (ClientGetDataConfigByChannelId(channelId, type, &dataConfig) != SOFTBUS_OK) {
|
||||
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get config failed.");
|
||||
return SOFTBUS_GET_CONFIG_VAL_ERR;
|
||||
}
|
||||
|
||||
(*(uint32_t*)value) = dataConfig;
|
||||
return SOFTBUS_OK;
|
||||
}
|
||||
|
||||
static const SessionOptionItem g_SessionOptionArr[SESSION_OPTION_BUTT] = {
|
||||
{true, ReadMaxSendBytesSize},
|
||||
{true, ReadMaxSendMessageSize},
|
||||
{true, ReadSessionLinkType},
|
||||
{true, ReadSessionSendDataSize},
|
||||
};
|
||||
|
||||
int GetSessionOption(int sessionId, SessionOption option, void* optionValue, uint32_t valueSize)
|
||||
|
Loading…
x
Reference in New Issue
Block a user