TrinityCore
AuthenticationPackets.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef AuthenticationPacketsWorld_h__
19#define AuthenticationPacketsWorld_h__
20
21#include "Packet.h"
22#include "Define.h"
23#include "Optional.h"
24#include "PacketUtilities.h"
25#include <array>
26#include <unordered_map>
27
30
31namespace WorldPackets
32{
33 namespace Auth
34 {
36 {
37 public:
38 EarlyProcessClientPacket(OpcodeClient opcode, WorldPacket&& packet) : ClientPacket(opcode, std::move(packet)) { }
39
40 bool ReadNoThrow();
41 };
42
43 class Ping final : public EarlyProcessClientPacket
44 {
45 public:
46 Ping(WorldPacket&& packet) : EarlyProcessClientPacket(CMSG_PING, std::move(packet)) { }
47
50
51 private:
52 void Read();
53 };
54
55 class Pong final : public ServerPacket
56 {
57 public:
58 Pong(uint32 serial) : ServerPacket(SMSG_PONG, 4), Serial(serial) { }
59
60 WorldPacket const* Write() override;
61
63 };
64
65 class AuthChallenge final : public ServerPacket
66 {
67 public:
69
70 WorldPacket const* Write() override;
71
72 std::array<uint8, 16> Challenge = { };
73 std::array<uint32, 8> DosChallenge = { };
75 };
76
78 {
79 public:
80 static uint32 const DigestLength = 24;
81
83 {
84 LocalChallenge.fill(0);
85 Digest.fill(0);
86 }
87
91 std::array<uint8, 16> LocalChallenge;
92 std::array<uint8, DigestLength> Digest;
94 std::string RealmJoinTicket;
95 bool UseIPv6 = false;
96
97 private:
98 void Read() override;
99 };
100
102 {
106 bool HasFCM = false;
108 };
109
111 {
113 VirtualRealmNameInfo(bool isHomeRealm, bool isInternalRealm, std::string const& realmNameActual, std::string const& realmNameNormalized) :
114 IsLocal(isHomeRealm), IsInternalRealm(isInternalRealm), RealmNameActual(realmNameActual), RealmNameNormalized(realmNameNormalized) { }
115
116 bool IsLocal;
118 std::string RealmNameActual;
120 };
121
123 {
125 VirtualRealmInfo(uint32 realmAddress, bool isHomeRealm, bool isInternalRealm, std::string const& realmNameActual, std::string const& realmNameNormalized) :
126 RealmAddress(realmAddress), RealmNameInfo(isHomeRealm, isInternalRealm, realmNameActual, realmNameNormalized) { }
127
130 };
131
132 class AuthResponse final : public ServerPacket
133 {
134 public:
136 {
137 struct GameTime
138 {
142 bool InGameRoom = false;
143 };
144
145 struct NewBuild
146 {
147 std::array<uint8, 16> NewBuildKey = { };
148 std::array<uint8, 16> SomeKey = { };
149 };
150
151 AuthSuccessInfo() { } // work around clang bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101227
152
156
161
163
164 std::vector<VirtualRealmInfo> VirtualRealms;
165 std::vector<CharacterTemplate const*> Templates;
166
167 std::vector<RaceClassAvailability> const* AvailableClasses = nullptr;
168
169 bool IsExpansionTrial = false;
175 };
176
178
179 WorldPacket const* Write() override;
180
184 };
185
186 class WaitQueueUpdate final : public ServerPacket
187 {
188 public:
190
191 WorldPacket const* Write() override;
192
194 };
195
196 class WaitQueueFinish final : public ServerPacket
197 {
198 public:
200
201 WorldPacket const* Write() override { return &_worldPacket; }
202 };
203
205 {
206 None = 0,
207 Realm = 14,
208 WorldAttempt1 = 17,
209 WorldAttempt2 = 35,
210 WorldAttempt3 = 53,
211 WorldAttempt4 = 71,
212 WorldAttempt5 = 89
213 };
214
215 class TC_GAME_API ConnectTo final : public ServerPacket
216 {
217 public:
218 static bool InitializeEncryption();
219 static void ShutdownEncryption();
220
222 {
223 None = 0,
224 IPv4 = 1,
225 IPv6 = 2,
226 NamedSocket = 3 // not supported by windows client
227 };
228
230 {
232 union
233 {
234 std::array<uint8, 4> V4;
235 std::array<uint8, 16> V6;
236 std::array<char, 128> Name;
237 } Address = { };
238 };
239
241 {
243 uint16 Port = 0;
244 std::array<uint8, 256> Signature = { };
245 };
246
247 ConnectTo();
248
249 WorldPacket const* Write() override;
250
251 uint64 Key = 0;
254 uint8 Con = 0;
255 };
256
258 {
259 public:
260 static uint32 const DigestLength = 24;
261
263 {
264 LocalChallenge.fill(0);
265 Digest.fill(0);
266 }
267
270 std::array<uint8, 16> LocalChallenge;
271 std::array<uint8, DigestLength> Digest;
272
273 private:
274 void Read() override;
275 };
276
277 class ResumeComms final : public ServerPacket
278 {
279 public:
281
282 WorldPacket const* Write() override { return &_worldPacket; }
283 };
284
286 {
287 public:
289
292
293 private:
294 void Read() override;
295 };
296
298 {
299 public:
300 static bool InitializeEncryption();
301 static void ShutdownEncryption();
302
303 EnterEncryptedMode(std::array<uint8, 16> const& encryptionKey, bool enabled) : ServerPacket(SMSG_ENTER_ENCRYPTED_MODE, 256 + 1),
304 EncryptionKey(encryptionKey), Enabled(enabled)
305 {
306 }
307
308 WorldPacket const* Write() override;
309
310 std::array<uint8, 16> const& EncryptionKey;
311 bool Enabled = false;
312 };
313 }
314}
315
318
319#endif // AuthenticationPacketsWorld_h__
ByteBuffer & operator<<(ByteBuffer &data, WorldPackets::Auth::VirtualRealmInfo const &realmInfo)
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
std::pair< uint32, ObjectGuid > Signature
Definition: PetitionMgr.h:50
WorldPacket const * Write() override
std::array< uint8, DigestLength > Digest
uint32 Result
the result of the authentication process, possible values are BattlenetRpcErrorCode
WorldPacket const * Write() override
Optional< AuthWaitInfo > WaitInfo
contains the queue wait information in case the account is in the login queue.
Optional< AuthSuccessInfo > SuccessInfo
contains the packet data in case that it has account information (It is never set when WaitInfo is se...
std::array< uint8, 16 > LocalChallenge
std::array< uint8, DigestLength > Digest
EarlyProcessClientPacket(OpcodeClient opcode, WorldPacket &&packet)
std::array< uint8, 16 > const & EncryptionKey
EnterEncryptedMode(std::array< uint8, 16 > const &encryptionKey, bool enabled)
Ping(WorldPacket &&packet)
WorldPacket const * Write() override
ResumeComms(ConnectionType connection)
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket _worldPacket
Definition: Packet.h:43
ConnectionType
Definition: Opcodes.h:29
OpcodeClient
Definition: Opcodes.h:46
@ CMSG_CONNECT_TO_FAILED
Definition: Opcodes.h:282
@ CMSG_AUTH_CONTINUED_SESSION
Definition: Opcodes.h:93
@ CMSG_PING
Definition: Opcodes.h:633
@ CMSG_AUTH_SESSION
Definition: Opcodes.h:94
@ SMSG_RESUME_COMMS
Definition: Opcodes.h:1862
@ SMSG_WAIT_QUEUE_FINISH
Definition: Opcodes.h:2061
@ SMSG_PONG
Definition: Opcodes.h:1756
@ SMSG_AUTH_CHALLENGE
Definition: Opcodes.h:978
@ SMSG_ENTER_ENCRYPTED_MODE
Definition: Opcodes.h:1230
@ SMSG_AUTH_RESPONSE
Definition: Opcodes.h:980
@ SMSG_WAIT_QUEUE_UPDATE
Definition: Opcodes.h:2062
STL namespace.
Definition: Realm.h:81
bool ForceCharacterTemplate
forces the client to always use a character template when creating a new character.
uint8 ActiveExpansionLevel
the current server expansion, the possible values are in Expansions
Optional< Timestamp<> > ExpansionTrialExpiration
expansion trial expiration unix timestamp
std::vector< VirtualRealmInfo > VirtualRealms
list of realms connected to this one (inclusive)
std::vector< RaceClassAvailability > const * AvailableClasses
the minimum AccountExpansion required to select race/class combinations
uint32 CurrencyID
this is probably used for the ingame shop.
Optional< uint16 > NumPlayersAlliance
number of alliance players in this realm.
Optional< uint16 > NumPlayersHorde
number of horde players in this realm.
uint32 TimeRested
affects the return value of the GetBillingTimeRested() client API call, it is the number of seconds y...
uint32 VirtualRealmAddress
a special identifier made from the Index, BattleGroup and Region.
std::vector< CharacterTemplate const * > Templates
list of pre-made character templates.
uint8 AccountExpansionLevel
the current expansion of this account, the possible values are in Expansions
bool HasFCM
true if the account has a forced character migration pending.
bool CanCreateOnlyIfExisting
Can create characters on realm only if player has other existing characters there.
uint32 WaitCount
position of the account in the login queue
uint32 WaitTime
Wait time in login queue in minutes, if sent queued and this value is 0 client displays "unknown time...
VirtualRealmInfo(uint32 realmAddress, bool isHomeRealm, bool isInternalRealm, std::string const &realmNameActual, std::string const &realmNameNormalized)
uint32 RealmAddress
the virtual address of this realm, constructed as RealmHandle::Region << 24 | RealmHandle::Battlegrou...
VirtualRealmNameInfo(bool isHomeRealm, bool isInternalRealm, std::string const &realmNameActual, std::string const &realmNameNormalized)
std::string RealmNameActual
the name of the realm
std::string RealmNameNormalized
the name of the realm without spaces
bool IsLocal
true if the realm is the same as the account's home realm