TrinityCore
Loading...
Searching...
No Matches
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 TRINITYCORE_AUTHENTICATION_PACKETS_H
19#define TRINITYCORE_AUTHENTICATION_PACKETS_H
20
21#include "Packet.h"
22#include "Define.h"
23#include "Optional.h"
24#include "PacketUtilities.h"
25#include <array>
26
29
30namespace WorldPackets
31{
32 namespace Auth
33 {
34 template <typename Derived>
36 {
37 explicit EarlyProcessClientPacket(OpcodeClient opcode, WorldPacket&& packet) : ClientPacket(opcode, std::move(packet)) { }
38
39 public:
40 bool ReadNoThrow() try
41 {
42 static_cast<Derived*>(this)->Read();
43 return true;
44 }
45 catch (ByteBufferException const& /*ex*/)
46 {
47 return false;
48 }
49
50 friend Derived;
51 };
52
53 class Ping final : public EarlyProcessClientPacket<Ping>
54 {
55 public:
56 explicit Ping(WorldPacket&& packet) : EarlyProcessClientPacket(CMSG_PING, std::move(packet)) { }
57
60
61 private:
63 void Read() override;
64 };
65
66 class Pong final : public ServerPacket
67 {
68 public:
69 explicit Pong(uint32 serial) : ServerPacket(SMSG_PONG, 4), Serial(serial) { }
70
71 WorldPacket const* Write() override;
72
74 };
75
76 class LogDisconnect final : public EarlyProcessClientPacket<LogDisconnect>
77 {
78 public:
80
82
83 private:
85 void Read() override;
86 };
87
88 class AuthChallenge final : public ServerPacket
89 {
90 public:
91 explicit AuthChallenge() : ServerPacket(SMSG_AUTH_CHALLENGE, 16 + 4 * 8 + 1) { }
92
93 WorldPacket const* Write() override;
94
95 std::array<uint8, 32> Challenge = { };
96 std::array<uint32, 8> DosChallenge = { };
98 };
99
100 class AuthSession final : public EarlyProcessClientPacket<AuthSession>
101 {
102 public:
103 static constexpr uint32 DigestLength = 24;
104
106
110 std::array<uint8, 32> LocalChallenge = { };
111 std::array<uint8, DigestLength> Digest = { };
113 std::string RealmJoinTicket;
114 bool UseIPv6 = false;
115
116 private:
118 void Read() override;
119 };
120
129
131 {
133 VirtualRealmNameInfo(bool isHomeRealm, bool isInternalRealm, std::string const& realmNameActual, std::string const& realmNameNormalized) :
134 IsLocal(isHomeRealm), IsInternalRealm(isInternalRealm), RealmNameActual(realmNameActual), RealmNameNormalized(realmNameNormalized) { }
135
136 bool IsLocal;
138 std::string RealmNameActual;
140 };
141
143 {
145 VirtualRealmInfo(uint32 realmAddress, bool isHomeRealm, bool isInternalRealm, std::string const& realmNameActual, std::string const& realmNameNormalized) :
146 RealmAddress(realmAddress), RealmNameInfo(isHomeRealm, isInternalRealm, realmNameActual, realmNameNormalized) { }
147
150 };
151
152 struct GameTime
153 {
157 bool IsInIGR = false;
158 bool IsPaidForByIGR = false;
159 bool IsCAISEnabled = false;
160 };
161
163 {
164 std::array<uint8, 16> BuildKey = { };
165 std::array<uint8, 16> ConfigKey = { };
166 };
167
193
194 class AuthResponse final : public ServerPacket
195 {
196 public:
198
199 WorldPacket const* Write() override;
200
204 };
205
206 class WaitQueueUpdate final : public ServerPacket
207 {
208 public:
210
211 WorldPacket const* Write() override;
212
214 };
215
216 class WaitQueueFinish final : public ServerPacket
217 {
218 public:
220
221 WorldPacket const* Write() override { return &_worldPacket; }
222 };
223
225 {
226 None = 0,
227 Realm = 14,
228 WorldAttempt1 = 17,
229 WorldAttempt2 = 35,
230 WorldAttempt3 = 53,
231 WorldAttempt4 = 71,
232 WorldAttempt5 = 89
233 };
234
235 class TC_GAME_API ConnectTo final : public ServerPacket
236 {
237 public:
238 static bool InitializeEncryption();
239 static void ShutdownEncryption();
240
242 {
243 None = 0,
244 IPv4 = 1,
245 IPv6 = 2,
246 NamedSocket = 3 // not supported by windows client
247 };
248
250 {
252 union
253 {
254 std::array<uint8, 4> V4;
255 std::array<uint8, 16> V6;
256 std::array<char, 128> Name;
257 } Address = { };
258 };
259
261 {
262 std::string_view Token;
263 std::string_view ProxyId;
264 std::string_view Address;
266 };
267
274
275 explicit ConnectTo() : ServerPacket(SMSG_CONNECT_TO, 4 + 4 + 1 + 8 + 4 + 4 + 1 + 16 + 2 + 1 + 3 + 1 + 8 + 0 + 0 + 0) { }
276
277 WorldPacket const* Write() override;
278
279 uint64 Key = 0;
280 uint32 NativeRealmAddress = 0;
281 uint32 Key3 = 0;
282 ConnectToSerial Serial = ConnectToSerial::None;
283 std::vector<ConnectPayload> Payload;
284 uint8 Con = 0;
285 };
286
287 class AuthContinuedSession final : public EarlyProcessClientPacket<AuthContinuedSession>
288 {
289 public:
290 static constexpr uint32 DigestLength = 24;
291
293
298 std::array<uint8, 32> LocalChallenge = { };
299 std::array<uint8, DigestLength> Digest = { };
300
301 private:
303 void Read() override;
304 };
305
306 class ResumeComms final : public ServerPacket
307 {
308 public:
309 explicit ResumeComms(ConnectionType connection) : ServerPacket(SMSG_RESUME_COMMS, 0, connection) { }
310
311 WorldPacket const* Write() override { return &_worldPacket; }
312 };
313
314 class ConnectToFailed final : public EarlyProcessClientPacket<ConnectToFailed>
315 {
316 public:
318
321
322 private:
324 void Read() override;
325 };
326
328 {
329 public:
330 static bool InitializeEncryption();
331 static void ShutdownEncryption();
332
333 explicit EnterEncryptedMode(std::array<uint8, 32> const& encryptionKey, bool enabled) : ServerPacket(SMSG_ENTER_ENCRYPTED_MODE, 4 + 256 + 1),
334 EncryptionKey(encryptionKey), Enabled(enabled)
335 {
336 }
337
338 WorldPacket const* Write() override;
339
340 int32 RegionGroup = 0;
341 std::array<uint8, 32> const& EncryptionKey;
342 bool Enabled = false;
343 };
344
345 class QueuedMessagesEnd final : public ClientPacket
346 {
347 public:
349
350 void Read() override;
351
353 };
354
355 ByteBuffer& operator<<(ByteBuffer& data, VirtualRealmInfo const& realmInfo);
356 ByteBuffer& operator<<(ByteBuffer& data, VirtualRealmNameInfo const& realmInfo);
357 }
358}
359
360#endif // TRINITYCORE_AUTHENTICATION_PACKETS_H
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
ConnectionType
Definition Opcodes.h:27
@ SMSG_RESUME_COMMS
Definition Opcodes.h:2264
@ SMSG_WAIT_QUEUE_FINISH
Definition Opcodes.h:2485
@ SMSG_PONG
Definition Opcodes.h:2149
@ SMSG_AUTH_CHALLENGE
Definition Opcodes.h:1192
@ SMSG_ENTER_ENCRYPTED_MODE
Definition Opcodes.h:1463
@ SMSG_CONNECT_TO
Definition Opcodes.h:1385
@ SMSG_AUTH_RESPONSE
Definition Opcodes.h:1194
@ SMSG_WAIT_QUEUE_UPDATE
Definition Opcodes.h:2486
OpcodeClient
Definition Opcodes.h:38
@ CMSG_CONNECT_TO_FAILED
Definition Opcodes.h:285
@ CMSG_AUTH_CONTINUED_SESSION
Definition Opcodes.h:86
@ CMSG_QUEUED_MESSAGES_END
Definition Opcodes.h:819
@ CMSG_PING
Definition Opcodes.h:771
@ CMSG_LOG_DISCONNECT
Definition Opcodes.h:576
@ CMSG_AUTH_SESSION
Definition Opcodes.h:87
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
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, DigestLength > Digest
std::vector< ConnectPayload > Payload
EarlyProcessClientPacket(OpcodeClient opcode, WorldPacket &&packet)
EnterEncryptedMode(std::array< uint8, 32 > const &encryptionKey, bool enabled)
std::array< uint8, 32 > const & EncryptionKey
WorldPacket const * Write() override
ResumeComms(ConnectionType connection)
WorldPacket const * Write() override
WorldPacket const * Write() override
virtual void Read()=0
WorldPacket _worldPacket
Definition Packet.h:43
ByteBuffer & operator<<(ByteBuffer &data, VirtualRealmNameInfo const &virtualRealmInfo)
STL namespace.
Definition Realm.h:139
std::vector< RaceClassAvailability > const * AvailableClasses
the minimum AccountExpansion required to select race/class combinations
uint8 ActiveExpansionLevel
the current server expansion, the possible values are in Expansions
uint8 AccountExpansionLevel
the current expansion of this account, the possible values are in Expansions
bool ForceCharacterTemplate
forces the client to always use a character template when creating a new character.
uint32 TimeRested
affects the return value of the GetBillingTimeRested() client API call, it is the number of seconds y...
std::vector< CharacterTemplate const * > Templates
list of pre-made character templates.
Optional< Timestamp<> > ExpansionTrialExpiration
expansion trial expiration unix timestamp
Optional< uint16 > NumPlayersAlliance
number of alliance players in this realm.
uint32 VirtualRealmAddress
a special identifier made from the Index, BattleGroup and Region.
uint32 CurrencyID
this is probably used for the ingame shop.
std::vector< VirtualRealmInfo > VirtualRealms
list of realms connected to this one (inclusive)
Optional< uint16 > NumPlayersHorde
number of horde players in this realm.
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...
Duration< std::chrono::nanoseconds > TokenLifespan
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