From dde620c402daf4ea8d132fb72a77eabc22f7a6d0 Mon Sep 17 00:00:00 2001 From: Shauren Date: Mon, 28 Mar 2016 17:12:57 +0200 Subject: Core: Updated to 6.2.4 * Rewrite bnetserver for new authentication protocol --- src/server/bnetserver/Packets/AchievementPackets.h | 42 -- .../bnetserver/Packets/AuthenticationPackets.cpp | 428 --------------------- .../bnetserver/Packets/AuthenticationPackets.h | 267 ------------- src/server/bnetserver/Packets/BitStream.cpp | 30 -- src/server/bnetserver/Packets/BitStream.h | 258 ------------- src/server/bnetserver/Packets/CachePackets.cpp | 111 ------ src/server/bnetserver/Packets/CachePackets.h | 110 ------ src/server/bnetserver/Packets/ChatPackets.h | 71 ---- .../bnetserver/Packets/ConnectionPackets.cpp | 123 ------ src/server/bnetserver/Packets/ConnectionPackets.h | 157 -------- src/server/bnetserver/Packets/FriendsPackets.cpp | 71 ---- src/server/bnetserver/Packets/FriendsPackets.h | 90 ----- src/server/bnetserver/Packets/PacketManager.cpp | 263 ------------- src/server/bnetserver/Packets/PacketManager.h | 105 ----- src/server/bnetserver/Packets/Packets.h | 32 -- src/server/bnetserver/Packets/PacketsBase.cpp | 46 --- src/server/bnetserver/Packets/PacketsBase.h | 119 ------ src/server/bnetserver/Packets/PacketsCommon.cpp | 111 ------ src/server/bnetserver/Packets/PacketsCommon.h | 182 --------- src/server/bnetserver/Packets/PresencePackets.h | 39 -- src/server/bnetserver/Packets/ProfilePackets.h | 44 --- src/server/bnetserver/Packets/SupportPackets.h | 35 -- src/server/bnetserver/Packets/WoWRealmPackets.cpp | 260 ------------- src/server/bnetserver/Packets/WoWRealmPackets.h | 238 ------------ 24 files changed, 3232 deletions(-) delete mode 100644 src/server/bnetserver/Packets/AchievementPackets.h delete mode 100644 src/server/bnetserver/Packets/AuthenticationPackets.cpp delete mode 100644 src/server/bnetserver/Packets/AuthenticationPackets.h delete mode 100644 src/server/bnetserver/Packets/BitStream.cpp delete mode 100644 src/server/bnetserver/Packets/BitStream.h delete mode 100644 src/server/bnetserver/Packets/CachePackets.cpp delete mode 100644 src/server/bnetserver/Packets/CachePackets.h delete mode 100644 src/server/bnetserver/Packets/ChatPackets.h delete mode 100644 src/server/bnetserver/Packets/ConnectionPackets.cpp delete mode 100644 src/server/bnetserver/Packets/ConnectionPackets.h delete mode 100644 src/server/bnetserver/Packets/FriendsPackets.cpp delete mode 100644 src/server/bnetserver/Packets/FriendsPackets.h delete mode 100644 src/server/bnetserver/Packets/PacketManager.cpp delete mode 100644 src/server/bnetserver/Packets/PacketManager.h delete mode 100644 src/server/bnetserver/Packets/Packets.h delete mode 100644 src/server/bnetserver/Packets/PacketsBase.cpp delete mode 100644 src/server/bnetserver/Packets/PacketsBase.h delete mode 100644 src/server/bnetserver/Packets/PacketsCommon.cpp delete mode 100644 src/server/bnetserver/Packets/PacketsCommon.h delete mode 100644 src/server/bnetserver/Packets/PresencePackets.h delete mode 100644 src/server/bnetserver/Packets/ProfilePackets.h delete mode 100644 src/server/bnetserver/Packets/SupportPackets.h delete mode 100644 src/server/bnetserver/Packets/WoWRealmPackets.cpp delete mode 100644 src/server/bnetserver/Packets/WoWRealmPackets.h (limited to 'src/server/bnetserver/Packets') diff --git a/src/server/bnetserver/Packets/AchievementPackets.h b/src/server/bnetserver/Packets/AchievementPackets.h deleted file mode 100644 index 3773e8475b7..00000000000 --- a/src/server/bnetserver/Packets/AchievementPackets.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef AchievementPackets_h__ -#define AchievementPackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Achievement - { - enum Opcode - { - CMSG_LISTEN_REQUEST = 0x0, // Not implemented - CMSG_CRITERIA_FLUSH_REQUEST = 0x3, // Not implemented - CMSG_CHANGE_TROPHY_CASE_REQUEST = 0x5, // Not implemented - - SMSG_DATA = 0x2, // Not implemented - SMSG_CRITERIA_FLUSH_RESPONSE = 0x3, // Not implemented - SMSG_ACHIEVEMENT_HANDLE_UPDATE = 0x4, // Not implemented - SMSG_CHANGE_TROPHY_CASE_RESULT = 0x6 // Not implemented - }; - } -} - -#endif // AchievementPackets_h__ - diff --git a/src/server/bnetserver/Packets/AuthenticationPackets.cpp b/src/server/bnetserver/Packets/AuthenticationPackets.cpp deleted file mode 100644 index d9dd3ad6bd7..00000000000 --- a/src/server/bnetserver/Packets/AuthenticationPackets.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "AuthenticationPackets.h" -#include "Session.h" -#include "Util.h" - -std::string Battlenet::Authentication::RequestCommon::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::RequestCommon" << std::endl; - APPEND_FIELD(stream, Program); - APPEND_FIELD(stream, Platform); - APPEND_FIELD(stream, Locale); - APPEND_FIELD(stream, Versions); - return stream.str(); -} - -void Battlenet::Authentication::ResumeRequest::Read() -{ - Common.Program = _stream.ReadFourCC(); - Common.Platform = _stream.ReadFourCC(); - Common.Locale = _stream.ReadFourCC(); - - Common.Versions.resize(_stream.Read(6)); - for (size_t i = 0; i < Common.Versions.size(); ++i) - { - Version::Record& component = Common.Versions[i]; - component.ProgramId = _stream.ReadFourCC(); - component.Component = _stream.ReadFourCC(); - component.Version = _stream.Read(32); - } - - Account = _stream.ReadString(9, 3); - GameAccountRegion = _stream.Read(8); - GameAccountName = _stream.ReadString(5, 1); -} - -std::string Battlenet::Authentication::ResumeRequest::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ResumeRequest" << std::endl; - APPEND_FIELD(stream, Common); - APPEND_FIELD(stream, Account); - APPEND_FIELD(stream, GameAccountRegion); - APPEND_FIELD(stream, GameAccountName); - return stream.str(); -} - -void Battlenet::Authentication::ResumeRequest::CallHandler(Session* session) -{ - session->HandleResumeRequest(*this); -} - -Battlenet::Authentication::ProofResponse::~ProofResponse() -{ - for (size_t i = 0; i < Response.size(); ++i) - delete Response[i]; -} - -void Battlenet::Authentication::ProofResponse::Read() -{ - Response.resize(_stream.Read(3)); - for (size_t i = 0; i < Response.size(); ++i) - { - BitStream*& dataStream = Response[i]; - dataStream = new BitStream(_stream.Read(10)); - memcpy(dataStream->GetBuffer(), _stream.ReadBytes(dataStream->GetSize()).get(), dataStream->GetSize()); - } -} - -std::string Battlenet::Authentication::ProofResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ProofRequest" << std::endl; - APPEND_FIELD(stream, Response.size()); - return stream.str(); -} - -void Battlenet::Authentication::ProofResponse::CallHandler(Session* session) -{ - session->HandleProofResponse(*this); -} - -void Battlenet::Authentication::LogonRequest3::Read() -{ - Common.Program = _stream.ReadFourCC(); - Common.Platform = _stream.ReadFourCC(); - Common.Locale = _stream.ReadFourCC(); - - Common.Versions.resize(_stream.Read(6)); - for (size_t i = 0; i < Common.Versions.size(); ++i) - { - Version::Record& component = Common.Versions[i]; - component.ProgramId = _stream.ReadFourCC(); - component.Component = _stream.ReadFourCC(); - component.Version = _stream.Read(32); - } - - if (_stream.Read(1)) - Account = _stream.ReadString(9, 3); - - Compatibility = _stream.Read(64); -} - -std::string Battlenet::Authentication::LogonRequest3::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::LogonRequest3" << std::endl; - APPEND_FIELD(stream, Common); - APPEND_FIELD(stream, Account); - APPEND_FIELD(stream, Compatibility); - return stream.str(); -} - -void Battlenet::Authentication::LogonRequest3::CallHandler(Session* session) -{ - session->HandleLogonRequest(*this); -} - -Battlenet::Authentication::LogonResponse::~LogonResponse() -{ - for (ModuleInfo* m : Result.Success.FinalRequest) - delete m; -} - -void Battlenet::Authentication::LogonResponse::Write() -{ - _stream.Write(Result.Type, 1); - if (Result.Type == ResultType::SUCCESS) - { - _stream.Write(Result.Success.FinalRequest.size(), 3); - for (size_t i = 0; i < Result.Success.FinalRequest.size(); ++i) - { - ModuleInfo* info = Result.Success.FinalRequest[i]; - _stream.WriteBytes(info->Handle.Type.c_str(), 4); - _stream.WriteFourCC(info->Handle.Region); - _stream.WriteBytes(info->Handle.ModuleId, 32); - _stream.Write(info->DataSize, 10); - _stream.WriteBytes(info->Data, info->DataSize); - } - - _stream.Write(Result.Success.PingTimeout + std::numeric_limits::min(), 32); - _stream.Write(Result.Success.RegulatorRules.is_initialized(), 1); - if (Result.Success.RegulatorRules.is_initialized()) - { - _stream.Write(Result.Success.RegulatorRules->Type == Regulator::LEAKY_BUCKET, 1); - if (Result.Success.RegulatorRules->Type == Regulator::LEAKY_BUCKET) - { - _stream.Write(Result.Success.RegulatorRules->LeakyBucket.Threshold, 32); - _stream.Write(Result.Success.RegulatorRules->LeakyBucket.Rate, 32); - } - } - - _stream.WriteString(Result.Success.FullName.GivenName, 8); - _stream.WriteString(Result.Success.FullName.Surname, 8); - _stream.Write(Result.Success.AccountId, 32); - _stream.Write(Result.Success.Region, 8); - _stream.Write(Result.Success.Flags, 64); - _stream.Write(Result.Success.GameAccountRegion, 8); - _stream.WriteString(Result.Success.GameAccountName, 5, -1); - _stream.Write(Result.Success.GameAccountFlags, 64); - _stream.Write(Result.Success.LogonFailures, 32); - } - else - { - _stream.Write(Result.Failure.Strings.is_initialized(), 1); - if (Result.Failure.Strings.is_initialized()) - { - _stream.WriteBytes(Result.Failure.Strings->Type.c_str(), 4); - _stream.WriteFourCC(Result.Failure.Strings->Region); - _stream.WriteBytes(Result.Failure.Strings->ModuleId, 32); - } - - _stream.Write(Result.Failure.Result.Type, 2); - if (Result.Failure.Result.Type == FailureType::FAILURE) - { - _stream.Write(Result.Failure.Result.Failure.Error, 16); - _stream.Write(Result.Failure.Result.Failure.Wait + std::numeric_limits::min(), 32); - } - } - - _stream.Write(Raf.is_initialized(), 1); - if (Raf.is_initialized()) - { - _stream.Write(Raf->size(), 10); - _stream.WriteBytes(Raf->data(), Raf->size()); - } -} - -std::string Battlenet::Authentication::LogonResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::LogonResponse" << std::endl; - APPEND_FIELD(stream, Result); - APPEND_FIELD(stream, Raf); - return stream.str(); -} - -std::string Battlenet::Authentication::FailureType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::FailureType" << std::endl; - APPEND_FIELD(stream, Strings); - APPEND_FIELD(stream, Result); - return stream.str(); -} - -std::string Battlenet::Authentication::FailureType::ResultType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ResponseFailure::Result" << std::endl; - switch (Type) - { - case UPDATE: - APPEND_FIELD(stream, Update); - break; - case FAILURE: - APPEND_FIELD(stream, Failure); - break; - case VERSION_CHECK_DISCONNECT: - APPEND_FIELD(stream, VersionCheckDisconnect); - break; - default: - break; - } - return stream.str(); -} - -std::string Battlenet::Authentication::FailureType::ResultType::UpdateType::ToString() const -{ - return "Battlenet::Authentication::ResponseFailure::Result::Update"; -} - -std::string Battlenet::Authentication::FailureType::ResultType::FailureType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ResponseFailure::Result::Failure" << std::endl; - APPEND_FIELD(stream, Error); - APPEND_FIELD(stream, Wait); - return stream.str(); -} - -std::string Battlenet::Authentication::FailureType::ResultType::VersionCheckDisconnectType::ToString() const -{ - return "Battlenet::Authentication::ResponseFailure::Result::VersionCheckDisconnect"; -} - -std::string Battlenet::Authentication::Regulator::NoneType::ToString() const -{ - return "Battlenet::Regulator::None"; -} - -std::string Battlenet::Authentication::Regulator::LeakyBucketType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Regulator::LeakyBucket" << std::endl; - APPEND_FIELD(stream, Threshold); - APPEND_FIELD(stream, Rate); - return stream.str(); -} - -std::string Battlenet::Authentication::Regulator::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Regulator" << std::endl; - switch (Type) - { - case NONE: - APPEND_FIELD(stream, None); - break; - case LEAKY_BUCKET: - APPEND_FIELD(stream, LeakyBucket); - break; - default: - break; - } - return stream.str(); -} - -std::string Battlenet::Authentication::LogonResponse::ResultType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::LogonResponse::Result" << std::endl; - switch (Type) - { - case SUCCESS: - APPEND_FIELD(stream, Success); - break; - case FAILURE: - APPEND_FIELD(stream, Failure); - break; - default: - break; - } - return stream.str(); -} - -std::string Battlenet::Authentication::LogonResponse::ResultType::SuccessType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::LogonResponse::Result::Success" << std::endl; - APPEND_FIELD(stream, FinalRequest); - APPEND_FIELD(stream, PingTimeout); - APPEND_FIELD(stream, RegulatorRules); - APPEND_FIELD(stream, FullName); - APPEND_FIELD(stream, AccountId); - APPEND_FIELD(stream, Region); - APPEND_FIELD(stream, Flags); - APPEND_FIELD(stream, GameAccountRegion); - APPEND_FIELD(stream, GameAccountName); - APPEND_FIELD(stream, GameAccountFlags); - APPEND_FIELD(stream, LogonFailures); - return stream.str(); -} - -void Battlenet::Authentication::LogonResponse::SetAuthResult(AuthResult result) -{ - Result.Type = result != AUTH_OK ? ResultType::FAILURE : ResultType::SUCCESS; - Result.Failure.Result.Failure.Error = result; -} - -Battlenet::Authentication::ResumeResponse::~ResumeResponse() -{ - for (ModuleInfo* m : Result.Success.FinalRequest) - delete m; -} - -void Battlenet::Authentication::ResumeResponse::Write() -{ - _stream.Write(Result.Type, 1); - if (Result.Type == ResultType::SUCCESS) - { - _stream.Write(Result.Success.FinalRequest.size(), 3); - for (size_t i = 0; i < Result.Success.FinalRequest.size(); ++i) - { - ModuleInfo* info = Result.Success.FinalRequest[i]; - _stream.WriteBytes(info->Handle.Type.c_str(), 4); - _stream.WriteFourCC(info->Handle.Region); - _stream.WriteBytes(info->Handle.ModuleId, 32); - _stream.Write(info->DataSize, 10); - _stream.WriteBytes(info->Data, info->DataSize); - } - - _stream.Write(Result.Success.PingTimeout + std::numeric_limits::min(), 32); - _stream.Write(Result.Success.RegulatorRules.is_initialized(), 1); - if (Result.Success.RegulatorRules.is_initialized()) - { - _stream.Write(Result.Success.RegulatorRules->Type == Regulator::LEAKY_BUCKET, 1); - if (Result.Success.RegulatorRules->Type == Regulator::LEAKY_BUCKET) - { - _stream.Write(Result.Success.RegulatorRules->LeakyBucket.Threshold, 32); - _stream.Write(Result.Success.RegulatorRules->LeakyBucket.Rate, 32); - } - } - } - else - { - _stream.Write(Result.Failure.Strings.is_initialized(), 1); - if (Result.Failure.Strings.is_initialized()) - { - _stream.WriteBytes(Result.Failure.Strings->Type.c_str(), 4); - _stream.WriteFourCC(Result.Failure.Strings->Region); - _stream.WriteBytes(Result.Failure.Strings->ModuleId, 32); - } - - _stream.Write(Result.Failure.Result.Type, 2); - if (Result.Failure.Result.Type == FailureType::FAILURE) - { - _stream.Write(Result.Failure.Result.Failure.Error, 16); - _stream.Write(Result.Failure.Result.Failure.Wait + std::numeric_limits::min(), 32); - } - } -} - -std::string Battlenet::Authentication::ResumeResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ResumeResponse" << std::endl; - return stream.str(); -} - -void Battlenet::Authentication::ResumeResponse::SetAuthResult(AuthResult result) -{ - Result.Type = result != AUTH_OK ? ResultType::FAILURE : ResultType::SUCCESS; - Result.Failure.Result.Failure.Error = result; -} - -Battlenet::Authentication::ProofRequest::~ProofRequest() -{ - for (size_t i = 0; i < Modules.size(); ++i) - delete Modules[i]; -} - -void Battlenet::Authentication::ProofRequest::Write() -{ - _stream.Write(Modules.size(), 3); - for (ModuleInfo const* info : Modules) - { - _stream.WriteBytes(info->Handle.Type.c_str(), 4); - _stream.WriteFourCC(info->Handle.Region); - _stream.WriteBytes(info->Handle.ModuleId, 32); - _stream.Write(info->DataSize, 10); - _stream.WriteBytes(info->Data, info->DataSize); - } -} - -std::string Battlenet::Authentication::ProofRequest::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Authentication::ProofRequest" << std::endl; - APPEND_FIELD(stream, Modules); - return stream.str(); -} diff --git a/src/server/bnetserver/Packets/AuthenticationPackets.h b/src/server/bnetserver/Packets/AuthenticationPackets.h deleted file mode 100644 index 9082585085d..00000000000 --- a/src/server/bnetserver/Packets/AuthenticationPackets.h +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef AuthenticationPackets_h__ -#define AuthenticationPackets_h__ - -#include "PacketsBase.h" -#include "ComponentManager.h" -#include "ModuleManager.h" - -namespace Battlenet -{ - namespace Authentication - { - enum Opcode - { - CMSG_LOGON_REQUEST = 0x0, // Deprecated - CMSG_RESUME_REQUEST = 0x1, - CMSG_PROOF_RESPONSE = 0x2, - CMSG_GENERATE_SINGLE_SIGN_ON_TOKEN_REQUEST_2 = 0x8, // Not implemented - CMSG_LOGON_REQUEST_3 = 0x9, - CMSG_SINGLE_SIGN_ON_REQUEST_3 = 0xA, // Not implemented - - SMSG_LOGON_RESPONSE = 0x0, - SMSG_RESUME_RESPONSE = 0x1, - SMSG_PROOF_REQUEST = 0x2, - SMSG_PATCH = 0x3, // Not implemented - SMSG_AUTHORIZED_LICENSES = 0x4, // Not implemented - SMSG_GENERATE_SINGLE_SIGN_ON_TOKEN_RESPONSE_2 = 0x8 // Not implemented - }; - - struct RequestCommon : public PrintableComponent - { - std::string Program; - std::string Platform; - std::string Locale; - std::vector Versions; - - std::string ToString() const override; - }; - - class ResumeRequest final : public ClientPacket - { - public: - ResumeRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_RESUME_REQUEST, AUTHENTICATION) && "Invalid packet header for ResumeRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - RequestCommon Common; - std::string Account; - uint8 GameAccountRegion = 0; - std::string GameAccountName; - }; - - class ProofResponse final : public ClientPacket - { - public: - ProofResponse(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_PROOF_RESPONSE, AUTHENTICATION) && "Invalid packet header for ProofResponse"); - } - - ~ProofResponse(); - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - std::vector Response; - }; - - class LogonRequest3 final : public ClientPacket - { - public: - LogonRequest3(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LOGON_REQUEST_3, AUTHENTICATION) && "Invalid packet header for LogonRequest3"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - RequestCommon Common; - std::string Account; - uint64 Compatibility = 0; - }; - - struct FailureType : public PrintableComponent - { - Optional Strings; - - enum - { - UPDATE = 0, - FAILURE = 1, - VERSION_CHECK_DISCONNECT = 2 - }; - - struct ResultType : public PrintableComponent - { - int32 Type = FAILURE; - - struct UpdateType : public PrintableComponent - { - std::string ToString() const override; - } Update; - - struct FailureType : public PrintableComponent - { - AuthResult Error = AUTH_OK; - int32 Wait = 0; - - std::string ToString() const override; - } Failure; - - struct VersionCheckDisconnectType : public PrintableComponent - { - std::string ToString() const override; - } VersionCheckDisconnect; - - std::string ToString() const override; - } Result; - - std::string ToString() const override; - }; - - struct Regulator : public PrintableComponent - { - enum - { - NONE = 0, - LEAKY_BUCKET = 1 - }; - - int32 Type = LEAKY_BUCKET; - struct NoneType : public PrintableComponent - { - std::string ToString() const override; - } None; - - struct LeakyBucketType : public PrintableComponent - { - uint32 Threshold = 25000000; - uint32 Rate = 1000; - - std::string ToString() const override; - } LeakyBucket; - - std::string ToString() const override; - }; - - class LogonResponse final : public ServerPacket - { - public: - LogonResponse() : ServerPacket(PacketHeader(SMSG_LOGON_RESPONSE, AUTHENTICATION)) - { - } - - ~LogonResponse(); - - void Write() override; - std::string ToString() const override; - void SetAuthResult(AuthResult result); - - struct ResultType : public PrintableComponent - { - enum - { - SUCCESS = 0, - FAILURE = 1 - }; - - int32 Type = SUCCESS; - struct SuccessType : public PrintableComponent - { - std::vector FinalRequest; - int32 PingTimeout = 120000; - Optional RegulatorRules; - Battlenet::Account::FullName FullName; - uint32 AccountId = 0; - uint8 Region = 2; - uint64 Flags = 0; - uint8 GameAccountRegion = 2; - std::string GameAccountName; - uint64 GameAccountFlags = 0; - uint32 LogonFailures = 0; - - std::string ToString() const override; - } Success; - - FailureType Failure; - - std::string ToString() const override; - } Result; - - Optional> Raf; - }; - - class ResumeResponse final : public ServerPacket - { - public: - ResumeResponse() : ServerPacket(PacketHeader(SMSG_RESUME_RESPONSE, AUTHENTICATION)) - { - } - - ~ResumeResponse(); - - void Write() override; - std::string ToString() const override; - - void SetAuthResult(AuthResult result); - - struct ResultType - { - enum - { - SUCCESS = 0, - FAILURE = 1 - }; - - int32 Type = SUCCESS; - struct SuccessType - { - std::vector FinalRequest; - int32 PingTimeout = 120000; - Optional RegulatorRules; - } Success; - - FailureType Failure; - } Result; - }; - - class ProofRequest final : public ServerPacket - { - public: - ProofRequest() : ServerPacket(PacketHeader(SMSG_PROOF_REQUEST, AUTHENTICATION)) { } - ~ProofRequest(); - - void Write() override; - std::string ToString() const override; - - std::vector Modules; - }; - } -} - -#endif // AuthenticationPackets_h__ diff --git a/src/server/bnetserver/Packets/BitStream.cpp b/src/server/bnetserver/Packets/BitStream.cpp deleted file mode 100644 index 1aeac731d28..00000000000 --- a/src/server/bnetserver/Packets/BitStream.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "BitStream.h" - -template<> -bool Battlenet::BitStream::Read(uint32 /*bitCount*/) -{ - return Read(1) != 0; -} - -template<> -void Battlenet::BitStream::Write(bool value, uint32 /*bitCount*/) -{ - Write(value ? 1 : 0, 1); -} diff --git a/src/server/bnetserver/Packets/BitStream.h b/src/server/bnetserver/Packets/BitStream.h deleted file mode 100644 index 0e91c930514..00000000000 --- a/src/server/bnetserver/Packets/BitStream.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef BitStream_h__ -#define BitStream_h__ - -#include "Common.h" -#include "ByteConverter.h" -#include "MessageBuffer.h" -#include -#include -#include -#include - -namespace Battlenet -{ - union FloatToInt - { - float AsFloat; - uint32 AsInt; - }; - - class BitStreamPositionException : public std::exception - { - static uint32 const MessageSize = 128; - - public: - BitStreamPositionException(bool read, uint32 operationSize, uint32 position, uint32 streamSize) - { - memset(_message, 0, MessageSize); - snprintf(_message, MessageSize, "Attempted to %s more bits (%u) %s stream than %s (%u)\n", - (read ? "read" : "write"), - operationSize + position, - (read ? "from" : "to"), - (read ? "exist" : "allowed"), - streamSize); - } - - char const* what() const throw() - { - return _message; - } - - private: - char _message[MessageSize]; - }; - - class BitStream - { - public: - static uint32 const MaxSize = 0x4000; - - // length : The maximum number of bytes to read - BitStream(uint32 length) : _writePos(length * 8), _readPos(0) - { - _buffer.resize(length, 0); - } - - BitStream(MessageBuffer&& buffer) : _writePos(uint32(buffer.GetActiveSize()) << 3), _readPos(0), _buffer(buffer.Move()) - { - } - - BitStream() : _writePos(0), _readPos(0) - { - _buffer.reserve(0x1000); - } - - void AlignToNextByte() - { - _readPos = (_readPos + 7) & ~7; - _writePos = (_writePos + 7) & ~7; - } - - std::string ReadString(uint32 bitCount, int32 baseLength = 0) - { - uint32 len = Read(bitCount) + baseLength; - AlignToNextByte(); - std::string str(reinterpret_cast(&_buffer[_readPos >> 3]), len); - _readPos += len * 8; - return str; - } - - std::unique_ptr ReadBytes(uint32 count) - { - AlignToNextByte(); - if (_readPos + count * 8 > _writePos) - throw BitStreamPositionException(true, count * 8, _readPos, _writePos); - - std::unique_ptr buf(new uint8[count]); - memcpy(buf.get(), &_buffer[_readPos >> 3], count); - _readPos += count * 8; - return buf; - } - - float ReadFloat() - { - union - { - float AsFloat; - uint32 AsInt; - } convert; - - convert.AsInt = Read(32); - return convert.AsFloat; - } - - std::string ReadFourCC() - { - uint32 fcc = Read(32); - EndianConvertReverse(fcc); - size_t len = 4; - while (!(fcc & 0xFF) && len) - { - fcc >>= 8; - --len; - } - - return std::string(reinterpret_cast(&fcc), len); - } - - template - T Read(uint32 bitCount) - { - static_assert(std::is_integral::value || std::is_enum::value, "T must be an integer type"); - - if (_readPos + bitCount > _writePos) - throw BitStreamPositionException(true, bitCount, _readPos, _writePos); - - uint64 ret = 0; - while (bitCount != 0) - { - uint32 bitPos = (_readPos & 7); - uint32 bitsLeftInByte = 8 - bitPos; - if (bitsLeftInByte >= bitCount) - bitsLeftInByte = bitCount; - - bitCount -= bitsLeftInByte; - ret |= (uint64)(_buffer[_readPos >> 3] >> bitPos & (uint32)((uint8)(1 << bitsLeftInByte) - 1)) << bitCount; - _readPos += bitsLeftInByte; - } - - return static_cast(ret); - } - - void WriteString(std::string const& str, uint32 bitCount, int32 baseLength = 0) - { - Write(str.length() + baseLength, bitCount); - WriteBytes(str.c_str(), uint32(str.length())); - } - - template - void WriteBytes(T* data, uint32 count) - { - AlignToNextByte(); - if (!count || !data) - return; - - if ((_writePos >> 3) + count > MaxSize) - throw BitStreamPositionException(false, count * 8, _writePos, MaxSize * 8); - - _buffer.resize(_buffer.size() + count); - memcpy(&_buffer[_writePos >> 3], data, count); - _writePos += count * 8; - } - - void WriteFloat(float value) - { - union - { - float AsFloat; - uint32 AsInt; - } convert; - - convert.AsFloat = value; - Write(convert.AsInt, 32); - } - - void WriteFourCC(std::string const& fcc) - { - uint32 intVal = *(uint32*)fcc.c_str(); - size_t len = fcc.length(); - EndianConvertReverse(intVal); - // Add padding - while (len++ < 4) - intVal >>= 8; - - Write(intVal, 32); - } - - template - void Write(T value, uint32 bitCount) - { - static_assert(std::is_integral::value || std::is_enum::value, "T must be an integer type"); - - if (_writePos + bitCount > 8 * MaxSize) - throw BitStreamPositionException(false, bitCount, _writePos, MaxSize * 8); - - while (bitCount != 0) - { - uint32 bitPos = (_writePos & 7); - uint32 bitsLeftInByte = 8 - bitPos; - if (bitsLeftInByte >= bitCount) - bitsLeftInByte = bitCount; - - bitCount -= bitsLeftInByte; - - uint8 firstHalf = (uint8)(~(((uint8)(1 << bitsLeftInByte) - 1) << bitPos)); - uint8 secondHalf = (uint8)((((uint8)(1 << bitsLeftInByte) - 1) & (uint8)(value >> bitCount)) << bitPos); - - if (_buffer.size() > (_writePos >> 3)) - _buffer[_writePos >> 3] = (uint8)((_buffer[_writePos >> 3] & firstHalf) | secondHalf); - else - _buffer.push_back(secondHalf); - - _writePos += bitsLeftInByte; - } - } - - bool IsRead() const { return _readPos >= _writePos; } - - uint8* GetBuffer() { return _buffer.data(); } - uint8 const* GetBuffer() const { return _buffer.data(); } - - uint32 GetReadPos() const { return _readPos; } - size_t GetSize() const { return ((_writePos + 7) & ~7) / 8; } - - // These methods are meant to only be used when their corresponding actions in the client ignore the value completely - void ReadSkip(uint32 bitCount) { _readPos += bitCount; } - void WriteSkip(uint32 bitCount) { Write(0, bitCount); } - - private: - uint32 _writePos; - uint32 _readPos; - std::vector _buffer; - }; - - template<> - bool BitStream::Read(uint32 bitCount); - - template<> - void BitStream::Write(bool value, uint32 bitCount); -} - -#endif // BitStream_h__ diff --git a/src/server/bnetserver/Packets/CachePackets.cpp b/src/server/bnetserver/Packets/CachePackets.cpp deleted file mode 100644 index ece7a9db08b..00000000000 --- a/src/server/bnetserver/Packets/CachePackets.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Session.h" -#include "Util.h" -#include "CachePackets.h" - -void Battlenet::Cache::GetStreamItemsRequest::Read() -{ - _stream.ReadSkip(31); - Token = _stream.Read(32); - ReferenceTime = _stream.Read(32) - std::numeric_limits::min(); - Direction = _stream.Read(1); - MaxItems = _stream.Read(6); - Locale = _stream.ReadFourCC(); - Stream.Type = _stream.Read(1); - if (Stream.Type == StreamId::DESCRIPTION) - { - Stream.Description.ItemName = _stream.ReadFourCC(); - Stream.Description.Channel = _stream.ReadFourCC(); - } - else - Stream.Index = _stream.Read(16); -} - -std::string Battlenet::Cache::GetStreamItemsRequest::StreamId::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Cache::GetStreamItemsRequest::StreamId" << std::endl; - - if (Type == INDEX) - APPEND_FIELD(stream, Index); - else - APPEND_FIELD(stream, Description); - - return stream.str(); -} - -std::string Battlenet::Cache::GetStreamItemsRequest::StreamId::DescriptionType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Cache::GetStreamItemsRequest::StreamId::Description" << std::endl; - APPEND_FIELD(stream, Channel); - APPEND_FIELD(stream, ItemName); - return stream.str(); -} - -std::string Battlenet::Cache::GetStreamItemsRequest::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Cache::GetStreamItemsRequest" << std::endl; - APPEND_FIELD(stream, Token); - APPEND_FIELD(stream, MaxItems); - APPEND_FIELD(stream, ReferenceTime); - APPEND_FIELD(stream, Direction); - APPEND_FIELD(stream, Stream); - APPEND_FIELD(stream, Locale); - return stream.str(); -} - -void Battlenet::Cache::GetStreamItemsRequest::CallHandler(Session* session) -{ - session->HandleGetStreamItemsRequest(*this); -} - -Battlenet::Cache::GetStreamItemsResponse::~GetStreamItemsResponse() -{ - for (size_t i = 0; i < Items.size(); ++i) - delete Items[i]; -} - -void Battlenet::Cache::GetStreamItemsResponse::Write() -{ - _stream.Write(Offset, 16); - _stream.Write(TotalNumItems, 16); - _stream.Write(Token, 32); - _stream.Write(Items.size(), 6); - for (ModuleInfo const* info : Items) - { - _stream.WriteBytes(info->Handle.Type.c_str(), 4); - _stream.WriteFourCC(info->Handle.Region); - _stream.WriteBytes(info->Handle.ModuleId, 32); - _stream.WriteSkip(27); - _stream.WriteBytes(info->Data, 4); - } -} - -std::string Battlenet::Cache::GetStreamItemsResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Cache::GetStreamItemsResponse" << std::endl; - APPEND_FIELD(stream, Items); - APPEND_FIELD(stream, Offset); - APPEND_FIELD(stream, TotalNumItems); - APPEND_FIELD(stream, Token); - return stream.str(); -} diff --git a/src/server/bnetserver/Packets/CachePackets.h b/src/server/bnetserver/Packets/CachePackets.h deleted file mode 100644 index 5cdd0905289..00000000000 --- a/src/server/bnetserver/Packets/CachePackets.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef CachePackets_h__ -#define CachePackets_h__ - -#include "ModuleManager.h" -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Cache - { - enum Opcode - { - CMSG_GATEWAY_LOOKUP_REQUEST = 0x2, // Not implemented - CMSG_CONNECT_REQUEST = 0x4, // Not implemented - CMSG_DATA_CHUNK = 0x7, // Not implemented - CMSG_GET_STREAM_ITEMS_REQUEST = 0x9, - - SMSG_GATEWAY_LOOKUP_RESPONSE = 0x3, // Not implemented - SMSG_CONNECT_RESPONSE = 0x4, // Not implemented - SMSG_PUBLISH_LIST_RESPONSE = 0x7, // Not implemented - SMSG_RESULT = 0x8, // Not implemented - SMSG_GET_STREAM_ITEMS_RESPONSE = 0x9 - }; - - class GetStreamItemsRequest final : public ClientPacket - { - public: - GetStreamItemsRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_GET_STREAM_ITEMS_REQUEST, CACHE) && "Invalid packet header for GetStreamItemsRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - enum - { - BEFORE = 0, - AFTER = 1 - }; - - uint32 Token = 0; - uint8 MaxItems = 0; - int32 ReferenceTime = 0; - uint8 Direction = BEFORE; - - struct StreamId : public PrintableComponent - { - enum - { - INDEX = 0, - DESCRIPTION = 1 - }; - - int32 Type; - - uint16 Index; - struct DescriptionType : public PrintableComponent - { - std::string Channel; - std::string ItemName; - - std::string ToString() const override; - } Description; - - std::string ToString() const override; - } Stream; - - std::string Locale; - }; - - class GetStreamItemsResponse final : public ServerPacket - { - public: - GetStreamItemsResponse() : ServerPacket(PacketHeader(SMSG_GET_STREAM_ITEMS_RESPONSE, CACHE)) - { - } - - ~GetStreamItemsResponse(); - - void Write() override; - std::string ToString() const override; - - std::vector Items; - uint16 Offset = 0; - uint16 TotalNumItems = 1; - uint32 Token = 0; - }; - } -} - -#endif // CachePackets_h__ diff --git a/src/server/bnetserver/Packets/ChatPackets.h b/src/server/bnetserver/Packets/ChatPackets.h deleted file mode 100644 index 3b1c5c155e0..00000000000 --- a/src/server/bnetserver/Packets/ChatPackets.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef ChatPackets_h__ -#define ChatPackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Chat - { - enum Opcode - { - CMSG_JOIN_REQUEST_2 = 0x00, // Not implemented - CMSG_LEAVE_REQUEST = 0x02, // Not implemented - CMSG_INVITE_REQUEST = 0x03, // Not implemented - CMSG_CREATE_AND_INVITE_REQUEST = 0x0A, // Not implemented - CMSG_MESSAGE_SEND = 0x0B, // Not implemented - CMSG_DATAGRAM_CONNECTION_UPDATE = 0x0D, // Not implemented - CMSG_REPORT_SPAM_REQUEST = 0x0E, // Not implemented - CMSG_WHISPER_SEND = 0x13, // Not implemented - CMSG_ENUM_CATEGORY_DESCRIPTIONS = 0x15, // Not implemented - CMSG_ENUM_CONFERENCE_DESCRIPTIONS = 0x17, // Not implemented - CMSG_ENUM_CONFERENCE_MEMBER_COUNTS = 0x19, // Not implemented - CMSG_MODIFY_CHANNEL_LIST_REQUEST = 0x1B, // Deprecated in client - CMSG_GET_MEMBER_COUNT_REQUEST = 0x1F, // Not implemented - CMSG_MODIFY_CHANNEL_LIST_REQUEST_2 = 0x20, // Not implemented - CMSG_GAME_DATA_SEND_REQUEST = 0x22, // Not implemented - - SMSG_MEMBERSHIP_CHANGE_NOTIFY = 0x01, // Not implemented - SMSG_INVITE_NOTIFY = 0x04, // Not implemented - SMSG_INVITE_CANCELED = 0x07, // Not implemented - SMSG_MESSAGE_RECV = 0x0B, // Not implemented - SMSG_MESSAGE_UNDELIVERABLE = 0x0C, // Not implemented - SMSG_DATAGRAM_CONNECTION_UPDATE = 0x0D, // Not implemented - SMSG_INVITE_FAILURE = 0x0F, // Not implemented - SMSG_SYSTEM_MESSAGE = 0x10, // Not implemented - SMSG_MESSAGE_BLOCKED = 0x12, // Not implemented - SMSG_WHISPER_RECV = 0x13, // Not implemented - SMSG_WHISPER_UNDELIVERABLE = 0x14, // Not implemented - SMSG_CATEGORY_DESCRIPTIONS = 0x16, // Not implemented - SMSG_CONFERENCE_DESCRIPTIONS = 0x18, // Not implemented - SMSG_CONFERENCE_MEMBER_COUNTS = 0x1A, // Not implemented - SMSG_JOIN_NOTIFY_2 = 0x1B, // Not implemented - SMSG_MODIFY_CHANNEL_LIST_RESPONSE = 0x1C, // Deprecated in client - SMSG_CONFIG_CHANGED = 0x1D, // Not implemented - SMSG_WHISPER_ECHO_RECV = 0x1E, // Not implemented - SMSG_GET_MEMBER_COUNT_RESPONSE = 0x1F, // Not implemented - SMSG_MODIFY_CHANNEL_LIST_RESPONSE_2 = 0x21, // Not implemented - SMSG_GAME_DATA_SEND_RESPONSE = 0x23, // Not implemented - SMSG_GAME_DATA_RECV = 0x24 // Not implemented - }; - } -} - -#endif // ChatPackets_h__ diff --git a/src/server/bnetserver/Packets/ConnectionPackets.cpp b/src/server/bnetserver/Packets/ConnectionPackets.cpp deleted file mode 100644 index cdb438085f1..00000000000 --- a/src/server/bnetserver/Packets/ConnectionPackets.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Session.h" -#include "ConnectionPackets.h" - -std::string Battlenet::Connection::Ping::ToString() const -{ - return "Battlenet::Connection::Ping"; -} - -void Battlenet::Connection::Ping::CallHandler(Session* session) -{ - session->HandlePing(*this); -} - -std::string Battlenet::Connection::EnableEncryption::ToString() const -{ - return "Battlenet::Connection::EnableEncryption"; -} - -void Battlenet::Connection::EnableEncryption::CallHandler(Session* session) -{ - session->HandleEnableEncryption(*this); -} - -std::string Battlenet::Connection::LogoutRequest::ToString() const -{ - return "Battlenet::Connection::LogoutRequest"; -} - -void Battlenet::Connection::LogoutRequest::CallHandler(Session* session) -{ - session->HandleLogoutRequest(*this); -} - -void Battlenet::Connection::DisconnectRequest::Read() -{ - Error = _stream.Read(16); - Timeout = _stream.Read(32); -} - -std::string Battlenet::Connection::DisconnectRequest::ToString() const -{ - std::ostringstream str; - str << "Battlenet::Connection::DisconnectRequest" << std::endl; - APPEND_FIELD(str, Error); - APPEND_FIELD(str, Timeout); - return str.str(); -} - -void Battlenet::Connection::ConnectionClosing::Read() -{ - Packets.resize(_stream.Read(6)); - for (size_t i = 0; i < Packets.size(); ++i) - { - PacketInfo& info = Packets[i]; - info.Command = _stream.ReadFourCC(); - info.Time = _stream.Read(32); - info.Size = _stream.Read(16); - info.Layer = _stream.ReadFourCC(); - info.Offset = _stream.Read(16); - } - - Reason = _stream.Read(4); - _stream.ReadBytes(_stream.Read(8)); // BadData - - if (_stream.Read(1)) // HasHeader - { - Header.Command = _stream.Read(6); - if (_stream.Read(1)) - Header.Channel = _stream.Read(4); - } - - Now = _stream.Read(32); -} - -std::string Battlenet::Connection::ConnectionClosing::PacketInfo::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Connection::ConnectionClosing::PacketInfo" << std::endl; - APPEND_FIELD(stream, Layer); - APPEND_FIELD(stream, Command); - APPEND_FIELD(stream, Offset); - APPEND_FIELD(stream, Size); - APPEND_FIELD(stream, Time); - return stream.str(); -} - -std::string Battlenet::Connection::ConnectionClosing::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Connection::ConnectionClosing" << std::endl; - APPEND_FIELD(stream, Header); - APPEND_FIELD(stream, Reason); - APPEND_FIELD(stream, Packets); - APPEND_FIELD(stream, Now); - return stream.str(); -} - -void Battlenet::Connection::ConnectionClosing::CallHandler(Session* session) -{ - session->HandleConnectionClosing(*this); -} - -std::string Battlenet::Connection::Pong::ToString() const -{ - return "Battlenet::Connection::Pong"; -} diff --git a/src/server/bnetserver/Packets/ConnectionPackets.h b/src/server/bnetserver/Packets/ConnectionPackets.h deleted file mode 100644 index 9987c65d770..00000000000 --- a/src/server/bnetserver/Packets/ConnectionPackets.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef ConnectionPackets_h__ -#define ConnectionPackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Connection - { - enum Opcode - { - CMSG_PING = 0x0, - CMSG_ENABLE_ENCRYPTION = 0x5, - CMSG_LOGOUT_REQUEST = 0x6, - CMSG_DISCONNECT_REQUEST = 0x7, // Not handled - CMSG_CONNECTION_CLOSING = 0x9, - - SMSG_PONG = 0x0, - SMSG_BOOM = 0x1, // Not implemented - SMSG_REGULATOR_UPDATE = 0x2, // Not implemented - SMSG_SERVER_VERSION = 0x3, // Not implemented - SMSG_STUN_SERVERS = 0x4 // Not implemented - }; - - class Ping final : public ClientPacket - { - public: - Ping(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_PING, CONNECTION) && "Invalid packet header for Ping"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) override; - }; - - class EnableEncryption final : public ClientPacket - { - public: - EnableEncryption(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_ENABLE_ENCRYPTION, CONNECTION) && "Invalid packet header for EnableEncryption"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) override; - uint8* GetRemainingData() { return _stream.GetBuffer() + (((_stream.GetReadPos() + 7) & ~7) / 8); } - size_t GetRemainingSize() const { return _stream.GetSize() - (((_stream.GetReadPos() + 7) & ~7) / 8); } - }; - - class LogoutRequest final : public ClientPacket - { - public: - LogoutRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LOGOUT_REQUEST, CONNECTION) && "Invalid packet header for LogoutRequest"); - } - - void Read() override { } - std::string ToString() const override; - void CallHandler(Session* session) override; - }; - - class DisconnectRequest final : public ClientPacket - { - public: - DisconnectRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_DISCONNECT_REQUEST, CONNECTION) && "Invalid packet header for DisconnectRequest"); - } - - void Read() override; - std::string ToString() const override; - - uint16 Error = 0; - uint32 Timeout = 0; - }; - - class ConnectionClosing final : public ClientPacket - { - public: - enum ClosingReason - { - PACKET_TOO_LARGE = 1, - PACKET_CORRUPT = 2, - PACKET_INVALID = 3, - PACKET_INCORRECT = 4, - HEADER_CORRUPT = 5, - HEADER_IGNORED = 6, - HEADER_INCORRECT = 7, - PACKET_REJECTED = 8, - CHANNEL_UNHANDLED = 9, - COMMAND_UNHANDLED = 10, - COMMAND_BAD_PERMISSIONS = 11, - DIRECT_CALL = 12, - TIMEOUT = 13, - }; - - struct PacketInfo : public PrintableComponent - { - std::string Layer; - std::string Command; - uint16 Offset; - uint16 Size; - uint32 Time; - - std::string ToString() const override; - }; - - ConnectionClosing(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_CONNECTION_CLOSING, CONNECTION) && "Invalid packet header for ConnectionClosing"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - PacketHeader Header; - ClosingReason Reason = PACKET_CORRUPT; - std::vector Packets; - time_t Now = 0; - }; - - class Pong final : public ServerPacket - { - public: - Pong() : ServerPacket(PacketHeader(SMSG_PONG, CONNECTION)) - { - } - - void Write() override { } - std::string ToString() const override; - }; - } -} - -#endif // ConnectionPackets_h__ diff --git a/src/server/bnetserver/Packets/FriendsPackets.cpp b/src/server/bnetserver/Packets/FriendsPackets.cpp deleted file mode 100644 index 90a124fb915..00000000000 --- a/src/server/bnetserver/Packets/FriendsPackets.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "FriendsPackets.h" - -void Battlenet::Friends::SendInvitationRequest::Read() -{ - Token = _stream.Read(32); - - if (_stream.Read(1)) - PresenceId = _stream.Read(32); - - if (_stream.Read(1)) - AccountMail = _stream.ReadString(9, 3); - - if (_stream.Read(1)) - AccountId = _stream.Read(32); - - if (_stream.Read(1)) - { - GameAccount = boost::in_place(); - GameAccount->Region = _stream.Read(8); - GameAccount->ProgramId = _stream.ReadFourCC(); - GameAccount->Id = _stream.Read(32); - } - - _stream.ReadSkip(7); - - if (_stream.Read(1)) - Nickname = _stream.ReadString(7); - - Source = _stream.ReadFourCC(); - Role = _stream.Read(32); - - if (_stream.Read(1)) - InvitationMsg = _stream.ReadString(9); -} - -std::string Battlenet::Friends::SendInvitationRequest::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Friends::SendInvitationRequest" << std::endl; - APPEND_FIELD(stream, Token); - APPEND_FIELD(stream, PresenceId); - APPEND_FIELD(stream, GameAccount); - APPEND_FIELD(stream, AccountId); - APPEND_FIELD(stream, AccountMail); - APPEND_FIELD(stream, Nickname); - APPEND_FIELD(stream, InvitationMsg); - APPEND_FIELD(stream, Source); - APPEND_FIELD(stream, Role); - return stream.str(); -} - -void Battlenet::Friends::SendInvitationRequest::CallHandler(Session* /*session*/) -{ -} diff --git a/src/server/bnetserver/Packets/FriendsPackets.h b/src/server/bnetserver/Packets/FriendsPackets.h deleted file mode 100644 index 8f1f513f521..00000000000 --- a/src/server/bnetserver/Packets/FriendsPackets.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef FriendsPackets_h__ -#define FriendsPackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Friends - { - enum Opcode - { - CMSG_FRIEND_INVITE = 0x01, // Not implemented - CMSG_FRIEND_INVITE_RESPONSE = 0x02, // Not implemented - CMSG_FRIEND_REMOVE = 0x04, // Not implemented - CMSG_FRIEND_NOTE = 0x05, // Not implemented - CMSG_TOONS_OF_FRIEND_REQUEST = 0x06, // Not implemented - CMSG_BLOCK_ADD = 0x08, // Not implemented - CMSG_BLOCK_REMOVE = 0x0A, // Not implemented - CMSG_GET_FRIENDS_OF_FRIEND = 0x0B, // Not implemented - CMSG_GET_SOCIAL_NETWORK_FRIENDS = 0x0D, // Deprecated in client - CMSG_SOCIAL_NETWORK_CONNECT = 0x0F, // Deprecated in client - CMSG_SOCIAL_NETWORK_DISCONNECT = 0x11, // Deprecated in client - CMSG_SOCIAL_NETWORK_CHECK_CONNECTED = 0x13, // Deprecated in client - CMSG_REALID_FRIEND_INVITE = 0x16, // Deprecated in client - CMSG_SEND_INVITATION_REQUEST = 0x1A, // Not implemented - - SMSG_FRIEND_INVITE_NOTIFY = 0x01, // Not implemented - SMSG_FRIEND_INVITE_RESULT = 0x03, // Not implemented - SMSG_TOONS_OF_FRIEND_NOTIFY = 0x06, // Not implemented - SMSG_BLOCK_INVITE_NOTIFY = 0x07, // Deprecated in client - SMSG_BLOCK_ADD_FAILURE = 0x09, // Not implemented - SMSG_FRIENDS_OF_FRIEND = 0x0C, // Deprecated in client - SMSG_SOCIAL_NETWORK_FRIENDS = 0x0E, // Deprecated in client - SMSG_SOCIAL_NETWORK_CONNECT_RESULT = 0x10, // Deprecated in client - SMSG_SOCIAL_NETWORK_DISCONNECT_RESULT = 0x12, // Deprecated in client - SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT = 0x14, // Deprecated in client - SMSG_MAX_FRIENDS_NOTIFY = 0x15, // Not implemented - SMSG_FRIENDS_LIST_NOTIFY_3 = 0x18, // Deprecated in client - SMSG_SEND_INVITATION_RESULT = 0x1B, // Not implemented - SMSG_FRIEND_INVITATION_ADDED_NOTIFY = 0x1C, // Not implemented - SMSG_FRIEND_INVITATION_REMOVED_NOTIFY = 0x1D, // Not implemented - SMSG_FRIENDS_LIST_NOTIFY_5 = 0x1E, // Not implemented - SMSG_ACCOUNT_BLOCK_ADDED_NOTIFY = 0x1F, // Not implemented - SMSG_ACCOUNT_BLOCK_REMOVED_NOTIFY = 0x20, // Not implemented - SMSG_TOON_BLOCK_NOTIFY = 0x21, // Not implemented - SMSG_FRIENDS_OF_FRIEND_RESULT = 0x22 // Not implemented - }; - - class SendInvitationRequest final : public ClientPacket - { - public: - SendInvitationRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) { } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - uint32 Token = 0; - - Optional PresenceId; - Optional GameAccount; - Optional AccountId; - Optional AccountMail; - Optional Nickname; - - Optional InvitationMsg; - std::string Source; - uint32 Role = 0; - }; - } -} - -#endif // FriendsPackets_h__ diff --git a/src/server/bnetserver/Packets/PacketManager.cpp b/src/server/bnetserver/Packets/PacketManager.cpp deleted file mode 100644 index 588ca1a0a86..00000000000 --- a/src/server/bnetserver/Packets/PacketManager.cpp +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "PacketManager.h" - -Battlenet::ClientPacket* Battlenet::PacketManager::CreateClientPacket(PacketHeader const& header, BitStream& stream) -{ - auto packetInfo = _clientPacketTable.find(header); - if (packetInfo == _clientPacketTable.end()) - return nullptr; - - if (!packetInfo->second.Constructor) - return nullptr; - - ClientPacket* packet = packetInfo->second.Constructor(header, stream); - packet->Read(); - return packet; -} - -char const* Battlenet::PacketManager::GetClientPacketName(PacketHeader const& header) -{ - auto packetInfo = _clientPacketTable.find(header); - if (packetInfo == _clientPacketTable.end()) - return nullptr; - - return packetInfo->second.Name; -} - -char const* Battlenet::PacketManager::GetServerPacketName(PacketHeader const& header) -{ - auto packetInfo = _serverPacketTable.find(header); - if (packetInfo == _serverPacketTable.end()) - return nullptr; - - return packetInfo->second.Name; -} - -bool Battlenet::PacketManager::IsHandled(PacketHeader const& header) -{ - auto packetInfo = _clientPacketTable.find(header); - if (packetInfo == _clientPacketTable.end()) - return false; - - return packetInfo->second.HasHandler; -} - -Battlenet::PacketManager::PacketManager() -{ - RegisterAuthenticationPackets(); - RegisterConnectionPackets(); - RegisterWoWRealmPackets(); - RegisterFriendsPackets(); - RegisterPresencePackets(); - RegisterChatPackets(); - RegisterSupportPackets(); - RegisterCachePackets(); - RegisterAchievementPackets(); - RegisterProfilePackets(); -} - -#define REGISTER_CLIENT_PACKET(header, packetClass) RegisterClientPacket(header, #packetClass) -#define REGISTER_SERVER_PACKET(header, packetClass) RegisterPacketName(_serverPacketTable, header, #packetClass) -#define REGISTER_CLIENT_PACKET_NAME(header, name) RegisterPacketName(_clientPacketTable, header, name) -#define REGISTER_SERVER_PACKET_NAME(header, name) RegisterPacketName(_serverPacketTable, header, name) - -void Battlenet::PacketManager::RegisterAuthenticationPackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Authentication::CMSG_LOGON_REQUEST, AUTHENTICATION), "Authentication::LogonRequest"); - REGISTER_CLIENT_PACKET(PacketHeader(Authentication::CMSG_RESUME_REQUEST, AUTHENTICATION), Authentication::ResumeRequest); - REGISTER_CLIENT_PACKET(PacketHeader(Authentication::CMSG_PROOF_RESPONSE, AUTHENTICATION), Authentication::ProofResponse); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Authentication::CMSG_GENERATE_SINGLE_SIGN_ON_TOKEN_REQUEST_2, AUTHENTICATION), "Authentication::GenerateSingleSignOnTokenRequest2"); - REGISTER_CLIENT_PACKET(PacketHeader(Authentication::CMSG_LOGON_REQUEST_3, AUTHENTICATION), Authentication::LogonRequest3); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Authentication::CMSG_SINGLE_SIGN_ON_REQUEST_3, AUTHENTICATION), "Authentication::SingleSignOnRequest3"); - - REGISTER_SERVER_PACKET(PacketHeader(Authentication::SMSG_LOGON_RESPONSE, AUTHENTICATION), Authentication::LogonResponse); - REGISTER_SERVER_PACKET(PacketHeader(Authentication::SMSG_RESUME_RESPONSE, AUTHENTICATION), Authentication::ResumeResponse); - REGISTER_SERVER_PACKET(PacketHeader(Authentication::SMSG_PROOF_REQUEST, AUTHENTICATION), Authentication::ProofRequest); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Authentication::SMSG_PATCH, AUTHENTICATION), "Authentication::Patch"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Authentication::SMSG_AUTHORIZED_LICENSES, AUTHENTICATION), "Authentication::AuthorizedLicenses"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Authentication::SMSG_GENERATE_SINGLE_SIGN_ON_TOKEN_RESPONSE_2, AUTHENTICATION), "Authentication::GenerateSingleSignOnTokenResponse2"); -} - -void Battlenet::PacketManager::RegisterConnectionPackets() -{ - REGISTER_CLIENT_PACKET(PacketHeader(Connection::CMSG_PING, CONNECTION), Connection::Ping); - REGISTER_CLIENT_PACKET(PacketHeader(Connection::CMSG_ENABLE_ENCRYPTION, CONNECTION), Connection::EnableEncryption); - REGISTER_CLIENT_PACKET(PacketHeader(Connection::CMSG_LOGOUT_REQUEST, CONNECTION), Connection::LogoutRequest); - REGISTER_CLIENT_PACKET(PacketHeader(Connection::CMSG_DISCONNECT_REQUEST, CONNECTION), Connection::DisconnectRequest); - REGISTER_CLIENT_PACKET(PacketHeader(Connection::CMSG_CONNECTION_CLOSING, CONNECTION), Connection::ConnectionClosing); - - REGISTER_SERVER_PACKET(PacketHeader(Connection::SMSG_PONG, CONNECTION), Connection::Pong); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Connection::SMSG_BOOM, CONNECTION), "Connection::Boom"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Connection::SMSG_REGULATOR_UPDATE, CONNECTION), "Connection::RegulatorUpdate"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Connection::SMSG_SERVER_VERSION, CONNECTION), "Connection::ServerVersion"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Connection::SMSG_STUN_SERVERS, CONNECTION), "Connection::STUNServers"); -} - -void Battlenet::PacketManager::RegisterWoWRealmPackets() -{ - REGISTER_CLIENT_PACKET(PacketHeader(WoWRealm::CMSG_LIST_SUBSCRIBE_REQUEST, WOWREALM), WoWRealm::ListSubscribeRequest); - REGISTER_CLIENT_PACKET(PacketHeader(WoWRealm::CMSG_LIST_UNSUBSCRIBE, WOWREALM), WoWRealm::ListUnsubscribe); - REGISTER_CLIENT_PACKET(PacketHeader(WoWRealm::CMSG_JOIN_REQUEST_V2, WOWREALM), WoWRealm::JoinRequestV2); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(WoWRealm::CMSG_MULTI_LOGON_REQUEST_V2, WOWREALM), "WoWRealm::MultiLogonRequestV2"); - - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_LIST_SUBSCRIBE_RESPONSE, WOWREALM), WoWRealm::ListSubscribeResponse); - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_LIST_UPDATE, WOWREALM), WoWRealm::ListUpdate); - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_LIST_COMPLETE, WOWREALM), WoWRealm::ListComplete); - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_TOON_READY, WOWREALM), WoWRealm::ToonReady); - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_TOON_LOGGED_OUT, WOWREALM), WoWRealm::ToonLoggedOut); - REGISTER_SERVER_PACKET(PacketHeader(WoWRealm::SMSG_JOIN_RESPONSE_V2, WOWREALM), WoWRealm::JoinResponseV2); -} - -void Battlenet::PacketManager::RegisterFriendsPackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_FRIEND_INVITE, FRIENDS), "Friends::FriendInvite"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_FRIEND_INVITE_RESPONSE, FRIENDS), "Friends::FriendInviteResponse"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_FRIEND_REMOVE, FRIENDS), "Friends::FriendRemove"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_FRIEND_NOTE, FRIENDS), "Friends::FriendNote"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_TOONS_OF_FRIEND_REQUEST, FRIENDS), "Friends::ToonsOfFriendRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_BLOCK_ADD, FRIENDS), "Friends::BlockAdd"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_BLOCK_REMOVE, FRIENDS), "Friends::BlockRemove"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_GET_FRIENDS_OF_FRIEND, FRIENDS), "Friends::GetFriendsOfFriend"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_GET_SOCIAL_NETWORK_FRIENDS, FRIENDS), "Friends::GetSocialNetworkFriends"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CONNECT, FRIENDS), "Friends::SocialNetworkConnect"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_SOCIAL_NETWORK_DISCONNECT, FRIENDS), "Friends::SocialNetworkDisconnect"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_SOCIAL_NETWORK_CHECK_CONNECTED, FRIENDS), "Friends::SocialNetworkCheckConnected"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Friends::CMSG_REALID_FRIEND_INVITE, FRIENDS), "Friends::RealIdFriendInvite"); - REGISTER_CLIENT_PACKET(PacketHeader(Friends::CMSG_SEND_INVITATION_REQUEST, FRIENDS), Friends::SendInvitationRequest); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIEND_INVITE_NOTIFY, FRIENDS), "Friends::FriendInviteNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIEND_INVITE_RESULT, FRIENDS), "Friends::FriendInviteResult"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_TOONS_OF_FRIEND_NOTIFY, FRIENDS), "Friends::ToonsOfFriendNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_BLOCK_INVITE_NOTIFY, FRIENDS), "Friends::BlockInviteNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_BLOCK_ADD_FAILURE, FRIENDS), "Friends::BlockAddFailure"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIENDS_OF_FRIEND, FRIENDS), "Friends::FriendsOfFriend"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_SOCIAL_NETWORK_FRIENDS, FRIENDS), "Friends::SocialNetworkFriends"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_SOCIAL_NETWORK_CONNECT_RESULT, FRIENDS), "Friends::SocialNetworkConnectResult"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_SOCIAL_NETWORK_DISCONNECT_RESULT, FRIENDS), "Friends::SocialNetworkDisconnectResult"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_SOCIAL_NETWORK_CHECK_CONNECTED_RESULT, FRIENDS), "Friends::SocialNetworkCheckConnectedResult"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_MAX_FRIENDS_NOTIFY, FRIENDS), "Friends::MaxFriendsNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIENDS_LIST_NOTIFY_3, FRIENDS), "Friends::FriendsListNotify3"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_SEND_INVITATION_RESULT, FRIENDS), "SendInvitationResult"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIEND_INVITATION_ADDED_NOTIFY, FRIENDS), "Friends::FriendInvitationAddedNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIEND_INVITATION_REMOVED_NOTIFY, FRIENDS), "Friends::FriendInvitationRemovedNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIENDS_LIST_NOTIFY_5, FRIENDS), "Friends::FriendsListNotify5"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_ACCOUNT_BLOCK_ADDED_NOTIFY, FRIENDS), "Friends::AccountBlockAddedNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_ACCOUNT_BLOCK_REMOVED_NOTIFY, FRIENDS), "Friends::AccountBlockRemovedNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_TOON_BLOCK_NOTIFY, FRIENDS), "Friends::ToonBlockNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Friends::SMSG_FRIENDS_OF_FRIEND_RESULT, FRIENDS), "Friends::FriendsOfFriendResult"); -} - -void Battlenet::PacketManager::RegisterPresencePackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Presence::CMSG_UPDATE_REQUEST, PRESENCE), "Presence::UpdateRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Presence::CMSG_STATISTIC_SUBSCRIBE, PRESENCE), "Presence::StatisticSubscribe"); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Presence::SMSG_UPDATE_NOTIFY, PRESENCE), "Presence::UpdateNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Presence::SMSG_FIELD_SPEC_ANNOUNCE, PRESENCE), "Presence::FieldSpecAnnounce"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Presence::SMSG_STATISTICS_UPDATE, PRESENCE), "Presence::StatisticsUpdate"); -} - -void Battlenet::PacketManager::RegisterChatPackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_JOIN_REQUEST_2, CHAT), "Chat::JoinRequest2"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_LEAVE_REQUEST, CHAT), "Chat::LeaveRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_INVITE_REQUEST, CHAT), "Chat::InviteRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_CREATE_AND_INVITE_REQUEST, CHAT), "Chat::CreateAndInviteRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_MESSAGE_SEND, CHAT), "Chat::MessageSend"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_DATAGRAM_CONNECTION_UPDATE, CHAT), "Chat::DatagramConnectionUpdate"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_REPORT_SPAM_REQUEST, CHAT), "Chat::ReportSpamRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_WHISPER_SEND, CHAT), "Chat::WhisperSend"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_ENUM_CATEGORY_DESCRIPTIONS, CHAT), "Chat::EnumCategoryDescriptions"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_ENUM_CONFERENCE_DESCRIPTIONS, CHAT), "Chat::EnumConferenceDescriptions"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_ENUM_CONFERENCE_MEMBER_COUNTS, CHAT), "Chat::EnumConferenceMemberCounts"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_MODIFY_CHANNEL_LIST_REQUEST, CHAT), "Chat::ModifyChannelListRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_GET_MEMBER_COUNT_REQUEST, CHAT), "Chat::GetMemberCountRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_MODIFY_CHANNEL_LIST_REQUEST_2, CHAT), "Chat::ModifyChannelListRequest2"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Chat::CMSG_GAME_DATA_SEND_REQUEST, CHAT), "Chat::GameDataSendRequest"); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MEMBERSHIP_CHANGE_NOTIFY, CHAT), "Chat::MembershipChangeNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_INVITE_NOTIFY, CHAT), "Chat::InviteNotify"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_INVITE_CANCELED, CHAT), "Chat::InviteCanceled"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MESSAGE_RECV, CHAT), "Chat::MessageRecv"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MESSAGE_UNDELIVERABLE, CHAT), "Chat::MessageUndeliverable"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_DATAGRAM_CONNECTION_UPDATE, CHAT), "Chat::DatagramConnectionUpdate"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_INVITE_FAILURE, CHAT), "Chat::InviteFailed"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_SYSTEM_MESSAGE, CHAT), "Chat::SystemMessage"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MESSAGE_BLOCKED, CHAT), "Chat::MessageBlocked"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_WHISPER_RECV, CHAT), "Chat::WhisperRecv"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_WHISPER_UNDELIVERABLE, CHAT), "Chat::WhisperUndeliverable"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_CATEGORY_DESCRIPTIONS, CHAT), "Chat::CategoryDescriptions"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_CONFERENCE_DESCRIPTIONS, CHAT), "Chat::ConferenceDescriptions"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_CONFERENCE_MEMBER_COUNTS, CHAT), "Chat::ConferenceMemberCounts"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_JOIN_NOTIFY_2, CHAT), "Chat::JoinNotify2"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MODIFY_CHANNEL_LIST_RESPONSE, CHAT), "Chat::ModifyChannelListResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_CONFIG_CHANGED, CHAT), "Chat::ConfigChanged"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_WHISPER_ECHO_RECV, CHAT), "Chat::WhisperEchoRecv"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_GET_MEMBER_COUNT_RESPONSE, CHAT), "Chat::GetMemberCountResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_MODIFY_CHANNEL_LIST_RESPONSE_2, CHAT), "Chat::ModifyChannelListResponse2"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_GAME_DATA_SEND_RESPONSE, CHAT), "Chat::GameDataSendResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Chat::SMSG_GAME_DATA_RECV, CHAT), "Chat::GameDataRecv"); -} - -void Battlenet::PacketManager::RegisterSupportPackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Support::CMSG_COMPLAINT_REQUEST, SUPPORT), "Support::ComplaintRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Support::CMSG_COMPLAINT_REQUEST_2, SUPPORT), "Support::ComplaintRequest2"); -} - -void Battlenet::PacketManager::RegisterAchievementPackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Achievement::CMSG_LISTEN_REQUEST, ACHIEVEMENT), "Achievement::ListenRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Achievement::CMSG_CRITERIA_FLUSH_REQUEST, ACHIEVEMENT), "Achievement::CriteriaFlushRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Achievement::CMSG_CHANGE_TROPHY_CASE_REQUEST, ACHIEVEMENT), "Achievement::ChangeTrophyCaseRequest"); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Achievement::SMSG_DATA, ACHIEVEMENT), "Achievement::Data"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Achievement::SMSG_CRITERIA_FLUSH_RESPONSE, ACHIEVEMENT), "Achievement::CriteriaFlushResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Achievement::SMSG_ACHIEVEMENT_HANDLE_UPDATE, ACHIEVEMENT), "Achievement::AchievementHandleUpdate"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Achievement::SMSG_CHANGE_TROPHY_CASE_RESULT, ACHIEVEMENT), "Achievement::ChangeTrophyCaseResult"); -} - -void Battlenet::PacketManager::RegisterCachePackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_GATEWAY_LOOKUP_REQUEST, CACHE), "Cache::GatewayLookupRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_CONNECT_REQUEST, CACHE), "Cache::ConnectRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Cache::CMSG_DATA_CHUNK, CACHE), "Cache::DataChunk"); - REGISTER_CLIENT_PACKET(PacketHeader(Cache::CMSG_GET_STREAM_ITEMS_REQUEST, CACHE), Cache::GetStreamItemsRequest); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_GATEWAY_LOOKUP_RESPONSE, CACHE), "Cache::GatewayLookupResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_CONNECT_RESPONSE, CACHE), "Cache::ConnectResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_PUBLISH_LIST_RESPONSE, CACHE), "Cache::PublishListResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Cache::SMSG_RESULT, CACHE), "Cache::Result"); - REGISTER_SERVER_PACKET(PacketHeader(Cache::SMSG_GET_STREAM_ITEMS_RESPONSE, CACHE), Cache::GetStreamItemsResponse); -} - -void Battlenet::PacketManager::RegisterProfilePackets() -{ - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Profile::CMSG_READ_REQUEST, PROFILE), "Profile::ReadRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Profile::CMSG_ADDRESS_QUERY_REQUEST, PROFILE), "Profile::AddressQueryRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Profile::CMSG_RESOLVE_TOON_HANDLE_TO_NAME_REQUEST, PROFILE), "Profile::ResolveHandleToToonNameRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Profile::CMSG_RESOLVE_TOON_NAME_TO_HANDLE_REQUEST, PROFILE), "Profile::ResolveToonNameToHandleRequest"); - REGISTER_CLIENT_PACKET_NAME(PacketHeader(Profile::CMSG_CHANGE_SETTINGS, PROFILE), "Profile::ChangeSettings"); - - REGISTER_SERVER_PACKET_NAME(PacketHeader(Profile::SMSG_READ_RESPONSE, PROFILE), "Profile::ReadResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Profile::SMSG_ADDRESS_QUERY_RESPONSE, PROFILE), "Profile::AddressQueryResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Profile::SMSG_RESOLVE_TOON_HANDLE_TO_NAME_RESPONSE, PROFILE), "Profile::ResolveHandleToToonNameResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Profile::SMSG_RESOLVE_TOON_NAME_TO_HANDLE_RESPONSE, PROFILE), "Profile::ResolveToonNameToHandleResponse"); - REGISTER_SERVER_PACKET_NAME(PacketHeader(Profile::SMSG_SETTINGS_AVAILABLE, PROFILE), "Profile::SettingsAvailable"); -} diff --git a/src/server/bnetserver/Packets/PacketManager.h b/src/server/bnetserver/Packets/PacketManager.h deleted file mode 100644 index 50fcaaa0d05..00000000000 --- a/src/server/bnetserver/Packets/PacketManager.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef PacketManager_h__ -#define PacketManager_h__ - -#include "Packets.h" -#include -#include - -template -struct has_call_handler -{ - template struct test_has_call_handler { }; - template static char Test(test_has_call_handler*); - template static int Test(...); - static const bool value = sizeof(Test(nullptr)) == sizeof(char); -}; - -namespace Battlenet -{ - class PacketManager - { - typedef ClientPacket*(*PacketCreateFn)(PacketHeader const& header, BitStream& stream); - - struct PacketInfo - { - PacketCreateFn Constructor; - char const* Name; - bool HasHandler; - }; - - PacketManager(); - - void RegisterAuthenticationPackets(); - void RegisterConnectionPackets(); - void RegisterWoWRealmPackets(); - void RegisterFriendsPackets(); - void RegisterPresencePackets(); - void RegisterChatPackets(); - void RegisterSupportPackets(); - void RegisterAchievementPackets(); - void RegisterCachePackets(); - void RegisterProfilePackets(); - - template - static ClientPacket* New(PacketHeader const& header, BitStream& stream) - { - return new PacketType(header, stream); - } - - void RegisterPacketName(std::map& packetTable, PacketHeader const& header, char const* name) - { - PacketInfo& info = packetTable[header]; - info.Constructor = nullptr; - info.Name = name; - info.HasHandler = false; - } - - template - void RegisterClientPacket(PacketHeader const& header, char const* name) - { - PacketInfo& info = _clientPacketTable[header]; - info.Constructor = &New; - info.Name = name; - info.HasHandler = has_call_handler::value; - } - - public: - ClientPacket* CreateClientPacket(PacketHeader const& header, BitStream& stream); - - char const* GetClientPacketName(PacketHeader const& header); - char const* GetServerPacketName(PacketHeader const& header); - - bool IsHandled(PacketHeader const& header); - - static PacketManager& Instance() - { - static PacketManager instance; - return instance; - } - - private: - std::map _clientPacketTable; - std::map _serverPacketTable; - }; -} - -#define sPacketManager Battlenet::PacketManager::Instance() - -#endif // PacketManager_h__ diff --git a/src/server/bnetserver/Packets/Packets.h b/src/server/bnetserver/Packets/Packets.h deleted file mode 100644 index 834bb735a16..00000000000 --- a/src/server/bnetserver/Packets/Packets.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef Packets_h__ -#define Packets_h__ - -#include "AuthenticationPackets.h" -#include "ConnectionPackets.h" -#include "WoWRealmPackets.h" -#include "FriendsPackets.h" -#include "PresencePackets.h" -#include "ChatPackets.h" -#include "SupportPackets.h" -#include "AchievementPackets.h" -#include "CachePackets.h" -#include "ProfilePackets.h" - -#endif // Packets_h__ diff --git a/src/server/bnetserver/Packets/PacketsBase.cpp b/src/server/bnetserver/Packets/PacketsBase.cpp deleted file mode 100644 index 61301307954..00000000000 --- a/src/server/bnetserver/Packets/PacketsBase.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "Packets.h" -#include "Session.h" -#include - -std::string Battlenet::PacketHeader::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::PacketHeader" << std::endl; - APPEND_FIELD(stream, Command); - APPEND_FIELD(stream, Channel); - return stream.str(); -} - -Battlenet::ServerPacket::ServerPacket(PacketHeader const& header) : Packet(header, *new BitStream()) -{ - _stream.Write(header.Command, 6); - _stream.Write(1, 1); - _stream.Write(header.Channel, 4); -} - -Battlenet::ServerPacket::~ServerPacket() -{ - delete &_stream; -} - -void Battlenet::ClientPacket::CallHandler(Session* session) -{ - session->LogUnhandledPacket(GetHeader()); -} diff --git a/src/server/bnetserver/Packets/PacketsBase.h b/src/server/bnetserver/Packets/PacketsBase.h deleted file mode 100644 index 856fbe258c3..00000000000 --- a/src/server/bnetserver/Packets/PacketsBase.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef PacketsBase_h__ -#define PacketsBase_h__ - -#include "AuthCodes.h" -#include "BitStream.h" -#include "Common.h" -#include "Errors.h" -#include "PacketsCommon.h" -#include -#include - -using boost::asio::ip::tcp; - -namespace Battlenet -{ - class BitStream; - class Session; - - enum Channel - { - AUTHENTICATION = 0, - CONNECTION = 1, - WOWREALM = 2, - FRIENDS = 3, - PRESENCE = 4, - CHAT = 5, - SUPPORT = 7, - ACHIEVEMENT = 8, - CACHE = 11, - PROFILE = 14 - }; - - struct PacketHeader : public PrintableComponent - { - PacketHeader(uint32 opcode, uint32 channel) : Command(opcode), Channel(channel) { } - PacketHeader() : Command(0), Channel(AUTHENTICATION) { } - - uint32 Command; - int32 Channel; - - bool operator<(PacketHeader const& right) const - { - if (Command < right.Command) - return true; - if (Command > right.Command) - return false; - - return Channel < right.Channel; - } - - bool operator==(PacketHeader const& right) const - { - return Command == right.Command && Channel == right.Channel; - } - - std::string ToString() const override; - }; - - class Packet : public PrintableComponent - { - public: - Packet(PacketHeader const& header, BitStream& stream) : _header(header), _stream(stream) { } - virtual ~Packet() { } - - PacketHeader const& GetHeader() const { return _header; } - - virtual void Write() = 0; - virtual void Read() = 0; - - protected: - PacketHeader _header; - BitStream& _stream; - - private: - Packet(Packet const& right) = delete; - Packet& operator=(Packet const& right) = delete; - }; - - class ClientPacket : public Packet - { - public: - ClientPacket(PacketHeader const& header, BitStream& stream) : Packet(header, stream) { } - - void Write() override final { ASSERT(!"Write not implemented for client packets."); } - virtual void CallHandler(Session* session); - }; - - class ServerPacket : public Packet - { - public: - ServerPacket(PacketHeader const& header); - ~ServerPacket(); - - void Read() override final { ASSERT(!"Read not implemented for server packets."); } - - uint8* GetData() { return _stream.GetBuffer(); } - uint8 const* GetData() const { return _stream.GetBuffer(); } - size_t GetSize() const { return _stream.GetSize(); } - }; -} - -#endif // PacketsBase_h__ diff --git a/src/server/bnetserver/Packets/PacketsCommon.cpp b/src/server/bnetserver/Packets/PacketsCommon.cpp deleted file mode 100644 index 59ab8540faf..00000000000 --- a/src/server/bnetserver/Packets/PacketsCommon.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "PacketsCommon.h" -#include "Util.h" - -std::string Battlenet::Version::Record::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Version::Record" << std::endl; - APPEND_FIELD(stream, ProgramId); - APPEND_FIELD(stream, Component); - APPEND_FIELD(stream, Version); - return stream.str(); -} - -std::string Battlenet::Cache::Handle::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Cache::Handle" << std::endl; - APPEND_FIELD(stream, Type); - APPEND_FIELD(stream, Region); - stream << "ModuleId: " << ByteArrayToHexStr(ModuleId, 32) << std::endl; - return stream.str(); -} - -std::string Battlenet::Account::FullName::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Account::FullName" << std::endl; - APPEND_FIELD(stream, GivenName); - APPEND_FIELD(stream, Surname); - return stream.str(); -} - -std::string Battlenet::GameAccount::Handle::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::GameAccount::Handle" << std::endl; - APPEND_FIELD(stream, Region); - APPEND_FIELD(stream, ProgramId); - APPEND_FIELD(stream, Id); - return stream.str(); -} - -std::string Battlenet::PrintableRealmHandle::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::RealmHandle" << std::endl; - APPEND_FIELD(stream, Region); - APPEND_FIELD(stream, Site); - APPEND_FIELD(stream, Realm); - return stream.str(); -} - -std::string Battlenet::Toon::FullName::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Toon::FullName" << std::endl; - APPEND_FIELD(stream, Region); - APPEND_FIELD(stream, ProgramId); - APPEND_FIELD(stream, Realm); - APPEND_FIELD(stream, Name); - return stream.str(); -} - -std::string Battlenet::Toon::Handle::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Toon::Handle" << std::endl; - APPEND_FIELD(stream, Region); - APPEND_FIELD(stream, ProgramId); - APPEND_FIELD(stream, Realm); - APPEND_FIELD(stream, Id); - return stream.str(); -} - -std::string Battlenet::Profile::RecordAddress::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::Profile::RecordAddress" << std::endl; - APPEND_FIELD(stream, Label); - APPEND_FIELD(stream, Id); - return stream.str(); -} - -std::ostream& Battlenet::Format::FieldToString(std::ostream& stream, char const* fieldName, PrintableComponent const& u, std::true_type) -{ - if (fieldName[0]) - stream << fieldName << ": "; - return stream << u.ToString(); -} - -std::ostream& Battlenet::Format::FieldToString(std::ostream& stream, char const* fieldName, uint8 const& u, std::false_type) -{ - return FieldToString(stream, fieldName, uint32(u), std::false_type()); -} diff --git a/src/server/bnetserver/Packets/PacketsCommon.h b/src/server/bnetserver/Packets/PacketsCommon.h deleted file mode 100644 index c2a264c3eae..00000000000 --- a/src/server/bnetserver/Packets/PacketsCommon.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef PacketsCommon_h__ -#define PacketsCommon_h__ - -#include "Common.h" -#include "Realm/Realm.h" -#include - -namespace Battlenet -{ - struct PrintableComponent - { - virtual ~PrintableComponent() { } - - virtual std::string ToString() const = 0; - }; - - namespace Format - { - template - struct is_printable : std::is_base_of::type>::type - { - }; - - template - typename std::enable_if::value, T>::type const& Dereference(T const& t) { return t; }; - - template - typename std::enable_if::value, typename std::remove_pointer::type>::type const& Dereference(T const& t) { return *t; }; - - template - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, T const& u, std::false_type) - { - if (fieldName[0]) - stream << fieldName << ": "; - return stream << u << std::endl; - } - - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, PrintableComponent const& u, std::true_type); - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, uint8 const& u, std::false_type); - - template - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, std::vector const& u, std::false_type) - { - stream << fieldName << ":" << std::endl; - for (T const& t : u) - FieldToString(stream, "", Dereference(t), is_printable()); - return stream; - } - - template - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, Optional const& u) - { - if (u) - FieldToString(stream, fieldName, Dereference(*u), is_printable()); - return stream; - } - - template - std::ostream& FieldToString(std::ostream& stream, char const* fieldName, T const& u) - { - return FieldToString(stream, fieldName, Dereference(u), is_printable()); - } - } - -#define APPEND_FIELD(stream, field) Format::FieldToString(stream, #field, field) - - namespace Version - { - struct Record : public PrintableComponent - { - std::string ProgramId; - std::string Component; - uint32 Version; - - std::string ToString() const override; - }; - } - - namespace Cache - { - struct Handle : public PrintableComponent - { - std::string Type; - std::string Region; - uint8 ModuleId[32] = { }; - - std::string ToString() const override; - }; - } - - namespace Account - { - struct FullName : public PrintableComponent - { - std::string GivenName; - std::string Surname; - - std::string ToString() const override; - }; - } - - namespace GameAccount - { - struct Handle : public PrintableComponent - { - uint8 Region = 0; - std::string ProgramId; - uint32 Id = 0; - - std::string ToString() const override; - }; - } - - // For use in packets - struct PrintableRealmHandle : public RealmHandle, public PrintableComponent - { - PrintableRealmHandle() : RealmHandle() { } - PrintableRealmHandle(uint8 region, uint8 battlegroup, uint32 index) - : RealmHandle(region, battlegroup, index) { } - - PrintableRealmHandle& operator=(RealmHandle const& r) - { - RealmHandle::operator=(r); - return *this; - } - - std::string ToString() const override; - }; - - namespace Toon - { - struct FullName : public PrintableComponent - { - uint8 Region = 0; - std::string ProgramId; - uint32 Realm = 0; - std::string Name; - - std::string ToString() const override; - }; - - struct Handle : public PrintableComponent - { - uint8 Region = 0; - std::string ProgramId; - uint32 Realm = 0; - uint64 Id = 0; - - std::string ToString() const override; - }; - } - - namespace Profile - { - struct RecordAddress : public PrintableComponent - { - uint32 Label = 0; - uint64 Id = 0; - - std::string ToString() const override; - }; - } -} - -#endif // PacketsCommon_h__ diff --git a/src/server/bnetserver/Packets/PresencePackets.h b/src/server/bnetserver/Packets/PresencePackets.h deleted file mode 100644 index e098d6e9053..00000000000 --- a/src/server/bnetserver/Packets/PresencePackets.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef PresencePackets_h__ -#define PresencePackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Presence - { - enum Opcode - { - CMSG_UPDATE_REQUEST = 0x0, // Not implemented - CMSG_STATISTIC_SUBSCRIBE = 0x2, // Not implemented - - SMSG_UPDATE_NOTIFY = 0x0, // Not implemented - SMSG_FIELD_SPEC_ANNOUNCE = 0x1, // Not implemented - SMSG_STATISTICS_UPDATE = 0x3 // Not implemented - }; - } -} - -#endif // PresencePackets_h__ diff --git a/src/server/bnetserver/Packets/ProfilePackets.h b/src/server/bnetserver/Packets/ProfilePackets.h deleted file mode 100644 index afa2f076c58..00000000000 --- a/src/server/bnetserver/Packets/ProfilePackets.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef ProfilePackets_h__ -#define ProfilePackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Profile - { - enum Opcode - { - CMSG_READ_REQUEST = 0x0, // Not implemented - CMSG_ADDRESS_QUERY_REQUEST = 0x1, // Not implemented - CMSG_RESOLVE_TOON_HANDLE_TO_NAME_REQUEST = 0x2, // Not implemented - CMSG_RESOLVE_TOON_NAME_TO_HANDLE_REQUEST = 0x3, // Not implemented - CMSG_CHANGE_SETTINGS = 0x5, // Not implemented - - SMSG_READ_RESPONSE = 0x0, // Not implemented - SMSG_ADDRESS_QUERY_RESPONSE = 0x1, // Not implemented - SMSG_RESOLVE_TOON_HANDLE_TO_NAME_RESPONSE = 0x2, // Not implemented - SMSG_RESOLVE_TOON_NAME_TO_HANDLE_RESPONSE = 0x3, // Not implemented - SMSG_SETTINGS_AVAILABLE = 0x4 // Not implemented - }; - } -} - -#endif // ProfilePackets_h__ diff --git a/src/server/bnetserver/Packets/SupportPackets.h b/src/server/bnetserver/Packets/SupportPackets.h deleted file mode 100644 index c84c96607f0..00000000000 --- a/src/server/bnetserver/Packets/SupportPackets.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef SupportPackets_h__ -#define SupportPackets_h__ - -#include "PacketsBase.h" - -namespace Battlenet -{ - namespace Support - { - enum Opcode - { - CMSG_COMPLAINT_REQUEST = 0x0, // Deprecated in client - CMSG_COMPLAINT_REQUEST_2 = 0x1 // Not implemented - }; - } -} - -#endif // SupportPackets_h__ diff --git a/src/server/bnetserver/Packets/WoWRealmPackets.cpp b/src/server/bnetserver/Packets/WoWRealmPackets.cpp deleted file mode 100644 index ca066b9064c..00000000000 --- a/src/server/bnetserver/Packets/WoWRealmPackets.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#include "WoWRealmPackets.h" -#include "Session.h" -#include -#include - -void Battlenet::WoWRealm::ListSubscribeRequest::CallHandler(Session* session) -{ - session->HandleListSubscribeRequest(*this); -} - -void Battlenet::WoWRealm::ListUnsubscribe::CallHandler(Session* session) -{ - session->HandleListUnsubscribe(*this); -} - -void Battlenet::WoWRealm::JoinRequestV2::Read() -{ - ClientSalt = _stream.Read(32); - _stream.ReadSkip(20); - Id.Region = _stream.Read(8); - _stream.ReadSkip(12); - Id.Site = _stream.Read(8); - Id.Realm = _stream.Read(32); -} - -std::string Battlenet::WoWRealm::JoinRequestV2::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::JoinRequestV2" << std::endl; - APPEND_FIELD(stream, Id); - APPEND_FIELD(stream, ClientSalt); - return stream.str(); -} - -void Battlenet::WoWRealm::JoinRequestV2::CallHandler(Session* session) -{ - session->HandleJoinRequestV2(*this); -} - -void Battlenet::WoWRealm::ListSubscribeResponse::Write() -{ - _stream.Write(Type, 1); - if (Type == SUCCESS) - { - _stream.Write(ToonCounts.size(), 7); - for (ToonCountEntry const& entry : ToonCounts) - { - _stream.Write(entry.Realm.Region, 8); - _stream.WriteSkip(12); - _stream.Write(entry.Realm.Site, 8); - _stream.Write(entry.Realm.Realm, 32); - _stream.Write(entry.Count, 16); - } - } - else - _stream.Write(Failure, 8); -} - -std::string Battlenet::WoWRealm::ListSubscribeResponse::ToonCountEntry::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListSubscribeResponse::ToonCountEntry" << std::endl; - APPEND_FIELD(stream, Realm); - APPEND_FIELD(stream, Count); - return stream.str(); -} - -std::string Battlenet::WoWRealm::ListSubscribeResponse::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListSubscribeResponse" << std::endl; - - if (Type == SUCCESS) - APPEND_FIELD(stream, ToonCounts); - else - APPEND_FIELD(stream, Failure); - - return stream.str(); -} - -void Battlenet::WoWRealm::ListUpdate::Write() -{ - _stream.Write(State.Type, 1); - if (State.Type == StateType::UPDATE) - { - _stream.Write(State.Update.Category, 32); - _stream.WriteFloat(State.Update.Population); - _stream.Write(State.Update.StateFlags, 8); - _stream.WriteSkip(19); - _stream.Write(State.Update.Type + -std::numeric_limits::min(), 32); - _stream.WriteString(State.Update.Name, 10); - _stream.Write(State.Update.PrivilegedData.is_initialized(), 1); - if (State.Update.PrivilegedData.is_initialized()) - { - _stream.WriteString(State.Update.PrivilegedData->Version, 5); - _stream.Write(State.Update.PrivilegedData->ConfigId, 32); - - boost::asio::ip::address_v4::bytes_type ip = State.Update.PrivilegedData->Address.address().to_v4().to_bytes(); - uint16 port = State.Update.PrivilegedData->Address.port(); - - EndianConvertReverse(ip); - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 4); - _stream.WriteBytes(&port, 2); - } - - _stream.Write(State.Update.InfoFlags, 8); - } - - _stream.Write(Id.Region, 8); - _stream.WriteSkip(12); - _stream.Write(Id.Site, 8); - _stream.Write(Id.Realm, 32); -} - -std::string Battlenet::WoWRealm::ListUpdate::PrivilegedDataType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::RealmInfo::PrivilegedData" << std::endl; - APPEND_FIELD(stream, Version); - APPEND_FIELD(stream, ConfigId); - APPEND_FIELD(stream, Address); - return stream.str(); -} - -std::string Battlenet::WoWRealm::ListUpdate::StateType::UpdateType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListUpdate::State::Update" << std::endl; - APPEND_FIELD(stream, InfoFlags); - APPEND_FIELD(stream, Name); - APPEND_FIELD(stream, Type); - APPEND_FIELD(stream, Category); - APPEND_FIELD(stream, StateFlags); - APPEND_FIELD(stream, Population); - APPEND_FIELD(stream, PrivilegedData); - return stream.str(); -} - -std::string Battlenet::WoWRealm::ListUpdate::StateType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListUpdate::State" << std::endl; - - if (Type == UPDATE) - APPEND_FIELD(stream, Update); - else - APPEND_FIELD(stream, Delete); - - return stream.str(); -} - -std::string Battlenet::WoWRealm::ListUpdate::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ListUpdate" << std::endl; - APPEND_FIELD(stream, Id); - APPEND_FIELD(stream, State); - return stream.str(); -} - -void Battlenet::WoWRealm::ToonReady::Write() -{ - _stream.Write(Name.Region, 8); - _stream.WriteFourCC(Name.ProgramId); - _stream.Write(Name.Realm, 32); - _stream.WriteString(Name.Name, 7, -2); - _stream.WriteSkip(21); - _stream.Write(ProfileAddress.Id, 64); - _stream.Write(ProfileAddress.Label, 32); - _stream.Write(Handle.Id, 64); - _stream.Write(Handle.Realm, 32); - _stream.Write(Handle.Region, 8); - _stream.WriteFourCC(Handle.ProgramId); -} - -std::string Battlenet::WoWRealm::ToonReady::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::ToonReady" << std::endl; - APPEND_FIELD(stream, Name); - APPEND_FIELD(stream, Handle); - APPEND_FIELD(stream, ProfileAddress); - return stream.str(); -} - -void Battlenet::WoWRealm::JoinResponseV2::Write() -{ - _stream.Write(Type, 1); - if (Type == SUCCESS) - { - _stream.Write(Success.ServerSalt, 32); - _stream.Write(Success.IPv4.size(), 5); - for (tcp::endpoint const& addr : Success.IPv4) - { - boost::asio::ip::address_v4::bytes_type ip = addr.address().to_v4().to_bytes(); - uint16 port = addr.port(); - - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 4); - _stream.WriteBytes(&port, 2); - } - - _stream.Write(Success.IPv6.size(), 5); - for (tcp::endpoint const& addr : Success.IPv6) - { - boost::asio::ip::address_v6::bytes_type ip = addr.address().to_v6().to_bytes(); - uint16 port = addr.port(); - - EndianConvertReverse(port); - - _stream.WriteBytes(ip.data(), 16); - _stream.WriteBytes(&port, 2); - } - } - else - _stream.Write(Failure, 8); -} - -std::string Battlenet::WoWRealm::JoinResponseV2::SuccessType::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::JoinResponseV2::Success" << std::endl; - APPEND_FIELD(stream, ServerSalt); - APPEND_FIELD(stream, IPv4); - APPEND_FIELD(stream, IPv6); - return stream.str(); -} - -std::string Battlenet::WoWRealm::JoinResponseV2::ToString() const -{ - std::ostringstream stream; - stream << "Battlenet::WoWRealm::JoinResponseV2" << std::endl; - - if (Type == SUCCESS) - APPEND_FIELD(stream, Success); - else - APPEND_FIELD(stream, Failure); - - return stream.str(); -} diff --git a/src/server/bnetserver/Packets/WoWRealmPackets.h b/src/server/bnetserver/Packets/WoWRealmPackets.h deleted file mode 100644 index 320270abb61..00000000000 --- a/src/server/bnetserver/Packets/WoWRealmPackets.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2008-2016 TrinityCore - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - */ - -#ifndef WoWRealmPackets_h__ -#define WoWRealmPackets_h__ - -#include "PacketsBase.h" -#include "RealmList.h" - -namespace Battlenet -{ - namespace WoWRealm - { - enum Opcode - { - CMSG_LIST_SUBSCRIBE_REQUEST = 0x0, - CMSG_LIST_UNSUBSCRIBE = 0x1, - CMSG_JOIN_REQUEST_V2 = 0x8, - CMSG_MULTI_LOGON_REQUEST_V2 = 0x9, // Not implemented - - SMSG_LIST_SUBSCRIBE_RESPONSE = 0x0, - SMSG_LIST_UPDATE = 0x2, - SMSG_LIST_COMPLETE = 0x3, - SMSG_TOON_READY = 0x6, // Not implemented - SMSG_TOON_LOGGED_OUT = 0x7, // Not implemented - SMSG_JOIN_RESPONSE_V2 = 0x8 - }; - - class ListSubscribeRequest final : public ClientPacket - { - public: - ListSubscribeRequest(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LIST_SUBSCRIBE_REQUEST, WOWREALM) && "Invalid packet header for ListSubscribeRequest"); - } - - void Read() override { } - std::string ToString() const override { return "Battlenet::WoWRealm::ListSubscribeRequest"; } - - void CallHandler(Session* session) override; - }; - - class ListUnsubscribe final : public ClientPacket - { - public: - ListUnsubscribe(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_LIST_UNSUBSCRIBE, WOWREALM) && "Invalid packet header for ListUnsubscribe"); - } - - void Read() override { } - std::string ToString() const override { return "Battlenet::WoWRealm::ListUnsubscribe"; } - void CallHandler(Session* session) override; - }; - - class JoinRequestV2 final : public ClientPacket - { - public: - JoinRequestV2(PacketHeader const& header, BitStream& stream) : ClientPacket(header, stream) - { - ASSERT(header == PacketHeader(CMSG_JOIN_REQUEST_V2, WOWREALM) && "Invalid packet header for RealmJoinRequest"); - } - - void Read() override; - std::string ToString() const override; - void CallHandler(Session* session) override; - - uint32 ClientSalt = 0; - PrintableRealmHandle Id; - }; - - class ListSubscribeResponse final : public ServerPacket - { - public: - ListSubscribeResponse() : ServerPacket(PacketHeader(SMSG_LIST_SUBSCRIBE_RESPONSE, WOWREALM)) - { - } - - struct ToonCountEntry : public PrintableComponent - { - ToonCountEntry(PrintableRealmHandle const& realm, uint16 count) : Realm(realm), Count(count) { } - - PrintableRealmHandle Realm; - uint16 Count; - - std::string ToString() const override; - }; - - void Write() override; - std::string ToString() const override; - - enum - { - SUCCESS = 0, - FAILURE = 1 - }; - - int32 Type = SUCCESS; - - std::vector ToonCounts; - Wow::AuthResult Failure = Wow::WOW_SUCCESS; - }; - - class ListUpdate final : public ServerPacket - { - public: - ListUpdate() : ServerPacket(PacketHeader(SMSG_LIST_UPDATE, WOWREALM)) - { - } - - void Write() override; - std::string ToString() const override; - - PrintableRealmHandle Id; - - struct PrivilegedDataType : public PrintableComponent - { - std::string Version; - uint32 ConfigId = 0; - tcp::endpoint Address; - - std::string ToString() const override; - }; - - struct StateType : public PrintableComponent - { - enum - { - DELETED = 0, - UPDATE = 1 - }; - - int32 Type = UPDATE; - struct DeleteType : public PrintableComponent - { - std::string ToString() const override { return "Battlenet::WoWRealm::ListUpdate::State::Delete"; } - } Delete; - - struct UpdateType : public PrintableComponent - { - uint8 InfoFlags = 0; - std::string Name; - int32 Type = 0; - uint32 Category = 0; - uint8 StateFlags = 0; - float Population = 0.0f; - Optional PrivilegedData; - - std::string ToString() const override; - } Update; - - std::string ToString() const override; - } State; - }; - - class ListComplete final : public ServerPacket - { - public: - ListComplete() : ServerPacket(PacketHeader(SMSG_LIST_COMPLETE, WOWREALM)) - { - } - - void Write() override { } - std::string ToString() const override { return "Battlenet::WoWRealm::ListComplete"; } - }; - - class ToonReady final : public ServerPacket - { - public: - ToonReady() : ServerPacket(PacketHeader(SMSG_TOON_READY, WOWREALM)) - { - } - - void Write() override; - std::string ToString() const override; - - Toon::FullName Name; - Toon::Handle Handle; - Profile::RecordAddress ProfileAddress; - }; - - class ToonLoggedOut final : public ServerPacket - { - public: - ToonLoggedOut() : ServerPacket(PacketHeader(SMSG_TOON_LOGGED_OUT, WOWREALM)) - { - } - - void Write() override { } - std::string ToString() const override { return "Battlenet::WoWRealm::ToonLoggedOut"; } - }; - - class JoinResponseV2 final : public ServerPacket - { - public: - JoinResponseV2() : ServerPacket(PacketHeader(SMSG_JOIN_RESPONSE_V2, WOWREALM)) - { - } - - void Write() override; - std::string ToString() const override; - - enum - { - SUCCESS = 0, - FAILURE = 1 - }; - - int32 Type = SUCCESS; - struct SuccessType : public PrintableComponent - { - uint32 ServerSalt; - std::vector IPv4; - std::vector IPv6; - - std::string ToString() const override; - } Success; - - Wow::AuthResult Failure = Wow::WOW_SUCCESS; - }; - } -} - -#endif // WoWRealmPackets_h__ -- cgit v1.2.3