chore(net): rearrange defines and enums for clarity

This commit is contained in:
fallenoak 2025-09-26 22:41:40 -07:00
parent 2d3327d3ae
commit a85bd4809f
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
10 changed files with 91 additions and 82 deletions

View File

@ -486,9 +486,9 @@ void CGlueMgr::PollLoginServerLogin() {
}
case LOGIN_STATE_CHECKINGVERSIONS: {
uint8_t versionChecksum[VERSION_CHECKSUM_LEN];
uint8_t versionChecksum[LOGIN_VERSION_CHECKSUM_LEN];
auto versionChallenge = ClientServices::LoginConnection()->GetVersionChallenge();
ChecksumExecutables(versionChallenge, VERSION_CHALLENGE_LEN, versionChecksum);
ChecksumExecutables(versionChallenge, LOGIN_VERSION_CHALLENGE_LEN, versionChecksum);
ClientServices::LoginConnection()->ProveVersion(versionChecksum);

View File

@ -2,8 +2,8 @@
#define GLUE_C_GLUE_MGR_HPP
#include "event/Event.hpp"
#include "net/Login.hpp"
#include "net/Types.hpp"
#include <cstdint>
class CDataStore;
class CSimpleTop;

View File

@ -3,5 +3,6 @@
#include "net/login/BattlenetLogin.hpp"
#include "net/login/GruntLogin.hpp"
#include "net/login/Types.hpp"
#endif

View File

@ -3,76 +3,6 @@
#include <cstdint>
#define VERSION_CHALLENGE_LEN 16
#define VERSION_CHECKSUM_LEN 20
enum LOGIN_RESULT {
LOGIN_OK = 0,
LOGIN_INVALID_CHALLENGE_MESSAGE = 1,
LOGIN_SRP_ERROR = 2,
LOGIN_INVALID_PROOF_MESSAGE = 3,
LOGIN_BAD_SERVER_PROOF = 4,
LOGIN_INVALID_RECODE_MESSAGE = 5,
LOGIN_BAD_SERVER_RECODE_PROOF = 6,
LOGIN_UNKNOWN_ACCOUNT = 7,
LOGIN_UNKNOWN_ACCOUNT_PIN = 8,
LOGIN_UNKNOWN_ACCOUNT_CALL = 9,
LOGIN_INCORRECT_PASSWORD = 10,
LOGIN_FAILED = 11,
LOGIN_SERVER_DOWN = 12,
LOGIN_BANNED = 13,
LOGIN_BADVERSION = 14,
LOGIN_ALREADYONLINE = 15,
LOGIN_NOTIME = 16,
LOGIN_DBBUSY = 17,
LOGIN_SUSPENDED = 18,
LOGIN_PARENTALCONTROL = 19,
LOGIN_LOCKED_ENFORCED = 20,
LOGIN_RESULT_21 = 21, // DISCONNECTED
LOGIN_ACCOUNT_CONVERTED = 22,
LOGIN_ANTI_INDULGENCE = 23,
LOGIN_EXPIRED = 24,
LOGIN_TRIAL_EXPIRED = 25,
LOGIN_NO_GAME_ACCOUNT = 26,
LOGIN_AUTH_OUTAGE = 27,
LOGIN_GAME_ACCOUNT_LOCKED = 28,
LOGIN_NO_BATTLENET_MANAGER = 29,
LOGIN_NO_BATTLENET_APPLICATION = 30,
LOGIN_MALFORMED_ACCOUNT_NAME = 31,
LOGIN_USE_GRUNT = 32,
LOGIN_TOO_FAST = 33,
LOGIN_CHARGEBACK = 34,
LOGIN_IGR_WITHOUT_BNET = 35,
LOGIN_UNLOCKABLE_LOCK = 36,
LOGIN_CONVERSION_REQUIRED = 37,
LOGIN_UNABLE_TO_DOWNLOAD_MODULE = 38,
LOGIN_NO_GAME_ACCOUNTS_IN_REGION = 39,
LOGIN_ACCOUNT_LOCKED = 40,
LOGIN_RESULT_MAX = 41,
};
enum LOGIN_STATE {
LOGIN_STATE_INITIALIZED = 0,
LOGIN_STATE_CONNECTING = 1,
LOGIN_STATE_HANDSHAKING = 2,
LOGIN_STATE_AUTHENTICATING = 3,
LOGIN_STATE_AUTHENTICATED = 4,
LOGIN_STATE_FAILED = 5,
LOGIN_STATE_DOWNLOADFILE = 6,
LOGIN_STATE_FIRST_SECURITY = 7,
LOGIN_STATE_PIN = 8,
LOGIN_STATE_PIN_WAIT = 9,
LOGIN_STATE_MATRIX = 10,
LOGIN_STATE_MATRIX_WAIT = 11,
LOGIN_STATE_TOKEN = 12,
LOGIN_STATE_TOKEN_WAIT = 13,
LOGIN_STATE_CHECKINGVERSIONS = 14,
LOGIN_STATE_15 = 15, // RESPONSE_CONNECTED
LOGIN_STATE_DISCONNECTED = 16,
LOGIN_STATE_SURVEY = 17,
LOGIN_STATE_MAX = 18,
};
enum NETMESSAGE {
MSG_NULL_ACTION = 0x0000,
CMSG_BOOTME = 0x0001,

View File

@ -2,6 +2,7 @@
#include "net/connection/WowConnection.hpp"
#include "net/grunt/ClientResponse.hpp"
#include "net/grunt/Command.hpp"
#include "net/login/Types.hpp"
#include "net/srp/SRP6_Random.hpp"
#include <common/MD5.hpp>
#include <storm/Error.hpp>
@ -114,13 +115,13 @@ int32_t Grunt::ClientLink::CmdAuthLogonChallenge(CDataStore& msg) {
uint8_t* salt;
uint8_t* versionChallenge;
if (!CanRead(msg, largeSafePrimeLen + SALT_LEN + VERSION_CHALLENGE_LEN)) {
if (!CanRead(msg, largeSafePrimeLen + SALT_LEN + LOGIN_VERSION_CHALLENGE_LEN)) {
return 0;
}
msg.GetDataInSitu(reinterpret_cast<void*&>(largeSafePrime), largeSafePrimeLen);
msg.GetDataInSitu(reinterpret_cast<void*&>(salt), SALT_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), VERSION_CHALLENGE_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), LOGIN_VERSION_CHALLENGE_LEN);
uint8_t logonFlags;
@ -353,7 +354,7 @@ int32_t Grunt::ClientLink::CmdAuthReconnectChallenge(CDataStore& msg) {
// Reconnect challenge success (result == 0)
msg.GetDataInSitu(reinterpret_cast<void*&>(reconnectKey), RECONNECT_KEY_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), VERSION_CHALLENGE_LEN);
msg.GetDataInSitu(reinterpret_cast<void*&>(versionChallenge), LOGIN_VERSION_CHALLENGE_LEN);
if (!msg.IsValid()) {
return 1;
@ -645,7 +646,7 @@ void Grunt::ClientLink::ProveVersion(const uint8_t* versionChecksum) {
SHA1_Init(&sha1);
SHA1_Update(&sha1, this->m_srpClient.clientPublicKey, sizeof(this->m_srpClient.clientPublicKey));
SHA1_Update(&sha1, versionChecksum, VERSION_CHECKSUM_LEN);
SHA1_Update(&sha1, versionChecksum, LOGIN_VERSION_CHECKSUM_LEN);
SHA1_Final(clientVersionProof, &sha1);
command.PutData(clientVersionProof, sizeof(clientVersionProof));
@ -695,7 +696,7 @@ void Grunt::ClientLink::ProveVersion(const uint8_t* versionChecksum) {
SHA1_Init(&sha1);
SHA1_Update(&sha1, clientSalt, sizeof(clientSalt));
SHA1_Update(&sha1, versionChecksum, VERSION_CHECKSUM_LEN);
SHA1_Update(&sha1, versionChecksum, LOGIN_VERSION_CHECKSUM_LEN);
SHA1_Final(clientVersionProof, &sha1);
command.PutData(clientVersionProof, sizeof(clientVersionProof));

View File

@ -2,10 +2,12 @@
#define NET_GRUNT_CLIENT_RESPONSE_HPP
#include "net/grunt/Grunt.hpp"
#include "net/Types.hpp"
#include "net/login/Types.hpp"
#include <cstdint>
class CDataStore;
class LoginResponse;
struct NETADDR;
class Grunt::ClientResponse {
public:

View File

@ -96,7 +96,7 @@ const uint8_t* GruntLogin::GetVersionChallenge() {
void GruntLogin::GetVersionProof(const uint8_t* versionChallenge) {
if (this->IsReconnect()) {
// During reconnect, version challenge is ignored and version checksum is zeroed out
uint8_t versionChecksum[VERSION_CHECKSUM_LEN] = {};
uint8_t versionChecksum[LOGIN_VERSION_CHECKSUM_LEN] = {};
this->m_clientLink->ProveVersion(versionChecksum);
} else {

View File

@ -4,12 +4,12 @@
#include "net/grunt/ClientResponse.hpp"
#include "net/grunt/Grunt.hpp"
#include "net/login/Login.hpp"
#include "net/Types.hpp"
#include "net/login/Types.hpp"
class GruntLogin : public Login {
public:
// Member variables
uint8_t m_versionChallenge[VERSION_CHALLENGE_LEN];
uint8_t m_versionChallenge[LOGIN_VERSION_CHALLENGE_LEN];
Grunt::ClientLink* m_clientLink = nullptr;
// Virtual member functions

View File

@ -1,6 +1,7 @@
#ifndef NET_LOGIN_LOGIN_RESPONSE_HPP
#define NET_LOGIN_LOGIN_RESPONSE_HPP
#include "net/login/Types.hpp"
#include "net/Types.hpp"
#include <storm/Array.hpp>

74
src/net/login/Types.hpp Normal file
View File

@ -0,0 +1,74 @@
#ifndef NET_LOGIN_TYPES_HPP
#define NET_LOGIN_TYPES_HPP
#define LOGIN_VERSION_CHALLENGE_LEN 16
#define LOGIN_VERSION_CHECKSUM_LEN 20
enum LOGIN_RESULT {
LOGIN_OK = 0,
LOGIN_INVALID_CHALLENGE_MESSAGE = 1,
LOGIN_SRP_ERROR = 2,
LOGIN_INVALID_PROOF_MESSAGE = 3,
LOGIN_BAD_SERVER_PROOF = 4,
LOGIN_INVALID_RECODE_MESSAGE = 5,
LOGIN_BAD_SERVER_RECODE_PROOF = 6,
LOGIN_UNKNOWN_ACCOUNT = 7,
LOGIN_UNKNOWN_ACCOUNT_PIN = 8,
LOGIN_UNKNOWN_ACCOUNT_CALL = 9,
LOGIN_INCORRECT_PASSWORD = 10,
LOGIN_FAILED = 11,
LOGIN_SERVER_DOWN = 12,
LOGIN_BANNED = 13,
LOGIN_BADVERSION = 14,
LOGIN_ALREADYONLINE = 15,
LOGIN_NOTIME = 16,
LOGIN_DBBUSY = 17,
LOGIN_SUSPENDED = 18,
LOGIN_PARENTALCONTROL = 19,
LOGIN_LOCKED_ENFORCED = 20,
LOGIN_RESULT_21 = 21, // DISCONNECTED
LOGIN_ACCOUNT_CONVERTED = 22,
LOGIN_ANTI_INDULGENCE = 23,
LOGIN_EXPIRED = 24,
LOGIN_TRIAL_EXPIRED = 25,
LOGIN_NO_GAME_ACCOUNT = 26,
LOGIN_AUTH_OUTAGE = 27,
LOGIN_GAME_ACCOUNT_LOCKED = 28,
LOGIN_NO_BATTLENET_MANAGER = 29,
LOGIN_NO_BATTLENET_APPLICATION = 30,
LOGIN_MALFORMED_ACCOUNT_NAME = 31,
LOGIN_USE_GRUNT = 32,
LOGIN_TOO_FAST = 33,
LOGIN_CHARGEBACK = 34,
LOGIN_IGR_WITHOUT_BNET = 35,
LOGIN_UNLOCKABLE_LOCK = 36,
LOGIN_CONVERSION_REQUIRED = 37,
LOGIN_UNABLE_TO_DOWNLOAD_MODULE = 38,
LOGIN_NO_GAME_ACCOUNTS_IN_REGION = 39,
LOGIN_ACCOUNT_LOCKED = 40,
LOGIN_RESULT_MAX = 41,
};
enum LOGIN_STATE {
LOGIN_STATE_INITIALIZED = 0,
LOGIN_STATE_CONNECTING = 1,
LOGIN_STATE_HANDSHAKING = 2,
LOGIN_STATE_AUTHENTICATING = 3,
LOGIN_STATE_AUTHENTICATED = 4,
LOGIN_STATE_FAILED = 5,
LOGIN_STATE_DOWNLOADFILE = 6,
LOGIN_STATE_FIRST_SECURITY = 7,
LOGIN_STATE_PIN = 8,
LOGIN_STATE_PIN_WAIT = 9,
LOGIN_STATE_MATRIX = 10,
LOGIN_STATE_MATRIX_WAIT = 11,
LOGIN_STATE_TOKEN = 12,
LOGIN_STATE_TOKEN_WAIT = 13,
LOGIN_STATE_CHECKINGVERSIONS = 14,
LOGIN_STATE_15 = 15, // RESPONSE_CONNECTED
LOGIN_STATE_DISCONNECTED = 16,
LOGIN_STATE_SURVEY = 17,
LOGIN_STATE_MAX = 18,
};
#endif