summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/packetsstatic_len.h3
-rw-r--r--src/login/login.c43
-rw-r--r--src/login/packets_ac_struct.h31
3 files changed, 50 insertions, 27 deletions
diff --git a/src/common/packetsstatic_len.h b/src/common/packetsstatic_len.h
index 31a3988e8..730516c27 100644
--- a/src/common/packetsstatic_len.h
+++ b/src/common/packetsstatic_len.h
@@ -29,6 +29,9 @@
(size_t)PACKET_LEN_##id, "Wrong size PACKET_"#name); \
enum { HEADER_##name = id };
+#define DEFINE_PACKET_ID(name, id) \
+ enum { HEADER_##name = id };
+
#define packetLen(id, len) PACKET_LEN_##id = (len),
enum packet_lengths {
#include "common/packets_len.h"
diff --git a/src/login/login.c b/src/login/login.c
index 67abd45af..4c40677fa 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -1370,36 +1370,25 @@ 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)));
diff --git a/src/login/packets_ac_struct.h b/src/login/packets_ac_struct.h
index 6ec92b38f..c9fb04f26 100644
--- a/src/login/packets_ac_struct.h
+++ b/src/login/packets_ac_struct.h
@@ -118,6 +118,37 @@ struct PACKET_AC_REQ_MOBILE_OTP {
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