summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-12-16 19:05:34 +0100
committerGitHub <noreply@github.com>2018-12-16 19:05:34 +0100
commitf1f1ef0ff2c9aa7d879df8b959072a7429d2722a (patch)
tree11a7121f30031a2a850015eced3803f060514fa3 /src/login
parent41d370cd3308be48b4ce00a50ee46515742978b0 (diff)
parent4b2e8684a9874ba435197936a4a9220510ff671f (diff)
downloadhercules-f1f1ef0ff2c9aa7d879df8b959072a7429d2722a.tar.gz
hercules-f1f1ef0ff2c9aa7d879df8b959072a7429d2722a.tar.bz2
hercules-f1f1ef0ff2c9aa7d879df8b959072a7429d2722a.tar.xz
hercules-f1f1ef0ff2c9aa7d879df8b959072a7429d2722a.zip
Merge pull request #2324 from 4144/updatepackets
Update packets up to 2018-12-12
Diffstat (limited to 'src/login')
-rw-r--r--src/login/HPMlogin.c2
-rw-r--r--src/login/lclif.c84
-rw-r--r--src/login/lclif.h4
-rw-r--r--src/login/lclif.p.h298
-rw-r--r--src/login/login.c58
-rw-r--r--src/login/login.h1
-rw-r--r--src/login/packets_ac_struct.h156
-rw-r--r--src/login/packets_ca_struct.h239
8 files changed, 505 insertions, 337 deletions
diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c
index e5dc126eb..304db5501 100644
--- a/src/login/HPMlogin.c
+++ b/src/login/HPMlogin.c
@@ -30,6 +30,8 @@
#include "login/lclif.p.h"
#include "login/login.h"
#include "login/loginlog.h"
+#include "login/packets_ac_struct.h"
+#include "login/packets_ca_struct.h"
#include "common/HPMi.h"
#include "common/conf.h"
#include "common/console.h"
diff --git a/src/login/lclif.c b/src/login/lclif.c
index 1cb8bfdbd..97871922d 100644
--- a/src/login/lclif.c
+++ b/src/login/lclif.c
@@ -24,6 +24,8 @@
#include "login/ipban.h"
#include "login/login.h"
#include "login/loginlog.h"
+#include "login/packets_ac_struct.h"
+#include "login/packets_ca_struct.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/db.h"
@@ -49,10 +51,10 @@ struct lclif_interface *lclif;
/// @copydoc lclif_interface::connection_error()
static void lclif_connection_error(int fd, uint8 error)
{
- struct packet_SC_NOTIFY_BAN *packet = NULL;
+ struct PACKET_SC_NOTIFY_BAN *packet = NULL;
WFIFOHEAD(fd, sizeof(*packet));
packet = WP2PTR(fd);
- packet->packet_id = PACKET_ID_SC_NOTIFY_BAN;
+ packet->packet_id = HEADER_SC_NOTIFY_BAN;
packet->error_code = error;
WFIFOSET(fd, sizeof(*packet));
}
@@ -68,7 +70,7 @@ static enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct l
static enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd)
{
- const struct packet_CA_EXE_HASHCHECK *packet = RP2PTR(fd);
+ const struct PACKET_CA_EXE_HASHCHECK *packet = RP2PTR(fd);
sd->has_client_hash = 1;
memcpy(sd->client_hash, packet->hash_value, 16);
return PACKET_VALID;
@@ -78,7 +80,7 @@ static enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_se
static enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -97,7 +99,7 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_da
static enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN2 *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN2 *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -113,7 +115,7 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_d
static enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN3 *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN3 *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -131,7 +133,7 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_d
static enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN4 *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN4 *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -149,7 +151,7 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_d
static enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN_PCBANG *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -171,7 +173,7 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_ses
static enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd)
{
- const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd);
+ const struct PACKET_CA_LOGIN_HAN *packet = RP2PTR(fd);
sd->version = packet->version;
sd->clienttype = packet->clienttype;
@@ -194,11 +196,11 @@ static enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_sessio
static enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd)
{
- const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd);
+ const struct PACKET_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd);
int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet);
if (tokenlen > PASSWD_LEN || tokenlen < 1) {
- ShowError("packet_CA_SSO_LOGIN_REQ: Token length is not between allowed password length, kicking player ('%s')", packet->id);
+ ShowError("PACKET_CA_SSO_LOGIN_REQ: Token length is not between allowed password length, kicking player ('%s')", packet->id);
sockt->eof(fd);
return PACKET_VALID;
}
@@ -220,11 +222,27 @@ static enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_se
static enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd)
{
- //const struct packet_CA_LOGIN_OTP *packet = RP2PTR(fd);
+ //const struct PACKET_CA_LOGIN_OTP *packet = RP2PTR(fd);
login->client_login_otp(fd, sd);
return PACKET_VALID;
}
+/// @copydoc lclif_interface_private::parse_CA_ACK_MOBILE_OTP()
+static enum parsefunc_rcode lclif_parse_CA_ACK_MOBILE_OTP(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
+static enum parsefunc_rcode lclif_parse_CA_ACK_MOBILE_OTP(int fd, struct login_session_data *sd)
+{
+ // TODO: parsing packet data
+ return PACKET_VALID;
+}
+
+/// @copydoc lclif_interface_private::parse_CA_OTP_CODE()
+static enum parsefunc_rcode lclif_parse_CA_OTP_CODE(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
+static enum parsefunc_rcode lclif_parse_CA_OTP_CODE(int fd, struct login_session_data *sd)
+{
+ // TODO: parsing packet data
+ return PACKET_VALID;
+}
+
/// @copydoc lclif_interface_private::parse_CA_REQ_HASH()
static enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd)
@@ -255,7 +273,7 @@ static bool lclif_send_server_list(struct login_session_data *sd)
{
int server_num = 0, i, n, length;
uint32 ip;
- struct packet_AC_ACCEPT_LOGIN *packet = NULL;
+ struct PACKET_AC_ACCEPT_LOGIN *packet = NULL;
for (i = 0; i < ARRAYLENGTH(login->dbs->server); ++i) {
if (sockt->session_is_active(login->dbs->server[i].fd))
@@ -272,9 +290,9 @@ static bool lclif_send_server_list(struct login_session_data *sd)
packet = WP2PTR(sd->fd);
#if PACKETVER < 20170315
- packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN;
+ packet->packet_id = HEADER_AC_ACCEPT_LOGIN;
#else
- packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN2;
+ packet->packet_id = HEADER_AC_ACCEPT_LOGIN2;
#endif
packet->packet_len = length;
packet->auth_code = sd->login_id1;
@@ -312,14 +330,14 @@ static bool lclif_send_server_list(struct login_session_data *sd)
static void lclif_send_auth_failed(int fd, time_t ban, uint32 error)
{
#if PACKETVER >= 20180627
- struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL;
- int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R3;
+ struct PACKET_AC_REFUSE_LOGIN_R2 *packet = NULL;
+ int packet_id = HEADER_AC_REFUSE_LOGIN_R3;
#elif PACKETVER >= 20101123
- struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL;
- int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R2;
+ struct PACKET_AC_REFUSE_LOGIN_R2 *packet = NULL;
+ int packet_id = HEADER_AC_REFUSE_LOGIN_R2;
#else
- struct packet_AC_REFUSE_LOGIN *packet = NULL;
- int packet_id = PACKET_ID_AC_REFUSE_LOGIN;
+ struct PACKET_AC_REFUSE_LOGIN *packet = NULL;
+ int packet_id = HEADER_AC_REFUSE_LOGIN;
#endif
WFIFOHEAD(fd, sizeof(*packet));
packet = WP2PTR(fd);
@@ -335,10 +353,10 @@ static void lclif_send_auth_failed(int fd, time_t ban, uint32 error)
/// @copydoc lclif_interface::login_error()
static void lclif_send_login_error(int fd, uint8 error)
{
- struct packet_AC_REFUSE_LOGIN *packet = NULL;
+ struct PACKET_AC_REFUSE_LOGIN *packet = NULL;
WFIFOHEAD(fd, sizeof(*packet));
packet = WP2PTR(fd);
- packet->packet_id = PACKET_ID_AC_REFUSE_LOGIN;
+ packet->packet_id = HEADER_AC_REFUSE_LOGIN;
packet->error_code = error;
memset(packet->block_date, '\0', sizeof(packet->block_date));
WFIFOSET(fd, sizeof(*packet));
@@ -348,12 +366,12 @@ static void lclif_send_login_error(int fd, uint8 error)
static void lclif_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static void lclif_send_coding_key(int fd, struct login_session_data *sd)
{
- struct packet_AC_ACK_HASH *packet = NULL;
+ struct PACKET_AC_ACK_HASH *packet = NULL;
int16 size = sizeof(*packet) + sd->md5keylen;
WFIFOHEAD(fd, size);
packet = WP2PTR(fd);
- packet->packet_id = PACKET_ID_AC_ACK_HASH;
+ packet->packet_id = HEADER_AC_ACK_HASH;
packet->packet_len = size;
memcpy(packet->secret, sd->md5key, sd->md5keylen);
WFIFOSET(fd, size);
@@ -476,7 +494,7 @@ static enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *s
/// @copydoc lclif_interface::packet()
static const struct login_packet_db *lclif_packet(int16 packet_id)
{
- if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT)
+ if (packet_id == HEADER_CA_CHARSERVERCONNECT)
return &lclif->p->dbs->packet_db[0];
if (packet_id > MAX_PACKET_LOGIN_DB || packet_id < MIN_PACKET_DB)
@@ -503,8 +521,8 @@ static void packetdb_loaddb(void)
int16 packet_len;
LoginParseFunc **pFunc;
} packet[] = {
-#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), &lclif->p->parse_ ## name }
-#define packet_def2(name, len) { PACKET_ID_ ## name, (len), &lclif->p->parse_ ## name }
+#define packet_def(name) { HEADER_ ## name, sizeof(struct PACKET_ ## name), &lclif->p->parse_ ## name }
+#define packet_def2(name, len) { HEADER_ ## name, (len), &lclif->p->parse_ ## name }
packet_def(CA_CONNECT_INFO_CHANGED),
packet_def(CA_EXE_HASHCHECK),
packet_def(CA_LOGIN),
@@ -515,6 +533,12 @@ static void packetdb_loaddb(void)
packet_def(CA_LOGIN_HAN),
packet_def2(CA_SSO_LOGIN_REQ, -1),
packet_def(CA_LOGIN_OTP),
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114
+ packet_def(CA_ACK_MOBILE_OTP),
+#endif
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114 || defined(PACKETVER_ZERO)
+ packet_def(CA_OTP_CODE),
+#endif
packet_def(CA_REQ_HASH),
#undef packet_def
#undef packet_def2
@@ -531,7 +555,7 @@ static void packetdb_loaddb(void)
}
//Explict case, we will save character login packet in position 0 which is unused and not valid by normal
- lclif->p->dbs->packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT);
+ lclif->p->dbs->packet_db[0].len = sizeof(struct PACKET_CA_CHARSERVERCONNECT);
lclif->p->dbs->packet_db[0].pFunc = &lclif->p->parse_CA_CHARSERVERCONNECT;
}
@@ -579,6 +603,8 @@ void lclif_defaults(void)
lclif->p->parse_CA_LOGIN_HAN = lclif_parse_CA_LOGIN_HAN;
lclif->p->parse_CA_SSO_LOGIN_REQ = lclif_parse_CA_SSO_LOGIN_REQ;
lclif->p->parse_CA_LOGIN_OTP = lclif_parse_CA_LOGIN_OTP;
+ lclif->p->parse_CA_ACK_MOBILE_OTP = lclif_parse_CA_ACK_MOBILE_OTP;
+ lclif->p->parse_CA_OTP_CODE = lclif_parse_CA_OTP_CODE;
lclif->p->parse_CA_REQ_HASH = lclif_parse_CA_REQ_HASH;
lclif->p->parse_CA_CHARSERVERCONNECT = lclif_parse_CA_CHARSERVERCONNECT;
}
diff --git a/src/login/lclif.h b/src/login/lclif.h
index d1e4317a2..26c061367 100644
--- a/src/login/lclif.h
+++ b/src/login/lclif.h
@@ -87,8 +87,8 @@ struct lclif_interface {
* @param fd The client connection file descriptor.
* @param ban The ban duration (if error == 6).
* @param error The authentication error code.
- * @see #PACKET_ID_AC_REFUSE_LOGIN.
- * @see #PACKET_ID_AC_REFUSE_LOGIN_R2.
+ * @see #HEADER_AC_REFUSE_LOGIN.
+ * @see #HEADER_AC_REFUSE_LOGIN_R2.
*/
void (*auth_failed)(int fd, time_t ban, uint32 error);
diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h
index a80caafa2..cc9805ea8 100644
--- a/src/login/lclif.p.h
+++ b/src/login/lclif.p.h
@@ -31,279 +31,17 @@
/* Definitions and macros */
/// Maximum amount of packets processed at once from the same client
+#ifndef MAX_PROCESSED_PACKETS
#define MAX_PROCESSED_PACKETS (3)
+#endif
// Packet DB
+#ifndef MIN_PACKET_DB
#define MIN_PACKET_DB 0x0064
-#define MAX_PACKET_LOGIN_DB 0x0acf
-
-/* Enums */
-
-/// Packet IDs
-enum login_packet_id {
- // CA (Client to Login)
- PACKET_ID_CA_LOGIN = 0x0064,
- PACKET_ID_CA_LOGIN2 = 0x01dd,
- PACKET_ID_CA_LOGIN3 = 0x01fa,
- PACKET_ID_CA_CONNECT_INFO_CHANGED = 0x0200,
- PACKET_ID_CA_EXE_HASHCHECK = 0x0204,
- PACKET_ID_CA_LOGIN_PCBANG = 0x0277,
- PACKET_ID_CA_LOGIN4 = 0x027c,
- PACKET_ID_CA_LOGIN_HAN = 0x02b0,
- PACKET_ID_CA_SSO_LOGIN_REQ = 0x0825,
- PACKET_ID_CA_LOGIN_OTP = 0x0acf,
- PACKET_ID_CA_REQ_HASH = 0x01db,
- PACKET_ID_CA_CHARSERVERCONNECT = 0x2710, // Custom Hercules Packet
- //PACKET_ID_CA_SSO_LOGIN_REQa = 0x825a, /* unused */
-
- // AC (Login to Client)
-
- PACKET_ID_AC_ACCEPT_LOGIN = 0x0069,
- PACKET_ID_AC_ACCEPT_LOGIN2 = 0x0ac4,
- PACKET_ID_AC_REFUSE_LOGIN = 0x006a,
- PACKET_ID_SC_NOTIFY_BAN = 0x0081,
- PACKET_ID_AC_ACK_HASH = 0x01dc,
- PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e,
- PACKET_ID_AC_REFUSE_LOGIN_R3 = 0x0b02,
-};
-
-/* Packets Structs */
-#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
-#pragma pack(push, 1)
-#endif // not NetBSD < 6 / Solaris
-
-/**
- * Packet structure for CA_LOGIN.
- */
-struct packet_CA_LOGIN {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- char password[24]; ///< Password
- uint8 clienttype; ///< Client Type
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN2.
- */
-struct packet_CA_LOGIN2 {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN2)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- uint8 password_md5[16]; ///< Password hash
- uint8 clienttype; ///< Client Type
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN3.
- */
-struct packet_CA_LOGIN3 {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN3)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- uint8 password_md5[16]; ///< Password hash
- uint8 clienttype; ///< Client Type
- uint8 clientinfo; ///< Index of the connection in the clientinfo file (+10 if the command-line contains "pc")
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN4.
- */
-struct packet_CA_LOGIN4 {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN4)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- uint8 password_md5[16]; ///< Password hash
- uint8 clienttype; ///< Client Type
- char mac_address[13]; ///< MAC Address
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN_PCBANG.
- */
-struct packet_CA_LOGIN_PCBANG {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN_PCBANG)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- char password[24]; ///< Password
- uint8 clienttype; ///< Client Type
- char ip[16]; ///< IP Address
- char mac_address[13]; ///< MAC Address
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN_HAN.
- */
-struct packet_CA_LOGIN_HAN {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN_HAN)
- uint32 version; ///< Client Version
- char id[24]; ///< Username
- char password[24]; ///< Password
- uint8 clienttype; ///< Client Type
- char ip[16]; ///< IP Address
- char mac_address[13]; ///< MAC Address
- uint8 is_han_game_user; ///< 'isGravityID'
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_SSO_LOGIN_REQ.
- *
- * Variable-length packet.
- */
-struct packet_CA_SSO_LOGIN_REQ {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_SSO_LOGIN_REQ)
- int16 packet_len; ///< Length (variable length)
- uint32 version; ///< Clientver
- uint8 clienttype; ///< Clienttype
- char id[24]; ///< Username
- char password[27]; ///< Password
- int8 mac_address[17]; ///< MAC Address
- char ip[15]; ///< IP Address
- char t1[]; ///< SSO Login Token (variable length)
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_LOGIN_OTP.
- */
-struct packet_CA_LOGIN_OTP {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_LOGIN_OTP)
-#if PACKETVER >= 20171113
- uint32 devFlags; ///< flags including dev flag
#endif
- char login[25]; ///< Username
- char password[32]; ///< Password encrypted by rijndael
- char flagsStr[5]; ///< Unknown flags. Normally string: G000
-} __attribute__((packed));
-
-#if 0 // Unused
-struct packet_CA_SSO_LOGIN_REQa {
- int16 packet_id;
- int16 packet_len;
- uint32 version;
- uint8 clienttype;
- char id[24];
- int8 mac_address[17];
- char ip[15];
- char t1[];
-} __attribute__((packed));
-#endif // unused
-
-/**
- * Packet structure for CA_CONNECT_INFO_CHANGED.
- *
- * New alive packet. Used to verify if client is always alive.
- */
-struct packet_CA_CONNECT_INFO_CHANGED {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_CONNECT_INFO_CHANGED)
- char id[24]; ///< account.userid
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_EXE_HASHCHECK.
- *
- * (kRO 2004-05-31aSakexe langtype 0 and 6)
- */
-struct packet_CA_EXE_HASHCHECK {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_EXE_HASHCHECK)
- uint8 hash_value[16]; ///< Client MD5 hash
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_REQ_HASH.
- */
-struct packet_CA_REQ_HASH {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_REQ_HASH)
-} __attribute__((packed));
-
-/**
- * Packet structure for CA_CHARSERVERCONNECT.
- *
- * This packet is used internally, to signal a char-server connection.
- */
-struct packet_CA_CHARSERVERCONNECT {
- int16 packet_id; ///< Packet ID (#PACKET_ID_CA_CHARSERVERCONNECT)
- char userid[24]; ///< Username
- char password[24]; ///< Password
- int32 unknown;
- int32 ip; ///< Charserver IP
- int16 port; ///< Charserver port
- char name[20]; ///< Charserver name
- int16 unknown2;
- int16 type; ///< Charserver type
- int16 new; ///< Whether charserver is to be marked as new
-} __attribute__((packed));
-
-/**
- * Packet structure for SC_NOTIFY_BAN.
- */
-struct packet_SC_NOTIFY_BAN {
- int16 packet_id; ///< Packet ID (#PACKET_ID_SC_NOTIFY_BAN)
- uint8 error_code; ///< Error code
-} __attribute__((packed));
-
-/**
- * Packet structure for AC_REFUSE_LOGIN.
- */
-struct packet_AC_REFUSE_LOGIN {
- int16 packet_id; ///< Packet ID (#PACKET_ID_AC_REFUSE_LOGIN)
- uint8 error_code; ///< Error code
- char block_date[20]; ///< Ban expiration date
-} __attribute__((packed));
-
-/**
- * Packet structure for AC_REFUSE_LOGIN_R2.
- */
-struct packet_AC_REFUSE_LOGIN_R2 {
- int16 packet_id; ///< Packet ID (#PACKET_ID_AC_REFUSE_LOGIN_R2)
- uint32 error_code; ///< Error code
- char block_date[20]; ///< Ban expiration date
-} __attribute__((packed));
-
-/**
- * Packet structure for AC_ACCEPT_LOGIN.
- *
- * Variable-length packet.
- */
-struct packet_AC_ACCEPT_LOGIN {
- int16 packet_id; ///< Packet ID (#PACKET_ID_AC_ACCEPT_LOGIN)
- int16 packet_len; ///< Packet length (variable length)
- int32 auth_code; ///< Authentication code
- uint32 aid; ///< Account ID
- uint32 user_level; ///< User level
- uint32 last_login_ip; ///< Last login IP
- char last_login_time[26]; ///< Last login timestamp
- uint8 sex; ///< Account sex
-#if PACKETVER >= 20170315
- char twitter_auth_token[16];
- uint8 twitter_flag;
+#ifndef MAX_PACKET_LOGIN_DB
+#define MAX_PACKET_LOGIN_DB 0x0ad0
#endif
- struct {
- uint32 ip; ///< Server IP address
- int16 port; ///< Server port
- char name[20]; ///< Server name
- uint16 usercount; ///< Online users
- uint16 state; ///< Server state
- uint16 property; ///< Server property
-#if PACKETVER >= 20170315
- char unknown2[128];
-#endif
- } server_list[]; ///< List of charservers
-} __attribute__((packed));
-
-/**
- * Packet structure for AC_ACK_HASH.
- *
- * Variable-length packet
- */
-struct packet_AC_ACK_HASH {
- int16 packet_id; ///< Packet ID (#PACKET_ID_AC_ACK_HASH)
- int16 packet_len; ///< Packet length (variable length)
- uint8 secret[]; ///< Challenge string
-} __attribute__((packed));
-
-#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
-#pragma pack(pop)
-#endif // not NetBSD < 6 / Solaris
/**
* Login Client Interface additional data
@@ -332,18 +70,20 @@ struct lclif_interface_private {
*/
enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd);
- LoginParseFunc *parse_CA_CONNECT_INFO_CHANGED; ///< Packet handler for #packet_CA_CONNECT_INFO_CHANGED.
- LoginParseFunc *parse_CA_EXE_HASHCHECK; ///< Packet handler for #packet_CA_EXE_HASHCHECK.
- LoginParseFunc *parse_CA_LOGIN; ///< Packet handler for #packet_CA_LOGIN.
- LoginParseFunc *parse_CA_LOGIN2; ///< Packet handler for #packet_CA_LOGIN2.
- LoginParseFunc *parse_CA_LOGIN3; ///< Packet handler for #packet_CA_LOGIN3.
- LoginParseFunc *parse_CA_LOGIN4; ///< Packet handler for #packet_CA_LOGIN4.
- LoginParseFunc *parse_CA_LOGIN_PCBANG; ///< Packet handler for #packet_CA_LOGIN_PCBANG.
- LoginParseFunc *parse_CA_LOGIN_HAN; ///< Packet handler for #packet_CA_LOGIN_HAN.
- LoginParseFunc *parse_CA_SSO_LOGIN_REQ; ///< Packet handler for #packet_CA_SSO_LOGIN_REQ.
- LoginParseFunc *parse_CA_LOGIN_OTP; ///< Packet handler for #packet_CA_LOGIN_OTP.
- LoginParseFunc *parse_CA_REQ_HASH; ///< Packet handler for #packet_CA_REQ_HASH.
- LoginParseFunc *parse_CA_CHARSERVERCONNECT; ///< Packet handler for #packet_CA_CHARSERVERCONNECT.
+ LoginParseFunc *parse_CA_CONNECT_INFO_CHANGED; ///< Packet handler for #PACKET_CA_CONNECT_INFO_CHANGED.
+ LoginParseFunc *parse_CA_EXE_HASHCHECK; ///< Packet handler for #PACKET_CA_EXE_HASHCHECK.
+ LoginParseFunc *parse_CA_LOGIN; ///< Packet handler for #PACKET_CA_LOGIN.
+ LoginParseFunc *parse_CA_LOGIN2; ///< Packet handler for #PACKET_CA_LOGIN2.
+ LoginParseFunc *parse_CA_LOGIN3; ///< Packet handler for #PACKET_CA_LOGIN3.
+ LoginParseFunc *parse_CA_LOGIN4; ///< Packet handler for #PACKET_CA_LOGIN4.
+ LoginParseFunc *parse_CA_LOGIN_PCBANG; ///< Packet handler for #PACKET_CA_LOGIN_PCBANG.
+ LoginParseFunc *parse_CA_LOGIN_HAN; ///< Packet handler for #PACKET_CA_LOGIN_HAN.
+ LoginParseFunc *parse_CA_SSO_LOGIN_REQ; ///< Packet handler for #PACKET_CA_SSO_LOGIN_REQ.
+ LoginParseFunc *parse_CA_LOGIN_OTP; ///< Packet handler for #PACKET_CA_LOGIN_OTP.
+ LoginParseFunc *parse_CA_ACK_MOBILE_OTP; ///< Packet handler for #PACKET_CA_ACK_MOBILE_OTP.
+ LoginParseFunc *parse_CA_OTP_CODE; ///< Packet handler for #PACKET_CA_OTP_CODE.
+ LoginParseFunc *parse_CA_REQ_HASH; ///< Packet handler for #PACKET_CA_REQ_HASH.
+ LoginParseFunc *parse_CA_CHARSERVERCONNECT; ///< Packet handler for #PACKET_CA_CHARSERVERCONNECT.
};
#endif // LOGIN_LCLIF_P_H
diff --git a/src/login/login.c b/src/login/login.c
index c1844cb25..4c40677fa 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -27,6 +27,7 @@
#include "login/ipban.h"
#include "login/loginlog.h"
#include "login/lclif.h"
+#include "login/packets_ac_struct.h"
#include "common/HPM.h"
#include "common/cbasetypes.h"
#include "common/conf.h"
@@ -35,6 +36,7 @@
#include "common/memmgr.h"
#include "common/md5calc.h"
#include "common/nullpo.h"
+#include "common/packetsstatic_len.h"
#include "common/random.h"
#include "common/showmsg.h"
#include "common/socket.h"
@@ -1368,36 +1370,37 @@ static bool login_client_login(int fd, struct login_session_data *sd)
static bool login_client_login_otp(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
static bool login_client_login_otp(int fd, struct login_session_data *sd)
{
+#if PACKETVER_MAIN_NUM >= 20170621 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO)
// send ok response with fake token
-#ifdef PACKETVER_ZERO
-#if PACKETVER >= 20171127
- WFIFOHEAD(fd, 33);
- WFIFOW(fd, 0) = 0x0ae3;
- WFIFOW(fd, 2) = 33; // len
- WFIFOL(fd, 4) = 0; // normal login
- safestrncpy(WFIFOP(fd, 8), "S1000", 6);
- safestrncpy(WFIFOP(fd, 28), "token", 6);
- WFIFOSET(fd, 33);
-#elif PACKETVER >= 20171123
- WFIFOHEAD(fd, 19);
- WFIFOW(fd, 0) = 0x0ae3;
- WFIFOW(fd, 2) = 19; // len
- WFIFOL(fd, 4) = 0; // normal login
- safestrncpy(WFIFOP(fd, 8), "S1000", 6);
- safestrncpy(WFIFOP(fd, 14), "token", 6);
- WFIFOSET(fd, 19);
-#else
- WFIFOHEAD(fd, 13);
- WFIFOW(fd, 0) = 0x0ad1;
- WFIFOW(fd, 2) = 13; // len
- WFIFOL(fd, 4) = 0; // normal login
- safestrncpy(WFIFOP(fd, 8), "token", 6);
- WFIFOSET(fd, 13);
-#endif
+ const int len = sizeof(struct PACKET_AC_LOGIN_OTP) + 6; // + "token" string
+ WFIFOHEAD(fd, len);
+ struct PACKET_AC_LOGIN_OTP *packet = WP2PTR(sd->fd);
+ memset(packet, 0, len);
+ packet->packet_id = HEADER_AC_LOGIN_OTP;
+ packet->packet_len = len;
+ packet->loginFlag = 0; // normal login
+#if PACKETVER_MAIN_NUM >= 20171213 || PACKETVER_RE_NUM >= 20171213 || PACKETVER_ZERO_NUM >= 20171123
+ safestrncpy(packet->loginFlag2, "S1000", 6);
+#endif // PACKETVER_MAIN_NUM >= 20171213 || PACKETVER_RE_NUM >= 20171213 || PACKETVER_ZERO_NUM >= 20171123
+
+ safestrncpy(packet->token, "token", 6);
+ WFIFOSET(fd, len);
return true;
-#else // PACKETVER_ZERO
+#else // PACKETVER_MAIN_NUM >= 20170621 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO)
return false;
-#endif // PACKETVER_ZERO
+#endif // PACKETVER_MAIN_NUM >= 20170621 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO)
+}
+
+static void login_client_login_mobile_otp_request(int fd, struct login_session_data *sd) __attribute__((nonnull (2)));
+static void login_client_login_mobile_otp_request(int fd, struct login_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114 || defined(PACKETVER_ZERO)
+ WFIFOHEAD(sd->fd, sizeof(struct PACKET_AC_REQ_MOBILE_OTP));
+ struct PACKET_AC_REQ_MOBILE_OTP *packet = WP2PTR(sd->fd);
+ packet->packet_id = HEADER_AC_REQ_MOBILE_OTP;
+ packet->aid = sd->account_id;
+ WFIFOSET(fd, sizeof(struct PACKET_AC_REQ_MOBILE_OTP));
+#endif
}
static void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2)));
@@ -2275,6 +2278,7 @@ void login_defaults(void)
login->parse_fromchar = login_parse_fromchar;
login->client_login = login_client_login;
login->client_login_otp = login_client_login_otp;
+ login->client_login_mobile_otp_request = login_client_login_mobile_otp_request;
login->parse_request_connection = login_parse_request_connection;
login->auth_ok = login_auth_ok;
login->auth_failed = login_auth_failed;
diff --git a/src/login/login.h b/src/login/login.h
index 8a863f5aa..7f74057c6 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -219,6 +219,7 @@ struct login_interface {
void (*auth_failed) (struct login_session_data* sd, int result);
bool (*client_login) (int fd, struct login_session_data *sd);
bool (*client_login_otp) (int fd, struct login_session_data *sd);
+ void (*client_login_mobile_otp_request) (int fd, struct login_session_data *sd);
void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status);
void (*parse_request_connection) (int fd, struct login_session_data* sd, const char *ip, uint32 ipl);
void (*config_set_defaults) (void);
diff --git a/src/login/packets_ac_struct.h b/src/login/packets_ac_struct.h
new file mode 100644
index 000000000..c9fb04f26
--- /dev/null
+++ b/src/login/packets_ac_struct.h
@@ -0,0 +1,156 @@
+/**
+ * This file is part of Hercules.
+ * http://herc.ws - http://github.com/HerculesWS/Hercules
+ *
+ * Copyright (C) 2016-2018 Hercules Dev Team
+ *
+ * Hercules 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 3 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 <http://www.gnu.org/licenses/>.
+ */
+#ifndef LOGIN_PACKETS_AC_STRUCT_H
+#define LOGIN_PACKETS_AC_STRUCT_H
+
+#include "common/hercules.h"
+#include "common/mmo.h"
+#include "common/packetsstatic_len.h"
+
+/* Enums */
+
+/// Packet IDs
+enum login_ac_packet_id {
+ HEADER_AC_ACCEPT_LOGIN = 0x0069,
+ HEADER_AC_ACCEPT_LOGIN2 = 0x0ac4,
+ HEADER_AC_REFUSE_LOGIN = 0x006a,
+ HEADER_SC_NOTIFY_BAN = 0x0081,
+ HEADER_AC_ACK_HASH = 0x01dc,
+ HEADER_AC_REFUSE_LOGIN_R2 = 0x083e,
+ HEADER_AC_REFUSE_LOGIN_R3 = 0x0b02,
+};
+
+/* Packets Structs */
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(push, 1)
+#endif // not NetBSD < 6 / Solaris
+
+/**
+ * Packet structure for SC_NOTIFY_BAN.
+ */
+struct PACKET_SC_NOTIFY_BAN {
+ int16 packet_id; ///< Packet ID (#HEADER_SC_NOTIFY_BAN)
+ uint8 error_code; ///< Error code
+} __attribute__((packed));
+
+/**
+ * Packet structure for AC_REFUSE_LOGIN.
+ */
+struct PACKET_AC_REFUSE_LOGIN {
+ int16 packet_id; ///< Packet ID (#HEADER_AC_REFUSE_LOGIN)
+ uint8 error_code; ///< Error code
+ char block_date[20]; ///< Ban expiration date
+} __attribute__((packed));
+
+/**
+ * Packet structure for AC_REFUSE_LOGIN_R2.
+ */
+struct PACKET_AC_REFUSE_LOGIN_R2 {
+ int16 packet_id; ///< Packet ID (#HEADER_AC_REFUSE_LOGIN_R2)
+ uint32 error_code; ///< Error code
+ char block_date[20]; ///< Ban expiration date
+} __attribute__((packed));
+
+/**
+ * Packet structure for AC_ACCEPT_LOGIN.
+ *
+ * Variable-length packet.
+ */
+struct PACKET_AC_ACCEPT_LOGIN {
+ int16 packet_id; ///< Packet ID (#HEADER_AC_ACCEPT_LOGIN)
+ int16 packet_len; ///< Packet length (variable length)
+ int32 auth_code; ///< Authentication code
+ uint32 aid; ///< Account ID
+ uint32 user_level; ///< User level
+ uint32 last_login_ip; ///< Last login IP
+ char last_login_time[26]; ///< Last login timestamp
+ uint8 sex; ///< Account sex
+#if PACKETVER >= 20170315
+ char twitter_auth_token[16];
+ uint8 twitter_flag;
+#endif
+ struct {
+ uint32 ip; ///< Server IP address
+ int16 port; ///< Server port
+ char name[20]; ///< Server name
+ uint16 usercount; ///< Online users
+ uint16 state; ///< Server state
+ uint16 property; ///< Server property
+#if PACKETVER >= 20170315
+ char unknown2[128];
+#endif
+ } server_list[]; ///< List of charservers
+} __attribute__((packed));
+
+/**
+ * Packet structure for AC_ACK_HASH.
+ *
+ * Variable-length packet
+ */
+struct PACKET_AC_ACK_HASH {
+ int16 packet_id; ///< Packet ID (#HEADER_AC_ACK_HASH)
+ int16 packet_len; ///< Packet length (variable length)
+ uint8 secret[]; ///< Challenge string
+} __attribute__((packed));
+
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114 || defined(PACKETVER_ZERO)
+struct PACKET_AC_REQ_MOBILE_OTP {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_SSO_LOGIN_REQ)
+ uint32 aid; ///< Account ID
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(AC_REQ_MOBILE_OTP, 0x09a2);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20171213 || PACKETVER_RE_NUM >= 20171213 || PACKETVER_ZERO_NUM >= 20171808
+// AC_LOGIN_OTP2
+struct PACKET_AC_LOGIN_OTP {
+ int16 packet_id;
+ int16 packet_len;
+ int32 loginFlag;
+ char loginFlag2[20];
+ char token[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(AC_LOGIN_OTP, 0x0ae3);
+#elif PACKETVER_ZERO_NUM >= 20171123
+// AC_LOGIN_OTP2
+struct PACKET_AC_LOGIN_OTP {
+ int16 packet_id;
+ int16 packet_len;
+ int32 loginFlag;
+ char loginFlag2[6];
+ char token[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(AC_LOGIN_OTP, 0x0ae3);
+#elif PACKETVER_MAIN_NUM >= 20170621 || PACKETVER_RE_NUM >= 20170621 || defined(PACKETVER_ZERO)
+// AC_LOGIN_OTP1
+struct PACKET_AC_LOGIN_OTP {
+ int16 packet_id;
+ int16 packet_len;
+ int32 loginFlag;
+ char token[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(AC_LOGIN_OTP, 0x0ad1);
+#endif
+
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(pop)
+#endif // not NetBSD < 6 / Solaris
+
+#endif // LOGIN_PACKETS_AC_STRUCT_H
diff --git a/src/login/packets_ca_struct.h b/src/login/packets_ca_struct.h
new file mode 100644
index 000000000..0828c7293
--- /dev/null
+++ b/src/login/packets_ca_struct.h
@@ -0,0 +1,239 @@
+/**
+ * This file is part of Hercules.
+ * http://herc.ws - http://github.com/HerculesWS/Hercules
+ *
+ * Copyright (C) 2016-2018 Hercules Dev Team
+ *
+ * Hercules 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 3 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 <http://www.gnu.org/licenses/>.
+ */
+#ifndef LOGIN_PACKETS_CA_STRUCT_H
+#define LOGIN_PACKETS_CA_STRUCT_H
+
+#include "common/hercules.h"
+#include "common/mmo.h"
+#include "common/packetsstatic_len.h"
+
+/* Enums */
+
+/// Packet IDs
+enum login_packet_ca_id {
+ HEADER_CA_LOGIN = 0x0064,
+ HEADER_CA_LOGIN2 = 0x01dd,
+ HEADER_CA_LOGIN3 = 0x01fa,
+ HEADER_CA_CONNECT_INFO_CHANGED = 0x0200,
+ HEADER_CA_EXE_HASHCHECK = 0x0204,
+ HEADER_CA_LOGIN_PCBANG = 0x0277,
+ HEADER_CA_LOGIN4 = 0x027c,
+ HEADER_CA_LOGIN_HAN = 0x02b0,
+ HEADER_CA_SSO_LOGIN_REQ = 0x0825,
+ HEADER_CA_LOGIN_OTP = 0x0acf,
+ HEADER_CA_REQ_HASH = 0x01db,
+ HEADER_CA_CHARSERVERCONNECT = 0x2710, // Custom Hercules Packet
+ //HEADER_CA_SSO_LOGIN_REQa = 0x825a, /* unused */
+};
+
+/* Packets Structs */
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(push, 1)
+#endif // not NetBSD < 6 / Solaris
+
+/**
+ * Packet structure for CA_LOGIN.
+ */
+struct PACKET_CA_LOGIN {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ char password[24]; ///< Password
+ uint8 clienttype; ///< Client Type
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_LOGIN2.
+ */
+struct PACKET_CA_LOGIN2 {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN2)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ uint8 password_md5[16]; ///< Password hash
+ uint8 clienttype; ///< Client Type
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_LOGIN3.
+ */
+struct PACKET_CA_LOGIN3 {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN3)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ uint8 password_md5[16]; ///< Password hash
+ uint8 clienttype; ///< Client Type
+ uint8 clientinfo; ///< Index of the connection in the clientinfo file (+10 if the command-line contains "pc")
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_LOGIN4.
+ */
+struct PACKET_CA_LOGIN4 {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN4)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ uint8 password_md5[16]; ///< Password hash
+ uint8 clienttype; ///< Client Type
+ char mac_address[13]; ///< MAC Address
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_LOGIN_PCBANG.
+ */
+struct PACKET_CA_LOGIN_PCBANG {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN_PCBANG)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ char password[24]; ///< Password
+ uint8 clienttype; ///< Client Type
+ char ip[16]; ///< IP Address
+ char mac_address[13]; ///< MAC Address
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_LOGIN_HAN.
+ */
+struct PACKET_CA_LOGIN_HAN {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN_HAN)
+ uint32 version; ///< Client Version
+ char id[24]; ///< Username
+ char password[24]; ///< Password
+ uint8 clienttype; ///< Client Type
+ char ip[16]; ///< IP Address
+ char mac_address[13]; ///< MAC Address
+ uint8 is_han_game_user; ///< 'isGravityID'
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_SSO_LOGIN_REQ.
+ *
+ * Variable-length packet.
+ */
+struct PACKET_CA_SSO_LOGIN_REQ {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_SSO_LOGIN_REQ)
+ int16 packet_len; ///< Length (variable length)
+ uint32 version; ///< Clientver
+ uint8 clienttype; ///< Clienttype
+ char id[24]; ///< Username
+ char password[27]; ///< Password
+ int8 mac_address[17]; ///< MAC Address
+ char ip[15]; ///< IP Address
+ char t1[]; ///< SSO Login Token (variable length)
+} __attribute__((packed));
+
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114
+/**
+ * Packet structure for CA_SSO_LOGIN_REQ.
+ *
+ * Variable-length packet.
+ */
+struct PACKET_CA_ACK_MOBILE_OTP {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_ACK_MOBILE_OTP)
+ int16 packet_len; ///< Length (variable length)
+ uint32 aid; ///< Account ID
+ char code[6]; ///< Code
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CA_ACK_MOBILE_OTP, 0x09a3);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20181114 || PACKETVER_RE_NUM >= 20181114 || defined(PACKETVER_ZERO)
+struct PACKET_CA_OTP_CODE {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_OTP_CODE)
+ char code[9]; ///< Code
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CA_OTP_CODE, 0x0ad0);
+#endif
+
+/**
+ * Packet structure for CA_LOGIN_OTP.
+ */
+struct PACKET_CA_LOGIN_OTP {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_LOGIN_OTP)
+#if PACKETVER >= 20171113
+ uint32 devFlags; ///< flags including dev flag
+#endif
+ char login[25]; ///< Username
+ char password[32]; ///< Password encrypted by rijndael
+ char flagsStr[5]; ///< Unknown flags. Normally string: G000
+} __attribute__((packed));
+
+#if 0 // Unused
+struct PACKET_CA_SSO_LOGIN_REQa {
+ int16 packet_id;
+ int16 packet_len;
+ uint32 version;
+ uint8 clienttype;
+ char id[24];
+ int8 mac_address[17];
+ char ip[15];
+ char t1[];
+} __attribute__((packed));
+#endif // unused
+
+/**
+ * Packet structure for CA_CONNECT_INFO_CHANGED.
+ *
+ * New alive packet. Used to verify if client is always alive.
+ */
+struct PACKET_CA_CONNECT_INFO_CHANGED {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_CONNECT_INFO_CHANGED)
+ char id[24]; ///< account.userid
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_EXE_HASHCHECK.
+ *
+ * (kRO 2004-05-31aSakexe langtype 0 and 6)
+ */
+struct PACKET_CA_EXE_HASHCHECK {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_EXE_HASHCHECK)
+ uint8 hash_value[16]; ///< Client MD5 hash
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_REQ_HASH.
+ */
+struct PACKET_CA_REQ_HASH {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_REQ_HASH)
+} __attribute__((packed));
+
+/**
+ * Packet structure for CA_CHARSERVERCONNECT.
+ *
+ * This packet is used internally, to signal a char-server connection.
+ */
+struct PACKET_CA_CHARSERVERCONNECT {
+ int16 packet_id; ///< Packet ID (#HEADER_CA_CHARSERVERCONNECT)
+ char userid[24]; ///< Username
+ char password[24]; ///< Password
+ int32 unknown;
+ int32 ip; ///< Charserver IP
+ int16 port; ///< Charserver port
+ char name[20]; ///< Charserver name
+ int16 unknown2;
+ int16 type; ///< Charserver type
+ int16 new; ///< Whether charserver is to be marked as new
+} __attribute__((packed));
+
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(pop)
+#endif // not NetBSD < 6 / Solaris
+
+#endif // LOGIN_PACKETS_CA_STRUCT_H