diff --git a/core/frame/small/init/src/trans_server_stub.c b/core/frame/small/init/src/trans_server_stub.c index 51a62f223..34597bc62 100644 --- a/core/frame/small/init/src/trans_server_stub.c +++ b/core/frame/small/init/src/trans_server_stub.c @@ -173,7 +173,9 @@ int32_t ServerNotifyAuthSuccess(IpcIo *req, IpcIo *reply) return SOFTBUS_INVALID_PARAM; } int32_t channelId = 0; + int32_t channelType = -1; ReadInt32(req, &channelId); + ReadInt32(req, &channelType); int32_t callingUid = GetCallingUid(); int32_t callingPid = GetCallingPid(); char pkgName[PKG_NAME_SIZE_MAX]; @@ -190,7 +192,7 @@ int32_t ServerNotifyAuthSuccess(IpcIo *req, IpcIo *reply) return SOFTBUS_PERMISSION_DENIED; } - int32_t ret = TransNotifyAuthSuccess(channelId); + int32_t ret = TransNotifyAuthSuccess(channelId, channelType); WriteInt32(reply, ret); return ret; } diff --git a/core/frame/standard/init/include/if_softbus_server.h b/core/frame/standard/init/include/if_softbus_server.h index 29b229bef..7c859c40c 100644 --- a/core/frame/standard/init/include/if_softbus_server.h +++ b/core/frame/standard/init/include/if_softbus_server.h @@ -39,7 +39,7 @@ public: virtual int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) = 0; virtual int32_t OpenSession(const SessionParam *param, TransInfo *info) = 0; virtual int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) = 0; - virtual int32_t NotifyAuthSuccess(int channelId) = 0; + virtual int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) = 0; virtual int32_t CloseChannel(int32_t channelId, int32_t channelType) = 0; virtual int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) = 0; diff --git a/core/frame/standard/init/include/softbus_server.h b/core/frame/standard/init/include/softbus_server.h index 40f63391d..dc61123a2 100644 --- a/core/frame/standard/init/include/softbus_server.h +++ b/core/frame/standard/init/include/softbus_server.h @@ -38,7 +38,7 @@ public: int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override; int32_t OpenSession(const SessionParam *param, TransInfo *info) override; int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override; - int32_t NotifyAuthSuccess(int32_t channelId) override; + int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override; int32_t CloseChannel(int32_t channelId, int32_t channelType) override; int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) override; diff --git a/core/frame/standard/init/src/softbus_server.cpp b/core/frame/standard/init/src/softbus_server.cpp index 738de1a2f..0f79e43e4 100644 --- a/core/frame/standard/init/src/softbus_server.cpp +++ b/core/frame/standard/init/src/softbus_server.cpp @@ -159,9 +159,9 @@ int32_t SoftBusServer::OpenAuthSession(const char *sessionName, const Connection return TransOpenAuthChannel(sessionName, &connOpt); } -int32_t SoftBusServer::NotifyAuthSuccess(int32_t channelId) +int32_t SoftBusServer::NotifyAuthSuccess(int32_t channelId, int32_t channelType) { - return TransNotifyAuthSuccess(channelId); + return TransNotifyAuthSuccess(channelId, channelType); } int32_t SoftBusServer::CloseChannel(int32_t channelId, int32_t channelType) diff --git a/core/frame/standard/init/src/softbus_server_stub.cpp b/core/frame/standard/init/src/softbus_server_stub.cpp index 29be5f5c2..a531a37e6 100644 --- a/core/frame/standard/init/src/softbus_server_stub.cpp +++ b/core/frame/standard/init/src/softbus_server_stub.cpp @@ -448,11 +448,16 @@ EXIT: int32_t SoftBusServerStub::NotifyAuthSuccessInner(MessageParcel &data, MessageParcel &reply) { int32_t channelId; + int32_t channelType; if (!data.ReadInt32(channelId)) { SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "NotifyAuthSuccessInner read channel Id failed!"); return SOFTBUS_ERR; } - int32_t retReply = NotifyAuthSuccess(channelId); + if (!data.ReadInt32(channelType)) { + SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "NotifyAuthSuccessInner read channel type failed!"); + return SOFTBUS_ERR; + } + int32_t retReply = NotifyAuthSuccess(channelId, channelType); if (!reply.WriteInt32(retReply)) { SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "NotifyAuthSuccessInner write reply failed!"); return SOFTBUS_ERR; diff --git a/core/transmission/trans_channel/auth/include/trans_auth_manager.h b/core/transmission/trans_channel/auth/include/trans_auth_manager.h index 5ff3dd389..2f327485b 100644 --- a/core/transmission/trans_channel/auth/include/trans_auth_manager.h +++ b/core/transmission/trans_channel/auth/include/trans_auth_manager.h @@ -31,10 +31,12 @@ void TransAuthDeinit(void); int32_t TransAuthGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName, uint16_t pkgLen, uint16_t sessionLen); int32_t TransOpenAuthMsgChannel(const char *sessionName, const ConnectOption *connOpt, int32_t *channedId); -int32_t TransNotifyAuthDataSuccess(int32_t channelId); +int32_t TransNotifyAuthDataSuccess(int32_t channelId, const ConnectOption *connOpt); int32_t TransCloseAuthChannel(int32_t channelId); int32_t TransSendAuthMsg(int32_t channelId, const char *msg, int32_t len); -int32_t TransGetAuthAppInfoByChanId(int32_t channelId, AppInfo *appInfo); +int32_t TransAuthGetAppInfoByChanId(int32_t channelId, AppInfo *appInfo); +int32_t TransAuthGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt); + #ifdef __cplusplus #if __cplusplus } diff --git a/core/transmission/trans_channel/auth/src/trans_auth_manager.c b/core/transmission/trans_channel/auth/src/trans_auth_manager.c index 04818a794..277b36ccf 100644 --- a/core/transmission/trans_channel/auth/src/trans_auth_manager.c +++ b/core/transmission/trans_channel/auth/src/trans_auth_manager.c @@ -700,24 +700,42 @@ int32_t TransSendAuthMsg(int32_t channelId, const char *data, int32_t len) return SOFTBUS_OK; } -int32_t TransNotifyAuthDataSuccess(int32_t channelId) +int32_t TransAuthGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt) { AuthChannelInfo chanInfo; if (GetAuthChannelInfoByChanId(channelId, &chanInfo) != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get auth channel info by chanid=%d fail", channelId); return SOFTBUS_ERR; } + if (!chanInfo.isConnOptValid) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "auth channel of conn opt invalid"); + return SOFTBUS_ERR; + } + + if (memcpy_s(connOpt, sizeof(ConnectOption), &(chanInfo.connOpt), sizeof(ConnectOption)) != EOK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "auth channel connopt memcpy fail"); + return SOFTBUS_ERR; + } + return SOFTBUS_OK; +} + +int32_t TransNotifyAuthDataSuccess(int32_t channelId, const ConnectOption *connOpt) +{ + if (connOpt == NULL) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "%s invalid param.", __func__); return SOFTBUS_ERR; } ConnectionAddr addr; (void)memset_s(&addr, sizeof(ConnectionAddr), 0, sizeof(ConnectionAddr)); - if (!LnnConvertOptionToAddr(&addr, &chanInfo.connOpt, CONNECTION_ADDR_WLAN)) { + if (!LnnConvertOptionToAddr(&addr, connOpt, CONNECTION_ADDR_WLAN)) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "channel=%d convert addr fail.", channelId); return SOFTBUS_ERR; } return LnnNotifyDiscoveryDevice(&addr); } -int32_t TransGetAuthAppInfoByChanId(int32_t channelId, AppInfo *appInfo) +int32_t TransAuthGetAppInfoByChanId(int32_t channelId, AppInfo *appInfo) { if (appInfo == NULL || g_authChannelList == NULL) { return SOFTBUS_INVALID_PARAM; diff --git a/core/transmission/trans_channel/manager/include/trans_channel_manager.h b/core/transmission/trans_channel/manager/include/trans_channel_manager.h index c1dc5f8c8..e40e3a9b8 100644 --- a/core/transmission/trans_channel/manager/include/trans_channel_manager.h +++ b/core/transmission/trans_channel/manager/include/trans_channel_manager.h @@ -40,7 +40,7 @@ int32_t TransRippleStats(int32_t channelId, int32_t channelType, const TrafficSt int32_t TransRequestQos(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality); -int32_t TransNotifyAuthSuccess(int32_t channelId); +int32_t TransNotifyAuthSuccess(int32_t channelId, int32_t channelType); int32_t TransCloseChannel(int32_t channelId, int32_t channelType); diff --git a/core/transmission/trans_channel/manager/src/trans_channel_manager.c b/core/transmission/trans_channel/manager/src/trans_channel_manager.c index 7005b961e..a97da1782 100644 --- a/core/transmission/trans_channel/manager/src/trans_channel_manager.c +++ b/core/transmission/trans_channel/manager/src/trans_channel_manager.c @@ -424,9 +424,27 @@ int32_t TransRippleStats(int32_t channelId, int32_t channelType, const TrafficSt return SOFTBUS_OK; } -int32_t TransNotifyAuthSuccess(int32_t channelId) +int32_t TransNotifyAuthSuccess(int32_t channelId, int32_t channelType) { - return TransNotifyAuthDataSuccess(channelId); + int32_t ret = SOFTBUS_ERR; + ConnectOption connOpt; + switch (channelType) { + case CHANNEL_TYPE_AUTH: + ret = TransAuthGetConnOptionByChanId(channelId, &connOpt); + break; + case CHANNEL_TYPE_PROXY: + ret = TransProxyGetConnOptionByChanId(channelId, &connOpt); + break; + default: + ret = SOFTBUS_ERR; + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "channel=%d, type=%d invalid.", channelId, channelType); + } + if (ret != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, + "channel=%d, type=%d,notfiy auth success error=%d.", channelId, channelType, ret); + return ret; + } + return TransNotifyAuthDataSuccess(channelId, &connOpt); } int32_t TransCloseChannel(int32_t channelId, int32_t channelType) @@ -504,7 +522,7 @@ int32_t TransGetAppInfoByChanId(int32_t channelId, int32_t channelType, AppInfo* case CHANNEL_TYPE_UDP: return TransGetUdpAppInfoByChannelId(channelId, appInfo); case CHANNEL_TYPE_AUTH: - return TransGetAuthAppInfoByChanId(channelId, appInfo); + return TransAuthGetAppInfoByChanId(channelId, appInfo); default: return SOFTBUS_INVALID_PARAM; } diff --git a/core/transmission/trans_channel/proxy/include/softbus_proxychannel_manager.h b/core/transmission/trans_channel/proxy/include/softbus_proxychannel_manager.h index 296f7edff..510059ee0 100644 --- a/core/transmission/trans_channel/proxy/include/softbus_proxychannel_manager.h +++ b/core/transmission/trans_channel/proxy/include/softbus_proxychannel_manager.h @@ -31,21 +31,30 @@ int32_t TransProxyGetNewChanSeq(int32_t channelId); int32_t TransProxyOpenProxyChannel(const AppInfo *appInfo, const ConnectOption *connInfo, int32_t *channelId); int32_t TransProxyCloseProxyChannel(int32_t channelId); int32_t TransProxySendMsg(int32_t channelId, const char *data, uint32_t dataLen, int32_t priority); + void TransProxyDelByConnId(uint32_t connId); +void TransProxyDelChanByReqId(int32_t reqId); +void TransProxyDelChanByChanId(int32_t chanlId); + void TransProxyOpenProxyChannelSuccess(int32_t chanId); void TransProxyOpenProxyChannelFail(int32_t channelId, const AppInfo *appInfo, int32_t errCode); void TransProxyonMessageReceived(const ProxyMessage *msg); + int32_t TransProxyGetSessionKeyByChanId(int32_t channelId, char *sessionKey, uint32_t sessionKeySize); int16_t TransProxyGetNewMyId(void); int32_t TransProxyGetSendMsgChanInfo(int32_t channelId, ProxyChannelInfo *chanInfo); -void TransProxyDelChanByReqId(int32_t reqId); + int32_t TransProxyCreateChanInfo(ProxyChannelInfo *chan, int32_t channelId, const AppInfo *appInfo); void TransProxyChanProcessByReqId(int32_t reqId, uint32_t connId); -void TransProxyDelChanByChanId(int32_t chanlId); + int64_t TransProxyGetAuthId(int32_t channelId); int32_t TransProxyGetNameByChanId(int32_t chanId, char *pkgName, char *sessionName, uint16_t pkgLen, uint16_t sessionLen); + void TransProxyDeathCallback(const char *pkgName, int32_t pid); + int32_t TransProxyGetAppInfoByChanId(int32_t chanId, AppInfo* appInfo); int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId); +int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt); + #endif diff --git a/core/transmission/trans_channel/proxy/include/softbus_proxychannel_transceiver.h b/core/transmission/trans_channel/proxy/include/softbus_proxychannel_transceiver.h index 5983102c2..60f9f5577 100644 --- a/core/transmission/trans_channel/proxy/include/softbus_proxychannel_transceiver.h +++ b/core/transmission/trans_channel/proxy/include/softbus_proxychannel_transceiver.h @@ -43,5 +43,6 @@ int32_t TransProxyTransSendMsg(uint32_t connectionId, uint8_t *buf, uint32_t len void TransCreateConnByConnId(uint32_t connId); int32_t TransDecConnRefByConnId(uint32_t connId); int32_t TransAddConnRefByConnId(uint32_t connId); +int32_t TransProxyGetConnInfoByConnId(uint32_t connId, ConnectOption *connInfo); #endif diff --git a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_manager.c b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_manager.c index 7b892ca42..d24bf060f 100644 --- a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_manager.c +++ b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_manager.c @@ -1304,4 +1304,25 @@ int32_t TransProxyGetConnIdByChanId(int32_t channelId, int32_t *connId) (void)SoftBusMutexUnlock(&g_proxyChannelList->lock); return SOFTBUS_ERR; } - + +int32_t TransProxyGetConnOptionByChanId(int32_t channelId, ConnectOption *connOpt) +{ + if (connOpt == NULL) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "[%s] invalid param.", __func__); + return SOFTBUS_ERR; + } + + int32_t connId = -1; + int32_t ret = TransProxyGetConnIdByChanId(channelId, &connId); + if (ret != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "channel=%d get proxy connid fail, %d.", channelId, ret); + return ret; + } + + ret = TransProxyGetConnInfoByConnId(connId, connOpt); + if (ret != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "channel=%d get conn optinfo fail, %d.", channelId, ret); + return ret; + } + return SOFTBUS_OK; +} diff --git a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_transceiver.c b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_transceiver.c index a2f14a999..80f1aca36 100644 --- a/core/transmission/trans_channel/proxy/src/softbus_proxychannel_transceiver.c +++ b/core/transmission/trans_channel/proxy/src/softbus_proxychannel_transceiver.c @@ -708,3 +708,38 @@ int32_t TransProxyTransInit(void) } return SOFTBUS_OK; } + +int32_t TransProxyGetConnInfoByConnId(uint32_t connId, ConnectOption *connInfo) +{ + if (connInfo == NULL) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "%s invalid param.", __func__); + return SOFTBUS_ERR; + } + + if (g_proxyConnectionList == NULL) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "proxy connect list empty."); + return SOFTBUS_ERR; + } + + if (SoftBusMutexLock(&g_proxyConnectionList->lock) != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "lock mutex fail."); + return SOFTBUS_ERR; + } + + ProxyConnInfo *item = NULL; + LIST_FOR_EACH_ENTRY(item, &g_proxyConnectionList->list, ProxyConnInfo, node) { + if (item->connId == connId) { + if (memcpy_s(connInfo, sizeof(ConnectOption), &(item->connInfo), sizeof(ConnectOption)) != EOK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "id=%u proxy connoption memcpy failed.", connId); + (void)SoftBusMutexUnlock(&g_proxyConnectionList->lock); + return SOFTBUS_ERR; + } + (void)SoftBusMutexUnlock(&g_proxyConnectionList->lock); + return SOFTBUS_OK; + } + } + (void)SoftBusMutexUnlock(&g_proxyConnectionList->lock); + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "id=%u proxy conn node not found.", connId); + return SOFTBUS_ERR; +} + diff --git a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c index 40f18fc9a..316be5d94 100644 --- a/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c +++ b/core/transmission/trans_channel/tcp_direct/src/trans_tcp_direct_p2p.c @@ -253,7 +253,7 @@ static int32_t OpenAuthConn(const char *uuid, uint32_t reqId, bool isMeta) AuthConnInfo auth; (void)memset_s(&auth, sizeof(AuthConnInfo), 0, sizeof(AuthConnInfo)); AuthConnCallback cb; - (void)memset_s(&auth, sizeof(AuthConnCallback), 0, sizeof(AuthConnCallback)); + (void)memset_s(&cb, sizeof(AuthConnCallback), 0, sizeof(AuthConnCallback)); if (AuthGetPreferConnInfo(uuid, &auth, isMeta) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "OpenAuthConn get auth info fail"); diff --git a/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h b/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h index e18b341e2..5428770bc 100644 --- a/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h +++ b/sdk/bus_center/ipc/standard/include/bus_center_server_proxy_standard.h @@ -35,7 +35,7 @@ public: int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override; int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override; int32_t OpenSession(const SessionParam *param, TransInfo *info) override; - int32_t NotifyAuthSuccess(int channelId) override; + int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override; int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override; int32_t CloseChannel(int32_t channelId, int32_t channelType) override; int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, diff --git a/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp b/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp index 5fdbc1636..9131e524e 100644 --- a/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp +++ b/sdk/bus_center/ipc/standard/src/bus_center_server_proxy_standard.cpp @@ -96,8 +96,10 @@ int32_t BusCenterServerProxy::OpenAuthSession(const char *sessionName, const Con return SOFTBUS_OK; } -int32_t BusCenterServerProxy::NotifyAuthSuccess(int channelId) +int32_t BusCenterServerProxy::NotifyAuthSuccess(int32_t channelId, int32_t channelType) { + (void)channelId; + (void)channelType; return SOFTBUS_OK; } diff --git a/sdk/discovery/ipc/standard/include/disc_server_proxy_standard.h b/sdk/discovery/ipc/standard/include/disc_server_proxy_standard.h index 07d994ede..c69f72099 100644 --- a/sdk/discovery/ipc/standard/include/disc_server_proxy_standard.h +++ b/sdk/discovery/ipc/standard/include/disc_server_proxy_standard.h @@ -36,7 +36,7 @@ public: int32_t CreateSessionServer(const char *pkgName, const char *sessionName) override; int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override; int32_t OpenSession(const SessionParam *param, TransInfo *info) override; - int32_t NotifyAuthSuccess(int32_t channelId) override; + int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override; int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override; int32_t CloseChannel(int32_t channelId, int32_t channelType) override; int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, diff --git a/sdk/discovery/ipc/standard/src/disc_server_proxy_standard.cpp b/sdk/discovery/ipc/standard/src/disc_server_proxy_standard.cpp index 2ed16ed86..ff046e15e 100644 --- a/sdk/discovery/ipc/standard/src/disc_server_proxy_standard.cpp +++ b/sdk/discovery/ipc/standard/src/disc_server_proxy_standard.cpp @@ -228,9 +228,10 @@ int32_t DiscServerProxy::OpenAuthSession(const char *sessionName, const Connecti return SOFTBUS_OK; } -int32_t DiscServerProxy::NotifyAuthSuccess(int32_t channelId) +int32_t DiscServerProxy::NotifyAuthSuccess(int32_t channelId, int32_t channelType) { (void)channelId; + (void)channelType; return SOFTBUS_OK; } diff --git a/sdk/frame/standard/include/softbus_server_proxy_standard.h b/sdk/frame/standard/include/softbus_server_proxy_standard.h index 958727fb2..2e48c65b6 100644 --- a/sdk/frame/standard/include/softbus_server_proxy_standard.h +++ b/sdk/frame/standard/include/softbus_server_proxy_standard.h @@ -39,7 +39,7 @@ public: int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override; int32_t OpenSession(const SessionParam *param, TransInfo *info) override; int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override; - int32_t NotifyAuthSuccess(int32_t channelId) override; + int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override; int32_t CloseChannel(int32_t channelId, int32_t channelType) override; int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) override; diff --git a/sdk/frame/standard/src/softbus_server_proxy_standard.cpp b/sdk/frame/standard/src/softbus_server_proxy_standard.cpp index 2fe764148..8b5a62572 100644 --- a/sdk/frame/standard/src/softbus_server_proxy_standard.cpp +++ b/sdk/frame/standard/src/softbus_server_proxy_standard.cpp @@ -137,9 +137,10 @@ int32_t SoftBusServerProxyFrame::OpenAuthSession(const char *sessionName, const return SOFTBUS_OK; } -int32_t SoftBusServerProxyFrame::NotifyAuthSuccess(int32_t channelId) +int32_t SoftBusServerProxyFrame::NotifyAuthSuccess(int32_t channelId, int32_t channelType) { (void)channelId; + (void)channelType; return SOFTBUS_OK; } diff --git a/sdk/transmission/ipc/include/trans_server_proxy.h b/sdk/transmission/ipc/include/trans_server_proxy.h index 42ba00819..be820762c 100644 --- a/sdk/transmission/ipc/include/trans_server_proxy.h +++ b/sdk/transmission/ipc/include/trans_server_proxy.h @@ -30,7 +30,7 @@ int32_t ServerIpcCreateSessionServer(const char *pkgName, const char *sessionNam int32_t ServerIpcRemoveSessionServer(const char *pkgName, const char *sessionName); int32_t ServerIpcOpenSession(const SessionParam *param, TransInfo *info); int32_t ServerIpcOpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo); -int32_t ServerIpcNotifyAuthSuccess(int channelId); +int32_t ServerIpcNotifyAuthSuccess(int32_t channelId, int32_t channelType); int32_t ServerIpcCloseChannel(int32_t channelId, int32_t channelType); int32_t ServerIpcSendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType); int32_t ServerIpcQosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality); diff --git a/sdk/transmission/ipc/mini/trans_server_proxy.c b/sdk/transmission/ipc/mini/trans_server_proxy.c index 9a9d02dc6..75a1c86bd 100644 --- a/sdk/transmission/ipc/mini/trans_server_proxy.c +++ b/sdk/transmission/ipc/mini/trans_server_proxy.c @@ -60,9 +60,9 @@ int32_t ServerIpcOpenAuthSession(const char *sessionName, const ConnectionAddr * return TransOpenAuthChannel(sessionName, &connOpt); } -int32_t ServerIpcNotifyAuthSuccess(int channelId) +int32_t ServerIpcNotifyAuthSuccess(int32_t channelId, int32_t channelType) { - return TransNotifyAuthSuccess(channelId); + return TransNotifyAuthSuccess(channelId, channelType); } int32_t ServerIpcCloseChannel(int32_t channelId, int32_t channelType) diff --git a/sdk/transmission/ipc/small/trans_server_proxy.c b/sdk/transmission/ipc/small/trans_server_proxy.c index ed1998051..797757e9b 100644 --- a/sdk/transmission/ipc/small/trans_server_proxy.c +++ b/sdk/transmission/ipc/small/trans_server_proxy.c @@ -216,7 +216,7 @@ int32_t ServerIpcOpenAuthSession(const char *sessionName, const ConnectionAddr * return ret; } -int32_t ServerIpcNotifyAuthSuccess(int channelId) +int32_t ServerIpcNotifyAuthSuccess(int32_t channelId, int32_t channelType) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "ServerIpcNotifyAuthSuccess begin"); @@ -224,6 +224,7 @@ int32_t ServerIpcNotifyAuthSuccess(int channelId) IpcIo request = {0}; IpcIoInit(&request, data, MAX_SOFT_BUS_IPC_LEN, 0); WriteInt32(&request, channelId); + WriteInt32(&request, channelType); int32_t ret = SOFTBUS_ERR; if (g_serverProxy == NULL) { SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "server proxy not init"); diff --git a/sdk/transmission/ipc/standard/include/trans_server_proxy_standard.h b/sdk/transmission/ipc/standard/include/trans_server_proxy_standard.h index 32cf8de23..f7c02f406 100644 --- a/sdk/transmission/ipc/standard/include/trans_server_proxy_standard.h +++ b/sdk/transmission/ipc/standard/include/trans_server_proxy_standard.h @@ -36,7 +36,7 @@ public: int32_t RemoveSessionServer(const char *pkgName, const char *sessionName) override; int32_t OpenSession(const SessionParam *param, TransInfo *info) override; int32_t OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo) override; - int32_t NotifyAuthSuccess(int32_t channelId) override; + int32_t NotifyAuthSuccess(int32_t channelId, int32_t channelType) override; int32_t CloseChannel(int32_t channelId, int32_t channelType) override; int32_t SendMessage(int32_t channelId, int32_t channelType, const void *data, uint32_t len, int32_t msgType) override; diff --git a/sdk/transmission/ipc/standard/src/trans_server_proxy.cpp b/sdk/transmission/ipc/standard/src/trans_server_proxy.cpp index ba3e53c86..43d5868a0 100644 --- a/sdk/transmission/ipc/standard/src/trans_server_proxy.cpp +++ b/sdk/transmission/ipc/standard/src/trans_server_proxy.cpp @@ -76,7 +76,9 @@ int32_t TransServerProxyInit(void) void TransServerProxyDeInit(void) { - delete g_serverProxy; + if (g_serverProxy != nullptr) { + delete g_serverProxy; + } g_serverProxy = nullptr; } @@ -143,9 +145,9 @@ int32_t ServerIpcOpenAuthSession(const char *sessionName, const ConnectionAddr * return channelId; } -int32_t ServerIpcNotifyAuthSuccess(int channelId) +int32_t ServerIpcNotifyAuthSuccess(int32_t channelId, int32_t channelType) { - return g_serverProxy->NotifyAuthSuccess(channelId); + return g_serverProxy->NotifyAuthSuccess(channelId, channelType); } int32_t ServerIpcCloseChannel(int32_t channelId, int32_t channelType) diff --git a/sdk/transmission/ipc/standard/src/trans_server_proxy_standard.cpp b/sdk/transmission/ipc/standard/src/trans_server_proxy_standard.cpp index 1b43f2034..f40e541e1 100644 --- a/sdk/transmission/ipc/standard/src/trans_server_proxy_standard.cpp +++ b/sdk/transmission/ipc/standard/src/trans_server_proxy_standard.cpp @@ -251,7 +251,7 @@ int32_t TransServerProxy::OpenAuthSession(const char *sessionName, const Connect return channelId; } -int32_t TransServerProxy::NotifyAuthSuccess(int channelId) +int32_t TransServerProxy::NotifyAuthSuccess(int32_t channelId, int32_t channelType) { sptr remote = GetSystemAbility(); if (remote == nullptr) { @@ -267,6 +267,10 @@ int32_t TransServerProxy::NotifyAuthSuccess(int channelId) SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ServerIpcNotifyAuthSuccess write channel id failed!"); return SOFTBUS_ERR; } + if (!data.WriteInt32(channelType)) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ServerIpcNotifyAuthSuccess write channel type failed!"); + return SOFTBUS_ERR; + } MessageParcel reply; MessageOption option; diff --git a/sdk/transmission/session/src/client_trans_session_service.c b/sdk/transmission/session/src/client_trans_session_service.c index f995a5cf5..77a938849 100644 --- a/sdk/transmission/session/src/client_trans_session_service.c +++ b/sdk/transmission/session/src/client_trans_session_service.c @@ -348,12 +348,12 @@ int OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo, int void NotifyAuthSuccess(int sessionId) { - int32_t channelId; - int32_t type; + int32_t channelId = -1; + int32_t channelType = -1; SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "NotifyAuthSuccess sessionId:%d", sessionId); - int32_t ret = ClientGetChannelBySessionId(sessionId, &channelId, &type, NULL); + int32_t ret = ClientGetChannelBySessionId(sessionId, &channelId, &channelType, NULL); if (ret != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get channel err"); + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "get session=%d channel err, ret:%d.", sessionId, ret); return; } @@ -368,8 +368,9 @@ void NotifyAuthSuccess(int sessionId) } SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_INFO, "device is client side"); - if (ServerIpcNotifyAuthSuccess(channelId) != SOFTBUS_OK) { - SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, "ServerIpcNotifyAuthSuccess err"); + if (ServerIpcNotifyAuthSuccess(channelId, channelType) != SOFTBUS_OK) { + SoftBusLog(SOFTBUS_LOG_TRAN, SOFTBUS_LOG_ERROR, + "channel=%d type=%d ServerIpcNotifyAuthSuccess err", channelId, channelType); return; } }