From 3dcb5de8cbdc1cc5ea7c0247a92c55ec0f80d3c9 Mon Sep 17 00:00:00 2001 From: xzh457 Date: Sat, 14 Sep 2024 14:59:18 +0800 Subject: [PATCH] hi3568 bind failed Signed-off-by: xzh457 Change-Id: I8bb51fffd73a18daa359d043b42c439a28782c31 --- core/frame/small/init/src/trans_server_stub.c | 48 +++++++++++++++++++ .../ipc/small/trans_server_proxy.c | 33 ++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/core/frame/small/init/src/trans_server_stub.c b/core/frame/small/init/src/trans_server_stub.c index cc178b887..e9de6739f 100644 --- a/core/frame/small/init/src/trans_server_stub.c +++ b/core/frame/small/init/src/trans_server_stub.c @@ -154,6 +154,50 @@ static void ServerReadSessionAttrs(IpcIo *req, SessionAttribute *getAttr) } } +static bool ReadQosInfo(IpcIo *req, SessionParam *param) +{ + if (req == NULL || param == NULL) { + TRANS_LOGE(TRANS_CTRL, "param or req is NULL"); + return false; + } + + if (!ReadBool(req, ¶m->isQosLane)) { + TRANS_LOGE(TRANS_SDK, "read qos flag failed!"); + return false; + } + + if (!param->isQosLane) { + return true; + } + + if (!ReadUint32(req, ¶m->qosCount)) { + TRANS_LOGE(TRANS_SDK, "read count of qos failed!"); + return false; + } + + if (param->qosCount == 0) { + return true; + } + + if (param->qosCount > QOS_TYPE_BUTT) { + TRANS_LOGE(TRANS_SDK, "read invalid qosCount=%{public}" PRIu32, param->qosCount); + return false; + } + + const QosTV *qosInfo = (QosTV *)ReadBuffer(req, sizeof(QosTV) * param->qosCount); + if (qosInfo == NULL) { + COMM_LOGE(COMM_SVC, "failed to read qos data"); + return false; + } + + if (memcpy_s(param->qos, sizeof(QosTV) * QOS_TYPE_BUTT, qosInfo, sizeof(QosTV) * param->qosCount) != EOK) { + COMM_LOGE(COMM_SVC, "failed memcpy qos info"); + return false; + } + + return true; +} + int32_t ServerOpenSession(IpcIo *req, IpcIo *reply) { TRANS_LOGI(TRANS_CTRL, "ipc server pop"); @@ -179,6 +223,10 @@ int32_t ServerOpenSession(IpcIo *req, IpcIo *reply) ReadInt32(req, ¶m.sessionId); ServerReadSessionAttrs(req, &getAttr); param.attr = &getAttr; + if (!ReadQosInfo(req, ¶m)) { + TRANS_LOGE(TRANS_CTRL, "failed to read qos info"); + return SOFTBUS_IPC_ERR; + } ret = CheckOpenSessionPremission(param.sessionName, param.peerSessionName); if (ret != SOFTBUS_OK) { diff --git a/sdk/transmission/ipc/small/trans_server_proxy.c b/sdk/transmission/ipc/small/trans_server_proxy.c index cd4269bad..1a6a4960c 100644 --- a/sdk/transmission/ipc/small/trans_server_proxy.c +++ b/sdk/transmission/ipc/small/trans_server_proxy.c @@ -59,6 +59,32 @@ static int OpenSessionProxyCallback(IOwner owner, int code, IpcIo *reply) return SOFTBUS_OK; } +static bool WriteQosInfo(IpcIo *request, const SessionParam *param) +{ + if (!WriteBool(request, param->isQosLane)) { + TRANS_LOGE(TRANS_SDK, "OpenSession write qos flag failed!"); + return false; + } + + if (!param->isQosLane) { + return true; + } + + if (!WriteUint32(request, param->qosCount)) { + TRANS_LOGE(TRANS_SDK, "OpenSession write count of qos failed!"); + return false; + } + + if (param->qosCount > 0) { + if (!WriteBuffer(request, param->qos, sizeof(QosTV) * param->qosCount)) { + TRANS_LOGE(TRANS_SDK, "OpenSession write qos info failed!"); + return false; + } + } + + return true; +} + int32_t TransServerProxyInit(void) { if (g_serverProxy != NULL) { @@ -154,7 +180,7 @@ int32_t ServerIpcRemoveSessionServer(const char *pkgName, const char *sessionNam static bool TransWriteIpcSessionAttrs(IpcIo *request, const SessionAttribute *attrs) { if (attrs == NULL || request == NULL) { - TRANS_LOGE(TRANS_SDK, "attrs is nullptr!"); + TRANS_LOGE(TRANS_SDK, "attrs is NULL!"); return false; } @@ -216,6 +242,11 @@ int32_t ServerIpcOpenSession(const SessionParam *param, TransInfo *info) return SOFTBUS_TRANS_PROXY_WRITERAWDATA_FAILED; } + if (!WriteQosInfo(&request, param)) { + TRANS_LOGE(TRANS_SDK, "OpenSession write qosinfo failed!"); + return SOFTBUS_TRANS_PROXY_WRITERAWDATA_FAILED; + } + TransSerializer transSerializer; transSerializer.ret = SOFTBUS_NO_INIT; /* sync */