check authexception and channel

Signed-off-by: 高兴烨 <gaoxingye@huawei.com>
This commit is contained in:
高兴烨 2024-10-11 09:06:37 +08:00
parent 590fa715e3
commit a4c464858d
3 changed files with 15 additions and 5 deletions

View File

@ -58,6 +58,11 @@ bool AuthNegotiateChannel::operator==(const AuthNegotiateChannel &other) const
return handle_.authId == other.handle_.authId && handle_.type == other.handle_.type;
}
bool AuthNegotiateChannel::operator==(const AuthHandle &otherHandle) const
{
return handle_.authId == otherHandle.authId && handle_.type == otherHandle.type;
}
bool AuthNegotiateChannel::IsMeta() const
{
bool isMeta = false;

View File

@ -65,6 +65,7 @@ public:
~AuthNegotiateChannel() override;
bool operator==(const AuthNegotiateChannel &other) const;
bool operator==(const AuthHandle &otherHandle) const;
bool IsMeta() const;
void SetClose();

View File

@ -603,12 +603,16 @@ void P2pV1Processor::ProcessAuthConnEvent(std::shared_ptr<AuthOpenEvent> &event)
void P2pV1Processor::ProcessAuthExceptionEvent(const std::shared_ptr<AuthExceptionEvent> &event)
{
CONN_CHECK_AND_RETURN_LOGE(connectCommand_ != nullptr, CONN_WIFI_DIRECT, "connect command is nullptr");
CONN_LOGE(CONN_WIFI_DIRECT, "AuthExceptionEvent error=%{public}d", event->error_);
if (connectCommand_ != nullptr) {
CleanupIfNeed(event->error_, connectCommand_->GetRemoteDeviceId());
connectCommand_->OnFailure(static_cast<WifiDirectErrorCode>(event->error_));
connectCommand_ = nullptr;
}
auto negotiateChannel = connectCommand_->GetConnectInfo().channel_;
CONN_CHECK_AND_RETURN_LOGE(negotiateChannel != nullptr, CONN_WIFI_DIRECT, "auth negotiate channel is nullptr");
auto authChannel = std::dynamic_pointer_cast<AuthNegotiateChannel>(negotiateChannel);
CONN_CHECK_AND_RETURN_LOGE(authChannel != nullptr && *authChannel == event->handle_,
CONN_WIFI_DIRECT, "other auth exception ignore");
CleanupIfNeed(event->error_, connectCommand_->GetRemoteDeviceId());
connectCommand_->OnFailure(static_cast<WifiDirectErrorCode>(event->error_));
connectCommand_ = nullptr;
Terminate();
}