From 0e882b69855dab5ae0c50e52b3db8316c6054751 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 14 Jan 2009 14:03:06 +0000 Subject: * 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 --- Changelog-Trunk.txt | 3 +++ src/common/cbasetypes.h | 8 +++++++ src/common/mmo.h | 6 ++++++ src/login/admin.c | 2 -- src/login/login.c | 57 ++++++++++++++++++++++++++++++++----------------- src/login/login.h | 12 ++++++++--- 6 files changed, 64 insertions(+), 24 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4b2338e26..357dac03c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,9 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2009/01/14 + * Added client login packets 0x01fa and 0x027c. [FlavioJS] + * Other minor cleanups. 2009/01/13 * Cleaned up command @users/#users: [FlavioJS] - displays everything on the target user (self for @users) 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 #include // 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 .l .24B .24B .B - case 0x01dd: // S 01dd .l .24B .16B .B - case 0x0277: // S 0277 .l .24B .24B .29B .B (kRO 2006-04-24aSakexe langtype 0) - case 0x02b0: // S 02b0 .l .24B .24B .B .16S .13S .B (kRO 2007-05-14aSakexe langtype 0) + // request client login (raw password) + case 0x0064: // S 0064 .L .24B .24B .B + case 0x0277: // S 0277 .L .24B .24B .B .16B .13B + case 0x02b0: // S 02b0 .L .24B .24B .B .16B .13B .B + // request client login (md5-hashed password) + case 0x01dd: // S 01dd .L .24B .16B .B + case 0x01fa: // S 01fa .L .24B .16B .B .B(index of the connection in the clientinfo file (+10 if the command-line contains "pc")) + case 0x027c: // S 027c .L .24B .16B .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; -- cgit v1.2.3-60-g2f50