summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-14 14:03:06 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-01-14 14:03:06 +0000
commit0e882b69855dab5ae0c50e52b3db8316c6054751 (patch)
tree81020725036353cacc2534c3dbd95535fc5b98e5 /src
parent6b405aa702e726f1eadcc3657c2da12f112afe0d (diff)
downloadhercules-0e882b69855dab5ae0c50e52b3db8316c6054751.tar.gz
hercules-0e882b69855dab5ae0c50e52b3db8316c6054751.tar.bz2
hercules-0e882b69855dab5ae0c50e52b3db8316c6054751.tar.xz
hercules-0e882b69855dab5ae0c50e52b3db8316c6054751.zip
* Added client login packets 0x01fa and 0x027c.
* Other minor cleanups. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13449 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/common/cbasetypes.h8
-rw-r--r--src/common/mmo.h6
-rw-r--r--src/login/admin.c2
-rw-r--r--src/login/login.c57
-rw-r--r--src/login/login.h12
5 files changed, 61 insertions, 24 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index f94e9c6e7..1890a0901 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -199,9 +199,17 @@ typedef unsigned long long uint64;
#ifdef __64BIT__
typedef uint64 uintptr;
typedef int64 intptr;
+#define UINTPTR_MIN UINT64_MIN
+#define UINTPTR_MAX UINT64_MAX
+#define INTPTR_MIN INT64_MIN;
+#define INTPTR_MAX INT64_MAX;
#else
typedef uint32 uintptr;
typedef int32 intptr;
+#define UINTPTR_MIN UINT32_MIN
+#define UINTPTR_MAX UINT32_MAX
+#define INTPTR_MIN INT32_MIN;
+#define INTPTR_MAX INT32_MAX;
#endif
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 2bd88c636..e138244bd 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -594,6 +594,12 @@ enum {
JOB_MAX,
};
+enum {
+ SEX_FEMALE = 0,
+ SEX_MALE,
+ SEX_SERVER
+};
+
// sanity checks...
#if MAX_ZENY > INT_MAX
#error MAX_ZENY is too big
diff --git a/src/login/admin.c b/src/login/admin.c
index 0387fd82d..d5175dca5 100644
--- a/src/login/admin.c
+++ b/src/login/admin.c
@@ -21,8 +21,6 @@
#include <string.h>
#include <sys/stat.h> // for stat/lstat/fstat
-#define MAX_SERVERS 30
-extern struct mmo_char_server server[MAX_SERVERS];
extern AccountDB* accounts;
int charif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
diff --git a/src/login/login.c b/src/login/login.c
index c92c8a970..4973ae7b9 100644
--- a/src/login/login.c
+++ b/src/login/login.c
@@ -23,12 +23,8 @@ bool ladmin_auth(struct login_session_data* sd, const char* ip);
struct Login_Config login_config;
int login_fd; // login server socket
-#define MAX_SERVERS 30
struct mmo_char_server server[MAX_SERVERS]; // char server data
-#define sex_num2str(num) ( (num == 0 ) ? 'F' : (num == 1 ) ? 'M' : 'S' )
-#define sex_str2num(str) ( (str == 'F' ) ? 0 : (str == 'M' ) ? 1 : 2 )
-
// Account engines available
static struct{
AccountDB* (*constructor)(void);
@@ -1130,6 +1126,7 @@ void login_auth_ok(struct login_session_data* sd)
WFIFOL(fd,12) = sd->login_id2;
WFIFOL(fd,16) = 0; // in old version, that was for ip (not more used)
//memcpy(WFIFOP(fd,20), sd->lastlogin, 24); // in old version, that was for name (not more used)
+ memset(WFIFOP(fd,20), 0, 24);
WFIFOW(fd,44) = 0; // unknown
WFIFOB(fd,46) = sex_str2num(sd->sex);
for( i = 0, n = 0; i < MAX_SERVERS; ++i )
@@ -1284,32 +1281,54 @@ int parse_login(int fd)
RFIFOSKIP(fd,18);
break;
- // request client login
- case 0x0064: // S 0064 <version>.l <username>.24B <password>.24B <version2>.B
- case 0x01dd: // S 01dd <version>.l <username>.24B <md5 hash>.16B <version2>.B
- case 0x0277: // S 0277 <version>.l <username>.24B <password>.24B <junk?>.29B <version2>.B (kRO 2006-04-24aSakexe langtype 0)
- case 0x02b0: // S 02b0 <version>.l <username>.24B <password>.24B <???>.B <ip address>.16S <mac address>.13S <version2>.B (kRO 2007-05-14aSakexe langtype 0)
+ // request client login (raw password)
+ case 0x0064: // S 0064 <version>.L <username>.24B <password>.24B <clienttype>.B
+ case 0x0277: // S 0277 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B
+ case 0x02b0: // S 02b0 <version>.L <username>.24B <password>.24B <clienttype>.B <ip address>.16B <adapter address>.13B <g_isGravityID>.B
+ // request client login (md5-hashed password)
+ case 0x01dd: // S 01dd <version>.L <username>.24B <password hash>.16B <clienttype>.B
+ case 0x01fa: // S 01fa <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.B(index of the connection in the clientinfo file (+10 if the command-line contains "pc"))
+ case 0x027c: // S 027c <version>.L <username>.24B <password hash>.16B <clienttype>.B <?>.13B(junk)
{
size_t packet_len = RFIFOREST(fd);
if( (command == 0x0064 && packet_len < 55)
- || (command == 0x01dd && packet_len < 47)
|| (command == 0x0277 && packet_len < 84)
- || (command == 0x02b0 && packet_len < 85) )
- return 0;
+ || (command == 0x02b0 && packet_len < 85)
+ || (command == 0x01dd && packet_len < 47)
+ || (command == 0x01fa && packet_len < 48)
+ || (command == 0x027c && packet_len < 60) )
+ return 0;
}
{
- int version = RFIFOL(fd,2);
- char* userid = (char*)RFIFOP(fd,6);
- char* passwd = (char*)RFIFOP(fd,30);
+ uint32 version;
+ char username[NAME_LENGTH];
+ char password[NAME_LENGTH];
+ unsigned char passhash[16];
+ uint8 clienttype;
+ bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0);
+
+ version = RFIFOL(fd,2);
+ safestrncpy(username, (const char*)RFIFOP(fd,6), NAME_LENGTH);
+ if( israwpass )
+ {
+ safestrncpy(password, (const char*)RFIFOP(fd,30), NAME_LENGTH);
+ clienttype = RFIFOB(fd,54);
+ }
+ else
+ {
+ memcpy(passhash, RFIFOP(fd,30), 16);
+ clienttype = RFIFOB(fd,46);
+ }
RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent
+ sd->clienttype = clienttype;
sd->version = version;
- safestrncpy(sd->userid, userid, NAME_LENGTH);
- if( command != 0x01dd )
+ safestrncpy(sd->userid, username, NAME_LENGTH);
+ if( israwpass )
{
ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip);
- safestrncpy(sd->passwd, passwd, NAME_LENGTH);
+ safestrncpy(sd->passwd, password, NAME_LENGTH);
if( login_config.use_md5_passwds )
MD5_String(sd->passwd, sd->passwd);
sd->passwdenc = 0;
@@ -1317,7 +1336,7 @@ int parse_login(int fd)
else
{
ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip);
- bin2hex(sd->passwd, (unsigned char*)passwd, 16); // raw binary data here!
+ bin2hex(sd->passwd, passhash, 16); // raw binary data here!
sd->passwdenc = PASSWORDENC;
}
diff --git a/src/login/login.h b/src/login/login.h
index d9d37c344..d2191fc2c 100644
--- a/src/login/login.h
+++ b/src/login/login.h
@@ -4,7 +4,7 @@
#ifndef _LOGIN_H_
#define _LOGIN_H_
-#include "../common/mmo.h" // NAME_LENGTH
+#include "../common/mmo.h" // NAME_LENGTH,SEX_*
#define LOGIN_CONF_NAME "conf/login_athena.conf"
#define LAN_CONF_NAME "conf/subnet_athena.conf"
@@ -17,7 +17,7 @@ struct login_session_data {
int account_id;
long login_id1;
long login_id2;
- char sex;
+ char sex;// 'F','M','S'
char userid[NAME_LENGTH];
char passwd[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords
@@ -27,7 +27,8 @@ struct login_session_data {
char lastlogin[24];
uint8 level;
- int version;
+ uint8 clienttype;
+ uint32 version;
int fd;
};
@@ -74,6 +75,11 @@ struct Login_Config {
char account_engine[256]; // name of the engine to use (defaults to auto, for the first available engine)
};
+#define sex_num2str(num) ( (num == SEX_FEMALE ) ? 'F' : (num == SEX_MALE ) ? 'M' : 'S' )
+#define sex_str2num(str) ( (str == 'F' ) ? SEX_FEMALE : (str == 'M' ) ? SEX_MALE : SEX_SERVER )
+
+#define MAX_SERVERS 30
+extern struct mmo_char_server server[MAX_SERVERS];
extern struct Login_Config login_config;