summaryrefslogtreecommitdiff
path: root/src/login/packets_ac_struct.h
blob: c9fb04f26cd7fb5011e3a1b845508615efbfaa29 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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