IPC统一接口切换修改

Signed-off-by: liubb_0516 <liubeibei8@huawei.com>
This commit is contained in:
liubb_0516 2022-05-05 14:51:21 +08:00
parent 8d852e84f6
commit f04fe23b7f
32 changed files with 653 additions and 615 deletions

View File

@ -72,7 +72,7 @@ if (defined(ohos_lite)) {
[ "$dsoftbus_root_path/core/bus_center/ipc/small/include" ]
bus_center_server_deps += [
"//build/lite/config/component/cJSON:cjson_shared",
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
]
}
} else {

View File

@ -18,7 +18,7 @@
#include <securec.h>
#include <stdint.h>
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_adapter_mem.h"
#include "softbus_client_info_manager.h"
#include "softbus_def.h"
@ -36,9 +36,6 @@ static int32_t GetSvcIdentityByPkgName(const char *pkgName, SvcIdentity *svc)
svc->handle = svcId.handle;
svc->token = svcId.token;
svc->cookie = svcId.cookie;
#ifdef __LINUX__
svc->ipcContext = svcId.ipcCtx;
#endif
return SOFTBUS_OK;
}
@ -63,9 +60,6 @@ static int32_t GetAllClientIdentity(SvcIdentity *svc, int num)
svc[i].handle = svcId[i].handle;
svc[i].token = svcId[i].token;
svc[i].cookie = svcId[i].cookie;
#ifdef __LINUX__
svc[i].ipcContext = svcId[i].ipcCtx;
#endif
}
SoftBusFree(svcId);
return SOFTBUS_OK;
@ -82,17 +76,21 @@ int32_t ClientOnJoinLNNResult(const char *pkgName, void *addr, uint32_t addrType
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushFlatObj(&io, addr, addrTypeLen);
IpcIoPushInt32(&io, retCode);
WriteUint32(&io, addrTypeLen);
WriteBuffer(&io, addr, addrTypeLen);
WriteInt32(&io, retCode);
if (retCode == 0) {
IpcIoPushString(&io, networkId);
WriteString(&io, networkId);
}
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnJoinLNNResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_JOIN_RESULT, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_JOIN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnJoinLNNResult callback SendRequest failed.");
return SOFTBUS_ERR;
@ -110,14 +108,17 @@ int32_t ClientOnLeaveLNNResult(const char *pkgName, const char *networkId, int r
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&io, networkId);
IpcIoPushInt32(&io, retCode);
WriteString(&io, networkId);
WriteInt32(&io, retCode);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnLeaveLNNResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_LEAVE_RESULT, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_LEAVE_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnLeaveLNNResult callback SendRequest failed.");
return SOFTBUS_ERR;
@ -135,8 +136,9 @@ int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoT
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushBool(&io, isOnline);
IpcIoPushFlatObj(&io, info, infoTypeLen);
WriteBool(&io, isOnline);
WriteUint32(&io, infoTypeLen);
WriteBuffer(&io, info, infoTypeLen);
int num;
int i;
if (SERVER_GetClientInfoNodeNum(&num) != SOFTBUS_OK) {
@ -157,9 +159,11 @@ int32_t ClinetOnNodeOnlineStateChanged(bool isOnline, void *info, uint32_t infoT
SoftBusFree(svc);
return SOFTBUS_ERR;
}
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
for (i = 0; i < num; i++) {
int32_t ans = SendRequest(NULL, svc[i], CLIENT_ON_NODE_ONLINE_STATE_CHANGED, &io, NULL,
LITEIPC_FLAG_ONEWAY, NULL);
int32_t ans = SendRequest(svc[i], CLIENT_ON_NODE_ONLINE_STATE_CHANGED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnNodeBasicInfoChanged callback SendRequest failed.");
SoftBusFree(svc);
@ -180,8 +184,9 @@ int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t t
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, type);
IpcIoPushFlatObj(&io, info, infoTypeLen);
WriteInt32(&io, type);
WriteUint32(&io, infoTypeLen);
WriteBuffer(&io, info, infoTypeLen);
int num;
int i;
if (SERVER_GetClientInfoNodeNum(&num) != SOFTBUS_OK) {
@ -202,9 +207,11 @@ int32_t ClinetOnNodeBasicInfoChanged(void *info, uint32_t infoTypeLen, int32_t t
SoftBusFree(svc);
return SOFTBUS_ERR;
}
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
for (i = 0; i < num; i++) {
int32_t ans = SendRequest(NULL, svc[i], CLIENT_ON_NODE_BASIC_INFO_CHANGED, &io, NULL,
LITEIPC_FLAG_ONEWAY, NULL);
int32_t ans = SendRequest(svc[i], CLIENT_ON_NODE_BASIC_INFO_CHANGED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClinetOnNodeBasicInfoChanged callback SendRequest failed.");
SoftBusFree(svc);
@ -225,14 +232,18 @@ int32_t ClientOnTimeSyncResult(const char *pkgName, const void *info, uint32_t i
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushFlatObj(&io, info, infoTypeLen);
IpcIoPushInt32(&io, retCode);
WriteUint32(&io, infoTypeLen);
WriteBuffer(&io, info, infoTypeLen);
WriteInt32(&io, retCode);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnTimeSyncResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_TIME_SYNC_RESULT, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_TIME_SYNC_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnTimeSyncResult callback SendRequest failed.");
return SOFTBUS_ERR;
@ -250,14 +261,17 @@ int32_t ClientOnPublishLNNResult(const char *pkgName, int32_t publishId, int32_t
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, publishId);
IpcIoPushInt32(&io, reason);
WriteInt32(&io, publishId);
WriteInt32(&io, reason);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnPublishLNNResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_PUBLISH_LNN_RESULT, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_PUBLISH_LNN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnPublishLNNResult callback SendRequest failed.");
return SOFTBUS_ERR;
@ -275,14 +289,17 @@ int32_t ClientOnRefreshLNNResult(const char *pkgName, int32_t refreshId, int32_t
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, refreshId);
IpcIoPushInt32(&io, reason);
WriteInt32(&io, refreshId);
WriteInt32(&io, reason);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnRefreshLNNResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_REFRESH_LNN_RESULT, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_REFRESH_LNN_RESULT, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnRefreshLNNResult callback SendRequest failed.");
return SOFTBUS_ERR;
@ -300,13 +317,17 @@ int32_t ClientOnRefreshDeviceFound(const char *pkgName, const void *device, uint
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN_EX];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN_EX, 0);
IpcIoPushFlatObj(&io, device, deviceLen);
WriteUint32(&io, deviceLen);
WriteBuffer(&io, device, deviceLen);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnRefreshDeviceFound callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_REFRESH_DEVICE_FOUND, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_REFRESH_DEVICE_FOUND, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientOnRefreshDeviceFound callback SendRequest failed.");
return SOFTBUS_ERR;

View File

@ -16,7 +16,7 @@ import("//foundation/communication/dsoftbus/dsoftbus.gni")
if (defined(ohos_lite)) {
softbus_permission_inc = [
"$dsoftbus_core_path/common/security/permission/include",
"//foundation/communication/ipc_lite/interfaces/kits",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc/include",
"//base/security/permission/interfaces/kits/permission_lite",
]
if (ohos_kernel_type == "liteos_m") {
@ -30,7 +30,7 @@ if (defined(ohos_lite)) {
]
softbus_permission_deps = [
"//base/security/permission/services/permission_lite/pms_client:pms_client",
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
]
}
} else {

View File

@ -18,7 +18,6 @@
#include <string.h>
#include <unistd.h>
#include "liteipc_adapter.h"
#include "permission_entry.h"
#include "pms_interface.h"
#include "pms_types.h"

View File

@ -37,7 +37,7 @@ if (defined(ohos_lite)) {
disc_server_src +=
[ "$dsoftbus_root_path/core/discovery/ipc/small/disc_client_proxy.c" ]
disc_server_deps +=
[ "//foundation/communication/ipc_lite:liteipc_adapter" ]
[ "//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single" ]
}
} else {
disc_server_src += [

View File

@ -15,7 +15,7 @@
#include "disc_client_proxy.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "serializer.h"
#include "softbus_client_info_manager.h"
#include "softbus_def.h"
@ -33,9 +33,6 @@ static int32_t GetSvcIdentityByPkgName(const char *pkgName, SvcIdentity *svc)
svc->handle = svcId.handle;
svc->token = svcId.token;
svc->cookie = svcId.cookie;
#ifdef __LINUX__
svc->ipcContext = svcId.ipcCtx;
#endif
return SOFTBUS_OK;
}
@ -45,13 +42,19 @@ int32_t ClientIpcOnDeviceFound(const char *pkgName, const DeviceInfo *device)
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN_EX] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN_EX, 0);
IpcIoPushFlatObj(&io, (const void*)device, sizeof(DeviceInfo));
bool ret = WriteRawData(&io, (const void*)device, sizeof(DeviceInfo));
if (!ret) {
return SOFTBUS_ERR;
}
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "ondevice found callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_DISCOVERY_DEVICE_FOUND, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_DISCOVERY_DEVICE_FOUND, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "ondevice found callback SendRequest failed.");
return SOFTBUS_ERR;
@ -65,14 +68,17 @@ int32_t ClientIpcOnDiscoverFailed(const char *pkgName, int subscribeId, int fail
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, subscribeId);
IpcIoPushInt32(&io, failReason);
WriteInt32(&io, subscribeId);
WriteInt32(&io, failReason);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on discovery failed callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_DISCOVERY_FAIL, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_DISCOVERY_FAIL, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on discovery failed callback SendRequest failed.");
return SOFTBUS_ERR;
@ -86,13 +92,16 @@ int32_t ClientIpcDiscoverySuccess(const char *pkgName, int subscribeId)
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, subscribeId);
WriteInt32(&io, subscribeId);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on discovery success callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_DISCOVERY_SUCC, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_DISCOVERY_SUCC, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on discovery success callback SendRequest failed.");
return SOFTBUS_ERR;
@ -106,13 +115,16 @@ int32_t ClientIpcOnPublishSuccess(const char *pkgName, int publishId)
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, publishId);
WriteInt32(&io, publishId);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on publish success callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_PUBLISH_SUCC, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_PUBLISH_SUCC, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on publish success callback SendRequest failed.");
return SOFTBUS_ERR;
@ -126,14 +138,17 @@ int32_t ClientIpcOnPublishFail(const char *pkgName, int publishId, int reason)
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, publishId);
IpcIoPushInt32(&io, reason);
WriteInt32(&io, publishId);
WriteInt32(&io, reason);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on publish failed callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_PUBLISH_FAIL, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_PUBLISH_FAIL, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "on publish failed callback SendRequest failed.");
return SOFTBUS_ERR;

View File

@ -106,7 +106,7 @@ if (defined(ohos_lite)) {
"$dsoftbus_root_path/adapter:softbus_adapter",
"$dsoftbus_root_path/core/common:softbus_utils",
"//build/lite/config/component/cJSON:cjson_shared",
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
"//third_party/bounds_checking_function:libsec_shared",
]

View File

@ -27,7 +27,6 @@ typedef struct {
unsigned int handle; /* use for small system device */
unsigned int token; /* use for small system device */
unsigned int cookie; /* use for small system device */
void *ipcCtx; /* use for small system device */
} SoftBusClientInfoNode;
static SoftBusList *g_clientInfoList = NULL;
@ -84,7 +83,6 @@ int SERVER_RegisterService(const char *name, const struct CommonScvId *svcId)
clientInfo->handle = svcId->handle;
clientInfo->token = svcId->token;
clientInfo->cookie = svcId->cookie;
clientInfo->ipcCtx = svcId->ipcCtx;
ListInit(&clientInfo->node);
if (SoftBusMutexLock(&g_clientInfoList->lock) != 0) {
@ -123,7 +121,6 @@ int SERVER_GetIdentityByPkgName(const char *name, struct CommonScvId *svcId)
svcId->handle = clientInfo->handle;
svcId->token = clientInfo->token;
svcId->cookie = clientInfo->cookie;
svcId->ipcCtx = clientInfo->ipcCtx;
(void)SoftBusMutexUnlock(&g_clientInfoList->lock);
return SOFTBUS_OK;
}
@ -171,7 +168,6 @@ int SERVER_GetAllClientIdentity(struct CommonScvId *svcId, int num)
svcId[i].handle = clientInfo->handle;
svcId[i].token = clientInfo->token;
svcId[i].cookie = clientInfo->cookie;
svcId[i].ipcCtx = clientInfo->ipcCtx;
i++;
}
}

View File

@ -25,20 +25,20 @@ extern "C" {
#endif
#endif
int32_t ServerJoinLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerLeaveLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerGetAllOnlineNodeInfo(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerGetLocalDeviceInfo(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerGetNodeKeyInfo(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStartTimeSync(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStopTimeSync(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerPublishLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStopPublishLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStopRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerActiveMetaNode(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerDeactiveMetaNode(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerGetAllMetaNodeInfo(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerJoinLNN(IpcIo *req, IpcIo *reply);
int32_t ServerLeaveLNN(IpcIo *req, IpcIo *reply);
int32_t ServerGetAllOnlineNodeInfo( IpcIo *req, IpcIo *reply);
int32_t ServerGetLocalDeviceInfo(IpcIo *req, IpcIo *reply);
int32_t ServerGetNodeKeyInfo(IpcIo *req, IpcIo *reply);
int32_t ServerStartTimeSync(IpcIo *req, IpcIo *reply);
int32_t ServerStopTimeSync( IpcIo *req, IpcIo *reply);
int32_t ServerPublishLNN(IpcIo *req, IpcIo *reply);
int32_t ServerStopPublishLNN(IpcIo *req, IpcIo *reply);
int32_t ServerRefreshLNN(IpcIo *req, IpcIo *reply);
int32_t ServerStopRefreshLNN(IpcIo *req, IpcIo *reply);
int32_t ServerActiveMetaNode(IpcIo *req, IpcIo *reply);
int32_t ServerDeactiveMetaNode(IpcIo *req, IpcIo *reply);
int32_t ServerGetAllMetaNodeInfo(IpcIo *req, IpcIo *reply);
#ifdef __cplusplus
#if __cplusplus

View File

@ -24,10 +24,10 @@ extern "C" {
#endif
#endif
int32_t ServerPublishService(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerUnPublishService(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStartDiscovery(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerStopDiscovery(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerPublishService(IpcIo *req, IpcIo *reply);
int32_t ServerUnPublishService(IpcIo *req, IpcIo *reply);
int32_t ServerStartDiscovery(IpcIo *req, IpcIo *reply);
int32_t ServerStopDiscovery(IpcIo *req, IpcIo *reply);
#ifdef __cplusplus
#if __cplusplus

View File

@ -23,13 +23,13 @@
extern "C" {
#endif
int32_t ServerCreateSessionServer(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerRemoveSessionServer(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerOpenSession(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerNotifyAuthSuccess(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerOpenAuthSession(const void *origin, IpcIo *req, IpcIo *reqly);
int32_t ServerCloseChannel(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerSendSessionMsg(const void *origin, IpcIo *req, IpcIo *reply);
int32_t ServerCreateSessionServer(IpcIo *req, IpcIo *reply);
int32_t ServerRemoveSessionServer(IpcIo *req, IpcIo *reply);
int32_t ServerOpenSession(IpcIo *req, IpcIo *reply);
int32_t ServerNotifyAuthSuccess(IpcIo *req, IpcIo *reply);
int32_t ServerOpenAuthSession(IpcIo *req, IpcIo *reqly);
int32_t ServerCloseChannel(IpcIo *req, IpcIo *reply);
int32_t ServerSendSessionMsg(IpcIo *req, IpcIo *reply);
#ifdef __cplusplus
}

View File

@ -17,7 +17,7 @@
#include <stdint.h>
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "lnn_bus_center_ipc.h"
#include "securec.h"
#include "softbus_adapter_mem.h"
@ -40,7 +40,7 @@ static int32_t CheckPermission(const char *pkgName, int32_t uid)
return SOFTBUS_OK;
}
int32_t ServerJoinLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerJoinLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerJoinLNN ipc server pop.");
if (req == NULL || reply == NULL) {
@ -48,15 +48,15 @@ int32_t ServerJoinLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
uint32_t addrTypeLen = IpcIoPopUint32(req);
void *addr = (void*)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char*)ReadString(req, &len);
uint32_t addrTypeLen;
ReadUint32(req,&addrTypeLen);
void *addr = (void*)ReadBuffer(req, addrTypeLen);
if (addr == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerJoinLNN read addr is null.");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerJoinLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -69,17 +69,17 @@ int32_t ServerJoinLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerLeaveLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerLeaveLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerLeaveLNN ipc server pop.");
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
const char *networkId = (const char*)IpcIoPopString(req, &len);
const char *pkgName = (const char*)ReadString(req, &len);
const char *networkId = (const char*)ReadString(req, &len);
if (networkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerLeaveLNN read networkId failed!");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerLeaveLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -92,15 +92,16 @@ int32_t ServerLeaveLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerGetAllOnlineNodeInfo(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerGetAllOnlineNodeInfo(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerGetAllOnlineNodeInfo ipc server pop.");
void *nodeInfo = NULL;
int32_t infoNum = 0;
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
uint32_t infoTypeLen = IpcIoPopUint32(req);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char*)ReadString(req, &len);
uint32_t infoTypeLen;
ReadUint32(req, &infoTypeLen);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetAllOnlineNodeInfo no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -114,21 +115,22 @@ int32_t ServerGetAllOnlineNodeInfo(const void *origin, IpcIo *req, IpcIo *reply)
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetAllOnlineNodeInfo node info is invalid");
return SOFTBUS_ERR;
}
IpcIoPushInt32(reply, infoNum);
WriteInt32(reply, infoNum);
if (infoNum > 0) {
IpcIoPushFlatObj(reply, nodeInfo, infoTypeLen * infoNum);
WriteUint32(reply, infoTypeLen * infoNum);
WriteBuffer(reply, nodeInfo, infoTypeLen * infoNum);
SoftBusFree(nodeInfo);
}
return SOFTBUS_OK;
}
int32_t ServerGetLocalDeviceInfo(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerGetLocalDeviceInfo(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerGetLocalDeviceInfo ipc server pop.");
void *nodeInfo = NULL;
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char*)ReadString(req, &len);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetLocalDeviceInfo no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -145,29 +147,32 @@ int32_t ServerGetLocalDeviceInfo(const void *origin, IpcIo *req, IpcIo *reply)
SoftBusFree(nodeInfo);
return SOFTBUS_ERR;
}
IpcIoPushFlatObj(reply, nodeInfo, infoTypeLen);
WriteUint32(reply, infoTypeLen);
WriteBuffer(reply, nodeInfo, infoTypeLen);
SoftBusFree(nodeInfo);
return SOFTBUS_OK;
}
int32_t ServerGetNodeKeyInfo(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerGetNodeKeyInfo(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerGetNodeKeyInfo ipc server pop.");
size_t length;
const char *pkgName = (const char*)IpcIoPopString(req, &length);
const char *networkId = (const char*)IpcIoPopString(req, &length);
const char *pkgName = (const char*)ReadString(req, &length);
const char *networkId = (const char*)ReadString(req, &length);
if (networkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "GetNodeKeyInfoInner read networkId failed!");
return SOFTBUS_ERR;
}
int32_t key = IpcIoPopInt32(req);
int32_t len = IpcIoPopInt32(req);
int32_t key;
int32_t len;
ReadInt32(req, &key);
ReadInt32(req, &len);
void *buf = SoftBusMalloc(len);
if (buf == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetNodeKeyInfo malloc buffer failed!");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetNodeKeyInfo no permission.");
SoftBusFree(buf);
@ -179,25 +184,27 @@ int32_t ServerGetNodeKeyInfo(const void *origin, IpcIo *req, IpcIo *reply)
SoftBusFree(buf);
return SOFTBUS_ERR;
}
IpcIoPushFlatObj(reply, buf, len);
WriteUint32(reply, len);
WriteBuffer(reply, buf, len);
SoftBusFree(buf);
return SOFTBUS_OK;
}
int32_t ServerStartTimeSync(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStartTimeSync(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerStartTimeSync ipc server pop.");
size_t length;
const char *pkgName = (const char*)IpcIoPopString(req, &length);
const char *targetNetworkId = (const char*)IpcIoPopString(req, &length);
const char *pkgName = (const char*)ReadString(req, &length);
const char *targetNetworkId = (const char*)ReadString(req, &length);
if (targetNetworkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStartTimeSync read targetNetworkId failed!");
return SOFTBUS_ERR;
}
int32_t accuracy = IpcIoPopInt32(req);
int32_t period = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
int32_t accuracy;
int32_t period;
ReadInt32(req, &accuracy);
ReadInt32(req, &period);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStartTimeSync no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -210,17 +217,17 @@ int32_t ServerStartTimeSync(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerStopTimeSync(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStopTimeSync(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerStopTimeSync ipc server pop.");
size_t length;
const char *pkgName = (const char*)IpcIoPopString(req, &length);
const char *targetNetworkId = (const char*)IpcIoPopString(req, &length);
const char *pkgName = (const char*)ReadString(req, &length);
const char *targetNetworkId = (const char*)ReadString(req, &length);
if (targetNetworkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopTimeSync read targetNetworkId failed!");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopTimeSync no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -233,7 +240,7 @@ int32_t ServerStopTimeSync(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerPublishLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerPublishLNN ipc server pop.");
if (req == NULL || reply == NULL) {
@ -241,15 +248,15 @@ int32_t ServerPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
uint32_t infoLen = IpcIoPopUint32(req);
void *info = (void*)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char*)ReadString(req, &len);
uint32_t infoLen;
ReadUint32(req, &infoLen);
void *info = (void*)ReadBuffer(req, infoLen);
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerPublishLNN read info is null.");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerPublishLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -262,7 +269,7 @@ int32_t ServerPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerStopPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStopPublishLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerStopPublishLNN ipc server pop.");
if (req == NULL || reply == NULL) {
@ -270,9 +277,10 @@ int32_t ServerStopPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
int32_t publishId = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char*)ReadString(req, &len);
int32_t publishId;
ReadInt32(req, &publishId);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopPublishLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -285,7 +293,7 @@ int32_t ServerStopPublishLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerRefreshLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerRefreshLNN ipc server pop.");
if (req == NULL || reply == NULL) {
@ -293,15 +301,15 @@ int32_t ServerRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
uint32_t infoTypeLen = IpcIoPopUint32(req);
void *info = (void*)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char*)ReadString(req, &len);
uint32_t infoTypeLen;
ReadUint32(req, &infoTypeLen);
void *info = (void*)ReadBuffer(req, infoTypeLen);
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerRefreshLNN read info is null.");
return SOFTBUS_ERR;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerRefreshLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -314,7 +322,7 @@ int32_t ServerRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerStopRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStopRefreshLNN(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "ServerStopRefreshLNN ipc server pop.");
if (req == NULL || reply == NULL) {
@ -322,9 +330,10 @@ int32_t ServerStopRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
int32_t refreshId = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char*)ReadString(req, &len);
int32_t refreshId;
ReadInt32(req, &refreshId);
int32_t callingUid = GetCallingUid();
if (CheckPermission(pkgName, callingUid) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerStopRefreshLNN no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -337,80 +346,82 @@ int32_t ServerStopRefreshLNN(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerActiveMetaNode(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerActiveMetaNode(IpcIo *req, IpcIo *reply)
{
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &size);
MetaNodeConfigInfo *info = (MetaNodeConfigInfo *)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char*)ReadString(req, &size);
MetaNodeConfigInfo *info = (MetaNodeConfigInfo *)ReadRawData(req, sizeof(MetaNodeConfigInfo));
if (info == NULL || size != sizeof(MetaNodeConfigInfo)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerActiveMetaNode read meta node config info failed!");
IpcIoPushInt32(reply, SOFTBUS_INVALID_PARAM);
WriteInt32(reply, SOFTBUS_INVALID_PARAM);
return SOFTBUS_ERR;
}
int32_t ret = CheckPermission(pkgName, GetCallingUid(origin));
int32_t ret = CheckPermission(pkgName, GetCallingUid());
if (ret != SOFTBUS_OK) {
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
char metaNodeId[NETWORK_ID_BUF_LEN] = {0};
ret = LnnIpcActiveMetaNode(info, metaNodeId);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerActiveMetaNode failed!");
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
IpcIoPushInt32(reply, SOFTBUS_OK);
IpcIoPushString(reply, metaNodeId);
WriteInt32(reply, SOFTBUS_OK);
WriteString(reply, metaNodeId);
return SOFTBUS_OK;
}
int32_t ServerDeactiveMetaNode(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerDeactiveMetaNode(IpcIo *req, IpcIo *reply)
{
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &size);
const char *metaNodeId = (const char*)IpcIoPopString(req, &size);
const char *pkgName = (const char*)ReadString(req, &size);
const char *metaNodeId = (const char*)ReadString(req, &size);
if (metaNodeId == NULL || size != (NETWORK_ID_BUF_LEN - 1)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR,
"ServerDeactiveMetaNode read meta node id failed, size=%d", size);
IpcIoPushInt32(reply, SOFTBUS_INVALID_PARAM);
WriteInt32(reply, SOFTBUS_INVALID_PARAM);
return SOFTBUS_ERR;
}
int32_t ret = CheckPermission(pkgName, GetCallingUid(origin));
int32_t ret = CheckPermission(pkgName, GetCallingUid());
if (ret != SOFTBUS_OK) {
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
ret = LnnIpcDeactiveMetaNode(metaNodeId);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerDeactiveMetaNode failed!");
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
IpcIoPushInt32(reply, SOFTBUS_OK);
WriteInt32(reply, SOFTBUS_OK);
return SOFTBUS_OK;
}
int32_t ServerGetAllMetaNodeInfo(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerGetAllMetaNodeInfo(IpcIo *req, IpcIo *reply)
{
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &size);
int32_t infoNum = IpcIoPopInt32(req);
const char *pkgName = (const char*)ReadString(req, &size);
int32_t infoNum;
ReadInt32(req, &infoNum);
MetaNodeInfo infos[MAX_META_NODE_NUM];
int32_t ret = CheckPermission(pkgName, GetCallingUid(origin));
int32_t ret = CheckPermission(pkgName, GetCallingUid());
if (ret != SOFTBUS_OK) {
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
ret = LnnIpcGetAllMetaNodeInfo(infos, &infoNum);
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerGetAllMetaNodeInfo failed!");
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_ERR;
}
IpcIoPushInt32(reply, SOFTBUS_OK);
IpcIoPushInt32(reply, infoNum);
WriteInt32(reply, SOFTBUS_OK);
WriteInt32(reply, infoNum);
if (infoNum > 0) {
IpcIoPushFlatObj(reply, infos, infoNum * sizeof(MetaNodeInfo));
WriteUint32(reply, infoNum * sizeof(MetaNodeInfo));
WriteBuffer(reply, infos, infoNum * sizeof(MetaNodeInfo));
}
return SOFTBUS_OK;
}

View File

@ -17,14 +17,14 @@
#include "disc_serializer.h"
#include "discovery_service.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_def.h"
#include "softbus_disc_server.h"
#include "softbus_errcode.h"
#include "softbus_log.h"
#include "softbus_permission.h"
int32_t ServerPublishService(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerPublishService(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "publish service ipc server pop.");
if (req == NULL || reply == NULL) {
@ -32,17 +32,16 @@ int32_t ServerPublishService(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
size_t len;
uint32_t size;
unsigned char *capabilityData = NULL;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
PublishSerializer *info = (PublishSerializer*)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char*)ReadString(req, &len);
PublishSerializer *info = (PublishSerializer*)ReadRawData(req, sizeof(PublishSerializer));
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ipc pop is null.");
return SOFTBUS_ERR;
}
char *capability = (char*)IpcIoPopString(req, &len);
char *capability = (char*)ReadString(req, &len);
if (info->commonSerializer.dataLen != 0) {
capabilityData = (unsigned char*)IpcIoPopString(req, &len);
capabilityData = (unsigned char*)ReadString(req, &len);
}
PublishInfo publishInfo = {
.capability = capability,
@ -53,7 +52,7 @@ int32_t ServerPublishService(const void *origin, IpcIo *req, IpcIo *reply)
.mode = info->commonSerializer.mode,
.publishId = info->commonSerializer.id.publishId
};
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (!CheckDiscPermission(callingUid, pkgName)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "publish service no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -66,13 +65,14 @@ int32_t ServerPublishService(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerUnPublishService(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerUnPublishService(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "unpublish service ipc server pop.");
size_t len;
const char *pkgName = (const char*)IpcIoPopString(req, &len);
int32_t publishId = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char*)ReadString(req, &len);
int32_t publishId;
ReadInt32(req, &publishId);
int32_t callingUid = GetCallingUid();
if (!CheckDiscPermission(callingUid, pkgName)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "publish service no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -85,21 +85,20 @@ int32_t ServerUnPublishService(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerStartDiscovery(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStartDiscovery(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "start discovery ipc server pop.");
size_t len;
uint32_t size;
unsigned char *capabilityData = NULL;
const char *pkgName = (const char *)IpcIoPopString(req, &len);
SubscribeSerializer *info = (SubscribeSerializer *)IpcIoPopFlatObj(req, &size);
const char *pkgName = (const char *)ReadString(req, &len);
SubscribeSerializer *info = (SubscribeSerializer *)ReadRawData(req, sizeof(SubscribeSerializer));
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ipc pop is null.");
return SOFTBUS_ERR;
}
char *capability = (char *)IpcIoPopString(req, &len);
char *capability = (char *)ReadString(req, &len);
if (info->commonSerializer.dataLen != 0) {
capabilityData = (unsigned char *)IpcIoPopString(req, &len);
capabilityData = (unsigned char *)ReadString(req, &len);
}
SubscribeInfo subscribeInfo = {
.capability = capability,
@ -112,7 +111,7 @@ int32_t ServerStartDiscovery(const void *origin, IpcIo *req, IpcIo *reply)
.isSameAccount = info->isSameAccount,
.isWakeRemote = info->isWakeRemote
};
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (!CheckDiscPermission(callingUid, pkgName)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "publish service no permission.");
return SOFTBUS_PERMISSION_DENIED;
@ -125,13 +124,14 @@ int32_t ServerStartDiscovery(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_OK;
}
int32_t ServerStopDiscovery(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerStopDiscovery(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "stop discovery ipc server pop.");
size_t len;
const char *pkgName = (const char *)IpcIoPopString(req, &len);
int32_t subscribeId = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
const char *pkgName = (const char *)ReadString(req, &len);
int32_t subscribeId;
ReadInt32(req, &subscribeId);
int32_t callingUid = GetCallingUid();
if (!CheckDiscPermission(callingUid, pkgName)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "publish service no permission.");
return SOFTBUS_PERMISSION_DENIED;

View File

@ -17,8 +17,8 @@
#include "bus_center_server_stub.h"
#include "disc_server_stub.h"
#include "ipc_skeleton.h"
#include "iproxy_server.h"
#include "liteipc_adapter.h"
#include "lnn_bus_center_ipc.h"
#include "samgr_lite.h"
#include "securec.h"
@ -87,62 +87,53 @@ static void ComponentDeathCallback(const char *pkgName)
BusCenterServerDeathCallback(pkgName);
}
static int32_t ClientDeathCb(const IpcContext *context, void *ipcMsg, IpcIo *data, void *arg)
static void ClientDeathCb(void *arg)
{
if (arg == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "package name is NULL.");
return SOFTBUS_INVALID_PARAM;
return;
}
struct CommonScvId svcId = {0};
if (SERVER_GetIdentityByPkgName((const char *)arg, &svcId) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "not found client by package name.");
SoftBusFree(arg);
arg = NULL;
return SOFTBUS_ERR;
return;
}
SERVER_UnregisterService((const char *)arg);
ComponentDeathCallback((const char *)arg);
SoftBusFree(arg);
arg = NULL;
#ifdef __LINUX__
BinderRelease(svcId.ipcCtx, svcId.handle);
#endif
SvcIdentity sid = {0};
sid.handle = svcId.handle;
sid.token = svcId.token;
sid.cookie = svcId.cookie;
UnregisterDeathCallback(sid, svcId.cbId);
return SOFTBUS_OK;
ReleaseSvc(sid);
}
static int32_t ServerRegisterService(const void *origin, IpcIo *req, IpcIo *reply)
static int32_t ServerRegisterService(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "register service ipc server pop.");
size_t len = 0;
int ret = SOFTBUS_ERR;
struct CommonScvId svcId = {0};
const char *name = (const char*)IpcIoPopString(req, &len);
SvcIdentity *svc = IpcIoPopSvc(req);
if (name == NULL || svc == NULL || len == 0) {
const char *name = (const char*)ReadString(req, &len);
SvcIdentity svc;
bool value = ReadRemoteObject(req, &svc);
if (!value || name == NULL || len == 0) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "get data fail");
goto EXIT;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingUid = GetCallingUid();
if (!CheckBusCenterPermission(callingUid, name)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerRegisterService no permission.");
goto EXIT;
}
svcId.handle = svc->handle;
svcId.token = svc->token;
svcId.cookie = svc->cookie;
SvcIdentity sid = *svc;
#ifdef __LINUX__
svcId.ipcCtx = svc->ipcContext;
BinderAcquire(svcId.ipcCtx, svcId.handle);
SoftBusFree(svc);
svc = NULL;
#endif
svcId.handle = svc.handle;
svcId.token = svc.token;
svcId.cookie = svc.cookie;
char *pkgName = (char *)SoftBusMalloc(len + 1);
if (pkgName == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "softbus malloc failed!");
@ -154,23 +145,17 @@ static int32_t ServerRegisterService(const void *origin, IpcIo *req, IpcIo *repl
goto EXIT;
}
uint32_t cbId = 0;
RegisterDeathCallback(NULL, sid, ClientDeathCb, pkgName, &cbId);
AddDeathRecipient(svc, ClientDeathCb, pkgName, &cbId);
svcId.cbId = cbId;
ret = SERVER_RegisterService(name, &svcId);
EXIT:
#ifdef __LINUX__
if (svc != NULL) {
SoftBusFree(svc);
svc = NULL;
}
#endif
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return SOFTBUS_OK;
}
typedef struct {
enum SoftBusFuncId id;
int32_t (*func)(const void *origin, IpcIo *req, IpcIo *reply);
int32_t (*func)(IpcIo *req, IpcIo *reply);
} ServerInvokeCmd;
ServerInvokeCmd g_serverInvokeCmdTbl[] = {
@ -207,13 +192,13 @@ static int32_t Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "RECEIVE FUNCID:%d", funcId);
if (GetServerIsInit() == false) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "server not init");
IpcIoPushInt32(reply, SOFTBUS_SERVER_NOT_INIT);
WriteInt32(reply, SOFTBUS_SERVER_NOT_INIT);
return SOFTBUS_ERR;
}
int tblSize = sizeof(g_serverInvokeCmdTbl) / sizeof(ServerInvokeCmd);
for (int i = 0; i < tblSize; i++) {
if (funcId == g_serverInvokeCmdTbl[i].id) {
return g_serverInvokeCmdTbl[i].func(origin, req, reply);
return g_serverInvokeCmdTbl[i].func(req, reply);
}
}
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "not support func[%d]", funcId);

View File

@ -15,7 +15,7 @@
#include "trans_server_stub.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "lnn_connection_addr_utils.h"
#include "securec.h"
#include "softbus_common.h"
@ -30,7 +30,8 @@
#include "trans_session_manager.h"
#include "trans_session_service.h"
int32_t ServerCreateSessionServer(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerCreateSessionServer(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "create session server ipc server pop");
if (req == NULL || reply == NULL) {
@ -38,21 +39,21 @@ int32_t ServerCreateSessionServer(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &size);
const char *sessionName = (const char *)IpcIoPopString(req, &size);
int32_t callingUid = GetCallingUid(origin);
int32_t callingPid = GetCallingPid(origin);
const char *pkgName = (const char*)ReadString(req, &size);
const char *sessionName = (const char *)ReadString(req, &size);
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_CREATE) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerCreateSessionServer no permission");
IpcIoPushInt32(reply, SOFTBUS_PERMISSION_DENIED);
WriteInt32(reply, SOFTBUS_PERMISSION_DENIED);
return SOFTBUS_PERMISSION_DENIED;
}
int32_t ret = TransCreateSessionServer(pkgName, sessionName, callingUid, callingPid);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
int32_t ServerRemoveSessionServer(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerRemoveSessionServer(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "remove session server ipc server pop");
if (req == NULL || reply == NULL) {
@ -60,21 +61,21 @@ int32_t ServerRemoveSessionServer(const void *origin, IpcIo *req, IpcIo *reply)
return SOFTBUS_INVALID_PARAM;
}
uint32_t size;
const char *pkgName = (const char*)IpcIoPopString(req, &size);
const char *sessionName = (const char *)IpcIoPopString(req, &size);
int32_t callingUid = GetCallingUid(origin);
int32_t callingPid = GetCallingPid(origin);
const char *pkgName = (const char*)ReadString(req, &size);
const char *sessionName = (const char *)ReadString(req, &size);
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_CREATE) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerRemoveSessionServer no permission");
IpcIoPushInt32(reply, SOFTBUS_PERMISSION_DENIED);
WriteInt32(reply, SOFTBUS_PERMISSION_DENIED);
return SOFTBUS_PERMISSION_DENIED;
}
int32_t ret = TransRemoveSessionServer(pkgName, sessionName);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
static int32_t CheckOpenSessionPremission(const void *origin, const char *sessionName, const char *peerSessionName)
static int32_t CheckOpenSessionPremission(const char *sessionName, const char *peerSessionName)
{
char pkgName[PKG_NAME_SIZE_MAX];
if (TransGetPkgNameBySessionName(sessionName, pkgName, PKG_NAME_SIZE_MAX) != SOFTBUS_OK) {
@ -82,8 +83,8 @@ static int32_t CheckOpenSessionPremission(const void *origin, const char *sessio
return SOFTBUS_INVALID_PARAM;
}
int32_t callingUid = GetCallingUid(origin);
int32_t callingPid = GetCallingPid(origin);
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_OPEN) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "OpenSession no permission");
return SOFTBUS_PERMISSION_DENIED;
@ -96,7 +97,7 @@ static int32_t CheckOpenSessionPremission(const void *origin, const char *sessio
return SOFTBUS_OK;
}
int32_t ServerOpenSession(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerOpenSession(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "open session ipc server pop");
if (req == NULL || reply == NULL) {
@ -110,26 +111,34 @@ int32_t ServerOpenSession(const void *origin, IpcIo *req, IpcIo *reply)
TransSerializer transSerializer;
transSerializer.transInfo.channelId = INVALID_CHANNEL_ID;
transSerializer.transInfo.channelType = CHANNEL_TYPE_BUTT;
param.sessionName = (const char*)IpcIoPopString(req, &size);
param.peerSessionName = (const char *)IpcIoPopString(req, &size);
param.peerDeviceId = (const char *)IpcIoPopString(req, &size);
param.groupId = (const char *)IpcIoPopString(req, &size);
param.attr = (SessionAttribute *)IpcIoPopFlatObj(req, &size);
param.sessionName = (const char*)ReadString(req, &size);
param.peerSessionName = (const char *)ReadString(req, &size);
param.peerDeviceId = (const char *)ReadString(req, &size);
param.groupId = (const char *)ReadString(req, &size);
param.attr = (SessionAttribute *)ReadRawData(req, sizeof(SessionAttribute));
ret = CheckOpenSessionPremission(origin, param.sessionName, param.peerSessionName);
ret = CheckOpenSessionPremission(param.sessionName, param.peerSessionName);
if (ret != SOFTBUS_OK) {
transSerializer.ret = ret;
IpcIoPushFlatObj(reply, (void *)&transSerializer, sizeof(TransSerializer));
WriteUint32(reply, sizeof(TransSerializer));
bool value = WriteBuffer(reply, (void *)&transSerializer, sizeof(TransSerializer));
if (!value) {
return SOFTBUS_ERR;
}
return ret;
}
ret = TransOpenSession(&param, &(transSerializer.transInfo));
transSerializer.ret = ret;
IpcIoPushFlatObj(reply, (void *)&transSerializer, sizeof(TransSerializer));
WriteUint32(reply, sizeof(TransSerializer));
bool value = WriteBuffer(reply, (void *)&transSerializer, sizeof(TransSerializer));
if (!value) {
return SOFTBUS_ERR;
}
return ret;
}
int32_t ServerOpenAuthSession(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerOpenAuthSession(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "open non encrypt session ipc server pop");
if (req == NULL || reply == NULL) {
@ -139,53 +148,54 @@ int32_t ServerOpenAuthSession(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ret;
uint32_t size;
ConnectOption connOpt;
const char *sessionName = (const char*)IpcIoPopString(req, &size);
ConnectionAddr *addr = (ConnectionAddr *)IpcIoPopFlatObj(req, &size);
const char *sessionName = (const char*)ReadString(req, &size);
ConnectionAddr *addr = (ConnectionAddr *)ReadRawData(req, sizeof(ConnectionAddr));
if (!LnnConvertAddrToOption(addr, &connOpt)) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "LnnConvertAddrToOption fail");
IpcIoPushInt32(reply, SOFTBUS_ERR);
WriteInt32(reply, SOFTBUS_ERR);
return SOFTBUS_ERR;
}
ret = CheckOpenSessionPremission(origin, sessionName, sessionName);
ret = CheckOpenSessionPremission(sessionName, sessionName);
if (ret != SOFTBUS_OK) {
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
ret = TransOpenAuthChannel(sessionName, &connOpt);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
int32_t ServerNotifyAuthSuccess(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerNotifyAuthSuccess(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "set auth result server pop");
if (req == NULL || reply == NULL) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
int32_t channelId = IpcIoPopInt32(req);
int32_t callingUid = GetCallingUid(origin);
int32_t callingPid = GetCallingPid(origin);
int32_t channelId = 0;
ReadInt32(req, &channelId);
int32_t callingUid = GetCallingUid();
int32_t callingPid = GetCallingPid();
char pkgName[PKG_NAME_SIZE_MAX];
char sessionName[SESSION_NAME_SIZE_MAX];
if (TransAuthGetNameByChanId(channelId, pkgName, sessionName,
PKG_NAME_SIZE_MAX, SESSION_NAME_SIZE_MAX) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "get session name fail");
IpcIoPushInt32(reply, SOFTBUS_TRANS_UDP_CLOSE_CHANNELID_INVALID);
WriteInt32(reply, SOFTBUS_TRANS_UDP_CLOSE_CHANNELID_INVALID);
return SOFTBUS_TRANS_UDP_CLOSE_CHANNELID_INVALID;
}
if (CheckTransPermission(callingUid, callingPid, pkgName, sessionName, ACTION_OPEN) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ServerCloseChannel no permission");
IpcIoPushInt32(reply, SOFTBUS_PERMISSION_DENIED);
WriteInt32(reply, SOFTBUS_PERMISSION_DENIED);
return SOFTBUS_PERMISSION_DENIED;
}
int32_t ret = TransNotifyAuthSuccess(channelId);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
int32_t ServerCloseChannel(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerCloseChannel(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "close channel ipc server pop");
if (req == NULL || reply == NULL) {
@ -195,30 +205,36 @@ int32_t ServerCloseChannel(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ret;
TransInfo info;
int32_t channelId = IpcIoPopInt32(req);
int32_t channelType = IpcIoPopInt32(req);
int32_t channelId = 0;
int32_t channelType = 0;
ReadInt32(req, &channelId);
ReadInt32(req, &channelType);
info.channelId = channelId;
info.channelType = channelType;
ret = TransCloseChannel(channelId, channelType);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}
int32_t ServerSendSessionMsg(const void *origin, IpcIo *req, IpcIo *reply)
int32_t ServerSendSessionMsg(IpcIo *req, IpcIo *reply)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "server send session msg ipc server pop");
if (req == NULL || reply == NULL) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "invalid param");
return SOFTBUS_INVALID_PARAM;
}
int32_t channelId = IpcIoPopInt32(req);
int32_t channelType = IpcIoPopInt32(req);
int32_t msgType = IpcIoPopInt32(req);
int32_t channelId = 0;
int32_t channelType = 0;
int32_t msgType = 0;
ReadInt32(req, &channelId);
ReadInt32(req, &channelType);
ReadInt32(req, &msgType);
uint32_t size = 0;
const void *data = (const void *)IpcIoPopFlatObj(req, &size);
ReadUint32(req, &size);
const void *data = (const void *)ReadBuffer(req, size);
int32_t ret = TransSendMsg(channelId, channelType, data, size, msgType);
IpcIoPushInt32(reply, ret);
WriteInt32(reply, ret);
return ret;
}

View File

@ -15,7 +15,7 @@
#include "trans_client_proxy.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "serializer.h"
#include "softbus_adapter_mem.h"
#include "softbus_base_listener.h"
@ -35,9 +35,7 @@ static int32_t GetSvcIdentityByPkgName(const char *pkgName, SvcIdentity *svc)
svc->handle = svcId.handle;
svc->token = svcId.token;
svc->cookie = svcId.cookie;
#ifdef __LINUX__
svc->ipcContext = svcId.ipcCtx;
#endif
return SOFTBUS_OK;
}
@ -45,14 +43,17 @@ static int32_t OnUdpChannelOpenedAsServer(const SvcIdentity *svc, IpcIo *io)
{
IpcIo reply;
uintptr_t ptr = 0;
int32_t ans = SendRequest(NULL, *svc, CLIENT_ON_CHANNEL_OPENED, io, &reply, LITEIPC_FLAG_DEFAULT, &ptr);
MessageOption option;
MessageOptionInit(&option);
int32_t ans = SendRequest(*svc, CLIENT_ON_CHANNEL_OPENED, io, &reply, option, &ptr);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpened SendRequest failed");
FreeBuffer(NULL, (void *)ptr);
FreeBuffer((void *)ptr);
return SOFTBUS_ERR;
}
int32_t udpPort = IpcIoPopInt32(&reply);
FreeBuffer(NULL, (void *)ptr);
int32_t udpPort;
ReadInt32(&reply, &udpPort);
FreeBuffer((void *)ptr);
return udpPort;
}
@ -66,20 +67,22 @@ int32_t ClientIpcOnChannelOpened(const char *pkgName, const char *sessionName, c
} else {
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN_EX, 0);
}
IpcIoPushString(&io, sessionName);
IpcIoPushInt32(&io, channel->channelId);
IpcIoPushInt32(&io, channel->channelType);
IpcIoPushBool(&io, channel->isServer);
IpcIoPushBool(&io, channel->isEnabled);
IpcIoPushInt32(&io, channel->peerUid);
IpcIoPushInt32(&io, channel->peerPid);
IpcIoPushString(&io, channel->groupId);
IpcIoPushUint32(&io, channel->keyLen);
IpcIoPushFlatObj(&io, channel->sessionKey, channel->keyLen);
IpcIoPushString(&io, channel->peerSessionName);
IpcIoPushString(&io, channel->peerDeviceId);
WriteString(&io, sessionName);
WriteInt32(&io, channel->channelId);
WriteInt32(&io, channel->channelType);
WriteBool(&io, channel->isServer);
WriteBool(&io, channel->isEnabled);
WriteInt32(&io, channel->peerUid);
WriteInt32(&io, channel->peerPid);
WriteString(&io, channel->groupId);
WriteUint32(&io, channel->keyLen);
WriteBuffer(&io, channel->sessionKey, channel->keyLen);
WriteString(&io, channel->peerSessionName);
WriteString(&io, channel->peerDeviceId);
if (channel->channelType == CHANNEL_TYPE_TCP_DIRECT) {
IpcIoPushFd(&io, channel->fd);
if (!WriteFileDescriptor(&io, channel->fd)){
return SOFTBUS_ERR;
}
}
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
@ -87,17 +90,20 @@ int32_t ClientIpcOnChannelOpened(const char *pkgName, const char *sessionName, c
return SOFTBUS_ERR;
}
if (channel->channelType == CHANNEL_TYPE_UDP) {
IpcIoPushInt32(&io, channel->businessType);
IpcIoPushString(&io, channel->myIp);
IpcIoPushInt32(&io, channel->streamType);
WriteInt32(&io, channel->businessType);
WriteString(&io, channel->myIp);
WriteInt32(&io, channel->streamType);
if (channel->isServer) {
return OnUdpChannelOpenedAsServer(&svc, &io);
}
IpcIoPushInt32(&io, channel->peerPort);
IpcIoPushString(&io, channel->peerIp);
WriteInt32(&io, channel->peerPort);
WriteString(&io, channel->peerIp);
}
IpcIoPushInt32(&io, channel->routeType);
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_CHANNEL_OPENED, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
WriteInt32(&io, channel->routeType);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_CHANNEL_OPENED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpened SendRequest failed");
}
@ -110,14 +116,17 @@ int32_t ClientIpcOnChannelOpenFailed(const char *pkgName, int32_t channelId, int
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, channelId);
IpcIoPushInt32(&io, channelType);
WriteInt32(&io, channelId);
WriteInt32(&io, channelType);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenFailed get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_CHANNEL_OPENFAILED, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_CHANNEL_OPENFAILED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenFailed SendRequest failed");
}
@ -134,14 +143,17 @@ int32_t ClientIpcOnChannelLinkDown(const char *pkgName, const char *networkId, i
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&io, networkId);
IpcIoPushInt32(&io, routeType);
WriteString(&io, networkId);
WriteInt32(&io, routeType);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "OnLeaveLNNResult callback get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_CHANNEL_LINKDOWN, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_CHANNEL_LINKDOWN, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "ClientIpcOnChannelLinkDown callback SendRequest failed.");
return SOFTBUS_ERR;
@ -155,38 +167,45 @@ int32_t ClientIpcOnChannelClosed(const char *pkgName, int32_t channelId, int32_t
IpcIo io;
uint8_t tmpData[MAX_SOFT_BUS_IPC_LEN];
IpcIoInit(&io, tmpData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, channelId);
IpcIoPushInt32(&io, channelType);
WriteInt32(&io, channelId);
WriteInt32(&io, channelType);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenClosed get svc failed.");
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_CHANNEL_CLOSED, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_CHANNEL_CLOSED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenClosed SendRequest failed");
}
return ans;
}
int32_t ClientIpcOnChannelMsgReceived(const char *pkgName, int32_t channelId, int32_t channelType,
int32_t ClientIpcOnChannelMsgReceived(const char *pkgName, int32_t channelId, int32_t channelType,
const void *data, unsigned int len, int32_t type)
{
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "on channel closed ipc server push");
IpcIo io;
uint8_t *tmpData = (uint8_t *)SoftBusCalloc(len + MAX_SOFT_BUS_IPC_LEN);
IpcIoInit(&io, tmpData, len + MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&io, channelId);
IpcIoPushInt32(&io, channelType);
IpcIoPushInt32(&io, type);
IpcIoPushFlatObj(&io, data, len);
WriteInt32(&io, channelId);
WriteInt32(&io, channelType);
WriteInt32(&io, type);
WriteUint32(&io, len);
WriteBuffer(&io, data, len);
SvcIdentity svc = {0};
if (GetSvcIdentityByPkgName(pkgName, &svc) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenClosed get svc failed.");
SoftBusFree(tmpData);
return SOFTBUS_ERR;
}
int32_t ans = SendRequest(NULL, svc, CLIENT_ON_CHANNEL_MSGRECEIVED, &io, NULL, LITEIPC_FLAG_ONEWAY, NULL);
MessageOption option;
MessageOptionInit(&option);
option.flags = TF_OP_ASYNC;
int32_t ans = SendRequest(svc, CLIENT_ON_CHANNEL_MSGRECEIVED, &io, NULL, option, NULL);
if (ans != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OnChannelOpenClosed SendRequest failed");
}

View File

@ -43,7 +43,7 @@ if (defined(ohos_lite)) {
]
trans_session_deps += [
"//build/lite/config/component/cJSON:cjson_shared",
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
]
}
} else {

View File

@ -37,7 +37,7 @@ if (defined(ohos_lite)) {
}
if (ohos_kernel_type != "liteos_m") {
common_client_deps += [
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
"//third_party/bounds_checking_function:libsec_shared",
]

View File

@ -44,7 +44,7 @@ if (defined(ohos_lite)) {
"$dsoftbus_root_path/sdk/bus_center/manager/src/client_bus_center_manager.c",
]
bus_center_manager_sdk_deps += [
"//foundation/communication/ipc_lite:liteipc_adapter",
"//foundation/communication/ipc/interfaces/innerkits/c/ipc:ipc_single",
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
]
}

View File

@ -48,25 +48,26 @@ typedef struct {
static IClientProxy *g_serverProxy = NULL;
static int32_t ClientBusCenterResultCb(IOwner owner, int code, IpcIo *reply)
static int32_t ClientBusCenterResultCb(Reply* info, IpcIo *reply)
{
Reply *info = (Reply *)owner;
uint32_t infoSize;
switch (info->id) {
case GET_ALL_ONLINE_NODE_INFO:
info->arg1 = IpcIoPopInt32(reply);
ReadInt32(reply, &(info->arg1));
if (info->arg1 > 0) {
info->data = (void *)IpcIoPopFlatObj(reply, &infoSize);
ReadUint32(reply, &infoSize);
info->data = (void *)ReadBuffer(reply, infoSize);
}
break;
case GET_LOCAL_DEVICE_INFO:
case GET_NODE_KEY_INFO:
info->data = (void *)IpcIoPopFlatObj(reply, &infoSize);
ReadUint32(reply, &infoSize);
info->data = (void *)ReadBuffer(reply, infoSize);
break;
case ACTIVE_META_NODE:
info->retCode = IpcIoPopInt32(reply);
ReadInt32(reply, &(info->retCode));
if (info->retCode == SOFTBUS_OK) {
info->data = (void *)IpcIoPopString(reply, &infoSize);
info->data = (void *)ReadString(reply, &infoSize);
if (infoSize != (NETWORK_ID_BUF_LEN - 1)) {
SoftBusLog(SOFTBUS_LOG_LNN, SOFTBUS_LOG_ERROR, "invalid meta node id length: %d", infoSize);
return SOFTBUS_ERR;
@ -74,14 +75,15 @@ static int32_t ClientBusCenterResultCb(IOwner owner, int code, IpcIo *reply)
}
break;
case DEACTIVE_META_NODE:
info->retCode = IpcIoPopInt32(reply);
ReadInt32(reply, &(info->retCode));
break;
case GET_ALL_META_NODE:
info->retCode = IpcIoPopInt32(reply);
ReadInt32(reply, &(info->retCode));
if (info->retCode == SOFTBUS_OK) {
info->arg1 = IpcIoPopInt32(reply);
ReadInt32(reply, &(info->arg1));
if (info->arg1 > 0) {
info->data = (void *)IpcIoPopFlatObj(reply, &infoSize);
ReadUint32(reply, &infoSize);
info->data = (void *)ReadBuffer(reply, infoSize);
}
}
break;
@ -143,8 +145,7 @@ int ServerIpcGetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t inf
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushUint32(&request, infoTypeLen);
WriteString(&request, pkgName);
Reply reply = {0};
reply.id = GET_ALL_ONLINE_NODE_INFO;
/* asynchronous invocation */
@ -190,8 +191,8 @@ int32_t ServerIpcGetLocalDeviceInfo(const char *pkgName, void *info, uint32_t in
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushUint32(&request, infoTypeLen);
WriteString(&request, pkgName);
WriteUint32(&request, infoTypeLen);
Reply reply = {0};
reply.id = GET_LOCAL_DEVICE_INFO;
/* asynchronous invocation */
@ -226,10 +227,10 @@ int32_t ServerIpcGetNodeKeyInfo(const char *pkgName, const char *networkId, int
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, networkId);
IpcIoPushInt32(&request, key);
IpcIoPushInt32(&request, len);
WriteString(&request, pkgName);
WriteString(&request, networkId);
WriteInt32(&request, key);
WriteInt32(&request, len);
Reply reply = {0};
reply.id = GET_NODE_KEY_INFO;
/* asynchronous invocation */
@ -264,9 +265,9 @@ int ServerIpcJoinLNN(const char *pkgName, void *addr, unsigned int addrTypeLen)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushUint32(&request, addrTypeLen);
IpcIoPushFlatObj(&request, addr, addrTypeLen);
WriteString(&request, pkgName);
WriteUint32(&request, addrTypeLen);
WriteBuffer(&request, addr, addrTypeLen);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_JOIN_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -290,8 +291,8 @@ int ServerIpcLeaveLNN(const char *pkgName, const char *networkId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, networkId);
WriteString(&request, pkgName);
WriteString(&request, networkId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_LEAVE_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -316,10 +317,10 @@ int32_t ServerIpcStartTimeSync(const char *pkgName, const char *targetNetworkId,
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, targetNetworkId);
IpcIoPushInt32(&request, accuracy);
IpcIoPushInt32(&request, period);
WriteString(&request, pkgName);
WriteString(&request, targetNetworkId);
WriteInt32(&request, accuracy);
WriteInt32(&request, period);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_START_TIME_SYNC, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -344,8 +345,8 @@ int32_t ServerIpcStopTimeSync(const char *pkgName, const char *targetNetworkId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, targetNetworkId);
WriteString(&request, pkgName);
WriteString(&request, targetNetworkId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_STOP_TIME_SYNC, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -369,9 +370,9 @@ int32_t ServerIpcPublishLNN(const char *pkgName, const void *info, uint32_t info
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushUint32(&request, infoLen);
IpcIoPushFlatObj(&request, info, infoLen);
WriteString(&request, pkgName);
WriteUint32(&request, infoLen);
WriteBuffer(&request, info, infoLen);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_PUBLISH_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -396,8 +397,8 @@ int32_t ServerIpcStopPublishLNN(const char *pkgName, int32_t publishId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushInt32(&request, publishId);
WriteString(&request, pkgName);
WriteInt32(&request, publishId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_STOP_PUBLISH_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -421,9 +422,9 @@ int32_t ServerIpcRefreshLNN(const char *pkgName, const void *info, uint32_t info
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushUint32(&request, infoTypeLen);
IpcIoPushFlatObj(&request, info, infoTypeLen);
WriteString(&request, pkgName);
WriteUint32(&request, infoTypeLen);
WriteBuffer(&request, info, infoTypeLen);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_REFRESH_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -448,8 +449,8 @@ int32_t ServerIpcStopRefreshLNN(const char *pkgName, int32_t refreshId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushInt32(&request, refreshId);
WriteString(&request, pkgName);
WriteInt32(&request, refreshId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_STOP_REFRESH_LNN, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -469,8 +470,11 @@ int32_t ServerIpcActiveMetaNode(const char *pkgName, const MetaNodeConfigInfo *i
uint8_t data[MAX_SOFT_BUS_IPC_LEN_EX] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN_EX, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushFlatObj(&request, info, sizeof(MetaNodeConfigInfo));
WriteString(&request, pkgName);
bool ret = WriteRawData(&request, info, sizeof(MetaNodeConfigInfo));
if (!ret) {
return SOFTBUS_ERR;
}
Reply reply = {0};
reply.id = ACTIVE_META_NODE;
/* asynchronous invocation */
@ -502,8 +506,8 @@ int32_t ServerIpcDeactiveMetaNode(const char *pkgName, const char *metaNodeId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, metaNodeId);
WriteString(&request, pkgName);
WriteString(&request, metaNodeId);
Reply reply = {0};
reply.id = DEACTIVE_META_NODE;
/* asynchronous invocation */
@ -527,8 +531,8 @@ int32_t ServerIpcGetAllMetaNodeInfo(const char *pkgName, MetaNodeInfo *infos, in
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushInt32(&request, *infoNum);
WriteString(&request, pkgName);
WriteInt32(&request, *infoNum);
Reply reply = {0};
reply.id = GET_ALL_META_NODE;
/* asynchronous invocation */

View File

@ -81,7 +81,7 @@ int ServerIpcPublishService(const char *pkgName, const PublishInfo *info)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
WriteString(&request, pkgName);
DiscSerializer serializer = {
.dataLen = info->dataLen,
.freq = info->freq,
@ -92,10 +92,13 @@ int ServerIpcPublishService(const char *pkgName, const PublishInfo *info)
PublishSerializer publishSerializer = {
.commonSerializer = serializer
};
IpcIoPushFlatObj(&request, (void*)&publishSerializer, sizeof(PublishSerializer));
IpcIoPushString(&request, info->capability);
bool ret = WriteRawData(&request, (void*)&publishSerializer, sizeof(PublishSerializer));
if (!ret) {
return SOFTBUS_ERR;
}
WriteString(&request, info->capability);
if (info->dataLen != 0) {
IpcIoPushString(&request, (const char *)(info->capabilityData));
WriteString(&request, (const char *)(info->capabilityData));
}
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_PUBLISH_SERVICE, &request, NULL, NULL);
@ -120,8 +123,8 @@ int ServerIpcUnPublishService(const char *pkgName, int publishId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushInt32(&request, publishId);
WriteString(&request, pkgName);
WriteInt32(&request, publishId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_UNPUBLISH_SERVICE, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {
@ -145,7 +148,7 @@ int ServerIpcStartDiscovery(const char *pkgName, const SubscribeInfo *info)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
WriteString(&request, pkgName);
DiscSerializer serializer = {
.dataLen = info->dataLen,
.freq = info->freq,
@ -158,10 +161,13 @@ int ServerIpcStartDiscovery(const char *pkgName, const SubscribeInfo *info)
.isSameAccount = info->isSameAccount,
.isWakeRemote = info->isWakeRemote
};
IpcIoPushFlatObj(&request, (void*)&subscribeSerializer, sizeof(SubscribeSerializer));
IpcIoPushString(&request, info->capability);
bool ret = WriteRawData(&request, (void*)&subscribeSerializer, sizeof(SubscribeSerializer));
if (!ret) {
return SOFTBUS_ERR;
}
WriteString(&request, info->capability);
if (info->dataLen != 0) {
IpcIoPushString(&request, (const char *)(info->capabilityData));
WriteString(&request, (const char *)(info->capabilityData));
}
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_START_DISCOVERY, &request, NULL, NULL);
@ -186,8 +192,8 @@ int ServerIpcStopDiscovery(const char *pkgName, int subscribeId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushInt32(&request, subscribeId);
WriteString(&request, pkgName);
WriteInt32(&request, subscribeId);
/* asynchronous invocation */
int32_t ans = g_serverProxy->Invoke(g_serverProxy, SERVER_STOP_DISCOVERY, &request, NULL, NULL);
if (ans != SOFTBUS_OK) {

View File

@ -24,14 +24,14 @@ extern "C" {
#endif
#endif
int32_t ClientOnJoinLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnLeaveLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnNodeOnlineStateChanged(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnNodeBasicInfoChanged(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnTimeSyncResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
void ClientOnPublishLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
void ClientOnRefreshLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
void ClientOnRefreshDeviceFound(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnJoinLNNResult(IpcIo *data, IpcIo *reply);
int32_t ClientOnLeaveLNNResult(IpcIo *data, IpcIo *reply);
int32_t ClientOnNodeOnlineStateChanged(IpcIo *data, IpcIo *reply);
int32_t ClientOnNodeBasicInfoChanged(IpcIo *data, IpcIo *reply);
int32_t ClientOnTimeSyncResult(IpcIo *data, IpcIo *reply);
void ClientOnPublishLNNResult(IpcIo *data, IpcIo *reply);
void ClientOnRefreshLNNResult(IpcIo *data, IpcIo *reply);
void ClientOnRefreshDeviceFound(IpcIo *data, IpcIo *reply);
#ifdef __cplusplus
#if __cplusplus

View File

@ -24,11 +24,11 @@ extern "C" {
#endif
#endif
int32_t ClientOnDiscoverySuccess(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnDiscoverFailed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnDeviceFound(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnPublishSuccess(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnPublishFail(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnDiscoverySuccess(IpcIo *data, IpcIo *reply);
int32_t ClientOnDiscoverFailed(IpcIo *data, IpcIo *reply);
int32_t ClientOnDeviceFound(IpcIo *data, IpcIo *reply);
int32_t ClientOnPublishSuccess(IpcIo *data, IpcIo *reply);
int32_t ClientOnPublishFail(IpcIo *data, IpcIo *reply);
#ifdef __cplusplus
#if __cplusplus

View File

@ -23,8 +23,8 @@ extern "C" {
int ClientContextInit(void);
void ClientContextDeinit(void);
void SetClientIdentity(unsigned int handle, unsigned int token, unsigned int cookie, void *ctx);
int GetClientIdentity(unsigned int *handle, unsigned int *token, unsigned int *cookie, void **ctx);
void SetClientIdentity(unsigned int handle, unsigned int token, unsigned int cookie);
int GetClientIdentity(unsigned int *handle, unsigned int *token, unsigned int *cookie);
#ifdef __cplusplus
}

View File

@ -22,10 +22,10 @@
extern "C" {
#endif
int32_t ClientOnChannelOpened(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnChannelOpenfailed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnChannelClosed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnChannelMsgreceived(IpcIo *reply, const IpcContext *ctx, void *ipcMsg);
int32_t ClientOnChannelOpened(IpcIo *data, IpcIo *reply);
int32_t ClientOnChannelOpenfailed(IpcIo *data, IpcIo *reply);
int32_t ClientOnChannelClosed(IpcIo *data, IpcIo *reply);
int32_t ClientOnChannelMsgreceived(IpcIo *data, IpcIo *reply);
#ifdef __cplusplus
}

View File

@ -18,183 +18,169 @@
#include <stdint.h>
#include "client_bus_center_manager.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_errcode.h"
#include "softbus_log.h"
int32_t ClientOnJoinLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnJoinLNNResult(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
uint32_t addrSize;
void *addr = (void *)IpcIoPopFlatObj(reply, &addrSize);
ReadUint32(data, &addrSize);
void *addr = (void *)ReadBuffer(data, addrSize);
if (addr == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnJoinLNNResult read addr failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
int32_t retCode = IpcIoPopInt32(reply);
int32_t retCode = 0;
ReadInt32(data, &retCode);
size_t networkIdLen;
const char *networkId = NULL;
if (retCode == 0) {
networkId = (const char *)IpcIoPopString(reply, &networkIdLen);
networkId = (const char *)ReadString(data, &networkIdLen);
if (networkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnJoinLNNResult read networkId failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
}
int32_t retReply = LnnOnJoinResult(addr, networkId, retCode);
if (retReply != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnJoinLNNResult LnnOnJoinResult failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnLeaveLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnLeaveLNNResult(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
size_t networkIdLen;
const char *networkId = (const char *)IpcIoPopString(reply, &networkIdLen);
const char *networkId = (const char *)ReadString(data, &networkIdLen);
if (networkId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnLeaveLNNResult read networkId failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
int32_t retCode = IpcIoPopInt32(reply);
int32_t retCode = 0;
ReadInt32(data, &retCode);
int32_t retReply = LnnOnLeaveResult(networkId, retCode);
if (retReply != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnLeaveLNNResult LnnOnLeaveResult failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnNodeOnlineStateChanged(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnNodeOnlineStateChanged(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data== NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
bool isOnline = IpcIoPopBool(reply);
uint32_t infoSize;
void *info = (void *)IpcIoPopFlatObj(reply, &infoSize);
bool isOnline;
ReadBool(data, &isOnline);
uint32_t infoSize = 0;
ReadUint32(data, &infoSize);
void *info = (void *)ReadBuffer(data, infoSize);
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnNodeOnlineStateChanged read basic info failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
int32_t retReply = LnnOnNodeOnlineStateChanged(isOnline, info);
if (retReply != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR,
"ClientOnNodeOnlineStateChanged LnnOnNodeOnlineStateChanged failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnNodeBasicInfoChanged(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnNodeBasicInfoChanged(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
int32_t type = IpcIoPopInt32(reply);
uint32_t infoSize;
void *info = (void *)IpcIoPopFlatObj(reply, &infoSize);
int32_t type = 0;
ReadInt32(data, &type);
uint32_t infoSize = 0;
ReadUint32(data, &infoSize);
void *info = (void *)ReadBuffer(data, infoSize);
int32_t retReply = LnnOnNodeBasicInfoChanged(info, type);
if (retReply != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR,
"ClientOnNodeBasicInfoChanged LnnOnNodeBasicInfoChanged failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnTimeSyncResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnTimeSyncResult(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
uint32_t infoSize;
void *info = (void *)IpcIoPopFlatObj(reply, &infoSize);
uint32_t infoSize = 0;
ReadUint32(data, &infoSize);
void *info = (void *)ReadBuffer(data, infoSize);
if (info == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnTimeSyncResult read info failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
int32_t retCode = IpcIoPopInt32(reply);
int32_t retCode = 0;
ReadInt32(data, &retCode);
int32_t retReply = LnnOnTimeSyncResult(info, retCode);
if (retReply != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "ClientOnTimeSyncResult LnnOnTimeSyncResult failed!");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
void ClientOnPublishLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
void ClientOnPublishLNNResult(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return;
}
int32_t publishId = IpcIoPopInt32(reply);
int32_t reason = IpcIoPopInt32(reply);
int32_t publishId;
ReadInt32(data, &publishId);
int32_t reason;
ReadInt32(data, &reason);
LnnOnPublishLNNResult(publishId, reason);
FreeBuffer(ctx, ipcMsg);
}
void ClientOnRefreshLNNResult(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
void ClientOnRefreshLNNResult(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return;
}
int32_t refreshId = IpcIoPopInt32(reply);
int32_t reason = IpcIoPopInt32(reply);
int32_t refreshId;
ReadInt32(data, &refreshId);
int32_t reason;
ReadInt32(data, &reason);
LnnOnRefreshLNNResult(refreshId, reason);
FreeBuffer(ctx, ipcMsg);
}
void ClientOnRefreshDeviceFound(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
void ClientOnRefreshDeviceFound(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return;
}
uint32_t infoSize;
void *info = (void *)IpcIoPopFlatObj(reply, &infoSize);
ReadUint32(data, &infoSize);
void *info = (void *)ReadBuffer(data, infoSize);
LnnOnRefreshDeviceFound(info);
FreeBuffer(ctx, ipcMsg);
}

View File

@ -16,83 +16,77 @@
#include "disc_client_stub.h"
#include "client_disc_manager.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_errcode.h"
#include "softbus_log.h"
int32_t ClientOnDiscoverySuccess(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnDiscoverySuccess(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t subscribeId = IpcIoPopInt32(reply);
int32_t subscribeId = 0;
ReadInt32(data, &subscribeId);
DiscClientOnDiscoverySuccess(subscribeId);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnDiscoverFailed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnDiscoverFailed(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t subscribeId = IpcIoPopInt32(reply);
int32_t failReason = IpcIoPopInt32(reply);
int32_t subscribeId = 0;
int32_t failReason = 0;
ReadInt32(data, &subscribeId);
ReadInt32(data, &failReason);
DiscClientOnDiscoverFailed(subscribeId, failReason);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnDeviceFound(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnDeviceFound(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
uint32_t size;
const DeviceInfo *deviceInfo = (const DeviceInfo*)IpcIoPopFlatObj(reply, &size);
const DeviceInfo *deviceInfo = (const DeviceInfo*)ReadRawData(reply, sizeof(DeviceInfo));
if (deviceInfo == NULL) {
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
DiscClientOnDeviceFound(deviceInfo);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnPublishSuccess(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnPublishSuccess(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t publishId = IpcIoPopInt32(reply);
int32_t publishId = 0;
ReadInt32(data, &publishId);
DiscClientOnPublishSuccess(publishId);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnPublishFail(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnPublishFail(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t publishId = IpcIoPopInt32(reply);
int32_t failReason = IpcIoPopInt32(reply);
int32_t publishId = 0;
int32_t failReason = 0;
ReadInt32(data, &publishId);
ReadInt32(data, &failReason);
DiscClientOnPublishFail(publishId, failReason);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}

View File

@ -23,7 +23,6 @@ typedef struct {
unsigned int handle;
unsigned int token;
unsigned int cookie;
void *ctx;
} SoftBusClientContext;
static SoftBusClientContext *g_clientCtx = NULL;
@ -51,7 +50,7 @@ void ClientContextDeinit(void)
g_clientCtx = NULL;
}
void SetClientIdentity(unsigned int handle, unsigned int token, unsigned int cookie, void *ctx)
void SetClientIdentity(unsigned int handle, unsigned int token, unsigned int cookie)
{
if (g_clientCtx == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "client ctx not init");
@ -61,12 +60,11 @@ void SetClientIdentity(unsigned int handle, unsigned int token, unsigned int coo
g_clientCtx->handle = handle;
g_clientCtx->token = token;
g_clientCtx->cookie = cookie;
g_clientCtx->ctx = ctx;
}
int GetClientIdentity(unsigned int *handle, unsigned int *token, unsigned int *cookie, void **ctx)
int GetClientIdentity(unsigned int *handle, unsigned int *token, unsigned int *cookie)
{
if (handle == NULL || token == NULL || cookie == NULL || ctx == NULL) {
if (handle == NULL || token == NULL || cookie == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param");
return SOFTBUS_ERR;
}
@ -79,7 +77,6 @@ int GetClientIdentity(unsigned int *handle, unsigned int *token, unsigned int *c
*handle = g_clientCtx->handle;
*token = g_clientCtx->token;
*cookie = g_clientCtx->cookie;
*ctx = g_clientCtx->ctx;
return SOFTBUS_OK;
}

View File

@ -16,7 +16,7 @@
#include "bus_center_client_stub.h"
#include "disc_client_stub.h"
#include "iproxy_client.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_adapter_mem.h"
#include "softbus_adapter_thread.h"
#include "softbus_adapter_timer.h"
@ -38,7 +38,7 @@ static SvcIdentity g_svcIdentity = {0};
struct SoftBusIpcClientCmd {
enum SoftBusFuncId code;
int32_t (*func)(IpcIo *io, const IpcContext *ctx, void *ipcMsg);
int32_t (*func)(IpcIo *data, IpcIo *reply);
};
static struct SoftBusIpcClientCmd g_softBusIpcClientCmdTbl[] = {
@ -61,22 +61,18 @@ static struct SoftBusIpcClientCmd g_softBusIpcClientCmdTbl[] = {
{ CLIENT_ON_CHANNEL_MSGRECEIVED, ClientOnChannelMsgreceived },
};
static int ClientIpcInterfaceMsgHandle(const IpcContext *ctx, void *ipcMsg, IpcIo *io, void *arg)
static int ClientIpcInterfaceMsgHandle(uint32_t code, IpcIo *data, IpcIo *reply, MessageOption option)
{
uint32_t code = 0;
(void)arg;
if (ipcMsg == NULL || io == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param");
return SOFTBUS_ERR;
}
GetCode(ipcMsg, &code);
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "receive ipc transact code(%u)", code);
unsigned int num = sizeof(g_softBusIpcClientCmdTbl) / sizeof(struct SoftBusIpcClientCmd);
for (unsigned int i = 0; i < num; i++) {
if (code == g_softBusIpcClientCmdTbl[i].code) {
return g_softBusIpcClientCmdTbl[i].func(io, ctx, ipcMsg);
return g_softBusIpcClientCmdTbl[i].func(data, reply);
}
}
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "not support code(%u)", code);
@ -93,7 +89,7 @@ static int InnerRegisterService(void)
}
struct CommonScvId svcId = {0};
if (GetClientIdentity(&svcId.handle, &svcId.token, &svcId.cookie, &svcId.ipcCtx) != SOFTBUS_OK) {
if (GetClientIdentity(&svcId.handle, &svcId.token, &svcId.cookie) != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "get client identity failed");
for (uint32_t i = 0; i < clientNameNum; i++) {
SoftBusFree(clientName[i]);
@ -114,7 +110,7 @@ static int InnerRegisterService(void)
static void UnregisterServerDeathCb(void)
{
UnregisterDeathCallback(g_svcIdentity, g_deathCbId);
RemoveDeathRecipient(g_svcIdentity, g_deathCbId);
g_deathCbId = INVALID_CB_ID;
g_svcIdentity.handle = 0;
g_svcIdentity.token = 0;
@ -165,34 +161,24 @@ static int StartDeathProcTask(void)
return ret;
}
static int32_t DeathCallback(const IpcContext *ctx, void *ipcMsg, IpcIo *data, void *arg)
static void DeathCallback()
{
(void)ctx;
(void)ipcMsg;
(void)data;
(void)arg;
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_WARN, "\n<< ATTENTION !!! >> SERVICE (%s) DEAD !!!\n", SOFTBUS_SERVICE);
if (StartDeathProcTask() != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "start death proc task failed");
return SOFTBUS_ERR;
} else {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "client start check softbus server...");
}
return SOFTBUS_OK;
}
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "client start check softbus server...");
}
static int RegisterServerDeathCb(void)
{
g_svcIdentity = SAMGR_GetRemoteIdentity(SOFTBUS_SERVICE, NULL);
g_deathCbId = INVALID_CB_ID;
if (RegisterDeathCallback(NULL, g_svcIdentity, DeathCallback, NULL, &g_deathCbId) != EC_SUCCESS) {
if (AddDeathRecipient(g_svcIdentity, DeathCallback, NULL, &g_deathCbId) != EC_SUCCESS) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "reg death callback failed");
return SOFTBUS_ERR;
}
return SOFTBUS_OK;
}
@ -202,23 +188,24 @@ int ClientStubInit(void)
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "server proxy init failed.");
return SOFTBUS_ERR;
}
SvcIdentity clientIdentity = {0};
int ret = RegisterIpcCallback(ClientIpcInterfaceMsgHandle, 0, IPC_WAIT_FOREVER, &clientIdentity, NULL);
if (ret != 0) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "register ipc cb failed");
return SOFTBUS_ERR;
}
ret = ClientContextInit();
static IpcObjectStub objectStub = {
.func = ClientIpcInterfaceMsgHandle,
.args = NULL,
.isRemote = false
};
SvcIdentity clientIdentity = {
.handle = IPC_INVALID_HANDLE,
.token = SERVICE_TYPE_ANONYMOUS,
.cookie = (uintptr_t)&objectStub
};
int ret = ClientContextInit();
if (ret != SOFTBUS_OK) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "client context init failed.");
return SOFTBUS_ERR;
}
#ifdef __LINUX__
SetClientIdentity(clientIdentity.handle, clientIdentity.token, clientIdentity.cookie, clientIdentity.ipcContext);
#else
SetClientIdentity(clientIdentity.handle, clientIdentity.token, clientIdentity.cookie, NULL);
#endif
SetClientIdentity(clientIdentity.handle, clientIdentity.token, clientIdentity.cookie);
if (RegisterServerDeathCb() != SOFTBUS_OK) {
ClientContextDeinit();
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "reg server death cb failed");

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#include "ipc_skeleton.h"
#include "iproxy_client.h"
#include "liteipc_adapter.h"
#include "samgr_lite.h"
#include "softbus_adapter_file.h"
#include "softbus_adapter_timer.h"
@ -31,7 +31,7 @@ static IClientProxy *g_serverProxy = NULL;
static int ClientSimpleResultCb(IOwner owner, int code, IpcIo *reply)
{
*(int *)owner = IpcIoPopInt32(reply);
ReadInt32(reply, (int *)owner);
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_INFO, "retvalue:%d", *(int *)owner);
return EC_SUCCESS;
}
@ -77,16 +77,16 @@ int32_t RegisterService(const char *name, const struct CommonScvId *svcId)
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 1);
IpcIoPushString(&request, name);
WriteString(&request, name);
SvcIdentity svc = {0};
svc.handle = svcId->handle;
svc.token = svcId->token;
svc.cookie = svcId->cookie;
#ifdef __LINUX__
svc.ipcContext = svcId->ipcCtx;
#endif
IpcIoPushSvc(&request, &svc);
bool value = WriteRemoteObject(&request, &svc);
if (!value) {
return SOFTBUS_ERR;
}
int ret = SOFTBUS_ERR;
if (g_serverProxy->Invoke(g_serverProxy, MANAGE_REGISTER_SERVICE, &request, &ret,

View File

@ -16,106 +16,101 @@
#include "trans_client_stub.h"
#include "client_trans_channel_callback.h"
#include "liteipc_adapter.h"
#include "ipc_skeleton.h"
#include "softbus_errcode.h"
#include "softbus_ipc_def.h"
#include "softbus_log.h"
int32_t ClientOnChannelOpened(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnChannelOpened(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
size_t size = 0;
ChannelInfo channel = {0};
const char *sessionName = (const char *)IpcIoPopString(reply, &size);
channel.channelId = IpcIoPopInt32(reply);
channel.channelType = IpcIoPopInt32(reply);
channel.isServer = IpcIoPopBool(reply);
channel.isEnabled = IpcIoPopBool(reply);
channel.peerUid = IpcIoPopInt32(reply);
channel.peerPid = IpcIoPopInt32(reply);
channel.groupId = (char *)IpcIoPopString(reply, &size);
channel.keyLen = IpcIoPopUint32(reply);
channel.sessionKey = (char *)IpcIoPopFlatObj(reply, &size);
channel.peerSessionName = (char *)IpcIoPopString(reply, &size);
channel.peerDeviceId = (char *)IpcIoPopString(reply, &size);
const char *sessionName = (const char *)ReadString(reply, &size);
ReadInt32(data, &(channel.channelId));
ReadInt32(data, &(channel.channelType));
ReadBool(data, &(channel.isServer));
ReadBool(data, &(channel.isEnabled));
ReadInt32(data, &(channel.peerUid));
ReadInt32(data, &(channel.peerPid));
channel.groupId = (char *)ReadString(data, &size);
ReadUint32(reply, &(channel.keyLen));
channel.sessionKey = (char *)ReadBuffer(data, channel.keyLen);
channel.peerSessionName = (char *)ReadString(data, &size);
channel.peerDeviceId = (char *)ReadString(data, &size);
if (channel.groupId == NULL || channel.sessionKey == NULL || channel.peerSessionName == NULL ||
channel.peerDeviceId == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "pointer null error.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_ERR;
}
if (channel.channelType == CHANNEL_TYPE_TCP_DIRECT) {
channel.fd = IpcIoPopFd(reply);
channel.fd = ReadFileDescriptor(reply);
}
if (channel.channelType == CHANNEL_TYPE_UDP) {
channel.businessType = IpcIoPopInt32(reply);
channel.myIp = (char *)IpcIoPopString(reply, &size);
channel.streamType = IpcIoPopInt32(reply);
ReadInt32(reply, &(channel.businessType));
channel.myIp = (char *)ReadString(reply, &size);
ReadInt32(reply, &(channel.streamType));
if (channel.isServer) {
int32_t udpPort = TransOnChannelOpened(sessionName, &channel);
IpcIo ret;
uint8_t tempData[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIoInit(&ret, tempData, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&ret, udpPort);
SendReply(NULL, ipcMsg, &ret);
WriteInt32(reply, udpPort);
return SOFTBUS_ERR;
}
channel.peerPort = IpcIoPopInt32(reply);
channel.peerIp = (char *)IpcIoPopString(reply, &size);
ReadInt32(reply, &(channel.peerPort));
channel.peerIp = (char *)ReadString(reply, &size);
}
int ret = TransOnChannelOpened(sessionName, &channel);
if (ret < 0) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "TransOnChannelOpened fail, error code: %d.", ret);
}
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnChannelOpenfailed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnChannelOpenfailed(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t channelId = IpcIoPopInt32(reply);
int32_t channelType = IpcIoPopInt32(reply);
int32_t channelId = 0;
int32_t channelType = 0;
ReadInt32(data, &channelId);
ReadInt32(data, &channelType);
(void)TransOnChannelOpenFailed(channelId, channelType);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnChannelClosed(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnChannelClosed(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t channelId = IpcIoPopInt32(reply);
int32_t channelType = IpcIoPopInt32(reply);
int32_t channelId = 0;
int32_t channelType = 0;
ReadInt32(data, &channelId);
ReadInt32(data, &channelType);
(void)TransOnChannelClosed(channelId, channelType);
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_OK;
}
int32_t ClientOnChannelMsgreceived(IpcIo *reply, const IpcContext *ctx, void *ipcMsg)
int32_t ClientOnChannelMsgreceived(IpcIo *data, IpcIo *reply)
{
if (reply == NULL) {
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "invalid param.");
FreeBuffer(ctx, ipcMsg);
return SOFTBUS_INVALID_PARAM;
}
int32_t channelId = IpcIoPopInt32(reply);
int32_t channelType = IpcIoPopInt32(reply);
int32_t type = IpcIoPopInt32(reply);
int32_t channelId = 0;
int32_t channelType = 0;
int32_t type = 0;
ReadInt32(data, &channelId);
ReadInt32(data, &channelType);
ReadInt32(data, &type);
uint32_t dataLen = 0;
void *data = IpcIoPopFlatObj(reply, &dataLen);
(void)TransOnChannelMsgReceived(channelId, channelType, data, dataLen, type);
FreeBuffer(ctx, ipcMsg);
ReadUint32(data, &dataLen);
void *data2 = ReadBuffer(data, dataLen);
(void)TransOnChannelMsgReceived(channelId, channelType, data2, dataLen, type);
return SOFTBUS_OK;
}

View File

@ -37,7 +37,7 @@ static int ProxyCallback(IOwner owner, int code, IpcIo *reply)
return SOFTBUS_ERR;
}
*(int32_t*)owner = IpcIoPopInt32(reply);
ReadInt32(reply, (int *)owner);
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "publish service return[%d].", *(int32_t*)owner);
return SOFTBUS_OK;
}
@ -49,8 +49,8 @@ static int OpenSessionProxyCallback(IOwner owner, int code, IpcIo *reply)
return SOFTBUS_ERR;
}
uint32_t size;
void *data = IpcIoPopFlatObj(reply, &size);
ReadUint32(reply, &size);
void *data = (void *)ReadBuffer(reply, size);
if (data == NULL) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "pop data is null.");
return SOFTBUS_ERR;
@ -107,8 +107,8 @@ int32_t ServerIpcCreateSessionServer(const char *pkgName, const char *sessionNam
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, sessionName);
WriteString(&request, pkgName);
WriteString(&request, sessionName);
int32_t ret = SOFTBUS_ERR;
/* sync */
@ -136,8 +136,8 @@ int32_t ServerIpcRemoveSessionServer(const char *pkgName, const char *sessionNam
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, pkgName);
IpcIoPushString(&request, sessionName);
WriteString(&request, pkgName);
WriteString(&request, sessionName);
int32_t ret = SOFTBUS_ERR;
/* sync */
@ -161,11 +161,14 @@ int32_t ServerIpcOpenSession(const SessionParam *param, TransInfo *info)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, param->sessionName);
IpcIoPushString(&request, param->peerSessionName);
IpcIoPushString(&request, param->peerDeviceId);
IpcIoPushString(&request, param->groupId);
IpcIoPushFlatObj(&request, (void*)param->attr, sizeof(SessionAttribute));
WriteString(&request, param->sessionName);
WriteString(&request, param->peerSessionName);
WriteString(&request, param->peerDeviceId);
WriteString(&request, param->groupId);
bool value = WriteRawData(&request, (void*)param->attr, sizeof(SessionAttribute));
if (!value) {
return SOFTBUS_ERR;
}
TransSerializer transSerializer;
transSerializer.ret = SOFTBUS_ERR;
@ -193,8 +196,11 @@ int32_t ServerIpcOpenAuthSession(const char *sessionName, const ConnectionAddr *
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushString(&request, sessionName);
IpcIoPushFlatObj(&request, (void*)addrInfo, sizeof(ConnectionAddr));
WriteString(&request, sessionName);
bool value = WriteRawData(&request, (void*)addrInfo, sizeof(ConnectionAddr));
if (!value) {
return SOFTBUS_ERR;
}
int32_t ret = SOFTBUS_ERR;
if (g_serverProxy == NULL) {
@ -217,7 +223,7 @@ int32_t ServerIpcNotifyAuthSuccess(int channelId)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&request, channelId);
WriteInt32(&request, channelId);
int32_t ret = SOFTBUS_ERR;
if (g_serverProxy == NULL) {
SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "server proxy not init");
@ -238,8 +244,8 @@ int32_t ServerIpcCloseChannel(int32_t channelId, int32_t channelType)
uint8_t data[MAX_SOFT_BUS_IPC_LEN] = {0};
IpcIo request = {0};
IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0);
IpcIoPushInt32(&request, channelId);
IpcIoPushInt32(&request, channelType);
WriteInt32(&request, channelId);
WriteInt32(&request, channelType);
int32_t ret = SOFTBUS_ERR;
/* sync */
@ -264,10 +270,11 @@ int32_t ServerIpcSendMessage(int32_t channelId, int32_t channelType, const void
uint8_t *ipcData = (uint8_t *)SoftBusCalloc(ipcDataLen);
IpcIo request = {0};
IpcIoInit(&request, ipcData, ipcDataLen, 0);
IpcIoPushInt32(&request, channelId);
IpcIoPushInt32(&request, channelType);
IpcIoPushInt32(&request, msgType);
IpcIoPushFlatObj(&request, data, len);
WriteInt32(&request, channelId);
WriteInt32(&request, channelType);
WriteInt32(&request, msgType);
WriteUint32(&request, len);
WriteBuffer(&request, data, len);
int32_t ret = SOFTBUS_ERR;
/* sync */