From c0178d2595e3c0ae2655b9ce2bd5e1ec46d81552 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 31 Mar 2016 00:16:02 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- .../HPMHooking/HPMHooking_char.HookingPoints.inc | 66 ++++++------ src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 66 ++++++------ .../HPMHooking/HPMHooking_login.HookingPoints.inc | 34 +++--- src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 34 +++--- .../HPMHooking/HPMHooking_map.HookingPoints.inc | 116 ++++++++++----------- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 116 ++++++++++----------- 6 files changed, 216 insertions(+), 216 deletions(-) (limited to 'src') diff --git a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc index fbf332ffb..ab273a852 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.HookingPoints.inc @@ -23,11 +23,11 @@ */ struct HookingPointData HookingPoints[] = { -/* HCache */ +/* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, { HP_POP(HCache->check, HP_HCache_check) }, { HP_POP(HCache->open, HP_HCache_open) }, -/* chr */ +/* char_interface */ { HP_POP(chr->waiting_disconnect, HP_chr_waiting_disconnect) }, { HP_POP(chr->delete_char_sql, HP_chr_delete_char_sql) }, { HP_POP(chr->create_online_char_data, HP_chr_create_online_char_data) }, @@ -186,21 +186,21 @@ struct HookingPointData HookingPoints[] = { { HP_POP(chr->sql_config_read, HP_chr_sql_config_read) }, { HP_POP(chr->config_dispatch, HP_chr_config_dispatch) }, { HP_POP(chr->config_read, HP_chr_config_read) }, -/* cmdline */ +/* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, { HP_POP(cmdline->arg_add, HP_cmdline_arg_add) }, { HP_POP(cmdline->exec, HP_cmdline_exec) }, { HP_POP(cmdline->arg_next_value, HP_cmdline_arg_next_value) }, { HP_POP(cmdline->arg_source, HP_cmdline_arg_source) }, -/* console */ +/* console_interface */ { HP_POP(console->init, HP_console_init) }, { HP_POP(console->final, HP_console_final) }, { HP_POP(console->display_title, HP_console_display_title) }, { HP_POP(console->display_gplnotice, HP_console_display_gplnotice) }, -/* core */ +/* core_interface */ { HP_POP(core->shutdown_callback, HP_core_shutdown_callback) }, -/* DB */ +/* db_interface */ { HP_POP(DB->fix_options, HP_DB_fix_options) }, { HP_POP(DB->default_cmp, HP_DB_default_cmp) }, { HP_POP(DB->default_hash, HP_DB_default_hash) }, @@ -220,11 +220,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, -/* geoip */ +/* geoip_interface */ { HP_POP(geoip->getcountry, HP_geoip_getcountry) }, { HP_POP(geoip->final, HP_geoip_final) }, { HP_POP(geoip->init, HP_geoip_init) }, -/* inter_auction */ +/* inter_auction_interface */ { HP_POP(inter_auction->count, HP_inter_auction_count) }, { HP_POP(inter_auction->save, HP_inter_auction_save) }, { HP_POP(inter_auction->create, HP_inter_auction_create) }, @@ -234,11 +234,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_auction->parse_frommap, HP_inter_auction_parse_frommap) }, { HP_POP(inter_auction->sql_init, HP_inter_auction_sql_init) }, { HP_POP(inter_auction->sql_final, HP_inter_auction_sql_final) }, -/* inter_elemental */ +/* inter_elemental_interface */ { HP_POP(inter_elemental->sql_init, HP_inter_elemental_sql_init) }, { HP_POP(inter_elemental->sql_final, HP_inter_elemental_sql_final) }, { HP_POP(inter_elemental->parse_frommap, HP_inter_elemental_parse_frommap) }, -/* inter_guild */ +/* inter_guild_interface */ { HP_POP(inter_guild->save_timer, HP_inter_guild_save_timer) }, { HP_POP(inter_guild->removemember_tosql, HP_inter_guild_removemember_tosql) }, { HP_POP(inter_guild->tosql, HP_inter_guild_tosql) }, @@ -261,11 +261,11 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_guild->parse_frommap, HP_inter_guild_parse_frommap) }, { HP_POP(inter_guild->leave, HP_inter_guild_leave) }, { HP_POP(inter_guild->broken, HP_inter_guild_broken) }, -/* inter_homunculus */ +/* inter_homunculus_interface */ { HP_POP(inter_homunculus->sql_init, HP_inter_homunculus_sql_init) }, { HP_POP(inter_homunculus->sql_final, HP_inter_homunculus_sql_final) }, { HP_POP(inter_homunculus->parse_frommap, HP_inter_homunculus_parse_frommap) }, -/* inter */ +/* inter_interface */ { HP_POP(inter->msg_txt, HP_inter_msg_txt) }, { HP_POP(inter->msg_config_read, HP_inter_msg_config_read) }, { HP_POP(inter->do_final_msg, HP_inter_do_final_msg) }, @@ -282,7 +282,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter->check_length, HP_inter_check_length) }, { HP_POP(inter->parse_frommap, HP_inter_parse_frommap) }, { HP_POP(inter->final, HP_inter_final) }, -/* inter_mail */ +/* inter_mail_interface */ { HP_POP(inter_mail->sql_init, HP_inter_mail_sql_init) }, { HP_POP(inter_mail->sql_final, HP_inter_mail_sql_final) }, { HP_POP(inter_mail->parse_frommap, HP_inter_mail_parse_frommap) }, @@ -291,14 +291,14 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_mail->loadmessage, HP_inter_mail_loadmessage) }, { HP_POP(inter_mail->DeleteAttach, HP_inter_mail_DeleteAttach) }, { HP_POP(inter_mail->sendmail, HP_inter_mail_sendmail) }, -/* inter_mercenary */ +/* inter_mercenary_interface */ { HP_POP(inter_mercenary->owner_fromsql, HP_inter_mercenary_owner_fromsql) }, { HP_POP(inter_mercenary->owner_tosql, HP_inter_mercenary_owner_tosql) }, { HP_POP(inter_mercenary->owner_delete, HP_inter_mercenary_owner_delete) }, { HP_POP(inter_mercenary->sql_init, HP_inter_mercenary_sql_init) }, { HP_POP(inter_mercenary->sql_final, HP_inter_mercenary_sql_final) }, { HP_POP(inter_mercenary->parse_frommap, HP_inter_mercenary_parse_frommap) }, -/* inter_party */ +/* inter_party_interface */ { HP_POP(inter_party->check_lv, HP_inter_party_check_lv) }, { HP_POP(inter_party->calc_state, HP_inter_party_calc_state) }, { HP_POP(inter_party->tosql, HP_inter_party_tosql) }, @@ -312,16 +312,16 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_party->leave, HP_inter_party_leave) }, { HP_POP(inter_party->CharOnline, HP_inter_party_CharOnline) }, { HP_POP(inter_party->CharOffline, HP_inter_party_CharOffline) }, -/* inter_pet */ +/* inter_pet_interface */ { HP_POP(inter_pet->tosql, HP_inter_pet_tosql) }, { HP_POP(inter_pet->fromsql, HP_inter_pet_fromsql) }, { HP_POP(inter_pet->sql_init, HP_inter_pet_sql_init) }, { HP_POP(inter_pet->sql_final, HP_inter_pet_sql_final) }, { HP_POP(inter_pet->delete_, HP_inter_pet_delete_) }, { HP_POP(inter_pet->parse_frommap, HP_inter_pet_parse_frommap) }, -/* inter_quest */ +/* inter_quest_interface */ { HP_POP(inter_quest->parse_frommap, HP_inter_quest_parse_frommap) }, -/* inter_storage */ +/* inter_storage_interface */ { HP_POP(inter_storage->tosql, HP_inter_storage_tosql) }, { HP_POP(inter_storage->fromsql, HP_inter_storage_fromsql) }, { HP_POP(inter_storage->guild_storage_tosql, HP_inter_storage_guild_storage_tosql) }, @@ -331,7 +331,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(inter_storage->delete_, HP_inter_storage_delete_) }, { HP_POP(inter_storage->guild_storage_delete, HP_inter_storage_guild_storage_delete) }, { HP_POP(inter_storage->parse_frommap, HP_inter_storage_parse_frommap) }, -/* libconfig */ +/* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, { HP_POP(libconfig->set_options, HP_libconfig_set_options) }, @@ -400,7 +400,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(libconfig->setting_lookup_int16, HP_libconfig_setting_lookup_int16) }, { HP_POP(libconfig->setting_lookup_mutable_string, HP_libconfig_setting_lookup_mutable_string) }, { HP_POP(libconfig->lookup_mutable_string, HP_libconfig_lookup_mutable_string) }, -/* loginif */ +/* loginif_interface */ { HP_POP(loginif->init, HP_loginif_init) }, { HP_POP(loginif->final, HP_loginif_final) }, { HP_POP(loginif->reset, HP_loginif_reset) }, @@ -414,7 +414,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(loginif->auth, HP_loginif_auth) }, { HP_POP(loginif->send_users_count, HP_loginif_send_users_count) }, { HP_POP(loginif->connect_to_server, HP_loginif_connect_to_server) }, -/* iMalloc */ +/* malloc_interface */ { HP_POP(iMalloc->init, HP_iMalloc_init) }, { HP_POP(iMalloc->final, HP_iMalloc_final) }, { HP_POP(iMalloc->malloc, HP_iMalloc_malloc) }, @@ -429,7 +429,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(iMalloc->usage, HP_iMalloc_usage) }, { HP_POP(iMalloc->post_shutdown, HP_iMalloc_post_shutdown) }, { HP_POP(iMalloc->init_messages, HP_iMalloc_init_messages) }, -/* mapif */ +/* mapif_interface */ { HP_POP(mapif->ban, HP_mapif_ban) }, { HP_POP(mapif->server_init, HP_mapif_server_init) }, { HP_POP(mapif->server_destroy, HP_mapif_server_destroy) }, @@ -599,7 +599,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapif->parse_RegistryRequest, HP_mapif_parse_RegistryRequest) }, { HP_POP(mapif->namechange_ack, HP_mapif_namechange_ack) }, { HP_POP(mapif->parse_NameChangeRequest, HP_mapif_parse_NameChangeRequest) }, -/* mapindex */ +/* mapindex_interface */ { HP_POP(mapindex->init, HP_mapindex_init) }, { HP_POP(mapindex->final, HP_mapindex_final) }, { HP_POP(mapindex->addmap, HP_mapindex_addmap) }, @@ -609,9 +609,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapindex->name2id, HP_mapindex_name2id) }, { HP_POP(mapindex->id2name, HP_mapindex_id2name) }, { HP_POP(mapindex->check_default, HP_mapindex_check_default) }, -/* nullpo */ +/* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, -/* pincode */ +/* pincode_interface */ { HP_POP(pincode->handle, HP_pincode_handle) }, { HP_POP(pincode->decrypt, HP_pincode_decrypt) }, { HP_POP(pincode->error, HP_pincode_error) }, @@ -622,12 +622,12 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pincode->compare, HP_pincode_compare) }, { HP_POP(pincode->check, HP_pincode_check) }, { HP_POP(pincode->config_read, HP_pincode_config_read) }, -/* showmsg */ +/* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, { HP_POP(showmsg->clearScreen, HP_showmsg_clearScreen) }, { HP_POP(showmsg->showMessageV, HP_showmsg_showMessageV) }, -/* sockt */ +/* socket_interface */ { HP_POP(sockt->init, HP_sockt_init) }, { HP_POP(sockt->final, HP_sockt_final) }, { HP_POP(sockt->perform, HP_sockt_perform) }, @@ -656,7 +656,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sockt->trusted_ip_check, HP_sockt_trusted_ip_check) }, { HP_POP(sockt->net_config_read_sub, HP_sockt_net_config_read_sub) }, { HP_POP(sockt->net_config_read, HP_sockt_net_config_read) }, -/* SQL */ +/* sql_interface */ { HP_POP(SQL->Connect, HP_SQL_Connect) }, { HP_POP(SQL->GetTimeout, HP_SQL_GetTimeout) }, { HP_POP(SQL->GetColumnNames, HP_SQL_GetColumnNames) }, @@ -689,7 +689,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(SQL->StmtFreeResult, HP_SQL_StmtFreeResult) }, { HP_POP(SQL->StmtFree, HP_SQL_StmtFree) }, { HP_POP(SQL->StmtShowDebug_, HP_SQL_StmtShowDebug_) }, -/* StrBuf */ +/* stringbuf_interface */ { HP_POP(StrBuf->Malloc, HP_StrBuf_Malloc) }, { HP_POP(StrBuf->Init, HP_StrBuf_Init) }, { HP_POP(StrBuf->Vprintf, HP_StrBuf_Vprintf) }, @@ -700,7 +700,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(StrBuf->Clear, HP_StrBuf_Clear) }, { HP_POP(StrBuf->Destroy, HP_StrBuf_Destroy) }, { HP_POP(StrBuf->Free, HP_StrBuf_Free) }, -/* strlib */ +/* strlib_interface */ { HP_POP(strlib->jstrescape, HP_strlib_jstrescape) }, { HP_POP(strlib->jstrescapecpy, HP_strlib_jstrescapecpy) }, { HP_POP(strlib->jmemescapecpy, HP_strlib_jmemescapecpy) }, @@ -716,7 +716,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(strlib->safestrnlen_, HP_strlib_safestrnlen_) }, { HP_POP(strlib->strline_, HP_strlib_strline_) }, { HP_POP(strlib->bin2hex_, HP_strlib_bin2hex_) }, -/* sv */ +/* sv_interface */ { HP_POP(sv->parse_next, HP_sv_parse_next) }, { HP_POP(sv->parse, HP_sv_parse) }, { HP_POP(sv->split, HP_sv_split) }, @@ -724,7 +724,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sv->unescape_c, HP_sv_unescape_c) }, { HP_POP(sv->skip_escaped_c, HP_sv_skip_escaped_c) }, { HP_POP(sv->readdb, HP_sv_readdb) }, -/* sysinfo */ +/* sysinfo_interface */ { HP_POP(sysinfo->getpagesize, HP_sysinfo_getpagesize) }, { HP_POP(sysinfo->platform, HP_sysinfo_platform) }, { HP_POP(sysinfo->osversion, HP_sysinfo_osversion) }, @@ -743,7 +743,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, -/* timer */ +/* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, { HP_POP(timer->add, HP_timer_add) }, diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index b06abebb7..8a0e334a7 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -23,7 +23,7 @@ * as it will get overwritten. */ -/* HCache */ +/* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; if( HPMHooks.count.HP_HCache_init_pre ) { @@ -104,7 +104,7 @@ FILE* HP_HCache_open(const char *file, const char *opt) { } return retVal___; } -/* chr */ +/* char_interface */ int HP_chr_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; @@ -4295,7 +4295,7 @@ int HP_chr_config_read(const char *cfgName) { } return retVal___; } -/* cmdline */ +/* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; if( HPMHooks.count.HP_cmdline_init_pre ) { @@ -4456,7 +4456,7 @@ const char* HP_cmdline_arg_source(struct CmdlineArgData *arg) { } return retVal___; } -/* console */ +/* console_interface */ void HP_console_init(void) { int hIndex = 0; if( HPMHooks.count.HP_console_init_pre ) { @@ -4561,7 +4561,7 @@ void HP_console_display_gplnotice(void) { } return; } -/* core */ +/* core_interface */ void HP_core_shutdown_callback(void) { int hIndex = 0; if( HPMHooks.count.HP_core_shutdown_callback_pre ) { @@ -4588,7 +4588,7 @@ void HP_core_shutdown_callback(void) { } return; } -/* DB */ +/* db_interface */ enum DBOptions HP_DB_fix_options(enum DBType type, enum DBOptions options) { int hIndex = 0; enum DBOptions retVal___ = DB_OPT_BASE; @@ -5108,7 +5108,7 @@ void HP_DB_final(void) { } return; } -/* geoip */ +/* geoip_interface */ const char* HP_geoip_getcountry(uint32 ipnum) { int hIndex = 0; const char* retVal___ = NULL; @@ -5188,7 +5188,7 @@ void HP_geoip_init(void) { } return; } -/* inter_auction */ +/* inter_auction_interface */ int HP_inter_auction_count(int char_id, bool buy) { int hIndex = 0; int retVal___ = 0; @@ -5428,7 +5428,7 @@ void HP_inter_auction_sql_final(void) { } return; } -/* inter_elemental */ +/* inter_elemental_interface */ void HP_inter_elemental_sql_init(void) { int hIndex = 0; if( HPMHooks.count.HP_inter_elemental_sql_init_pre ) { @@ -5508,7 +5508,7 @@ int HP_inter_elemental_parse_frommap(int fd) { } return retVal___; } -/* inter_guild */ +/* inter_guild_interface */ int HP_inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) { int hIndex = 0; int retVal___ = 0; @@ -6108,7 +6108,7 @@ int HP_inter_guild_broken(int guild_id) { } return retVal___; } -/* inter_homunculus */ +/* inter_homunculus_interface */ int HP_inter_homunculus_sql_init(void) { int hIndex = 0; int retVal___ = 0; @@ -6189,7 +6189,7 @@ int HP_inter_homunculus_parse_frommap(int fd) { } return retVal___; } -/* inter */ +/* inter_interface */ const char* HP_inter_msg_txt(int msg_number) { int hIndex = 0; const char* retVal___ = NULL; @@ -6636,7 +6636,7 @@ void HP_inter_final(void) { } return; } -/* inter_mail */ +/* inter_mail_interface */ int HP_inter_mail_sql_init(void) { int hIndex = 0; int retVal___ = 0; @@ -6851,7 +6851,7 @@ void HP_inter_mail_sendmail(int send_id, const char *send_name, int dest_id, con } return; } -/* inter_mercenary */ +/* inter_mercenary_interface */ bool HP_inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { int hIndex = 0; bool retVal___ = false; @@ -7013,7 +7013,7 @@ int HP_inter_mercenary_parse_frommap(int fd) { } return retVal___; } -/* inter_party */ +/* inter_party_interface */ int HP_inter_party_check_lv(struct party_data *p) { int hIndex = 0; int retVal___ = 0; @@ -7363,7 +7363,7 @@ int HP_inter_party_CharOffline(int char_id, int party_id) { } return retVal___; } -/* inter_pet */ +/* inter_pet_interface */ int HP_inter_pet_tosql(const struct s_pet *p) { int hIndex = 0; int retVal___ = 0; @@ -7525,7 +7525,7 @@ int HP_inter_pet_parse_frommap(int fd) { } return retVal___; } -/* inter_quest */ +/* inter_quest_interface */ int HP_inter_quest_parse_frommap(int fd) { int hIndex = 0; int retVal___ = 0; @@ -7553,7 +7553,7 @@ int HP_inter_quest_parse_frommap(int fd) { } return retVal___; } -/* inter_storage */ +/* inter_storage_interface */ int HP_inter_storage_tosql(int account_id, struct storage_data *p) { int hIndex = 0; int retVal___ = 0; @@ -7796,7 +7796,7 @@ int HP_inter_storage_parse_frommap(int fd) { } return retVal___; } -/* libconfig */ +/* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; int retVal___ = 0; @@ -9623,7 +9623,7 @@ int HP_libconfig_lookup_mutable_string(const struct config_t *config, const char } return retVal___; } -/* loginif */ +/* loginif_interface */ void HP_loginif_init(void) { int hIndex = 0; if( HPMHooks.count.HP_loginif_init_pre ) { @@ -9962,7 +9962,7 @@ void HP_loginif_connect_to_server(void) { } return; } -/* iMalloc */ +/* malloc_interface */ void HP_iMalloc_init(void) { int hIndex = 0; if( HPMHooks.count.HP_iMalloc_init_pre ) { @@ -10335,7 +10335,7 @@ void HP_iMalloc_init_messages(void) { } return; } -/* mapif */ +/* mapif_interface */ void HP_mapif_ban(int id, unsigned int flag, int status) { int hIndex = 0; if( HPMHooks.count.HP_mapif_ban_pre ) { @@ -14833,7 +14833,7 @@ int HP_mapif_parse_NameChangeRequest(int fd) { } return retVal___; } -/* mapindex */ +/* mapindex_interface */ int HP_mapindex_init(void) { int hIndex = 0; int retVal___ = 0; @@ -15075,7 +15075,7 @@ bool HP_mapindex_check_default(void) { } return retVal___; } -/* nullpo */ +/* nullpo_interface */ void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { int hIndex = 0; if( HPMHooks.count.HP_nullpo_assert_report_pre ) { @@ -15102,7 +15102,7 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const } return; } -/* pincode */ +/* pincode_interface */ void HP_pincode_handle(int fd, struct char_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_pincode_handle_pre ) { @@ -15365,7 +15365,7 @@ bool HP_pincode_config_read(char *w1, char *w2) { } return retVal___; } -/* showmsg */ +/* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; if( HPMHooks.count.HP_showmsg_init_pre ) { @@ -15477,7 +15477,7 @@ int HP_showmsg_showMessageV(const char *string, va_list ap) { } return retVal___; } -/* sockt */ +/* socket_interface */ void HP_sockt_init(void) { int hIndex = 0; if( HPMHooks.count.HP_sockt_init_pre ) { @@ -16224,7 +16224,7 @@ void HP_sockt_net_config_read(const char *filename) { } return; } -/* SQL */ +/* sql_interface */ int HP_SQL_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db) { int hIndex = 0; int retVal___ = 0; @@ -17095,7 +17095,7 @@ void HP_SQL_StmtShowDebug_(struct SqlStmt *self, const char *debug_file, const u } return; } -/* StrBuf */ +/* stringbuf_interface */ StringBuf* HP_StrBuf_Malloc(void) { int hIndex = 0; StringBuf* retVal___ = NULL; @@ -17368,7 +17368,7 @@ void HP_StrBuf_Free(StringBuf *self) { } return; } -/* strlib */ +/* strlib_interface */ char* HP_strlib_jstrescape(char *pt) { int hIndex = 0; char* retVal___ = NULL; @@ -17774,7 +17774,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { } return retVal___; } -/* sv */ +/* sv_interface */ int HP_sv_parse_next(struct s_svstate *svstate) { int hIndex = 0; int retVal___ = 0; @@ -17964,7 +17964,7 @@ bool HP_sv_readdb(const char *directory, const char *filename, char delim, int m } return retVal___; } -/* sysinfo */ +/* sysinfo_interface */ int HP_sysinfo_getpagesize(void) { int hIndex = 0; int retVal___ = 0; @@ -18448,7 +18448,7 @@ void HP_sysinfo_final(void) { } return; } -/* timer */ +/* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; int64 retVal___ = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 0460f4ca4..50efba987 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -23,25 +23,25 @@ */ struct HookingPointData HookingPoints[] = { -/* HCache */ +/* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, { HP_POP(HCache->check, HP_HCache_check) }, { HP_POP(HCache->open, HP_HCache_open) }, -/* cmdline */ +/* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, { HP_POP(cmdline->arg_add, HP_cmdline_arg_add) }, { HP_POP(cmdline->exec, HP_cmdline_exec) }, { HP_POP(cmdline->arg_next_value, HP_cmdline_arg_next_value) }, { HP_POP(cmdline->arg_source, HP_cmdline_arg_source) }, -/* console */ +/* console_interface */ { HP_POP(console->init, HP_console_init) }, { HP_POP(console->final, HP_console_final) }, { HP_POP(console->display_title, HP_console_display_title) }, { HP_POP(console->display_gplnotice, HP_console_display_gplnotice) }, -/* core */ +/* core_interface */ { HP_POP(core->shutdown_callback, HP_core_shutdown_callback) }, -/* DB */ +/* db_interface */ { HP_POP(DB->fix_options, HP_DB_fix_options) }, { HP_POP(DB->default_cmp, HP_DB_default_cmp) }, { HP_POP(DB->default_hash, HP_DB_default_hash) }, @@ -61,7 +61,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, -/* libconfig */ +/* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, { HP_POP(libconfig->set_options, HP_libconfig_set_options) }, @@ -130,7 +130,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(libconfig->setting_lookup_int16, HP_libconfig_setting_lookup_int16) }, { HP_POP(libconfig->setting_lookup_mutable_string, HP_libconfig_setting_lookup_mutable_string) }, { HP_POP(libconfig->lookup_mutable_string, HP_libconfig_lookup_mutable_string) }, -/* login */ +/* login_interface */ { HP_POP(login->mmo_auth, HP_login_mmo_auth) }, { HP_POP(login->mmo_auth_new, HP_login_mmo_auth_new) }, { HP_POP(login->waiting_disconnect_timer, HP_login_waiting_disconnect_timer) }, @@ -187,7 +187,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(login->parse_login, HP_login_parse_login) }, { HP_POP(login->config_set_defaults, HP_login_config_set_defaults) }, { HP_POP(login->config_read, HP_login_config_read) }, -/* iMalloc */ +/* malloc_interface */ { HP_POP(iMalloc->init, HP_iMalloc_init) }, { HP_POP(iMalloc->final, HP_iMalloc_final) }, { HP_POP(iMalloc->malloc, HP_iMalloc_malloc) }, @@ -202,14 +202,14 @@ struct HookingPointData HookingPoints[] = { { HP_POP(iMalloc->usage, HP_iMalloc_usage) }, { HP_POP(iMalloc->post_shutdown, HP_iMalloc_post_shutdown) }, { HP_POP(iMalloc->init_messages, HP_iMalloc_init_messages) }, -/* nullpo */ +/* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, -/* showmsg */ +/* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, { HP_POP(showmsg->clearScreen, HP_showmsg_clearScreen) }, { HP_POP(showmsg->showMessageV, HP_showmsg_showMessageV) }, -/* sockt */ +/* socket_interface */ { HP_POP(sockt->init, HP_sockt_init) }, { HP_POP(sockt->final, HP_sockt_final) }, { HP_POP(sockt->perform, HP_sockt_perform) }, @@ -238,7 +238,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sockt->trusted_ip_check, HP_sockt_trusted_ip_check) }, { HP_POP(sockt->net_config_read_sub, HP_sockt_net_config_read_sub) }, { HP_POP(sockt->net_config_read, HP_sockt_net_config_read) }, -/* SQL */ +/* sql_interface */ { HP_POP(SQL->Connect, HP_SQL_Connect) }, { HP_POP(SQL->GetTimeout, HP_SQL_GetTimeout) }, { HP_POP(SQL->GetColumnNames, HP_SQL_GetColumnNames) }, @@ -271,7 +271,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(SQL->StmtFreeResult, HP_SQL_StmtFreeResult) }, { HP_POP(SQL->StmtFree, HP_SQL_StmtFree) }, { HP_POP(SQL->StmtShowDebug_, HP_SQL_StmtShowDebug_) }, -/* StrBuf */ +/* stringbuf_interface */ { HP_POP(StrBuf->Malloc, HP_StrBuf_Malloc) }, { HP_POP(StrBuf->Init, HP_StrBuf_Init) }, { HP_POP(StrBuf->Vprintf, HP_StrBuf_Vprintf) }, @@ -282,7 +282,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(StrBuf->Clear, HP_StrBuf_Clear) }, { HP_POP(StrBuf->Destroy, HP_StrBuf_Destroy) }, { HP_POP(StrBuf->Free, HP_StrBuf_Free) }, -/* strlib */ +/* strlib_interface */ { HP_POP(strlib->jstrescape, HP_strlib_jstrescape) }, { HP_POP(strlib->jstrescapecpy, HP_strlib_jstrescapecpy) }, { HP_POP(strlib->jmemescapecpy, HP_strlib_jmemescapecpy) }, @@ -298,7 +298,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(strlib->safestrnlen_, HP_strlib_safestrnlen_) }, { HP_POP(strlib->strline_, HP_strlib_strline_) }, { HP_POP(strlib->bin2hex_, HP_strlib_bin2hex_) }, -/* sv */ +/* sv_interface */ { HP_POP(sv->parse_next, HP_sv_parse_next) }, { HP_POP(sv->parse, HP_sv_parse) }, { HP_POP(sv->split, HP_sv_split) }, @@ -306,7 +306,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sv->unescape_c, HP_sv_unescape_c) }, { HP_POP(sv->skip_escaped_c, HP_sv_skip_escaped_c) }, { HP_POP(sv->readdb, HP_sv_readdb) }, -/* sysinfo */ +/* sysinfo_interface */ { HP_POP(sysinfo->getpagesize, HP_sysinfo_getpagesize) }, { HP_POP(sysinfo->platform, HP_sysinfo_platform) }, { HP_POP(sysinfo->osversion, HP_sysinfo_osversion) }, @@ -325,7 +325,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, -/* timer */ +/* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, { HP_POP(timer->add, HP_timer_add) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index d49998deb..44f08fe22 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -23,7 +23,7 @@ * as it will get overwritten. */ -/* HCache */ +/* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; if( HPMHooks.count.HP_HCache_init_pre ) { @@ -104,7 +104,7 @@ FILE* HP_HCache_open(const char *file, const char *opt) { } return retVal___; } -/* cmdline */ +/* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; if( HPMHooks.count.HP_cmdline_init_pre ) { @@ -265,7 +265,7 @@ const char* HP_cmdline_arg_source(struct CmdlineArgData *arg) { } return retVal___; } -/* console */ +/* console_interface */ void HP_console_init(void) { int hIndex = 0; if( HPMHooks.count.HP_console_init_pre ) { @@ -370,7 +370,7 @@ void HP_console_display_gplnotice(void) { } return; } -/* core */ +/* core_interface */ void HP_core_shutdown_callback(void) { int hIndex = 0; if( HPMHooks.count.HP_core_shutdown_callback_pre ) { @@ -397,7 +397,7 @@ void HP_core_shutdown_callback(void) { } return; } -/* DB */ +/* db_interface */ enum DBOptions HP_DB_fix_options(enum DBType type, enum DBOptions options) { int hIndex = 0; enum DBOptions retVal___ = DB_OPT_BASE; @@ -917,7 +917,7 @@ void HP_DB_final(void) { } return; } -/* libconfig */ +/* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; int retVal___ = 0; @@ -2744,7 +2744,7 @@ int HP_libconfig_lookup_mutable_string(const struct config_t *config, const char } return retVal___; } -/* login */ +/* login_interface */ int HP_login_mmo_auth(struct login_session_data *sd, bool isServer) { int hIndex = 0; int retVal___ = 0; @@ -4237,7 +4237,7 @@ int HP_login_config_read(const char *cfgName) { } return retVal___; } -/* iMalloc */ +/* malloc_interface */ void HP_iMalloc_init(void) { int hIndex = 0; if( HPMHooks.count.HP_iMalloc_init_pre ) { @@ -4610,7 +4610,7 @@ void HP_iMalloc_init_messages(void) { } return; } -/* nullpo */ +/* nullpo_interface */ void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { int hIndex = 0; if( HPMHooks.count.HP_nullpo_assert_report_pre ) { @@ -4637,7 +4637,7 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const } return; } -/* showmsg */ +/* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; if( HPMHooks.count.HP_showmsg_init_pre ) { @@ -4749,7 +4749,7 @@ int HP_showmsg_showMessageV(const char *string, va_list ap) { } return retVal___; } -/* sockt */ +/* socket_interface */ void HP_sockt_init(void) { int hIndex = 0; if( HPMHooks.count.HP_sockt_init_pre ) { @@ -5496,7 +5496,7 @@ void HP_sockt_net_config_read(const char *filename) { } return; } -/* SQL */ +/* sql_interface */ int HP_SQL_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db) { int hIndex = 0; int retVal___ = 0; @@ -6367,7 +6367,7 @@ void HP_SQL_StmtShowDebug_(struct SqlStmt *self, const char *debug_file, const u } return; } -/* StrBuf */ +/* stringbuf_interface */ StringBuf* HP_StrBuf_Malloc(void) { int hIndex = 0; StringBuf* retVal___ = NULL; @@ -6640,7 +6640,7 @@ void HP_StrBuf_Free(StringBuf *self) { } return; } -/* strlib */ +/* strlib_interface */ char* HP_strlib_jstrescape(char *pt) { int hIndex = 0; char* retVal___ = NULL; @@ -7046,7 +7046,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { } return retVal___; } -/* sv */ +/* sv_interface */ int HP_sv_parse_next(struct s_svstate *svstate) { int hIndex = 0; int retVal___ = 0; @@ -7236,7 +7236,7 @@ bool HP_sv_readdb(const char *directory, const char *filename, char delim, int m } return retVal___; } -/* sysinfo */ +/* sysinfo_interface */ int HP_sysinfo_getpagesize(void) { int hIndex = 0; int retVal___ = 0; @@ -7720,7 +7720,7 @@ void HP_sysinfo_final(void) { } return; } -/* timer */ +/* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; int64 retVal___ = 0; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 714da27bf..8d9752849 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -23,11 +23,11 @@ */ struct HookingPointData HookingPoints[] = { -/* HCache */ +/* HCache_interface */ { HP_POP(HCache->init, HP_HCache_init) }, { HP_POP(HCache->check, HP_HCache_check) }, { HP_POP(HCache->open, HP_HCache_open) }, -/* atcommand */ +/* atcommand_interface */ { HP_POP(atcommand->init, HP_atcommand_init) }, { HP_POP(atcommand->final, HP_atcommand_final) }, { HP_POP(atcommand->exec, HP_atcommand_exec) }, @@ -63,7 +63,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(atcommand->expand_message_table, HP_atcommand_expand_message_table) }, { HP_POP(atcommand->msgfd, HP_atcommand_msgfd) }, { HP_POP(atcommand->msgsd, HP_atcommand_msgsd) }, -/* battle */ +/* battle_interface */ { HP_POP(battle->init, HP_battle_init) }, { HP_POP(battle->final, HP_battle_final) }, { HP_POP(battle->calc_attack, HP_battle_calc_attack) }, @@ -119,7 +119,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(battle->calc_skillratio_magic_unknown, HP_battle_calc_skillratio_magic_unknown) }, { HP_POP(battle->calc_skillratio_weapon_unknown, HP_battle_calc_skillratio_weapon_unknown) }, { HP_POP(battle->calc_misc_attack_unknown, HP_battle_calc_misc_attack_unknown) }, -/* bg */ +/* battleground_interface */ { HP_POP(bg->init, HP_bg_init) }, { HP_POP(bg->final, HP_bg_final) }, { HP_POP(bg->name2arena, HP_bg_name2arena) }, @@ -151,7 +151,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(bg->team_db_final, HP_bg_team_db_final) }, { HP_POP(bg->str2teamtype, HP_bg_str2teamtype) }, { HP_POP(bg->config_read, HP_bg_config_read) }, -/* buyingstore */ +/* buyingstore_interface */ { HP_POP(buyingstore->setup, HP_buyingstore_setup) }, { HP_POP(buyingstore->create, HP_buyingstore_create) }, { HP_POP(buyingstore->close, HP_buyingstore_close) }, @@ -160,7 +160,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(buyingstore->search, HP_buyingstore_search) }, { HP_POP(buyingstore->searchall, HP_buyingstore_searchall) }, { HP_POP(buyingstore->getuid, HP_buyingstore_getuid) }, -/* channel */ +/* channel_interface */ { HP_POP(channel->init, HP_channel_init) }, { HP_POP(channel->final, HP_channel_final) }, { HP_POP(channel->search, HP_channel_search) }, @@ -182,7 +182,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(channel->quit_guild, HP_channel_quit_guild) }, { HP_POP(channel->irc_join, HP_channel_irc_join) }, { HP_POP(channel->config_read, HP_channel_config_read) }, -/* chat */ +/* chat_interface */ { HP_POP(chat->create_pc_chat, HP_chat_create_pc_chat) }, { HP_POP(chat->join, HP_chat_join) }, { HP_POP(chat->leave, HP_chat_leave) }, @@ -196,7 +196,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(chat->npc_kick_all, HP_chat_npc_kick_all) }, { HP_POP(chat->trigger_event, HP_chat_trigger_event) }, { HP_POP(chat->create, HP_chat_create) }, -/* chrif */ +/* chrif_interface */ { HP_POP(chrif->init, HP_chrif_init) }, { HP_POP(chrif->final, HP_chrif_final) }, { HP_POP(chrif->setuserid, HP_chrif_setuserid) }, @@ -267,7 +267,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(chrif->parse, HP_chrif_parse) }, { HP_POP(chrif->save_scdata_single, HP_chrif_save_scdata_single) }, { HP_POP(chrif->del_scdata_single, HP_chrif_del_scdata_single) }, -/* clif */ +/* clif_interface */ { HP_POP(clif->init, HP_clif_init) }, { HP_POP(clif->final, HP_clif_final) }, { HP_POP(clif->setip, HP_clif_setip) }, @@ -948,21 +948,21 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->selectcart, HP_clif_selectcart) }, { HP_POP(clif->pSelectCart, HP_clif_pSelectCart) }, { HP_POP(clif->get_bl_name, HP_clif_get_bl_name) }, -/* cmdline */ +/* cmdline_interface */ { HP_POP(cmdline->init, HP_cmdline_init) }, { HP_POP(cmdline->final, HP_cmdline_final) }, { HP_POP(cmdline->arg_add, HP_cmdline_arg_add) }, { HP_POP(cmdline->exec, HP_cmdline_exec) }, { HP_POP(cmdline->arg_next_value, HP_cmdline_arg_next_value) }, { HP_POP(cmdline->arg_source, HP_cmdline_arg_source) }, -/* console */ +/* console_interface */ { HP_POP(console->init, HP_console_init) }, { HP_POP(console->final, HP_console_final) }, { HP_POP(console->display_title, HP_console_display_title) }, { HP_POP(console->display_gplnotice, HP_console_display_gplnotice) }, -/* core */ +/* core_interface */ { HP_POP(core->shutdown_callback, HP_core_shutdown_callback) }, -/* DB */ +/* db_interface */ { HP_POP(DB->fix_options, HP_DB_fix_options) }, { HP_POP(DB->default_cmp, HP_DB_default_cmp) }, { HP_POP(DB->default_hash, HP_DB_default_hash) }, @@ -982,7 +982,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, -/* duel */ +/* duel_interface */ { HP_POP(duel->create, HP_duel_create) }, { HP_POP(duel->invite, HP_duel_invite) }, { HP_POP(duel->accept, HP_duel_accept) }, @@ -992,7 +992,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(duel->checktime, HP_duel_checktime) }, { HP_POP(duel->init, HP_duel_init) }, { HP_POP(duel->final, HP_duel_final) }, -/* elemental */ +/* elemental_interface */ { HP_POP(elemental->init, HP_elemental_init) }, { HP_POP(elemental->final, HP_elemental_final) }, { HP_POP(elemental->class, HP_elemental_class) }, @@ -1025,7 +1025,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(elemental->ai_sub_foreachclient, HP_elemental_ai_sub_foreachclient) }, { HP_POP(elemental->ai_timer, HP_elemental_ai_timer) }, { HP_POP(elemental->read_db, HP_elemental_read_db) }, -/* guild */ +/* guild_interface */ { HP_POP(guild->init, HP_guild_init) }, { HP_POP(guild->final, HP_guild_final) }, { HP_POP(guild->skill_get_max, HP_guild_skill_get_max) }, @@ -1112,7 +1112,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(guild->check_member, HP_guild_check_member) }, { HP_POP(guild->get_alliance_count, HP_guild_get_alliance_count) }, { HP_POP(guild->castle_reconnect_sub, HP_guild_castle_reconnect_sub) }, -/* gstorage */ +/* guild_storage_interface */ { HP_POP(gstorage->ensure, HP_gstorage_ensure) }, { HP_POP(gstorage->init, HP_gstorage_init) }, { HP_POP(gstorage->final, HP_gstorage_final) }, @@ -1129,7 +1129,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(gstorage->save, HP_gstorage_save) }, { HP_POP(gstorage->saved, HP_gstorage_saved) }, { HP_POP(gstorage->create, HP_gstorage_create) }, -/* homun */ +/* homunculus_interface */ { HP_POP(homun->init, HP_homun_init) }, { HP_POP(homun->final, HP_homun_final) }, { HP_POP(homun->reload, HP_homun_reload) }, @@ -1177,7 +1177,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(homun->addspiritball, HP_homun_addspiritball) }, { HP_POP(homun->delspiritball, HP_homun_delspiritball) }, { HP_POP(homun->get_intimacy_grade, HP_homun_get_intimacy_grade) }, -/* instance */ +/* instance_interface */ { HP_POP(instance->init, HP_instance_init) }, { HP_POP(instance->final, HP_instance_final) }, { HP_POP(instance->reload, HP_instance_reload) }, @@ -1196,7 +1196,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(instance->set_timeout, HP_instance_set_timeout) }, { HP_POP(instance->valid, HP_instance_valid) }, { HP_POP(instance->destroy_timer, HP_instance_destroy_timer) }, -/* intif */ +/* intif_interface */ { HP_POP(intif->parse, HP_intif_parse) }, { HP_POP(intif->create_pet, HP_intif_create_pet) }, { HP_POP(intif->broadcast, HP_intif_broadcast) }, @@ -1328,7 +1328,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(intif->pRecvHomunculusData, HP_intif_pRecvHomunculusData) }, { HP_POP(intif->pSaveHomunculusOk, HP_intif_pSaveHomunculusOk) }, { HP_POP(intif->pDeleteHomunculusOk, HP_intif_pDeleteHomunculusOk) }, -/* ircbot */ +/* irc_bot_interface */ { HP_POP(ircbot->init, HP_ircbot_init) }, { HP_POP(ircbot->final, HP_ircbot_final) }, { HP_POP(ircbot->parse, HP_ircbot_parse) }, @@ -1345,7 +1345,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(ircbot->userjoin, HP_ircbot_userjoin) }, { HP_POP(ircbot->userleave, HP_ircbot_userleave) }, { HP_POP(ircbot->usernick, HP_ircbot_usernick) }, -/* itemdb */ +/* itemdb_interface */ { HP_POP(itemdb->init, HP_itemdb_init) }, { HP_POP(itemdb->final, HP_itemdb_final) }, { HP_POP(itemdb->reload, HP_itemdb_reload) }, @@ -1405,7 +1405,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(itemdb->id2combo, HP_itemdb_id2combo) }, { HP_POP(itemdb->is_item_usable, HP_itemdb_is_item_usable) }, { HP_POP(itemdb->lookup_const, HP_itemdb_lookup_const) }, -/* libconfig */ +/* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, { HP_POP(libconfig->set_options, HP_libconfig_set_options) }, @@ -1474,7 +1474,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(libconfig->setting_lookup_int16, HP_libconfig_setting_lookup_int16) }, { HP_POP(libconfig->setting_lookup_mutable_string, HP_libconfig_setting_lookup_mutable_string) }, { HP_POP(libconfig->lookup_mutable_string, HP_libconfig_lookup_mutable_string) }, -/* logs */ +/* log_interface */ { HP_POP(logs->pick_pc, HP_logs_pick_pc) }, { HP_POP(logs->pick_mob, HP_logs_pick_mob) }, { HP_POP(logs->zeny, HP_logs_zeny) }, @@ -1497,7 +1497,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(logs->picktype2char, HP_logs_picktype2char) }, { HP_POP(logs->chattype2char, HP_logs_chattype2char) }, { HP_POP(logs->should_log_item, HP_logs_should_log_item) }, -/* mail */ +/* mail_interface */ { HP_POP(mail->clear, HP_mail_clear) }, { HP_POP(mail->removeitem, HP_mail_removeitem) }, { HP_POP(mail->removezeny, HP_mail_removezeny) }, @@ -1507,7 +1507,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mail->openmail, HP_mail_openmail) }, { HP_POP(mail->deliveryfail, HP_mail_deliveryfail) }, { HP_POP(mail->invalid_operation, HP_mail_invalid_operation) }, -/* iMalloc */ +/* malloc_interface */ { HP_POP(iMalloc->init, HP_iMalloc_init) }, { HP_POP(iMalloc->final, HP_iMalloc_final) }, { HP_POP(iMalloc->malloc, HP_iMalloc_malloc) }, @@ -1522,7 +1522,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(iMalloc->usage, HP_iMalloc_usage) }, { HP_POP(iMalloc->post_shutdown, HP_iMalloc_post_shutdown) }, { HP_POP(iMalloc->init_messages, HP_iMalloc_init_messages) }, -/* map */ +/* map_interface */ { HP_POP(map->zone_init, HP_map_zone_init) }, { HP_POP(map->zone_remove, HP_map_zone_remove) }, { HP_POP(map->zone_apply, HP_map_zone_apply) }, @@ -1656,7 +1656,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(map->remove_questinfo, HP_map_remove_questinfo) }, { HP_POP(map->merge_zone, HP_map_merge_zone) }, { HP_POP(map->zone_clear_single, HP_map_zone_clear_single) }, -/* mapindex */ +/* mapindex_interface */ { HP_POP(mapindex->init, HP_mapindex_init) }, { HP_POP(mapindex->final, HP_mapindex_final) }, { HP_POP(mapindex->addmap, HP_mapindex_addmap) }, @@ -1666,7 +1666,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapindex->name2id, HP_mapindex_name2id) }, { HP_POP(mapindex->id2name, HP_mapindex_id2name) }, { HP_POP(mapindex->check_default, HP_mapindex_check_default) }, -/* mapit */ +/* mapit_interface */ { HP_POP(mapit->alloc, HP_mapit_alloc) }, { HP_POP(mapit->free, HP_mapit_free) }, { HP_POP(mapit->first, HP_mapit_first) }, @@ -1674,7 +1674,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapit->next, HP_mapit_next) }, { HP_POP(mapit->prev, HP_mapit_prev) }, { HP_POP(mapit->exists, HP_mapit_exists) }, -/* mapreg */ +/* mapreg_interface */ { HP_POP(mapreg->init, HP_mapreg_init) }, { HP_POP(mapreg->final, HP_mapreg_final) }, { HP_POP(mapreg->readreg, HP_mapreg_readreg) }, @@ -1687,7 +1687,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mapreg->destroyreg, HP_mapreg_destroyreg) }, { HP_POP(mapreg->reload, HP_mapreg_reload) }, { HP_POP(mapreg->config_read, HP_mapreg_config_read) }, -/* mercenary */ +/* mercenary_interface */ { HP_POP(mercenary->init, HP_mercenary_init) }, { HP_POP(mercenary->class, HP_mercenary_class) }, { HP_POP(mercenary->get_viewdata, HP_mercenary_get_viewdata) }, @@ -1713,7 +1713,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mercenary->contract_end_timer, HP_mercenary_contract_end_timer) }, { HP_POP(mercenary->read_db_sub, HP_mercenary_read_db_sub) }, { HP_POP(mercenary->read_skill_db_sub, HP_mercenary_read_skill_db_sub) }, -/* mob */ +/* mob_interface */ { HP_POP(mob->init, HP_mob_init) }, { HP_POP(mob->final, HP_mob_final) }, { HP_POP(mob->reload, HP_mob_reload) }, @@ -1817,7 +1817,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(mob->load, HP_mob_load) }, { HP_POP(mob->clear_spawninfo, HP_mob_clear_spawninfo) }, { HP_POP(mob->destroy_mob_db, HP_mob_destroy_mob_db) }, -/* npc_chat */ +/* npc_chat_interface */ { HP_POP(npc_chat->sub, HP_npc_chat_sub) }, { HP_POP(npc_chat->finalize, HP_npc_chat_finalize) }, { HP_POP(npc_chat->def_pattern, HP_npc_chat_def_pattern) }, @@ -1827,7 +1827,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(npc_chat->activate_pcreset, HP_npc_chat_activate_pcreset) }, { HP_POP(npc_chat->lookup_pcreset, HP_npc_chat_lookup_pcreset) }, { HP_POP(npc_chat->finalize_pcrematch_entry, HP_npc_chat_finalize_pcrematch_entry) }, -/* npc */ +/* npc_interface */ { HP_POP(npc->init, HP_npc_init) }, { HP_POP(npc->final, HP_npc_final) }, { HP_POP(npc->get_new_npc_id, HP_npc_get_new_npc_id) }, @@ -1938,9 +1938,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(npc->market_delfromsql_sub, HP_npc_market_delfromsql_sub) }, { HP_POP(npc->db_checkid, HP_npc_db_checkid) }, { HP_POP(npc->secure_timeout_timer, HP_npc_secure_timeout_timer) }, -/* nullpo */ +/* nullpo_interface */ { HP_POP(nullpo->assert_report, HP_nullpo_assert_report) }, -/* party */ +/* party_interface */ { HP_POP(party->init, HP_party_init) }, { HP_POP(party->final, HP_party_final) }, { HP_POP(party->search, HP_party_search) }, @@ -1990,7 +1990,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(party->check_state, HP_party_check_state) }, { HP_POP(party->create_booking_data, HP_party_create_booking_data) }, { HP_POP(party->db_final, HP_party_db_final) }, -/* path */ +/* path_interface */ { HP_POP(path->blownpos, HP_path_blownpos) }, { HP_POP(path->search, HP_path_search) }, { HP_POP(path->search_long, HP_path_search_long) }, @@ -1998,7 +1998,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(path->distance, HP_path_distance) }, { HP_POP(path->check_distance_client, HP_path_check_distance_client) }, { HP_POP(path->distance_client, HP_path_distance_client) }, -/* pcg */ +/* pc_groups_interface */ { HP_POP(pcg->init, HP_pcg_init) }, { HP_POP(pcg->final, HP_pcg_final) }, { HP_POP(pcg->reload, HP_pcg_reload) }, @@ -2010,7 +2010,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pcg->get_name, HP_pcg_get_name) }, { HP_POP(pcg->get_level, HP_pcg_get_level) }, { HP_POP(pcg->get_idx, HP_pcg_get_idx) }, -/* pc */ +/* pc_interface */ { HP_POP(pc->init, HP_pc_init) }, { HP_POP(pc->final, HP_pc_final) }, { HP_POP(pc->get_dummy_sd, HP_pc_get_dummy_sd) }, @@ -2228,7 +2228,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->check_job_name, HP_pc_check_job_name) }, { HP_POP(pc->update_idle_time, HP_pc_update_idle_time) }, { HP_POP(pc->have_magnifier, HP_pc_have_magnifier) }, -/* libpcre */ +/* pcre_interface */ { HP_POP(libpcre->compile, HP_libpcre_compile) }, { HP_POP(libpcre->study, HP_libpcre_study) }, { HP_POP(libpcre->exec, HP_libpcre_exec) }, @@ -2237,7 +2237,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(libpcre->free_substring, HP_libpcre_free_substring) }, { HP_POP(libpcre->copy_named_substring, HP_libpcre_copy_named_substring) }, { HP_POP(libpcre->get_substring, HP_libpcre_get_substring) }, -/* pet */ +/* pet_interface */ { HP_POP(pet->init, HP_pet_init) }, { HP_POP(pet->final, HP_pet_final) }, { HP_POP(pet->hungry_val, HP_pet_hungry_val) }, @@ -2276,7 +2276,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pet->recovery_timer, HP_pet_recovery_timer) }, { HP_POP(pet->skill_support_timer, HP_pet_skill_support_timer) }, { HP_POP(pet->read_db, HP_pet_read_db) }, -/* quest */ +/* quest_interface */ { HP_POP(quest->init, HP_quest_init) }, { HP_POP(quest->final, HP_quest_final) }, { HP_POP(quest->reload, HP_quest_reload) }, @@ -2292,7 +2292,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(quest->clear, HP_quest_clear) }, { HP_POP(quest->read_db, HP_quest_read_db) }, { HP_POP(quest->read_db_sub, HP_quest_read_db_sub) }, -/* script */ +/* script_interface */ { HP_POP(script->init, HP_script_init) }, { HP_POP(script->final, HP_script_final) }, { HP_POP(script->reload, HP_script_reload) }, @@ -2462,7 +2462,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->run_use_script, HP_script_run_use_script) }, { HP_POP(script->run_item_equip_script, HP_script_run_item_equip_script) }, { HP_POP(script->run_item_unequip_script, HP_script_run_item_unequip_script) }, -/* searchstore */ +/* searchstore_interface */ { HP_POP(searchstore->open, HP_searchstore_open) }, { HP_POP(searchstore->query, HP_searchstore_query) }, { HP_POP(searchstore->querynext, HP_searchstore_querynext) }, @@ -2473,12 +2473,12 @@ struct HookingPointData HookingPoints[] = { { HP_POP(searchstore->queryremote, HP_searchstore_queryremote) }, { HP_POP(searchstore->clearremote, HP_searchstore_clearremote) }, { HP_POP(searchstore->result, HP_searchstore_result) }, -/* showmsg */ +/* showmsg_interface */ { HP_POP(showmsg->init, HP_showmsg_init) }, { HP_POP(showmsg->final, HP_showmsg_final) }, { HP_POP(showmsg->clearScreen, HP_showmsg_clearScreen) }, { HP_POP(showmsg->showMessageV, HP_showmsg_showMessageV) }, -/* skill */ +/* skill_interface */ { HP_POP(skill->init, HP_skill_init) }, { HP_POP(skill->final, HP_skill_final) }, { HP_POP(skill->reload, HP_skill_reload) }, @@ -2696,7 +2696,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(skill->get_requirement_off_unknown, HP_skill_get_requirement_off_unknown) }, { HP_POP(skill->get_requirement_item_unknown, HP_skill_get_requirement_item_unknown) }, { HP_POP(skill->get_requirement_unknown, HP_skill_get_requirement_unknown) }, -/* sockt */ +/* socket_interface */ { HP_POP(sockt->init, HP_sockt_init) }, { HP_POP(sockt->final, HP_sockt_final) }, { HP_POP(sockt->perform, HP_sockt_perform) }, @@ -2725,7 +2725,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sockt->trusted_ip_check, HP_sockt_trusted_ip_check) }, { HP_POP(sockt->net_config_read_sub, HP_sockt_net_config_read_sub) }, { HP_POP(sockt->net_config_read, HP_sockt_net_config_read) }, -/* SQL */ +/* sql_interface */ { HP_POP(SQL->Connect, HP_SQL_Connect) }, { HP_POP(SQL->GetTimeout, HP_SQL_GetTimeout) }, { HP_POP(SQL->GetColumnNames, HP_SQL_GetColumnNames) }, @@ -2758,7 +2758,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(SQL->StmtFreeResult, HP_SQL_StmtFreeResult) }, { HP_POP(SQL->StmtFree, HP_SQL_StmtFree) }, { HP_POP(SQL->StmtShowDebug_, HP_SQL_StmtShowDebug_) }, -/* status */ +/* status_interface */ { HP_POP(status->init, HP_status_init) }, { HP_POP(status->final, HP_status_final) }, { HP_POP(status->get_refine_chance, HP_status_get_refine_chance) }, @@ -2871,7 +2871,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(status->readdb_scconfig, HP_status_readdb_scconfig) }, { HP_POP(status->read_job_db, HP_status_read_job_db) }, { HP_POP(status->read_job_db_sub, HP_status_read_job_db_sub) }, -/* storage */ +/* storage_interface */ { HP_POP(storage->reconnect, HP_storage_reconnect) }, { HP_POP(storage->delitem, HP_storage_delitem) }, { HP_POP(storage->open, HP_storage_open) }, @@ -2885,7 +2885,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(storage->comp_item, HP_storage_comp_item) }, { HP_POP(storage->sortitem, HP_storage_sortitem) }, { HP_POP(storage->reconnect_sub, HP_storage_reconnect_sub) }, -/* StrBuf */ +/* stringbuf_interface */ { HP_POP(StrBuf->Malloc, HP_StrBuf_Malloc) }, { HP_POP(StrBuf->Init, HP_StrBuf_Init) }, { HP_POP(StrBuf->Vprintf, HP_StrBuf_Vprintf) }, @@ -2896,7 +2896,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(StrBuf->Clear, HP_StrBuf_Clear) }, { HP_POP(StrBuf->Destroy, HP_StrBuf_Destroy) }, { HP_POP(StrBuf->Free, HP_StrBuf_Free) }, -/* strlib */ +/* strlib_interface */ { HP_POP(strlib->jstrescape, HP_strlib_jstrescape) }, { HP_POP(strlib->jstrescapecpy, HP_strlib_jstrescapecpy) }, { HP_POP(strlib->jmemescapecpy, HP_strlib_jmemescapecpy) }, @@ -2912,7 +2912,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(strlib->safestrnlen_, HP_strlib_safestrnlen_) }, { HP_POP(strlib->strline_, HP_strlib_strline_) }, { HP_POP(strlib->bin2hex_, HP_strlib_bin2hex_) }, -/* sv */ +/* sv_interface */ { HP_POP(sv->parse_next, HP_sv_parse_next) }, { HP_POP(sv->parse, HP_sv_parse) }, { HP_POP(sv->split, HP_sv_split) }, @@ -2920,7 +2920,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sv->unescape_c, HP_sv_unescape_c) }, { HP_POP(sv->skip_escaped_c, HP_sv_skip_escaped_c) }, { HP_POP(sv->readdb, HP_sv_readdb) }, -/* sysinfo */ +/* sysinfo_interface */ { HP_POP(sysinfo->getpagesize, HP_sysinfo_getpagesize) }, { HP_POP(sysinfo->platform, HP_sysinfo_platform) }, { HP_POP(sysinfo->osversion, HP_sysinfo_osversion) }, @@ -2939,7 +2939,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(sysinfo->is_superuser, HP_sysinfo_is_superuser) }, { HP_POP(sysinfo->init, HP_sysinfo_init) }, { HP_POP(sysinfo->final, HP_sysinfo_final) }, -/* timer */ +/* timer_interface */ { HP_POP(timer->gettick, HP_timer_gettick) }, { HP_POP(timer->gettick_nocache, HP_timer_gettick_nocache) }, { HP_POP(timer->add, HP_timer_add) }, @@ -2953,7 +2953,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(timer->perform, HP_timer_perform) }, { HP_POP(timer->init, HP_timer_init) }, { HP_POP(timer->final, HP_timer_final) }, -/* trade */ +/* trade_interface */ { HP_POP(trade->request, HP_trade_request) }, { HP_POP(trade->ack, HP_trade_ack) }, { HP_POP(trade->check_impossible, HP_trade_check_impossible) }, @@ -2963,7 +2963,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(trade->ok, HP_trade_ok) }, { HP_POP(trade->cancel, HP_trade_cancel) }, { HP_POP(trade->commit, HP_trade_commit) }, -/* unit */ +/* unit_interface */ { HP_POP(unit->init, HP_unit_init) }, { HP_POP(unit->final, HP_unit_final) }, { HP_POP(unit->bl2ud, HP_unit_bl2ud) }, @@ -3012,7 +3012,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(unit->remove_map_pc, HP_unit_remove_map_pc) }, { HP_POP(unit->free_pc, HP_unit_free_pc) }, { HP_POP(unit->free, HP_unit_free) }, -/* vending */ +/* vending_interface */ { HP_POP(vending->init, HP_vending_init) }, { HP_POP(vending->final, HP_vending_final) }, { HP_POP(vending->close, HP_vending_close) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 71ced808b..669d405cc 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -23,7 +23,7 @@ * as it will get overwritten. */ -/* HCache */ +/* HCache_interface */ void HP_HCache_init(void) { int hIndex = 0; if( HPMHooks.count.HP_HCache_init_pre ) { @@ -104,7 +104,7 @@ FILE* HP_HCache_open(const char *file, const char *opt) { } return retVal___; } -/* atcommand */ +/* atcommand_interface */ void HP_atcommand_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_atcommand_init_pre ) { @@ -1077,7 +1077,7 @@ const char* HP_atcommand_msgsd(struct map_session_data *sd, int msg_number) { } return retVal___; } -/* battle */ +/* battle_interface */ void HP_battle_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_battle_init_pre ) { @@ -2580,7 +2580,7 @@ void HP_battle_calc_misc_attack_unknown(struct block_list *src, struct block_lis } return; } -/* bg */ +/* battleground_interface */ void HP_bg_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_bg_init_pre ) { @@ -3419,7 +3419,7 @@ void HP_bg_config_read(void) { } return; } -/* buyingstore */ +/* buyingstore_interface */ bool HP_buyingstore_setup(struct map_session_data *sd, unsigned char slots) { int hIndex = 0; bool retVal___ = false; @@ -3632,7 +3632,7 @@ unsigned int HP_buyingstore_getuid(void) { } return retVal___; } -/* channel */ +/* channel_interface */ int HP_channel_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -4185,7 +4185,7 @@ void HP_channel_config_read(void) { } return; } -/* chat */ +/* chat_interface */ bool HP_chat_create_pc_chat(struct map_session_data *sd, const char *title, const char *pass, int limit, bool pub) { int hIndex = 0; bool retVal___ = false; @@ -4537,7 +4537,7 @@ struct chat_data* HP_chat_create(struct block_list *bl, const char *title, const } return retVal___; } -/* chrif */ +/* chrif_interface */ void HP_chrif_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_chrif_init_pre ) { @@ -6416,7 +6416,7 @@ void HP_chrif_del_scdata_single(int account_id, int char_id, short type) { } return; } -/* clif */ +/* clif_interface */ int HP_clif_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -24172,7 +24172,7 @@ const char* HP_clif_get_bl_name(const struct block_list *bl) { } return retVal___; } -/* cmdline */ +/* cmdline_interface */ void HP_cmdline_init(void) { int hIndex = 0; if( HPMHooks.count.HP_cmdline_init_pre ) { @@ -24333,7 +24333,7 @@ const char* HP_cmdline_arg_source(struct CmdlineArgData *arg) { } return retVal___; } -/* console */ +/* console_interface */ void HP_console_init(void) { int hIndex = 0; if( HPMHooks.count.HP_console_init_pre ) { @@ -24438,7 +24438,7 @@ void HP_console_display_gplnotice(void) { } return; } -/* core */ +/* core_interface */ void HP_core_shutdown_callback(void) { int hIndex = 0; if( HPMHooks.count.HP_core_shutdown_callback_pre ) { @@ -24465,7 +24465,7 @@ void HP_core_shutdown_callback(void) { } return; } -/* DB */ +/* db_interface */ enum DBOptions HP_DB_fix_options(enum DBType type, enum DBOptions options) { int hIndex = 0; enum DBOptions retVal___ = DB_OPT_BASE; @@ -24985,7 +24985,7 @@ void HP_DB_final(void) { } return; } -/* duel */ +/* duel_interface */ int HP_duel_create(struct map_session_data *sd, const unsigned int maxpl) { int hIndex = 0; int retVal___ = 0; @@ -25222,7 +25222,7 @@ void HP_duel_final(void) { } return; } -/* elemental */ +/* elemental_interface */ int HP_elemental_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -26094,7 +26094,7 @@ int HP_elemental_read_db(void) { } return retVal___; } -/* guild */ +/* guild_interface */ void HP_guild_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_guild_init_pre ) { @@ -28455,7 +28455,7 @@ void HP_guild_castle_reconnect_sub(void *key, void *data, va_list ap) { } return; } -/* gstorage */ +/* guild_storage_interface */ struct guild_storage* HP_gstorage_ensure(int guild_id) { int hIndex = 0; struct guild_storage* retVal___ = NULL; @@ -28893,7 +28893,7 @@ struct DBData HP_gstorage_create(union DBKey key, va_list args) { } return retVal___; } -/* homun */ +/* homunculus_interface */ void HP_homun_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_homun_init_pre ) { @@ -30146,7 +30146,7 @@ int8 HP_homun_get_intimacy_grade(struct homun_data *hd) { } return retVal___; } -/* instance */ +/* instance_interface */ void HP_instance_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_instance_init_pre ) { @@ -30636,7 +30636,7 @@ int HP_instance_destroy_timer(int tid, int64 tick, int id, intptr_t data) { } return retVal___; } -/* intif */ +/* intif_interface */ int HP_intif_parse(int fd) { int hIndex = 0; int retVal___ = 0; @@ -34116,7 +34116,7 @@ void HP_intif_pDeleteHomunculusOk(int fd) { } return; } -/* ircbot */ +/* irc_bot_interface */ void HP_ircbot_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_ircbot_init_pre ) { @@ -34538,7 +34538,7 @@ void HP_ircbot_usernick(int fd, char *cmd, char *source, char *target, char *msg } return; } -/* itemdb */ +/* itemdb_interface */ void HP_itemdb_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_itemdb_init_pre ) { @@ -36132,7 +36132,7 @@ bool HP_itemdb_lookup_const(const struct config_setting_t *it, const char *name, } return retVal___; } -/* libconfig */ +/* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; int retVal___ = 0; @@ -37959,7 +37959,7 @@ int HP_libconfig_lookup_mutable_string(const struct config_t *config, const char } return retVal___; } -/* logs */ +/* log_interface */ void HP_logs_pick_pc(struct map_session_data *sd, e_log_pick_type type, int amount, struct item *itm, struct item_data *data) { int hIndex = 0; if( HPMHooks.count.HP_logs_pick_pc_pre ) { @@ -38536,7 +38536,7 @@ bool HP_logs_should_log_item(int nameid, int amount, int refine, struct item_dat } return retVal___; } -/* mail */ +/* mail_interface */ void HP_mail_clear(struct map_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_mail_clear_pre ) { @@ -38777,7 +38777,7 @@ bool HP_mail_invalid_operation(struct map_session_data *sd) { } return retVal___; } -/* iMalloc */ +/* malloc_interface */ void HP_iMalloc_init(void) { int hIndex = 0; if( HPMHooks.count.HP_iMalloc_init_pre ) { @@ -39150,7 +39150,7 @@ void HP_iMalloc_init_messages(void) { } return; } -/* map */ +/* map_interface */ void HP_map_zone_init(void) { int hIndex = 0; if( HPMHooks.count.HP_map_zone_init_pre ) { @@ -42855,7 +42855,7 @@ void HP_map_zone_clear_single(struct map_zone_data *zone) { } return; } -/* mapindex */ +/* mapindex_interface */ int HP_mapindex_init(void) { int hIndex = 0; int retVal___ = 0; @@ -43097,7 +43097,7 @@ bool HP_mapindex_check_default(void) { } return retVal___; } -/* mapit */ +/* mapit_interface */ struct s_mapiterator* HP_mapit_alloc(enum e_mapitflags flags, enum bl_type types) { int hIndex = 0; struct s_mapiterator* retVal___ = NULL; @@ -43286,7 +43286,7 @@ bool HP_mapit_exists(struct s_mapiterator *iter) { } return retVal___; } -/* mapreg */ +/* mapreg_interface */ void HP_mapreg_init(void) { int hIndex = 0; if( HPMHooks.count.HP_mapreg_init_pre ) { @@ -43612,7 +43612,7 @@ bool HP_mapreg_config_read(const char *w1, const char *w2) { } return retVal___; } -/* mercenary */ +/* mercenary_interface */ void HP_mercenary_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_mercenary_init_pre ) { @@ -44285,7 +44285,7 @@ bool HP_mercenary_read_skill_db_sub(char *str[], int columns, int current) { } return retVal___; } -/* mob */ +/* mob_interface */ int HP_mob_init(bool mimimal) { int hIndex = 0; int retVal___ = 0; @@ -47137,7 +47137,7 @@ void HP_mob_destroy_mob_db(int index) { } return; } -/* npc_chat */ +/* npc_chat_interface */ int HP_npc_chat_sub(struct block_list *bl, va_list ap) { int hIndex = 0; int retVal___ = 0; @@ -47381,7 +47381,7 @@ void HP_npc_chat_finalize_pcrematch_entry(struct pcrematch_entry *e) { } return; } -/* npc */ +/* npc_interface */ int HP_npc_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -50390,7 +50390,7 @@ int HP_npc_secure_timeout_timer(int tid, int64 tick, int id, intptr_t data) { } return retVal___; } -/* nullpo */ +/* nullpo_interface */ void HP_nullpo_assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { int hIndex = 0; if( HPMHooks.count.HP_nullpo_assert_report_pre ) { @@ -50417,7 +50417,7 @@ void HP_nullpo_assert_report(const char *file, int line, const char *func, const } return; } -/* party */ +/* party_interface */ void HP_party_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_party_init_pre ) { @@ -51750,7 +51750,7 @@ int HP_party_db_final(union DBKey key, struct DBData *data, va_list ap) { } return retVal___; } -/* path */ +/* path_interface */ int HP_path_blownpos(struct block_list *bl, int16 m, int16 x0, int16 y0, int16 dx, int16 dy, int count) { int hIndex = 0; int retVal___ = 0; @@ -51940,7 +51940,7 @@ int HP_path_distance_client(int dx, int dy) { } return retVal___; } -/* pcg */ +/* pc_groups_interface */ void HP_pcg_init(void) { int hIndex = 0; if( HPMHooks.count.HP_pcg_init_pre ) { @@ -52235,7 +52235,7 @@ int HP_pcg_get_idx(GroupSettings *group) { } return retVal___; } -/* pc */ +/* pc_interface */ void HP_pc_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_pc_init_pre ) { @@ -58079,7 +58079,7 @@ int HP_pc_have_magnifier(struct map_session_data *sd) { } return retVal___; } -/* libpcre */ +/* pcre_interface */ pcre* HP_libpcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr) { int hIndex = 0; pcre* retVal___ = NULL; @@ -58294,7 +58294,7 @@ int HP_libpcre_get_substring(const char *subject, int *ovector, int stringcount, } return retVal___; } -/* pet */ +/* pet_interface */ int HP_pet_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -59332,7 +59332,7 @@ int HP_pet_read_db(void) { } return retVal___; } -/* quest */ +/* quest_interface */ void HP_quest_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_quest_init_pre ) { @@ -59739,7 +59739,7 @@ struct quest_db* HP_quest_read_db_sub(struct config_setting_t *cs, int n, const } return retVal___; } -/* script */ +/* script_interface */ void HP_script_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_script_init_pre ) { @@ -64375,7 +64375,7 @@ void HP_script_run_item_unequip_script(struct map_session_data *sd, struct item_ } return; } -/* searchstore */ +/* searchstore_interface */ bool HP_searchstore_open(struct map_session_data *sd, unsigned int uses, unsigned short effect) { int hIndex = 0; bool retVal___ = false; @@ -64640,7 +64640,7 @@ bool HP_searchstore_result(struct map_session_data *sd, unsigned int store_id, i } return retVal___; } -/* showmsg */ +/* showmsg_interface */ void HP_showmsg_init(void) { int hIndex = 0; if( HPMHooks.count.HP_showmsg_init_pre ) { @@ -64752,7 +64752,7 @@ int HP_showmsg_showMessageV(const char *string, va_list ap) { } return retVal___; } -/* skill */ +/* skill_interface */ int HP_skill_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -70726,7 +70726,7 @@ void HP_skill_get_requirement_unknown(struct status_change *sc, struct map_sessi } return; } -/* sockt */ +/* socket_interface */ void HP_sockt_init(void) { int hIndex = 0; if( HPMHooks.count.HP_sockt_init_pre ) { @@ -71473,7 +71473,7 @@ void HP_sockt_net_config_read(const char *filename) { } return; } -/* SQL */ +/* sql_interface */ int HP_SQL_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db) { int hIndex = 0; int retVal___ = 0; @@ -72344,7 +72344,7 @@ void HP_SQL_StmtShowDebug_(struct SqlStmt *self, const char *debug_file, const u } return; } -/* status */ +/* status_interface */ int HP_status_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -75365,7 +75365,7 @@ void HP_status_read_job_db_sub(int idx, const char *name, struct config_setting_ } return; } -/* storage */ +/* storage_interface */ void HP_storage_reconnect(void) { int hIndex = 0; if( HPMHooks.count.HP_storage_reconnect_pre ) { @@ -75719,7 +75719,7 @@ int HP_storage_reconnect_sub(union DBKey key, struct DBData *data, va_list ap) { } return retVal___; } -/* StrBuf */ +/* stringbuf_interface */ StringBuf* HP_StrBuf_Malloc(void) { int hIndex = 0; StringBuf* retVal___ = NULL; @@ -75992,7 +75992,7 @@ void HP_StrBuf_Free(StringBuf *self) { } return; } -/* strlib */ +/* strlib_interface */ char* HP_strlib_jstrescape(char *pt) { int hIndex = 0; char* retVal___ = NULL; @@ -76398,7 +76398,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { } return retVal___; } -/* sv */ +/* sv_interface */ int HP_sv_parse_next(struct s_svstate *svstate) { int hIndex = 0; int retVal___ = 0; @@ -76588,7 +76588,7 @@ bool HP_sv_readdb(const char *directory, const char *filename, char delim, int m } return retVal___; } -/* sysinfo */ +/* sysinfo_interface */ int HP_sysinfo_getpagesize(void) { int hIndex = 0; int retVal___ = 0; @@ -77072,7 +77072,7 @@ void HP_sysinfo_final(void) { } return; } -/* timer */ +/* timer_interface */ int64 HP_timer_gettick(void) { int hIndex = 0; int64 retVal___ = 0; @@ -77422,7 +77422,7 @@ void HP_timer_final(void) { } return; } -/* trade */ +/* trade_interface */ void HP_trade_request(struct map_session_data *sd, struct map_session_data *target_sd) { int hIndex = 0; if( HPMHooks.count.HP_trade_request_pre ) { @@ -77659,7 +77659,7 @@ void HP_trade_commit(struct map_session_data *sd) { } return; } -/* unit */ +/* unit_interface */ int HP_unit_init(bool minimal) { int hIndex = 0; int retVal___ = 0; @@ -78950,7 +78950,7 @@ int HP_unit_free(struct block_list *bl, clr_type clrtype) { } return retVal___; } -/* vending */ +/* vending_interface */ void HP_vending_init(bool minimal) { int hIndex = 0; if( HPMHooks.count.HP_vending_init_pre ) { -- cgit v1.2.3-70-g09d2 From ab42483e0450fb9a9bd904a8b50df559e099a773 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 31 Mar 2016 14:42:56 +0200 Subject: Updated GNU Make build system to support private headers Signed-off-by: Haru --- src/char/Makefile.in | 21 ++++++++++++--------- src/common/Makefile.in | 31 +++++++++++++++++-------------- src/login/Makefile.in | 21 ++++++++++++--------- src/map/Makefile.in | 21 ++++++++++++--------- src/plugins/Makefile.in | 3 ++- src/test/Makefile.in | 4 ++-- src/tool/Makefile.in | 4 ++-- 7 files changed, 59 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 8d9094f18..456f7e9d2 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ CONFIG_D = ../config CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. @@ -47,6 +47,7 @@ CHAR_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(CHAR_C))) CHAR_H = char.h HPMchar.h loginif.h mapif.h geoip.h inter.h int_auction.h int_elemental.h int_guild.h \ int_homun.h int_mail.h int_mercenary.h int_party.h int_pet.h \ int_quest.h int_storage.h pincode.h +CHAR_PH = HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) @@ -89,7 +90,7 @@ help: Makefile: Makefile.in @$(MAKE) -C ../.. src/char/Makefile -$(SYSINFO_INC): $(CHAR_C) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) +$(SYSINFO_INC): $(CHAR_C) $(CHAR_PH) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " MAKE $@" @$(MAKE) -C ../.. sysinfo @@ -112,12 +113,6 @@ char-server: ../../char-server@EXEEXT@ @$(CC) @STATIC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_D)/obj_sql/common_sql.a \ $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ -# char object files - -obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql - @echo " CC $<" - @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - # missing object files $(COMMON_D)/obj_all/common.a: @echo " MAKE $@" @@ -134,3 +129,11 @@ $(MT19937AR_OBJ): $(LIBCONFIG_OBJ): @echo " MAKE $@" @$(MAKE) -C $(LIBCONFIG_D) + +.SECONDEXPANSION: + +# char object files + +obj_sql/%.o: %.c $$(filter %.p.h, $(CHAR_PH)) $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql + @echo " CC $<" + @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 9d4b2d044..4580f70b8 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -51,6 +51,7 @@ COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \ grfio.h hercules.h HPM.h HPMi.h memmgr.h mapindex.h md5calc.h \ mmo.h mutex.h nullpo.h random.h showmsg.h socket.h spinlock.h \ sql.h strlib.h sysinfo.h thread.h timer.h utils.h winapi.h +COMMON_PH = COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h @@ -95,7 +96,7 @@ help: Makefile: Makefile.in @$(MAKE) -C ../.. src/common/Makefile -$(SYSINFO_INC): $(COMMON_C) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) +$(SYSINFO_INC): $(COMMON_C) $(COMMON_PH) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " MAKE $@" @$(MAKE) -C ../.. sysinfo @@ -131,25 +132,27 @@ common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a Makefile -obj_all/sysinfo.o: sysinfo.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) $(SYSINFO_INC) | obj_all +# missing object files +$(MT19937AR_OBJ): + @echo " MAKE $@" + @$(MAKE) -C $(MT19937AR_D) + +$(LIBCONFIG_OBJ): + @echo " MAKE $@" + @$(MAKE) -C $(LIBCONFIG_D) + +.SECONDEXPANSION: + +obj_all/sysinfo.o: sysinfo.c $(filter sysinfo.p.h, $(COMMON_PH)) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) $(SYSINFO_INC) | obj_all obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all @echo " CC $<" @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_all/mini%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all +obj_all/mini%.o: %.c $$(filter %.p.h, $(COMMON_PH)) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all @echo " CC $<" @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(CONFIG_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_sql +obj_sql/%.o: %.c $$(filter %.p.h, $(COMMON_PH)) $(COMMON_H) $(COMMON_SQL_H) $(CONFIG_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_sql @echo " CC $<" @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -# missing object files -$(MT19937AR_OBJ): - @echo " MAKE $@" - @$(MAKE) -C $(MT19937AR_D) - -$(LIBCONFIG_OBJ): - @echo " MAKE $@" - @$(MAKE) -C $(LIBCONFIG_D) diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 6560e6497..8e10be6d8 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ CONFIG_D = ../config CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. @@ -43,6 +43,7 @@ MT19937AR_H = $(MT19937AR_D)/mt19937ar.h LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c login.c loginlog_sql.c LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C))) LOGIN_H = login.h account.h HPMlogin.h ipban.h loginlog.h +LOGIN_PH = HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) @@ -85,7 +86,7 @@ help: Makefile: Makefile.in @$(MAKE) -C ../.. src/login/Makefile -$(SYSINFO_INC): $(LOGIN_C) $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) +$(SYSINFO_INC): $(LOGIN_C) $(LOGIN_PH) $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " MAKE $@" @$(MAKE) -C ../.. sysinfo @@ -108,12 +109,6 @@ login-server: ../../login-server@EXEEXT@ @$(CC) @STATIC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_D)/obj_sql/common_sql.a \ $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ -# login object files - -obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql - @echo " CC $<" - @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - # missing object files $(COMMON_D)/obj_all/common.a: @echo " MAKE $@" @@ -130,3 +125,11 @@ $(MT19937AR_OBJ): $(LIBCONFIG_OBJ): @echo " MAKE $@" @$(MAKE) -C $(LIBCONFIG_D) + +.SECONDEXPANSION: + +# login object files + +obj_sql/%.o: %.c $$(filter %.p.h, $(LOGIN_PH)) $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql + @echo " CC $<" + @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/map/Makefile.in b/src/map/Makefile.in index b5a3d4461..ff582d2f9 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ CONFIG_D = ../config CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. @@ -53,6 +53,7 @@ MAP_H = atcommand.h battle.h battleground.h buyingstore.h channel.h chat.h \ mercenary.h mob.h npc.h packets.h packets_struct.h party.h path.h \ pc.h pc_groups.h pet.h quest.h script.h searchstore.h skill.h \ status.h storage.h trade.h unit.h vending.h +MAP_PH = HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) @@ -95,7 +96,7 @@ help: Makefile: Makefile.in @$(MAKE) -C ../.. src/map/Makefile -$(SYSINFO_INC): $(MAP_C) $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) +$(SYSINFO_INC): $(MAP_C) $(MAP_PH) $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " MAKE $@" @$(MAKE) -C ../.. sysinfo @@ -118,12 +119,6 @@ map-server: ../../map-server@EXEEXT@ @$(CC) @STATIC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) $(COMMON_D)/obj_sql/common_sql.a \ $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ -# map object files - -obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql - @echo " CC $<" - @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - # missing object files $(COMMON_D)/obj_all/common.a: @echo " MAKE $@" @@ -140,3 +135,11 @@ $(MT19937AR_OBJ): $(LIBCONFIG_OBJ): @echo " MAKE $@" @$(MAKE) -C $(LIBCONFIG_D) + +.SECONDEXPANSION: + +# map object files + +obj_sql/%.o: %.c $$(filter %.p.h, $(MAP_PH)) $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql + @echo " CC $<" + @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 3fe38b6bc..c3baa2f30 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2013-2015 Hercules Dev Team +# Copyright (C) 2013-2016 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 @@ -46,6 +46,7 @@ ALLPLUGINS = $(filter-out HPMHooking, $(basename $(wildcard *.c))) $(HPMHOOKING) PLUGINS = sample db2sql HPMHooking_char HPMHooking_login HPMHooking_map $(MYPLUGINS) COMMON_D = ../common +# Includes private headers (plugins might need them) COMMON_H = $(wildcard $(COMMON_D)/*.h) COMMON_INCLUDE = -I.. diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 6d2187733..c8006e5cf 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ CONFIG_D = ../config CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 614ede4b7..eb1362780 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,7 +1,7 @@ # This file is part of Hercules. # http://herc.ws - http://github.com/HerculesWS/Hercules # -# Copyright (C) 2012-2015 Hercules Dev Team +# Copyright (C) 2012-2016 Hercules Dev Team # Copyright (C) Athena Dev Teams # # Hercules is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ CONFIG_D = ../config CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h) COMMON_D = ../common -COMMON_H = $(wildcard $(COMMON_D)/*.h) +COMMON_H = $(filter-out %.p.h, $(wildcard $(COMMON_D)/*.h)) SYSINFO_INC = $(COMMON_D)/sysinfo.inc COMMON_INCLUDE = -I.. -- cgit v1.2.3-70-g09d2 From d04db4e48cc76accc559bbb30451b25936289a0d Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 31 Mar 2016 04:16:15 +0200 Subject: Added const qualifier to the input parameter of bin2hex Signed-off-by: Haru --- src/common/strlib.c | 7 +++---- src/common/strlib.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/common/strlib.c b/src/common/strlib.c index 997b01ffa..8f164f2e9 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -424,13 +424,12 @@ int strlib_strline(const char *str, size_t pos) /// @param output Output string /// @param input Binary input buffer /// @param count Number of bytes to convert -bool strlib_bin2hex(char *output, unsigned char *input, size_t count) +bool strlib_bin2hex(char *output, const unsigned char *input, size_t count) { char toHex[] = "0123456789abcdef"; size_t i; - for( i = 0; i < count; ++i ) - { + for (i = 0; i < count; ++i) { *output++ = toHex[(*input & 0xF0) >> 4]; *output++ = toHex[(*input & 0x0F) >> 0]; ++input; diff --git a/src/common/strlib.h b/src/common/strlib.h index c523f5d86..36dceef2d 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -125,7 +125,7 @@ struct strlib_interface { /// Produces the hexadecimal representation of the given input. /// The output buffer must be at least count*2+1 in size. /// Returns true on success, false on failure. - bool (*bin2hex_) (char* output, unsigned char* input, size_t count); + bool (*bin2hex_) (char *output, const unsigned char *input, size_t count); }; struct stringbuf_interface { -- cgit v1.2.3-70-g09d2 From 1c6b5afe8a2926b2364d85d122c3a56ca526e98e Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 31 Mar 2016 04:29:04 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 6 +++--- src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 6 +++--- src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index 8a0e334a7..04dc90c6c 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -17747,11 +17747,11 @@ int HP_strlib_strline_(const char *str, size_t pos) { } return retVal___; } -bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { +bool HP_strlib_bin2hex_(char *output, const unsigned char *input, size_t count) { int hIndex = 0; bool retVal___ = false; if( HPMHooks.count.HP_strlib_bin2hex__pre ) { - bool (*preHookFunc) (char *output, unsigned char *input, size_t *count); + bool (*preHookFunc) (char *output, const unsigned char *input, size_t *count); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_strlib_bin2hex__pre[hIndex].func; @@ -17766,7 +17766,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { retVal___ = HPMHooks.source.strlib.bin2hex_(output, input, count); } if( HPMHooks.count.HP_strlib_bin2hex__post ) { - bool (*postHookFunc) (bool retVal___, char *output, unsigned char *input, size_t *count); + bool (*postHookFunc) (bool retVal___, char *output, const unsigned char *input, size_t *count); for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_strlib_bin2hex__post[hIndex].func; retVal___ = postHookFunc(retVal___, output, input, &count); diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 44f08fe22..bd33f0d42 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -7019,11 +7019,11 @@ int HP_strlib_strline_(const char *str, size_t pos) { } return retVal___; } -bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { +bool HP_strlib_bin2hex_(char *output, const unsigned char *input, size_t count) { int hIndex = 0; bool retVal___ = false; if( HPMHooks.count.HP_strlib_bin2hex__pre ) { - bool (*preHookFunc) (char *output, unsigned char *input, size_t *count); + bool (*preHookFunc) (char *output, const unsigned char *input, size_t *count); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_strlib_bin2hex__pre[hIndex].func; @@ -7038,7 +7038,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { retVal___ = HPMHooks.source.strlib.bin2hex_(output, input, count); } if( HPMHooks.count.HP_strlib_bin2hex__post ) { - bool (*postHookFunc) (bool retVal___, char *output, unsigned char *input, size_t *count); + bool (*postHookFunc) (bool retVal___, char *output, const unsigned char *input, size_t *count); for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_strlib_bin2hex__post[hIndex].func; retVal___ = postHookFunc(retVal___, output, input, &count); diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 669d405cc..fa7b192c6 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -76371,11 +76371,11 @@ int HP_strlib_strline_(const char *str, size_t pos) { } return retVal___; } -bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { +bool HP_strlib_bin2hex_(char *output, const unsigned char *input, size_t count) { int hIndex = 0; bool retVal___ = false; if( HPMHooks.count.HP_strlib_bin2hex__pre ) { - bool (*preHookFunc) (char *output, unsigned char *input, size_t *count); + bool (*preHookFunc) (char *output, const unsigned char *input, size_t *count); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_strlib_bin2hex__pre[hIndex].func; @@ -76390,7 +76390,7 @@ bool HP_strlib_bin2hex_(char *output, unsigned char *input, size_t count) { retVal___ = HPMHooks.source.strlib.bin2hex_(output, input, count); } if( HPMHooks.count.HP_strlib_bin2hex__post ) { - bool (*postHookFunc) (bool retVal___, char *output, unsigned char *input, size_t *count); + bool (*postHookFunc) (bool retVal___, char *output, const unsigned char *input, size_t *count); for(hIndex = 0; hIndex < HPMHooks.count.HP_strlib_bin2hex__post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_strlib_bin2hex__post[hIndex].func; retVal___ = postHookFunc(retVal___, output, input, &count); -- cgit v1.2.3-70-g09d2 From 480e959347ac5903d9c0b659376db139792eb44b Mon Sep 17 00:00:00 2001 From: hemagx Date: Mon, 28 Mar 2016 21:54:46 +0200 Subject: Rewrite client interface for login server (part 1) Rewritten incoming/outgoing packet handlers to use structs instead of manipulating the WFIFO buffer bytes directly Signed-off-by: Haru --- src/common/mmo.h | 7 +- src/login/login.c | 613 ++++++++++++++++++++++++++++++++++------------- src/login/login.h | 4 +- src/map/packets_struct.h | 7 +- 4 files changed, 454 insertions(+), 177 deletions(-) (limited to 'src') diff --git a/src/common/mmo.h b/src/common/mmo.h index 7df52e450..a2080d900 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -213,11 +213,6 @@ #define JOBL_BABY 0x2000 //8192 #define JOBL_THIRD 0x4000 //16384 -//Packet DB -#define MIN_PACKET_DB 0x0064 //what's the point of minimum packet id ? [hemagx] -#define MAX_PACKET_DB 0x0F00 -#define MAX_PACKET_POS 20 - #define SCRIPT_VARNAME_LENGTH 32 ///< Maximum length of a script variable #define INFINITE_DURATION (-1) // Infinite duration for status changes diff --git a/src/login/login.c b/src/login/login.c index f7babde86..27cdb1fa3 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -48,6 +48,192 @@ struct login_interface *login; struct Login_Config login_config_; struct mmo_char_server server[MAX_SERVERS]; // char server data +// Packet DB +#define MIN_PACKET_DB 0x0064 +#define MAX_PACKET_DB 0x08ff + +/// 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_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_REFUSE_LOGIN = 0x006a, + PACKET_ID_SC_NOTIFY_BAN = 0x0081, + PACKET_ID_AC_ACK_HASH = 0x01dc, + PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, +}; + +/* 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 + +struct packet_CA_LOGIN { + int16 packet_id; + uint32 version; + char id[24]; + char password[24]; + uint8 clienttype; +} __attribute__((packed)); + +struct packet_CA_LOGIN2 { + int16 packet_id; + uint32 version; + char id[24]; + uint8 password_md5[16]; + uint8 clienttype; +} __attribute__((packed)); + +struct packet_CA_LOGIN3 { + int16 packet_id; + uint32 version; + char id[24]; + uint8 password_md5[16]; + uint8 clienttype; + uint8 clientinfo; +} __attribute__((packed)); + +struct packet_CA_LOGIN4 { + int16 packet_id; + uint32 version; + char id[24]; + uint8 password_md5[16]; + uint8 clienttype; + char mac_address[13]; +} __attribute__((packed)); + +struct packet_CA_LOGIN_PCBANG { + int16 packet_id; + uint32 version; + char id[24]; + char password[24]; + uint8 clienttype; + char ip[16]; + char mac_address[13]; +} __attribute__((packed)); + +struct packet_CA_LOGIN_HAN { + int16 packet_id; + uint32 version; + char id[24]; + char password[24]; + uint8 clienttype; + char ip[16]; + char mac_address[13]; + uint8 is_han_game_user; +} __attribute__((packed)); + +struct packet_CA_SSO_LOGIN_REQ { + int16 packet_id; + int16 packet_len; + uint32 version; + uint8 clienttype; + char id[24]; + char password[27]; + int8 mac_address[17]; + char ip[15]; + char t1[]; +} __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 + +struct packet_CA_CONNECT_INFO_CHANGED { + int16 packet_id; + char id[24]; +} __attribute__((packed)); + +struct packet_CA_EXE_HASHCHECK { + int16 packet_id; + uint8 hash_value[16]; +} __attribute__((packed)); + +struct packet_CA_REQ_HASH { + int16 packet_id; +} __attribute__((packed)); + +struct packet_CA_CHARSERVERCONNECT { + int16 packet_id; + char userid[24]; + char password[24]; + int32 unknown; + int32 ip; + int16 port; + char name[20]; + int16 unknown2; + int16 type; + int16 new; +} __attribute__((packed)); + +struct packet_SC_NOTIFY_BAN { + int16 packet_id; + uint8 error_code; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN { + int16 packet_id; + uint8 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN_R2 { + int16 packet_id; + uint32 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_ACCEPT_LOGIN { + int16 packet_id; + int16 packet_len; + int32 auth_code; + uint32 aid; + uint32 user_level; + uint32 last_login_ip; + char last_login_time[26]; + uint8 sex; + struct { + uint32 ip; + int16 port; + char name[20]; + uint16 usercount; + uint16 state; + uint16 property; + } server_list[]; +} __attribute__((packed)); + +struct packet_AC_ACK_HASH { + int16 packet_id; + int16 packet_len; + uint8 secret[]; +} __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 + struct Account_engine account_engine[] = { {account_db_sql, NULL} }; @@ -1180,12 +1366,14 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return -1; // account OK } -void login_connection_problem(int fd, uint8 status) +void login_connection_problem(int fd, uint8 error) { - WFIFOHEAD(fd,3); - WFIFOW(fd,0) = 0x81; - WFIFOB(fd,2) = status; - WFIFOSET(fd,3); + struct packet_SC_NOTIFY_BAN *packet = NULL; + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = PACKET_ID_SC_NOTIFY_BAN; + packet->error_code = error; + WFIFOSET(fd, sizeof(*packet)); } void login_kick(struct login_session_data* sd) @@ -1265,38 +1453,45 @@ void login_auth_ok(struct login_session_data* sd) login_log(ip, sd->userid, 100, "login ok"); ShowStatus("Connection of the account '%s' accepted.\n", sd->userid); - WFIFOHEAD(fd,47+32*server_num); - WFIFOW(fd,0) = 0x69; - WFIFOW(fd,2) = 47+32*server_num; - WFIFOL(fd,4) = sd->login_id1; - WFIFOL(fd,8) = sd->account_id; - 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 < ARRAYLENGTH(server); ++i) { - uint32 subnet_char_ip; - - if (!sockt->session_is_valid(server[i].fd)) - continue; + { + struct packet_AC_ACCEPT_LOGIN *packet = NULL; + int length = sizeof(*packet) + sizeof(packet->server_list[0]) * server_num; + ip = sockt->session[sd->fd]->client_addr; + + // Allocate the packet + WFIFOHEAD(sd->fd, length); + packet = WP2PTR(sd->fd); + + packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN; + packet->packet_len = length; + packet->auth_code = sd->login_id1; + packet->aid = sd->account_id; + packet->user_level = sd->login_id2; + packet->last_login_ip = 0; // Not used anymore + memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // not used anymore + packet->sex = sex_str2num(sd->sex); + for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { + uint32 subnet_char_ip; + + if (!sockt->session_is_valid(server[i].fd)) + continue; - subnet_char_ip = login->lan_subnet_check(ip); - WFIFOL(fd,47+n*32) = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); - WFIFOW(fd,47+n*32+4) = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] - memcpy(WFIFOP(fd,47+n*32+6), server[i].name, 20); - WFIFOW(fd,47+n*32+26) = server[i].users; + subnet_char_ip = login->lan_subnet_check(ip); + packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); + packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] + safestrncpy(packet->server_list[n].name, server[i].name, 20); + packet->server_list[n].usercount = server[i].users; - if( server[i].type == CST_PAYING && sd->expiration_time > time(NULL) ) - WFIFOW(fd,47+n*32+28) = CST_NORMAL; - else - WFIFOW(fd,47+n*32+28) = server[i].type; + if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) + packet->server_list[n].property = CST_NORMAL; + else + packet->server_list[n].property = server[i].type; - WFIFOW(fd,47+n*32+30) = server[i].new_; - n++; + packet->server_list[n].state = server[i].new_; + ++n; + } + WFIFOSET(sd->fd, length); } - WFIFOSET(fd,47+32*server_num); // create temporary auth entry CREATE(node, struct login_auth_node, 1); @@ -1365,121 +1560,191 @@ void login_auth_failed(struct login_session_data* sd, int result) ipban_log(ip); // log failed password attempt #if PACKETVER >= 20120000 /* not sure when this started */ - WFIFOHEAD(fd,26); - WFIFOW(fd,0) = 0x83e; - WFIFOL(fd,2) = result; - if( result != 6 ) - memset(WFIFOP(fd,6), '\0', 20); - else { // 6 = Your are Prohibited to log in until %s - struct mmo_account acc; - time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; - timestamp2string(WFIFOP(fd,6), 20, unban_time, login->config->date_format); - } - WFIFOSET(fd,26); + struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL; + int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R2; #else - WFIFOHEAD(fd,23); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = (uint8)result; - if( result != 6 ) - memset(WFIFOP(fd,3), '\0', 20); - else { // 6 = Your are Prohibited to log in until %s + struct packet_AC_REFUSE_LOGIN *packet = NULL; + int packet_id = PACKET_ID_AC_REFUSE_LOGIN; +#endif + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = packet_id; + packet->error_code = result; + if (result == 6) { struct mmo_account acc; time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; - timestamp2string(WFIFOP(fd,3), 20, unban_time, login->config->date_format); + timestamp2string(packet->block_date, sizeof(packet->block_date), unban_time, login->config->date_format); + } else { + memset(packet->block_date, '\0', sizeof(packet->block_date)); } - WFIFOSET(fd,23); -#endif + WFIFOSET(fd, sizeof(*packet)); } -void login_login_error(int fd, uint8 status) +void login_login_error(int fd, uint8 error) { - WFIFOHEAD(fd,23); - WFIFOW(fd,0) = 0x6a; - WFIFOB(fd,2) = status; - WFIFOSET(fd,23); + struct packet_AC_REFUSE_LOGIN *packet = NULL; + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = PACKET_ID_AC_REFUSE_LOGIN; + packet->error_code = error; + memset(packet->block_date, '\0', sizeof(packet->block_date)); + WFIFOSET(fd, sizeof(*packet)); } +// CA_CONNECT_INFO_CHANGED void login_parse_ping(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); void login_parse_ping(int fd, struct login_session_data* sd) { - RFIFOSKIP(fd,26); + RFIFOSKIP(fd, sizeof(struct packet_CA_CONNECT_INFO_CHANGED)); } +// CA_EXE_HASHCHECK void login_parse_client_md5(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); void login_parse_client_md5(int fd, struct login_session_data* sd) { + const struct packet_CA_EXE_HASHCHECK *packet = RP2PTR(fd); sd->has_client_hash = 1; - memcpy(sd->client_hash, RFIFOP(fd, 2), 16); - - RFIFOSKIP(fd,18); + memcpy(sd->client_hash, packet->hash_value, 16); + RFIFOSKIP(fd,sizeof(*packet)); } bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) __attribute__((nonnull (2))); bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) { - uint32 version; - char username[NAME_LENGTH]; - char password[PASSWD_LEN]; - unsigned char passhash[16]; - uint8 clienttype; int result; uint16 command = RFIFOW(fd,0); - bool israwpass = (command==0x0064 || command==0x0277 || command==0x02b0 || command == 0x0825); - // Shinryo: For the time being, just use token as password. - if(command == 0x0825) + switch (command) { + case PACKET_ID_CA_SSO_LOGIN_REQ: { - const char *accname = RFIFOP(fd, 9); - const char *token = RFIFOP(fd, 0x5C); - size_t uAccLen = strlen(accname); - size_t uTokenLen = RFIFOREST(fd) - 0x5C; + const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd); + int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet); - version = RFIFOL(fd,4); - - if(uAccLen <= 0 || uTokenLen <= 0) { + if (tokenlen > PASSWD_LEN || tokenlen < 1) { + RFIFOSKIP(fd, RFIFOREST(fd)); // assume no other packet was sent login->auth_failed(sd, 3); return true; } - safestrncpy(username, accname, NAME_LENGTH); - safestrncpy(password, token, min(uTokenLen+1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary - clienttype = RFIFOB(fd, 8); + sd->clienttype = packet->clienttype; + sd->version = packet->version; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary + + RFIFOSKIP(fd, sizeof(*packet)); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; } - else + break; + case PACKET_ID_CA_LOGIN: { - version = RFIFOL(fd,2); - safestrncpy(username, RFIFOP(fd,6), NAME_LENGTH); - if( israwpass ) - { - safestrncpy(password, RFIFOP(fd,30), NAME_LENGTH); - clienttype = RFIFOB(fd,54); - } - else - { - memcpy(passhash, RFIFOP(fd,30), 16); - clienttype = RFIFOB(fd,46); - } + const struct packet_CA_LOGIN *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + RFIFOSKIP(fd, sizeof(*packet)); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + } + break; + case PACKET_ID_CA_LOGIN2: + { + const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; + + RFIFOSKIP(fd, sizeof(*packet)); + } + break; + case PACKET_ID_CA_LOGIN3: + { + const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* sd->clientinfo = packet->clientinfo; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; + + RFIFOSKIP(fd, sizeof(*packet)); } - RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent + break; + case PACKET_ID_CA_LOGIN4: + { + const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; - sd->clienttype = clienttype; - sd->version = version; - safestrncpy(sd->userid, username, NAME_LENGTH); - if( israwpass ) + RFIFOSKIP(fd, sizeof(*packet)); + } + break; + case PACKET_ID_CA_LOGIN_PCBANG: { - ShowStatus("Request for connection of %s (ip: %s).\n", sd->userid, ip); - safestrncpy(sd->passwd, password, PASSWD_LEN); + const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + RFIFOSKIP(fd, sizeof(*packet)); + if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; } - else + break; + + case PACKET_ID_CA_LOGIN_HAN: { - ShowStatus("Request for connection (passwdenc mode) of %s (ip: %s).\n", sd->userid, ip); - bin2hex(sd->passwd, passhash, 16); // raw binary data here! - sd->passwdenc = PASSWORDENC; + const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + /* sd->ishan = packet->is_han_game_user; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + RFIFOSKIP(fd, sizeof(*packet)); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + } + break; + default: + RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent + login->auth_failed(sd, 3); // send "rejected from server" + return true; } + ShowStatus("Request for connection %sof %s (ip: %s).\n", sd->passwdenc == PASSWORDENC ? " (passwdenc mode)" : "", sd->userid, ip); + if (sd->passwdenc != PWENC_NONE && login->config->use_md5_passwds) { login->auth_failed(sd, 3); // send "rejected from server" return true; @@ -1497,16 +1762,22 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char void login_send_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); void login_send_coding_key(int fd, struct login_session_data* sd) { - WFIFOHEAD(fd,4 + sd->md5keylen); - WFIFOW(fd,0) = 0x01dc; - WFIFOW(fd,2) = 4 + sd->md5keylen; - memcpy(WFIFOP(fd,4), sd->md5key, sd->md5keylen); - WFIFOSET(fd,WFIFOW(fd,2)); + 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_len = size; + memcpy(packet->secret, sd->md5key, sd->md5keylen); + WFIFOSET(fd, size); } +// CA_REQ_HASH void login_parse_request_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); void login_parse_request_coding_key(int fd, struct login_session_data* sd) { + RFIFOSKIP(fd, sizeof(struct packet_CA_REQ_HASH)); memset(sd->md5key, '\0', sizeof(sd->md5key)); sd->md5keylen = (uint16)(12 + rnd() % 4); MD5_Salt(sd->md5keylen, sd->md5key); @@ -1588,21 +1859,18 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const //---------------------------------------------------------------------------------------- int login_parse_login(int fd) { - struct login_session_data* sd = (struct login_session_data*)sockt->session[fd]->session_data; - + struct login_session_data *sd = NULL; char ip[16]; uint32 ipl = sockt->session[fd]->client_addr; sockt->ip2str(ipl, ip); - if( sockt->session[fd]->flag.eof ) - { + if (sockt->session[fd]->flag.eof) { ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip); sockt->close(fd); return 0; } - if( sd == NULL ) - { + if ((sd = sockt->session[fd]->session_data) == NULL) { // Perform ip-ban check if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) { ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); @@ -1614,81 +1882,90 @@ int login_parse_login(int fd) // create a session for this new connection CREATE(sockt->session[fd]->session_data, struct login_session_data, 1); - sd = (struct login_session_data*)sockt->session[fd]->session_data; + sd = sockt->session[fd]->session_data; sd->fd = fd; } while (RFIFOREST(fd) >= 2) { - uint16 command = RFIFOW(fd,0); + int16 packet_id = RFIFOW(fd, 0); + int packet_len = (int)RFIFOREST(fd); + + if (packet_len < 2) + return 0; if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { - int result = HPM->parse_packets(fd,command,hpParse_Login); + int result = HPM->parse_packets(fd, packet_id, hpParse_Login); if (result == 1) continue; if (result == 2) return 0; } - switch (command) { - - case 0x0200: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. - if (RFIFOREST(fd) < 26) + switch (packet_id) { + case PACKET_ID_CA_CONNECT_INFO_CHANGED: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. + if (packet_len < (int)sizeof(struct packet_CA_CONNECT_INFO_CHANGED)) return 0; login->parse_ping(fd, sd); - break; - - // client md5 hash (binary) - case 0x0204: // S 0204 .16B (kRO 2004-05-31aSakexe langtype 0 and 6) - if (RFIFOREST(fd) < 18) + break; + case PACKET_ID_CA_EXE_HASHCHECK: // S 0204 .16B (kRO 2004-05-31aSakexe langtype 0 and 6) + if (packet_len < (int)sizeof(struct packet_CA_EXE_HASHCHECK)) return 0; - login->parse_client_md5(fd, sd); - break; - - // 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) - case 0x0825: // S 0825 .W .L .B .24B .27B .17B .15B .(packetsize - 0x5C)B - { - size_t packet_len = RFIFOREST(fd); - - if( (command == 0x0064 && packet_len < 55) - || (command == 0x0277 && packet_len < 84) - || (command == 0x02b0 && packet_len < 85) - || (command == 0x01dd && packet_len < 47) - || (command == 0x01fa && packet_len < 48) - || (command == 0x027c && packet_len < 60) - || (command == 0x0825 && (packet_len < 4 || packet_len < RFIFOW(fd, 2))) ) + break; + case PACKET_ID_CA_LOGIN: // S 0064 .L .24B .24B .B + if (packet_len < (int)sizeof(struct packet_CA_LOGIN)) return 0; - } - { if (login->parse_client_login(fd, sd, ip)) return 0; - } - break; - - case 0x01db: // Sending request of the coding key - RFIFOSKIP(fd,2); - { + break; + case PACKET_ID_CA_LOGIN_PCBANG: // S 0277 .L .24B .24B .B .16B .13B + if (packet_len < (int)sizeof(struct packet_CA_LOGIN_PCBANG)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_LOGIN_HAN: // S 02b0 .L .24B .24B .B .16B .13B .B + if (packet_len < (int)sizeof(struct packet_CA_LOGIN_HAN)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_LOGIN2: // S 01dd .L .24B .16B .B + if (packet_len < (int)sizeof(struct packet_CA_LOGIN2)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_LOGIN3: // S 01fa .L .24B .16B .B .B(index of the connection in the clientinfo file (+10 if the command-line contains "pc")) + if (packet_len < (int)sizeof(struct packet_CA_LOGIN3)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_LOGIN4: // S 027c .L .24B .16B .B .13B(junk) + if (packet_len < (int)sizeof(struct packet_CA_LOGIN4)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_SSO_LOGIN_REQ: // S 0825 .W .L .B .24B .27B .17B .15B .(packetsize - 0x5C)B + if (packet_len < (int)sizeof(struct packet_CA_SSO_LOGIN_REQ) || packet_len < RFIFOW(fd, 2)) + return 0; + if (login->parse_client_login(fd, sd, ip)) + return 0; + break; + case PACKET_ID_CA_REQ_HASH: + if (packet_len < (int)sizeof(struct packet_CA_REQ_HASH)) + return 0; login->parse_request_coding_key(fd, sd); - } - break; - - case 0x2710: // Connection request of a char-server - if (RFIFOREST(fd) < 86) + break; + case PACKET_ID_CA_CHARSERVERCONNECT: + if (packet_len < (int)sizeof(struct packet_CA_CHARSERVERCONNECT)) return 0; - { login->parse_request_connection(fd, sd, ip, ipl); - } - return 0; // processing will continue elsewhere - + return 0; // processing will continue elsewhere default: - ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, command); + ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, (unsigned int)packet_id); sockt->eof(fd); return 0; } diff --git a/src/login/login.h b/src/login/login.h index 1aca47c85..0676aee1f 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -196,11 +196,11 @@ struct login_interface { bool (*fromchar_parse_wrong_pincode) (int fd); void (*fromchar_parse_accinfo) (int fd); int (*parse_fromchar) (int fd); - void (*connection_problem) (int fd, uint8 status); + void (*connection_problem) (int fd, uint8 error); void (*kick) (struct login_session_data* sd); void (*auth_ok) (struct login_session_data* sd); void (*auth_failed) (struct login_session_data* sd, int result); - void (*login_error) (int fd, uint8 status); + void (*login_error) (int fd, uint8 error); void (*parse_ping) (int fd, struct login_session_data* sd); void (*parse_client_md5) (int fd, struct login_session_data* sd); bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *ip); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index e8f04c653..25b20cddf 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2015 Hercules Dev Team + * Copyright (C) 2013-2016 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 @@ -26,6 +26,11 @@ #include "common/cbasetypes.h" #include "common/mmo.h" +// Packet DB +#define MIN_PACKET_DB 0x0064 +#define MAX_PACKET_DB 0x0F00 +#define MAX_PACKET_POS 20 + /** * **/ -- cgit v1.2.3-70-g09d2 From 9defceef6a3371d09b580ac8f2cffd0476033ea6 Mon Sep 17 00:00:00 2001 From: hemagx Date: Mon, 28 Mar 2016 21:54:46 +0200 Subject: Rewrite client interface for login server (part 2) Split login packet-related code into functions Signed-off-by: Haru --- src/login/login.c | 362 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 203 insertions(+), 159 deletions(-) (limited to 'src') diff --git a/src/login/login.c b/src/login/login.c index 27cdb1fa3..f20959979 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1385,13 +1385,64 @@ void login_kick(struct login_session_data* sd) charif_sendallwos(-1, buf, 6); } +bool login_send_server_list(struct login_session_data *sd) +{ + int server_num = 0, i, n, length; + uint32 ip; + struct packet_AC_ACCEPT_LOGIN *packet = NULL; + + for (i = 0; i < ARRAYLENGTH(server); ++i) { + if (sockt->session_is_active(server[i].fd)) + server_num++; + } + if (server_num == 0) + return false; + + length = sizeof(*packet) + sizeof(packet->server_list[0]) * server_num; + ip = sockt->session[sd->fd]->client_addr; + + // Allocate the packet + WFIFOHEAD(sd->fd, length); + packet = WP2PTR(sd->fd); + + packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN; + packet->packet_len = length; + packet->auth_code = sd->login_id1; + packet->aid = sd->account_id; + packet->user_level = sd->login_id2; + packet->last_login_ip = 0; // Not used anymore + memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // not used anymore + packet->sex = sex_str2num(sd->sex); + for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { + uint32 subnet_char_ip; + + if (!sockt->session_is_valid(server[i].fd)) + continue; + + subnet_char_ip = login->lan_subnet_check(ip); + packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); + packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] + safestrncpy(packet->server_list[n].name, server[i].name, 20); + packet->server_list[n].usercount = server[i].users; + + if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) + packet->server_list[n].property = CST_NORMAL; + else + packet->server_list[n].property = server[i].type; + + packet->server_list[n].state = server[i].new_; + ++n; + } + WFIFOSET(sd->fd, length); + + return true; +} + void login_auth_ok(struct login_session_data* sd) { int fd = 0; uint32 ip; - uint8 server_num, n; struct login_auth_node* node; - int i; nullpo_retv(sd); fd = sd->fd; @@ -1413,18 +1464,6 @@ void login_auth_ok(struct login_session_data* sd) return; } - server_num = 0; - for( i = 0; i < ARRAYLENGTH(server); ++i ) - if (sockt->session_is_active(server[i].fd)) - server_num++; - - if( server_num == 0 ) - {// if no char-server, don't send void list of servers, just disconnect the player with proper message - ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - login->connection_problem(fd, 1); // 01 = server closed - return; - } - { struct online_login_data* data = (struct online_login_data*)idb_get(login->online_db, sd->account_id); if( data ) @@ -1450,49 +1489,16 @@ void login_auth_ok(struct login_session_data* sd) } } + if (!login_send_server_list(sd)) { + // if no char-server, don't send void list of servers, just disconnect the player with proper message + ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); + login->connection_problem(fd, 1); // 01 = server closed + return; + } + login_log(ip, sd->userid, 100, "login ok"); ShowStatus("Connection of the account '%s' accepted.\n", sd->userid); - { - struct packet_AC_ACCEPT_LOGIN *packet = NULL; - int length = sizeof(*packet) + sizeof(packet->server_list[0]) * server_num; - ip = sockt->session[sd->fd]->client_addr; - - // Allocate the packet - WFIFOHEAD(sd->fd, length); - packet = WP2PTR(sd->fd); - - packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN; - packet->packet_len = length; - packet->auth_code = sd->login_id1; - packet->aid = sd->account_id; - packet->user_level = sd->login_id2; - packet->last_login_ip = 0; // Not used anymore - memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // not used anymore - packet->sex = sex_str2num(sd->sex); - for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { - uint32 subnet_char_ip; - - if (!sockt->session_is_valid(server[i].fd)) - continue; - - subnet_char_ip = login->lan_subnet_check(ip); - packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); - packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] - safestrncpy(packet->server_list[n].name, server[i].name, 20); - packet->server_list[n].usercount = server[i].users; - - if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) - packet->server_list[n].property = CST_NORMAL; - else - packet->server_list[n].property = server[i].type; - - packet->server_list[n].state = server[i].new_; - ++n; - } - WFIFOSET(sd->fd, length); - } - // create temporary auth entry CREATE(node, struct login_auth_node, 1); node->account_id = sd->account_id; @@ -1608,134 +1614,171 @@ void login_parse_client_md5(int fd, struct login_session_data* sd) RFIFOSKIP(fd,sizeof(*packet)); } -bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) __attribute__((nonnull (2))); -bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) +// CA_LOGIN +void login_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN(int fd, struct login_session_data *sd) { - int result; - uint16 command = RFIFOW(fd,0); + const struct packet_CA_LOGIN *packet = RP2PTR(fd); - switch (command) { - case PACKET_ID_CA_SSO_LOGIN_REQ: - { - const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd); - int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet); + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - if (tokenlen > PASSWD_LEN || tokenlen < 1) { - RFIFOSKIP(fd, RFIFOREST(fd)); // assume no other packet was sent - login->auth_failed(sd, 3); - return true; - } + RFIFOSKIP(fd, sizeof(*packet)); - sd->clienttype = packet->clienttype; - sd->version = packet->version; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; +} - RFIFOSKIP(fd, sizeof(*packet)); +// CA_LOGIN2 +void login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - } - break; - case PACKET_ID_CA_LOGIN: - { - const struct packet_CA_LOGIN *packet = RP2PTR(fd); + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; - sd->version = packet->version; - sd->clienttype = packet->clienttype; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + RFIFOSKIP(fd, sizeof(*packet)); +} - RFIFOSKIP(fd, sizeof(*packet)); +// CA_LOGIN3 +void login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - } - break; - case PACKET_ID_CA_LOGIN2: - { - const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* sd->clientinfo = packet->clientinfo; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; - sd->version = packet->version; - sd->clienttype = packet->clienttype; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; + RFIFOSKIP(fd, sizeof(*packet)); +} - RFIFOSKIP(fd, sizeof(*packet)); - } - break; - case PACKET_ID_CA_LOGIN3: - { - const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); +// CA_LOGIN4 +void login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* sd->clientinfo = packet->clientinfo; */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; - RFIFOSKIP(fd, sizeof(*packet)); - } - break; - case PACKET_ID_CA_LOGIN4: - { - const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); + RFIFOSKIP(fd, sizeof(*packet)); +} - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; +// CA_LOGIN_PCBANG +void login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); - RFIFOSKIP(fd, sizeof(*packet)); - } - break; - case PACKET_ID_CA_LOGIN_PCBANG: - { - const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + RFIFOSKIP(fd, sizeof(*packet)); - RFIFOSKIP(fd, sizeof(*packet)); + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; +} - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - } - break; +// CA_LOGIN_HAN +void login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); - case PACKET_ID_CA_LOGIN_HAN: - { - const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + /* sd->ishan = packet->is_han_game_user; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + RFIFOSKIP(fd, sizeof(*packet)); - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - /* sd->ishan = packet->is_han_game_user; */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; +} - RFIFOSKIP(fd, sizeof(*packet)); +// CA_SSO_LOGIN_REQ +bool login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +bool login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) +{ + const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd); + int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet); - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; + if (tokenlen > PASSWD_LEN || tokenlen < 1) { + RFIFOSKIP(fd, RFIFOREST(fd)); // assume no other packet was sent + return false; } + + sd->clienttype = packet->clienttype; + sd->version = packet->version; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary + + RFIFOSKIP(fd, sizeof(*packet)); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + return true; +} + +bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) __attribute__((nonnull (2))); +bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) +{ + int result; + uint16 command = RFIFOW(fd,0); + + switch (command) { + case PACKET_ID_CA_SSO_LOGIN_REQ: + if (!login_parse_CA_SSO_LOGIN_REQ(fd, sd)) { + login->auth_failed(sd, 3); + return true; + } + break; + case PACKET_ID_CA_LOGIN: + login_parse_CA_LOGIN(fd, sd); + break; + case PACKET_ID_CA_LOGIN2: + login_parse_CA_LOGIN2(fd, sd); + break; + case PACKET_ID_CA_LOGIN3: + login_parse_CA_LOGIN3(fd, sd); + break; + case PACKET_ID_CA_LOGIN4: + login_parse_CA_LOGIN4(fd, sd); + break; + case PACKET_ID_CA_LOGIN_PCBANG: + login_parse_CA_LOGIN_PCBANG(fd, sd); + break; + case PACKET_ID_CA_LOGIN_HAN: + login_parse_CA_LOGIN_HAN(fd, sd); break; default: RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent @@ -1794,6 +1837,7 @@ void login_char_server_connection_status(int fd, struct login_session_data* sd, WFIFOSET(fd,3); } +// CA_CHARSERVERCONNECT void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3))); void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) { -- cgit v1.2.3-70-g09d2 From d60ef91d8355f117c1ad5209b3f43647b9656892 Mon Sep 17 00:00:00 2001 From: hemagx Date: Mon, 28 Mar 2016 21:54:46 +0200 Subject: Rewrite client interface for login server (part 3) Rewritten login clif parser, using a packet db Signed-off-by: Haru --- src/login/login.c | 507 ++++++++++++++++++++++++----------------- src/login/login.h | 19 +- tools/HPMHookGen/HPMHookGen.pl | 2 + 3 files changed, 313 insertions(+), 215 deletions(-) (limited to 'src') diff --git a/src/login/login.c b/src/login/login.c index f20959979..bbd16abab 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -52,6 +52,8 @@ struct mmo_char_server server[MAX_SERVERS]; // char server data #define MIN_PACKET_DB 0x0064 #define MAX_PACKET_DB 0x08ff +/* Enums */ + /// Packet IDs enum login_packet_id { // CA (Client to Login) @@ -76,76 +78,109 @@ enum login_packet_id { PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, }; +/* Function Typedefs */ +typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data *sd); + +/* Structs */ +/// Login packet DB entry +struct login_packet_db { + int16 len; ///< Packet length + LoginParseFunc *pFunc; ///< Packet parsing function +}; + /* 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; - uint32 version; - char id[24]; - char password[24]; - uint8 clienttype; + 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; - uint32 version; - char id[24]; - uint8 password_md5[16]; - uint8 clienttype; + 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; - uint32 version; - char id[24]; - uint8 password_md5[16]; - uint8 clienttype; - uint8 clientinfo; + 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; - uint32 version; - char id[24]; - uint8 password_md5[16]; - uint8 clienttype; - char mac_address[13]; + 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; - uint32 version; - char id[24]; - char password[24]; - uint8 clienttype; - char ip[16]; - char mac_address[13]; + 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; - uint32 version; - char id[24]; - char password[24]; - uint8 clienttype; - char ip[16]; - char mac_address[13]; - uint8 is_han_game_user; + 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; - int16 packet_len; - uint32 version; - uint8 clienttype; - char id[24]; - char password[27]; - int8 mac_address[17]; - char ip[15]; - char t1[]; + 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)); #if 0 // Unused @@ -161,18 +196,31 @@ struct packet_CA_SSO_LOGIN_REQa { } __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; - char id[24]; + 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; - uint8 hash_value[16]; + 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; + int16 packet_id; ///< Packet ID (#PACKET_ID_CA_REQ_HASH) } __attribute__((packed)); struct packet_CA_CHARSERVERCONNECT { @@ -238,6 +286,8 @@ struct Account_engine account_engine[] = { {account_db_sql, NULL} }; +struct login_packet_db packet_db[MAX_PACKET_DB + 1]; + // account database AccountDB* accounts = NULL; @@ -1597,26 +1647,23 @@ void login_login_error(int fd, uint8 error) WFIFOSET(fd, sizeof(*packet)); } -// CA_CONNECT_INFO_CHANGED -void login_parse_ping(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); -void login_parse_ping(int fd, struct login_session_data* sd) +enum parsefunc_rcode login_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) { - RFIFOSKIP(fd, sizeof(struct packet_CA_CONNECT_INFO_CHANGED)); + return PACKET_VALID; } -// CA_EXE_HASHCHECK -void login_parse_client_md5(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); -void login_parse_client_md5(int fd, struct login_session_data* sd) +enum parsefunc_rcode login_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) { const struct packet_CA_EXE_HASHCHECK *packet = RP2PTR(fd); sd->has_client_hash = 1; memcpy(sd->client_hash, packet->hash_value, 16); - RFIFOSKIP(fd,sizeof(*packet)); + return PACKET_VALID; } -// CA_LOGIN -void login_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN *packet = RP2PTR(fd); @@ -1625,16 +1672,16 @@ void login_parse_CA_LOGIN(int fd, struct login_session_data *sd) safestrncpy(sd->userid, packet->id, NAME_LENGTH); safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - RFIFOSKIP(fd, sizeof(*packet)); - if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_LOGIN2 -void login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); @@ -1644,12 +1691,12 @@ void login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) bin2hex(sd->passwd, packet->password_md5, 16); sd->passwdenc = PASSWORDENC; - RFIFOSKIP(fd, sizeof(*packet)); + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_LOGIN3 -void login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); @@ -1661,12 +1708,12 @@ void login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) bin2hex(sd->passwd, packet->password_md5, 16); sd->passwdenc = PASSWORDENC; - RFIFOSKIP(fd, sizeof(*packet)); + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_LOGIN4 -void login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); @@ -1678,12 +1725,12 @@ void login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) bin2hex(sd->passwd, packet->password_md5, 16); sd->passwdenc = PASSWORDENC; - RFIFOSKIP(fd, sizeof(*packet)); + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_LOGIN_PCBANG -void login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); @@ -1695,16 +1742,16 @@ void login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) safestrncpy(sd->userid, packet->id, NAME_LENGTH); safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - RFIFOSKIP(fd, sizeof(*packet)); - if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_LOGIN_HAN -void login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); @@ -1717,23 +1764,24 @@ void login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) safestrncpy(sd->userid, packet->id, NAME_LENGTH); safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - RFIFOSKIP(fd, sizeof(*packet)); - if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; } -// CA_SSO_LOGIN_REQ -bool login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -bool login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) +enum parsefunc_rcode login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) { const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd); int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet); if (tokenlen > PASSWD_LEN || tokenlen < 1) { - RFIFOSKIP(fd, RFIFOREST(fd)); // assume no other packet was sent - return false; + ShowError("login_parse_CA_SSO_LOGIN_REQ: Token length is not between allowed password length, kicking player ('%s')", packet->id); + sockt->eof(fd); + return PACKET_VALID; } sd->clienttype = packet->clienttype; @@ -1741,50 +1789,21 @@ bool login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) safestrncpy(sd->userid, packet->id, NAME_LENGTH); safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary - RFIFOSKIP(fd, sizeof(*packet)); - if (login->config->use_md5_passwds) MD5_String(sd->passwd, sd->passwd); sd->passwdenc = PWENC_NONE; - return true; + + login->client_login(fd, sd); + return PACKET_VALID; } -bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) __attribute__((nonnull (2))); -bool login_parse_client_login(int fd, struct login_session_data* sd, const char *const ip) +bool login_client_login(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +bool login_client_login(int fd, struct login_session_data *sd) { int result; - uint16 command = RFIFOW(fd,0); - - switch (command) { - case PACKET_ID_CA_SSO_LOGIN_REQ: - if (!login_parse_CA_SSO_LOGIN_REQ(fd, sd)) { - login->auth_failed(sd, 3); - return true; - } - break; - case PACKET_ID_CA_LOGIN: - login_parse_CA_LOGIN(fd, sd); - break; - case PACKET_ID_CA_LOGIN2: - login_parse_CA_LOGIN2(fd, sd); - break; - case PACKET_ID_CA_LOGIN3: - login_parse_CA_LOGIN3(fd, sd); - break; - case PACKET_ID_CA_LOGIN4: - login_parse_CA_LOGIN4(fd, sd); - break; - case PACKET_ID_CA_LOGIN_PCBANG: - login_parse_CA_LOGIN_PCBANG(fd, sd); - break; - case PACKET_ID_CA_LOGIN_HAN: - login_parse_CA_LOGIN_HAN(fd, sd); - break; - default: - RFIFOSKIP(fd,RFIFOREST(fd)); // assume no other packet was sent - login->auth_failed(sd, 3); // send "rejected from server" - return true; - } + char ip[16]; + uint32 ipl = sockt->session[fd]->client_addr; + sockt->ip2str(ipl, ip); ShowStatus("Request for connection %sof %s (ip: %s).\n", sd->passwdenc == PASSWORDENC ? " (passwdenc mode)" : "", sd->userid, ip); @@ -1794,11 +1813,11 @@ bool login_parse_client_login(int fd, struct login_session_data* sd, const char } result = login->mmo_auth(sd, false); - if( result == -1 ) login->auth_ok(sd); else login->auth_failed(sd, result); + return false; } @@ -1816,16 +1835,15 @@ void login_send_coding_key(int fd, struct login_session_data* sd) WFIFOSET(fd, size); } -// CA_REQ_HASH -void login_parse_request_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); -void login_parse_request_coding_key(int fd, struct login_session_data* sd) +enum parsefunc_rcode login_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) { - RFIFOSKIP(fd, sizeof(struct packet_CA_REQ_HASH)); memset(sd->md5key, '\0', sizeof(sd->md5key)); sd->md5keylen = (uint16)(12 + rnd() % 4); MD5_Salt(sd->md5keylen, sd->md5key); login->send_coding_key(fd, sd); + return PACKET_VALID; } void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2))); @@ -1837,7 +1855,18 @@ void login_char_server_connection_status(int fd, struct login_session_data* sd, WFIFOSET(fd,3); } -// CA_CHARSERVERCONNECT +enum parsefunc_rcode login_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode login_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) +{ + char ip[16]; + uint32 ipl = sockt->session[fd]->client_addr; + sockt->ip2str(ipl, ip); + + login->parse_request_connection(fd, sd, ip, ipl); + + return PACKET_STOPPARSE; +} + void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3))); void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) { @@ -1860,7 +1889,6 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const safestrncpy(server_name, RFIFOP(fd,60), 20); type = RFIFOW(fd,82); new_ = RFIFOW(fd,84); - RFIFOSKIP(fd,86); ShowInfo("Connection request of the char-server '%s' @ %u.%u.%u.%u:%u (account: '%s', pass: '%s', ip: '%s')\n", server_name, CONVIP(server_ip), server_port, sd->userid, sd->passwd, ip); sprintf(message, "charserver - %s@%u.%u.%u.%u:%u", server_name, CONVIP(server_ip), server_port); @@ -1898,6 +1926,25 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const } } +struct login_packet_db *login_lclif_packet(int16 packet_id) +{ + if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) + return &packet_db[0]; + + if (packet_id > MAX_PACKET_DB || packet_id < MIN_PACKET_DB) + return NULL; + + return &packet_db[packet_id]; +} + +enum parsefunc_rcode login_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) +{ + int result; + result = lpd->pFunc(fd, sd); + RFIFOSKIP(fd, (lpd->len == -1) ? RFIFOW(fd, 2) : lpd->len); + return result; +} + //---------------------------------------------------------------------------------------- // Default packet parsing (normal players or char-server connection requests) //---------------------------------------------------------------------------------------- @@ -1931,93 +1978,86 @@ int login_parse_login(int fd) } while (RFIFOREST(fd) >= 2) { + enum parsefunc_rcode result; int16 packet_id = RFIFOW(fd, 0); int packet_len = (int)RFIFOREST(fd); if (packet_len < 2) return 0; - if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { - int result = HPM->parse_packets(fd, packet_id, hpParse_Login); - if (result == 1) - continue; - if (result == 2) - return 0; - } + result = login->parse_login_sub(fd, sd); - switch (packet_id) { - case PACKET_ID_CA_CONNECT_INFO_CHANGED: // New alive packet: structure: 0x200 .24B. used to verify if client is always alive. - if (packet_len < (int)sizeof(struct packet_CA_CONNECT_INFO_CHANGED)) - return 0; - login->parse_ping(fd, sd); - break; - case PACKET_ID_CA_EXE_HASHCHECK: // S 0204 .16B (kRO 2004-05-31aSakexe langtype 0 and 6) - if (packet_len < (int)sizeof(struct packet_CA_EXE_HASHCHECK)) - return 0; - login->parse_client_md5(fd, sd); - break; - case PACKET_ID_CA_LOGIN: // S 0064 .L .24B .24B .B - if (packet_len < (int)sizeof(struct packet_CA_LOGIN)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_LOGIN_PCBANG: // S 0277 .L .24B .24B .B .16B .13B - if (packet_len < (int)sizeof(struct packet_CA_LOGIN_PCBANG)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_LOGIN_HAN: // S 02b0 .L .24B .24B .B .16B .13B .B - if (packet_len < (int)sizeof(struct packet_CA_LOGIN_HAN)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_LOGIN2: // S 01dd .L .24B .16B .B - if (packet_len < (int)sizeof(struct packet_CA_LOGIN2)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_LOGIN3: // S 01fa .L .24B .16B .B .B(index of the connection in the clientinfo file (+10 if the command-line contains "pc")) - if (packet_len < (int)sizeof(struct packet_CA_LOGIN3)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_LOGIN4: // S 027c .L .24B .16B .B .13B(junk) - if (packet_len < (int)sizeof(struct packet_CA_LOGIN4)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_SSO_LOGIN_REQ: // S 0825 .W .L .B .24B .27B .17B .15B .(packetsize - 0x5C)B - if (packet_len < (int)sizeof(struct packet_CA_SSO_LOGIN_REQ) || packet_len < RFIFOW(fd, 2)) - return 0; - if (login->parse_client_login(fd, sd, ip)) - return 0; - break; - case PACKET_ID_CA_REQ_HASH: - if (packet_len < (int)sizeof(struct packet_CA_REQ_HASH)) - return 0; - login->parse_request_coding_key(fd, sd); - break; - case PACKET_ID_CA_CHARSERVERCONNECT: - if (packet_len < (int)sizeof(struct packet_CA_CHARSERVERCONNECT)) - return 0; - login->parse_request_connection(fd, sd, ip, ipl); - return 0; // processing will continue elsewhere - default: - ShowNotice("Abnormal end of connection (ip: %s): Unknown packet 0x%x\n", ip, (unsigned int)packet_id); + switch (result) { + case PACKET_SKIP: + continue; + case PACKET_INCOMPLETE: + case PACKET_STOPPARSE: + return 0; + case PACKET_UNKNOWN: + ShowWarning("login_parse_login: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); +#ifdef DUMP_INVALID_PACKET + ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); +#endif + sockt->eof(fd); + return 0; + case PACKET_INVALIDLENGTH: + ShowWarning("login_parse_login: Received packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); +#ifdef DUMP_INVALID_PACKET + ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); +#endif sockt->eof(fd); return 0; } } - return 0; } +enum parsefunc_rcode login_parse_login_sub(int fd, struct login_session_data *sd) +{ + int packet_len = (int)RFIFOREST(fd); + int16 packet_id = RFIFOW(fd, 0); + const struct login_packet_db *lpd; + + if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { + int result = HPM->parse_packets(fd, packet_id, hpParse_Login); + if (result == 1) + return PACKET_VALID; + if (result == 2) + return PACKET_INCOMPLETE; // Packet not completed yet + } + + lpd = login_lclif_packet(packet_id); + + if (lpd == NULL) + return PACKET_UNKNOWN; + + if (lpd->len == 0) + return PACKET_UNKNOWN; + + if (lpd->len > 0 && lpd->pFunc == NULL) + return PACKET_UNKNOWN; //This Packet is defined for length purpose ? should never be sent from client ? + + if (lpd->len == -1) { + uint16 packet_var_len = 0; //Max Variable Packet length is signed int16 size + + if (packet_len < 4) + return PACKET_INCOMPLETE; //Packet incomplete + + packet_var_len = RFIFOW(fd, 2); + + if (packet_var_len < 4 || packet_var_len > SINT16_MAX) + return PACKET_INVALIDLENGTH; //Something is wrong, close connection. + + if (RFIFOREST(fd) < packet_var_len) + return PACKET_INCOMPLETE; //Packet incomplete again. + + return login->parse_packet(lpd, fd, sd); + } else if (lpd->len <= packet_len) { + return login->parse_packet(lpd, fd, sd); + } + + return PACKET_VALID; +} void login_config_set_defaults(void) { @@ -2286,6 +2326,47 @@ void cmdline_args_init_local(void) CMDLINEARG_DEF2(net-config, netconfig, "Alternative subnet configuration.", CMDLINE_OPT_PARAM); } +void packetdb_loaddb(void) +{ + + int i; + struct packet { + int16 packet_id; + int16 packet_len; + int (*pFunc)(int, struct login_session_data *); + } packet[] = { +#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), login_parse_ ## name } +#define packet_def2(name, len) { PACKET_ID_ ## name, (len), login_parse_ ## name } + packet_def(CA_CONNECT_INFO_CHANGED), + packet_def(CA_EXE_HASHCHECK), + packet_def(CA_LOGIN), + packet_def(CA_LOGIN2), + packet_def(CA_LOGIN3), + packet_def(CA_LOGIN4), + packet_def(CA_LOGIN_PCBANG), + packet_def(CA_LOGIN_HAN), + packet_def2(CA_SSO_LOGIN_REQ, -1), + packet_def(CA_REQ_HASH), +#undef packet_def +#undef packet_def2 + }; + int length = ARRAYLENGTH(packet); + + memset(packet_db, '\0', sizeof(packet_db)); + + for (i = 0; i < length; ++i) { + int16 packet_id = packet[i].packet_id; + Assert_retb(packet_id >= MIN_PACKET_DB && packet_id < MAX_PACKET_DB); + packet_db[packet_id].len = packet[i].packet_len; + packet_db[packet_id].pFunc = packet[i].pFunc; + } + + //Explict case, we will save character login packet in position 0 which is unused and not valid by normal + packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); + packet_db[0].pFunc = login_parse_CA_CHARSERVERCONNECT; + +} + //------------------------------ // Login server initialization //------------------------------ @@ -2318,6 +2399,8 @@ int do_init(int argc, char** argv) login_config_read(login->LOGIN_CONF_NAME); sockt->net_config_read(login->NET_CONF_NAME); + packetdb_loaddb(); + for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_init(i); @@ -2429,11 +2512,6 @@ void login_defaults(void) { login->parse_fromchar = login_parse_fromchar; login->parse_login = login_parse_login; - login->parse_ping = login_parse_ping; - login->parse_client_md5 = login_parse_client_md5; - login->parse_client_login = login_parse_client_login; - login->parse_request_coding_key = login_parse_request_coding_key; - login->parse_request_connection = login_parse_request_connection; login->auth_ok = login_auth_ok; login->auth_failed = login_auth_failed; login->char_server_connection_status = login_char_server_connection_status; @@ -2446,4 +2524,7 @@ void login_defaults(void) { login->config_read = login_config_read; login->LOGIN_CONF_NAME = NULL; login->NET_CONF_NAME = NULL; + + login->parse_packet = login_parse_packet; + login->parse_login_sub = login_parse_login_sub; } diff --git a/src/login/login.h b/src/login/login.h index 0676aee1f..e29953b9e 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -28,6 +28,7 @@ struct mmo_account; struct AccountDB; +struct login_packet_db; enum E_LOGINSERVER_ST { @@ -43,6 +44,16 @@ enum password_enc { PWENC_BOTH = PWENC_ENCRYPT|PWENC_ENCRYPT2, ///< both the above }; +/// Parse function return code +enum parsefunc_rcode { + PACKET_VALID = 1, + PACKET_INCOMPLETE = 0, + PACKET_UNKNOWN = -1, + PACKET_INVALIDLENGTH = -2, + PACKET_STOPPARSE = -3, + PACKET_SKIP = -4, //internal parser will skip this packet and go parser another, meant for plugins. [hemagx] +}; + #define PASSWORDENC PWENC_BOTH #define PASSWD_LEN (32+1) // 23+1 for plaintext, 32+1 for md5-ed passwords @@ -203,7 +214,7 @@ struct login_interface { void (*login_error) (int fd, uint8 error); void (*parse_ping) (int fd, struct login_session_data* sd); void (*parse_client_md5) (int fd, struct login_session_data* sd); - bool (*parse_client_login) (int fd, struct login_session_data* sd, const char *ip); + bool (*client_login) (int fd, struct login_session_data *sd); void (*send_coding_key) (int fd, struct login_session_data* sd); void (*parse_request_coding_key) (int fd, struct login_session_data* sd); void (*char_server_connection_status) (int fd, struct login_session_data* sd, uint8 status); @@ -213,6 +224,10 @@ struct login_interface { int (*config_read) (const char *cfgName); char *LOGIN_CONF_NAME; char *NET_CONF_NAME; ///< Network configuration filename + + // lclif + enum parsefunc_rcode (*parse_packet)(const struct login_packet_db *lpd, int fd, struct login_session_data *sd); + enum parsefunc_rcode (*parse_login_sub)(int fd, struct login_session_data *sd); }; #ifdef HERCULES_CORE diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl index 9b6fcdf8b..74cc0f863 100755 --- a/tools/HPMHookGen/HPMHookGen.pl +++ b/tools/HPMHookGen/HPMHookGen.pl @@ -237,6 +237,8 @@ sub parse($$) { $rtinit = ' = HCS_STATUS_FAIL'; } elsif ($x =~ /^enum\s+bg_queue_types$/) { # Known enum bg_queue_types $rtinit = ' = BGQT_INVALID'; + } elsif ($x =~ /^enum\s+parsefunc_rcode$/) { # Known enum parsefunc_rcode + $rtinit = ' = PACKET_UNKNOWN'; } elsif ($x =~ /^(?:enum\s+)?DBOptions$/) { # Known enum DBOptions $rtinit = ' = DB_OPT_BASE'; } elsif ($x eq 'DBComparator' or $x eq 'DBHasher' or $x eq 'DBReleaser') { # DB function pointers -- cgit v1.2.3-70-g09d2 From c7653654a4429751bf36e19f2529fd4c1303d636 Mon Sep 17 00:00:00 2001 From: hemagx Date: Tue, 12 Apr 2016 15:24:30 +0200 Subject: Rewrite client interface for login server (part 4) Changed login server packet processing so that no more than 3 packets are processed at once (same as the map server's clif processing) Signed-off-by: Haru --- src/login/login.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/login/login.c b/src/login/login.c index bbd16abab..f0a51103f 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -48,6 +48,9 @@ struct login_interface *login; struct Login_Config login_config_; struct mmo_char_server server[MAX_SERVERS]; // char server data +/// Maximum amount of packets processed at once from the same client +#define MAX_PROCESSED_PACKETS (3) + // Packet DB #define MIN_PACKET_DB 0x0064 #define MAX_PACKET_DB 0x08ff @@ -1821,8 +1824,8 @@ bool login_client_login(int fd, struct login_session_data *sd) return false; } -void login_send_coding_key(int fd, struct login_session_data* sd) __attribute__((nonnull (2))); -void login_send_coding_key(int fd, struct login_session_data* sd) +void login_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void login_send_coding_key(int fd, struct login_session_data *sd) { struct packet_AC_ACK_HASH *packet = NULL; int16 size = sizeof(*packet) + sd->md5keylen; @@ -1951,6 +1954,7 @@ enum parsefunc_rcode login_parse_packet(const struct login_packet_db *lpd, int f int login_parse_login(int fd) { struct login_session_data *sd = NULL; + int i; char ip[16]; uint32 ipl = sockt->session[fd]->client_addr; sockt->ip2str(ipl, ip); @@ -1977,7 +1981,7 @@ int login_parse_login(int fd) sd->fd = fd; } - while (RFIFOREST(fd) >= 2) { + for (i = 0; i < MAX_PROCESSED_PACKETS; ++i) { enum parsefunc_rcode result; int16 packet_id = RFIFOW(fd, 0); int packet_len = (int)RFIFOREST(fd); -- cgit v1.2.3-70-g09d2 From d8da35deb6afe62c9efd4a7f553832f4a596eab1 Mon Sep 17 00:00:00 2001 From: hemagx Date: Tue, 12 Apr 2016 15:25:50 +0200 Subject: Rewrite client interface for login server (part 5) Renamed login->connection_problem() to login->connection_error() Split login->send_auth_failed() out of login->auth_failed() Signed-off-by: Haru --- src/login/login.c | 39 ++++++++++++++++++++++++--------------- src/login/login.h | 3 ++- 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/login/login.c b/src/login/login.c index f0a51103f..a98389f7e 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -1419,7 +1419,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return -1; // account OK } -void login_connection_problem(int fd, uint8 error) +void login_connection_error(int fd, uint8 error) { struct packet_SC_NOTIFY_BAN *packet = NULL; WFIFOHEAD(fd, sizeof(*packet)); @@ -1503,17 +1503,17 @@ void login_auth_ok(struct login_session_data* sd) if( core->runflag != LOGINSERVER_ST_RUNNING ) { // players can only login while running - login->connection_problem(fd, 1); // 01 = server closed + login->connection_error(fd, 1); // 01 = server closed return; } if (login->config->group_id_to_connect >= 0 && sd->group_id != login->config->group_id_to_connect) { ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login->config->group_id_to_connect, sd->userid, sd->group_id); - login->connection_problem(fd, 1); // 01 = server closed + login->connection_error(fd, 1); // 01 = server closed return; } else if (login->config->min_group_id_to_connect >= 0 && login->config->group_id_to_connect == -1 && sd->group_id < login->config->min_group_id_to_connect) { ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login->config->min_group_id_to_connect, sd->userid, sd->group_id); - login->connection_problem(fd, 1); // 01 = server closed + login->connection_error(fd, 1); // 01 = server closed return; } @@ -1528,7 +1528,7 @@ void login_auth_ok(struct login_session_data* sd) if( data->waiting_disconnect == INVALID_TIMER ) data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0); - login->connection_problem(fd, 8); // 08 = Server still recognizes your last login + login->connection_error(fd, 8); // 08 = Server still recognizes your last login return; } else @@ -1545,7 +1545,7 @@ void login_auth_ok(struct login_session_data* sd) if (!login_send_server_list(sd)) { // if no char-server, don't send void list of servers, just disconnect the player with proper message ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - login->connection_problem(fd, 1); // 01 = server closed + login->connection_error(fd, 1); // 01 = server closed return; } @@ -1576,10 +1576,11 @@ void login_auth_ok(struct login_session_data* sd) } } -void login_auth_failed(struct login_session_data* sd, int result) +void login_auth_failed(struct login_session_data *sd, int result) { int fd; uint32 ip; + time_t ban_time = 0; nullpo_retv(sd); fd = sd->fd; @@ -1618,6 +1619,16 @@ void login_auth_failed(struct login_session_data* sd, int result) if (result == 1 && login->config->dynamic_pass_failure_ban && !sockt->trusted_ip_check(ip)) ipban_log(ip); // log failed password attempt + if (result == 6) { + struct mmo_account acc = { 0 }; + if (accounts->load_str(accounts, &acc, sd->userid)) + ban_time = acc.unban_time; + } + login->send_auth_failed(fd, ban_time, result); +} + +void login_send_auth_failed(int fd, time_t ban, uint32 error) +{ #if PACKETVER >= 20120000 /* not sure when this started */ struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL; int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R2; @@ -1628,14 +1639,11 @@ void login_auth_failed(struct login_session_data* sd, int result) WFIFOHEAD(fd, sizeof(*packet)); packet = WP2PTR(fd); packet->packet_id = packet_id; - packet->error_code = result; - if (result == 6) { - struct mmo_account acc; - time_t unban_time = ( accounts->load_str(accounts, &acc, sd->userid) ) ? acc.unban_time : 0; - timestamp2string(packet->block_date, sizeof(packet->block_date), unban_time, login->config->date_format); - } else { + packet->error_code = error; + if (error == 6) + timestamp2string(packet->block_date, sizeof(packet->block_date), ban, login->config->date_format); + else memset(packet->block_date, '\0', sizeof(packet->block_date)); - } WFIFOSET(fd, sizeof(*packet)); } @@ -2518,8 +2526,9 @@ void login_defaults(void) { login->parse_login = login_parse_login; login->auth_ok = login_auth_ok; login->auth_failed = login_auth_failed; + login->send_auth_failed = login_send_auth_failed; login->char_server_connection_status = login_char_server_connection_status; - login->connection_problem = login_connection_problem; + login->connection_error = login_connection_error; login->kick = login_kick; login->login_error = login_login_error; login->send_coding_key = login_send_coding_key; diff --git a/src/login/login.h b/src/login/login.h index e29953b9e..9402dbd74 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -207,10 +207,11 @@ struct login_interface { bool (*fromchar_parse_wrong_pincode) (int fd); void (*fromchar_parse_accinfo) (int fd); int (*parse_fromchar) (int fd); - void (*connection_problem) (int fd, uint8 error); + void (*connection_error) (int fd, uint8 error); void (*kick) (struct login_session_data* sd); void (*auth_ok) (struct login_session_data* sd); void (*auth_failed) (struct login_session_data* sd, int result); + void (*send_auth_failed) (int fd, time_t ban, uint32 error); void (*login_error) (int fd, uint8 error); void (*parse_ping) (int fd, struct login_session_data* sd); void (*parse_client_md5) (int fd, struct login_session_data* sd); -- cgit v1.2.3-70-g09d2 From c8ff1e77501d3edd9bf79fa7ab0281092906735c Mon Sep 17 00:00:00 2001 From: hemagx Date: Tue, 12 Apr 2016 14:35:21 +0200 Subject: Rewrite client interface for login server (part 6) Moved login clif code to lclif.c/lclif.h Signed-off-by: Haru --- Hercules.xcodeproj/project.pbxproj | 6 + src/login/HPMlogin.c | 1 + src/login/Makefile.in | 4 +- src/login/lclif.c | 750 +++++++++++++++++++++++++++++++++ src/login/lclif.h | 70 +++ src/login/login.c | 732 +------------------------------- src/login/login.h | 23 - src/plugins/HPMHooking.c | 3 +- vcproj-10/login-server.vcxproj | 2 + vcproj-10/login-server.vcxproj.filters | 6 + vcproj-11/login-server.vcxproj | 2 + vcproj-11/login-server.vcxproj.filters | 6 + vcproj-12/login-server.vcxproj | 2 + vcproj-12/login-server.vcxproj.filters | 6 + vcproj-14/login-server.vcxproj | 2 + vcproj-14/login-server.vcxproj.filters | 6 + 16 files changed, 881 insertions(+), 740 deletions(-) create mode 100644 src/login/lclif.c create mode 100644 src/login/lclif.h (limited to 'src') diff --git a/Hercules.xcodeproj/project.pbxproj b/Hercules.xcodeproj/project.pbxproj index 69edeacd3..4055a64b2 100644 --- a/Hercules.xcodeproj/project.pbxproj +++ b/Hercules.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + A5296FCD1CAC40CF001ABCAC /* lclif.c in Sources */ = {isa = PBXBuildFile; fileRef = A5296FCA1CAC40CF001ABCAC /* lclif.c */; }; A5380CD71856CE3C0090CBC4 /* mapcache.c in Sources */ = {isa = PBXBuildFile; fileRef = A5380CD61856CE3C0090CBC4 /* mapcache.c */; }; A5380CD81856CE8A0090CBC4 /* console.c in Sources */ = {isa = PBXBuildFile; fileRef = A56CC692185643BB009EB79C /* console.c */; }; A5380CD91856CF4A0090CBC4 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = A56CC694185643BB009EB79C /* core.c */; }; @@ -218,6 +219,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + A5296FCA1CAC40CF001ABCAC /* lclif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lclif.c; path = src/login/lclif.c; sourceTree = SOURCE_ROOT; }; + A5296FCB1CAC40CF001ABCAC /* lclif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lclif.h; path = src/login/lclif.h; sourceTree = SOURCE_ROOT; }; A5380CCD1856CE180090CBC4 /* mapcache */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mapcache; sourceTree = BUILT_PRODUCTS_DIR; }; A5380CD61856CE3C0090CBC4 /* mapcache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mapcache.c; path = src/tool/mapcache.c; sourceTree = ""; }; A5467AD11A16FCB4008AFAA6 /* loginif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = loginif.c; path = src/char/loginif.c; sourceTree = SOURCE_ROOT; }; @@ -550,6 +553,8 @@ A56CC66B18564315009EB79C /* login-server */ = { isa = PBXGroup; children = ( + A5296FCA1CAC40CF001ABCAC /* lclif.c */, + A5296FCB1CAC40CF001ABCAC /* lclif.h */, A5B894A81A03CDD4005AD22E /* HPMlogin.c */, A5B894A91A03CDD4005AD22E /* HPMlogin.h */, A56CC68118564387009EB79C /* account_sql.c */, @@ -1189,6 +1194,7 @@ A5F7946C191CA34E002293AB /* sysinfo.c in Sources */, A56CC74018564C23009EB79C /* mt19937ar.c in Sources */, A5B894AA1A03CDD4005AD22E /* HPMlogin.c in Sources */, + A5296FCD1CAC40CF001ABCAC /* lclif.c in Sources */, A56CC6DE185643BB009EB79C /* grfio.c in Sources */, A56CC68C18564387009EB79C /* loginlog_sql.c in Sources */, A56CC73118564C05009EB79C /* libconfig.c in Sources */, diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c index f12996915..e3f580341 100644 --- a/src/login/HPMlogin.c +++ b/src/login/HPMlogin.c @@ -25,6 +25,7 @@ #include "common/cbasetypes.h" #include "login/account.h" +#include "login/lclif.h" #include "login/login.h" #include "common/HPMi.h" #include "common/conf.h" diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 8e10be6d8..222c87e2a 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -40,9 +40,9 @@ MT19937AR_D = $(THIRDPARTY_D)/mt19937ar MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o MT19937AR_H = $(MT19937AR_D)/mt19937ar.h -LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c login.c loginlog_sql.c +LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c lclif.c login.c loginlog_sql.c LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C))) -LOGIN_H = login.h account.h HPMlogin.h ipban.h loginlog.h +LOGIN_H = login.h account.h HPMlogin.h ipban.h lclif.h loginlog.h LOGIN_PH = HAVE_MYSQL=@HAVE_MYSQL@ diff --git a/src/login/lclif.c b/src/login/lclif.c new file mode 100644 index 000000000..203b0cbbc --- /dev/null +++ b/src/login/lclif.c @@ -0,0 +1,750 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 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 . + */ +#define HERCULES_CORE + +#include "lclif.h" + +#include "login/ipban.h" +#include "login/login.h" +#include "login/loginlog.h" +#include "common/HPM.h" +#include "common/cbasetypes.h" +#include "common/db.h" +#include "common/md5calc.h" +#include "common/memmgr.h" +#include "common/mmo.h" +#include "common/nullpo.h" +#include "common/random.h" +#include "common/showmsg.h" +#include "common/socket.h" +#include "common/strlib.h" +#include "common/utils.h" + +struct lclif_interface lclif_s; +struct lclif_interface *lclif; + +/* Definitions and macros */ +/// Maximum amount of packets processed at once from the same client +#define MAX_PROCESSED_PACKETS (3) + +// Packet DB +#define MIN_PACKET_DB 0x0064 +#define MAX_PACKET_DB 0x08ff + +/* 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_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_REFUSE_LOGIN = 0x006a, + PACKET_ID_SC_NOTIFY_BAN = 0x0081, + PACKET_ID_AC_ACK_HASH = 0x01dc, + PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, +}; + +/* 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; ///< Client Version + uint8 clienttype; ///< Client Type + 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 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)); + +struct packet_CA_CHARSERVERCONNECT { + int16 packet_id; + char userid[24]; + char password[24]; + int32 unknown; + int32 ip; + int16 port; + char name[20]; + int16 unknown2; + int16 type; + int16 new; +} __attribute__((packed)); + +struct packet_SC_NOTIFY_BAN { + int16 packet_id; + uint8 error_code; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN { + int16 packet_id; + uint8 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN_R2 { + int16 packet_id; + uint32 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_ACCEPT_LOGIN { + int16 packet_id; + int16 packet_len; + int32 auth_code; + uint32 aid; + uint32 user_level; + uint32 last_login_ip; + char last_login_time[26]; + uint8 sex; + struct { + uint32 ip; + int16 port; + char name[20]; + uint16 usercount; + uint16 state; + uint16 property; + } server_list[]; +} __attribute__((packed)); + +struct packet_AC_ACK_HASH { + int16 packet_id; + int16 packet_len; + uint8 secret[]; +} __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 + +struct login_packet_db packet_db[MAX_PACKET_DB + 1]; + +void lclif_connection_error(int fd, uint8 error) +{ + struct packet_SC_NOTIFY_BAN *packet = NULL; + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = PACKET_ID_SC_NOTIFY_BAN; + packet->error_code = error; + WFIFOSET(fd, sizeof(*packet)); +} + +enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) +{ + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) +{ + 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; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* sd->clientinfo = packet->clientinfo; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + bin2hex(sd->passwd, packet->password_md5, 16); + sd->passwdenc = PASSWORDENC; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) +{ + const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); + + sd->version = packet->version; + sd->clienttype = packet->clienttype; + /* unused */ + /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ + /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ + /* sd->ishan = packet->is_han_game_user; */ + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->password, PASSWD_LEN); + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +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); + 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); + sockt->eof(fd); + return PACKET_VALID; + } + + sd->clienttype = packet->clienttype; + sd->version = packet->version; + safestrncpy(sd->userid, packet->id, NAME_LENGTH); + safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary + + if (login->config->use_md5_passwds) + MD5_String(sd->passwd, sd->passwd); + sd->passwdenc = PWENC_NONE; + + login->client_login(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) +{ + memset(sd->md5key, '\0', sizeof(sd->md5key)); + sd->md5keylen = (uint16)(12 + rnd() % 4); + MD5_Salt(sd->md5keylen, sd->md5key); + + lclif->coding_key(fd, sd); + return PACKET_VALID; +} + +enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) +{ + char ip[16]; + uint32 ipl = sockt->session[fd]->client_addr; + sockt->ip2str(ipl, ip); + + login->parse_request_connection(fd, sd, ip, ipl); + + return PACKET_STOPPARSE; +} + +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; + + for (i = 0; i < ARRAYLENGTH(server); ++i) { + if (sockt->session_is_active(server[i].fd)) + server_num++; + } + if (server_num == 0) + return false; + + length = sizeof(*packet) + sizeof(packet->server_list[0]) * server_num; + ip = sockt->session[sd->fd]->client_addr; + + // Allocate the packet + WFIFOHEAD(sd->fd, length); + packet = WP2PTR(sd->fd); + + packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN; + packet->packet_len = length; + packet->auth_code = sd->login_id1; + packet->aid = sd->account_id; + packet->user_level = sd->login_id2; + packet->last_login_ip = 0; // Not used anymore + memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // Not used anymore + packet->sex = sex_str2num(sd->sex); + for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { + uint32 subnet_char_ip; + + if (!sockt->session_is_valid(server[i].fd)) + continue; + + subnet_char_ip = login->lan_subnet_check(ip); + packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); + packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] + safestrncpy(packet->server_list[n].name, server[i].name, 20); + packet->server_list[n].usercount = server[i].users; + + if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) + packet->server_list[n].property = CST_NORMAL; + else + packet->server_list[n].property = server[i].type; + + packet->server_list[n].state = server[i].new_; + ++n; + } + WFIFOSET(sd->fd, length); + + return true; +} + +void lclif_send_auth_failed(int fd, time_t ban, uint32 error) +{ +#if PACKETVER >= 20120000 /* not sure when this started */ + struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL; + int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R2; +#else + struct packet_AC_REFUSE_LOGIN *packet = NULL; + int packet_id = PACKET_ID_AC_REFUSE_LOGIN; +#endif + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = packet_id; + packet->error_code = error; + if (error == 6) + timestamp2string(packet->block_date, sizeof(packet->block_date), ban, login->config->date_format); + else + memset(packet->block_date, '\0', sizeof(packet->block_date)); + WFIFOSET(fd, sizeof(*packet)); +} + +void lclif_send_login_error(int fd, uint8 error) +{ + struct packet_AC_REFUSE_LOGIN *packet = NULL; + WFIFOHEAD(fd, sizeof(*packet)); + packet = WP2PTR(fd); + packet->packet_id = PACKET_ID_AC_REFUSE_LOGIN; + packet->error_code = error; + memset(packet->block_date, '\0', sizeof(packet->block_date)); + WFIFOSET(fd, sizeof(*packet)); +} + +void lclif_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +void lclif_send_coding_key(int fd, struct login_session_data *sd) +{ + 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_len = size; + memcpy(packet->secret, sd->md5key, sd->md5keylen); + WFIFOSET(fd, size); +} + +int lclif_parse(int fd) +{ + struct login_session_data *sd = NULL; + int i; + char ip[16]; + uint32 ipl = sockt->session[fd]->client_addr; + sockt->ip2str(ipl, ip); + + if (sockt->session[fd]->flag.eof) { + ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip); + sockt->close(fd); + return 0; + } + + if ((sd = sockt->session[fd]->session_data) == NULL) { + // Perform ip-ban check + if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) { + ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); + login_log(ipl, "unknown", -3, "ip banned"); + lclif->login_error(fd, 3); // 3 = Rejected from Server + sockt->eof(fd); + return 0; + } + + // create a session for this new connection + CREATE(sockt->session[fd]->session_data, struct login_session_data, 1); + sd = sockt->session[fd]->session_data; + sd->fd = fd; + } + + for (i = 0; i < MAX_PROCESSED_PACKETS; ++i) { + enum parsefunc_rcode result; + int16 packet_id = RFIFOW(fd, 0); + int packet_len = (int)RFIFOREST(fd); + + if (packet_len < 2) + return 0; + + result = lclif->parse_sub(fd, sd); + + switch (result) { + case PACKET_SKIP: + continue; + case PACKET_INCOMPLETE: + case PACKET_STOPPARSE: + return 0; + case PACKET_UNKNOWN: + ShowWarning("lclif_parse: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); +#ifdef DUMP_INVALID_PACKET + ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); +#endif + sockt->eof(fd); + return 0; + case PACKET_INVALIDLENGTH: + ShowWarning("lclif_parse: Received packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); +#ifdef DUMP_INVALID_PACKET + ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); +#endif + sockt->eof(fd); + return 0; + } + } + return 0; +} + +enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) +{ + int packet_len = (int)RFIFOREST(fd); + int16 packet_id = RFIFOW(fd, 0); + const struct login_packet_db *lpd; + + if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { + int result = HPM->parse_packets(fd, packet_id, hpParse_Login); + if (result == 1) + return PACKET_VALID; + if (result == 2) + return PACKET_INCOMPLETE; // Packet not completed yet + } + + lpd = lclif->packet(packet_id); + + if (lpd == NULL) + return PACKET_UNKNOWN; + + if (lpd->len == 0) + return PACKET_UNKNOWN; + + if (lpd->len > 0 && lpd->pFunc == NULL) + return PACKET_UNKNOWN; //This Packet is defined for length purpose ? should never be sent from client ? + + if (lpd->len == -1) { + uint16 packet_var_len = 0; //Max Variable Packet length is signed int16 size + + if (packet_len < 4) + return PACKET_INCOMPLETE; //Packet incomplete + + packet_var_len = RFIFOW(fd, 2); + + if (packet_var_len < 4 || packet_var_len > SINT16_MAX) + return PACKET_INVALIDLENGTH; //Something is wrong, close connection. + + if (RFIFOREST(fd) < packet_var_len) + return PACKET_INCOMPLETE; //Packet incomplete again. + + return lclif->parse_packet(lpd, fd, sd); + } else if (lpd->len <= packet_len) { + return lclif->parse_packet(lpd, fd, sd); + } + + return PACKET_VALID; +} + +const struct login_packet_db *lclif_packet(int16 packet_id) +{ + if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) + return &packet_db[0]; + + if (packet_id > MAX_PACKET_DB || packet_id < MIN_PACKET_DB) + return NULL; + + return &packet_db[packet_id]; +} + +enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) +{ + int result; + result = lpd->pFunc(fd, sd); + RFIFOSKIP(fd, (lpd->len == -1) ? RFIFOW(fd, 2) : lpd->len); + return result; +} + +void packetdb_loaddb(void) +{ + int i; + struct packet { + int16 packet_id; + int16 packet_len; + int (*pFunc)(int, struct login_session_data *); + } packet[] = { +#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), lclif_parse_ ## name } +#define packet_def2(name, len) { PACKET_ID_ ## name, (len), lclif_parse_ ## name } + packet_def(CA_CONNECT_INFO_CHANGED), + packet_def(CA_EXE_HASHCHECK), + packet_def(CA_LOGIN), + packet_def(CA_LOGIN2), + packet_def(CA_LOGIN3), + packet_def(CA_LOGIN4), + packet_def(CA_LOGIN_PCBANG), + packet_def(CA_LOGIN_HAN), + packet_def2(CA_SSO_LOGIN_REQ, -1), + packet_def(CA_REQ_HASH), +#undef packet_def +#undef packet_def2 + }; + int length = ARRAYLENGTH(packet); + + memset(packet_db, '\0', sizeof(packet_db)); + + for (i = 0; i < length; ++i) { + int16 packet_id = packet[i].packet_id; + Assert_retb(packet_id >= MIN_PACKET_DB && packet_id < MAX_PACKET_DB); + packet_db[packet_id].len = packet[i].packet_len; + packet_db[packet_id].pFunc = packet[i].pFunc; + } + + //Explict case, we will save character login packet in position 0 which is unused and not valid by normal + packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); + packet_db[0].pFunc = lclif_parse_CA_CHARSERVERCONNECT; +} + +void lclif_init(void) +{ + packetdb_loaddb(); +} + +void lclif_final(void) +{ +} + +void lclif_defaults(void) +{ + lclif = &lclif_s; + + lclif->init = lclif_init; + lclif->final = lclif_final; + + lclif->connection_error = lclif_connection_error; + lclif->server_list = lclif_send_server_list; + lclif->auth_failed = lclif_send_auth_failed; + lclif->login_error = lclif_send_login_error; + lclif->coding_key = lclif_send_coding_key; + + lclif->packet = lclif_packet; + lclif->parse_packet = lclif_parse_packet; + lclif->parse = lclif_parse; + lclif->parse_sub = lclif_parse_sub; +} diff --git a/src/login/lclif.h b/src/login/lclif.h new file mode 100644 index 000000000..b6dac5d35 --- /dev/null +++ b/src/login/lclif.h @@ -0,0 +1,70 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 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 . + */ +#ifndef LOGIN_LCLIF_H +#define LOGIN_LCLIF_H + +#include "common/hercules.h" + +/* Forward Declarations */ +struct login_session_data; + +/* Enums */ +/// Parse function return code +enum parsefunc_rcode { + PACKET_VALID = 1, + PACKET_INCOMPLETE = 0, + PACKET_UNKNOWN = -1, + PACKET_INVALIDLENGTH = -2, + PACKET_STOPPARSE = -3, + PACKET_SKIP = -4, //internal parser will skip this packet and go parser another, meant for plugins. [hemagx] +}; + +/* Function Typedefs */ +typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data *sd); + +/* Structs */ +/// Login packet DB entry +struct login_packet_db { + int16 len; ///< Packet length + LoginParseFunc *pFunc; ///< Packet parsing function +}; + +struct lclif_interface { + void (*init)(void); + void (*final)(void); + + void (*connection_error)(int fd, uint8 error); + bool (*server_list)(struct login_session_data *sd); + void (*auth_failed)(int fd, time_t ban, uint32 error); + void (*login_error)(int fd, uint8 error); + void (*coding_key)(int fd, struct login_session_data *sd); + const struct login_packet_db *(*packet)(int16 packet_id); + enum parsefunc_rcode (*parse_packet)(const struct login_packet_db *lpd, int fd, struct login_session_data *sd); + int (*parse)(int fd); + enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); +}; + +#ifdef HERCULES_CORE +void lclif_defaults(void); +#endif + +HPShared struct lclif_interface *lclif; + +#endif // LOGIN_LCLIF_H diff --git a/src/login/login.c b/src/login/login.c index a98389f7e..38e2651c5 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -26,6 +26,7 @@ #include "login/account.h" #include "login/ipban.h" #include "login/loginlog.h" +#include "login/lclif.h" #include "common/HPM.h" #include "common/cbasetypes.h" #include "common/core.h" @@ -48,249 +49,10 @@ struct login_interface *login; struct Login_Config login_config_; struct mmo_char_server server[MAX_SERVERS]; // char server data -/// Maximum amount of packets processed at once from the same client -#define MAX_PROCESSED_PACKETS (3) - -// Packet DB -#define MIN_PACKET_DB 0x0064 -#define MAX_PACKET_DB 0x08ff - -/* 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_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_REFUSE_LOGIN = 0x006a, - PACKET_ID_SC_NOTIFY_BAN = 0x0081, - PACKET_ID_AC_ACK_HASH = 0x01dc, - PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, -}; - -/* Function Typedefs */ -typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data *sd); - -/* Structs */ -/// Login packet DB entry -struct login_packet_db { - int16 len; ///< Packet length - LoginParseFunc *pFunc; ///< Packet parsing function -}; - -/* 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)); - -#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)); - -struct packet_CA_CHARSERVERCONNECT { - int16 packet_id; - char userid[24]; - char password[24]; - int32 unknown; - int32 ip; - int16 port; - char name[20]; - int16 unknown2; - int16 type; - int16 new; -} __attribute__((packed)); - -struct packet_SC_NOTIFY_BAN { - int16 packet_id; - uint8 error_code; -} __attribute__((packed)); - -struct packet_AC_REFUSE_LOGIN { - int16 packet_id; - uint8 error_code; - char block_date[20]; -} __attribute__((packed)); - -struct packet_AC_REFUSE_LOGIN_R2 { - int16 packet_id; - uint32 error_code; - char block_date[20]; -} __attribute__((packed)); - -struct packet_AC_ACCEPT_LOGIN { - int16 packet_id; - int16 packet_len; - int32 auth_code; - uint32 aid; - uint32 user_level; - uint32 last_login_ip; - char last_login_time[26]; - uint8 sex; - struct { - uint32 ip; - int16 port; - char name[20]; - uint16 usercount; - uint16 state; - uint16 property; - } server_list[]; -} __attribute__((packed)); - -struct packet_AC_ACK_HASH { - int16 packet_id; - int16 packet_len; - uint8 secret[]; -} __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 - struct Account_engine account_engine[] = { {account_db_sql, NULL} }; -struct login_packet_db packet_db[MAX_PACKET_DB + 1]; - // account database AccountDB* accounts = NULL; @@ -1419,16 +1181,6 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return -1; // account OK } -void login_connection_error(int fd, uint8 error) -{ - struct packet_SC_NOTIFY_BAN *packet = NULL; - WFIFOHEAD(fd, sizeof(*packet)); - packet = WP2PTR(fd); - packet->packet_id = PACKET_ID_SC_NOTIFY_BAN; - packet->error_code = error; - WFIFOSET(fd, sizeof(*packet)); -} - void login_kick(struct login_session_data* sd) { uint8 buf[6]; @@ -1438,59 +1190,6 @@ void login_kick(struct login_session_data* sd) charif_sendallwos(-1, buf, 6); } -bool login_send_server_list(struct login_session_data *sd) -{ - int server_num = 0, i, n, length; - uint32 ip; - struct packet_AC_ACCEPT_LOGIN *packet = NULL; - - for (i = 0; i < ARRAYLENGTH(server); ++i) { - if (sockt->session_is_active(server[i].fd)) - server_num++; - } - if (server_num == 0) - return false; - - length = sizeof(*packet) + sizeof(packet->server_list[0]) * server_num; - ip = sockt->session[sd->fd]->client_addr; - - // Allocate the packet - WFIFOHEAD(sd->fd, length); - packet = WP2PTR(sd->fd); - - packet->packet_id = PACKET_ID_AC_ACCEPT_LOGIN; - packet->packet_len = length; - packet->auth_code = sd->login_id1; - packet->aid = sd->account_id; - packet->user_level = sd->login_id2; - packet->last_login_ip = 0; // Not used anymore - memset(packet->last_login_time, '\0', sizeof(packet->last_login_time)); // not used anymore - packet->sex = sex_str2num(sd->sex); - for (i = 0, n = 0; i < ARRAYLENGTH(server); ++i) { - uint32 subnet_char_ip; - - if (!sockt->session_is_valid(server[i].fd)) - continue; - - subnet_char_ip = login->lan_subnet_check(ip); - packet->server_list[n].ip = htonl((subnet_char_ip) ? subnet_char_ip : server[i].ip); - packet->server_list[n].port = sockt->ntows(htons(server[i].port)); // [!] LE byte order here [!] - safestrncpy(packet->server_list[n].name, server[i].name, 20); - packet->server_list[n].usercount = server[i].users; - - if (server[i].type == CST_PAYING && sd->expiration_time > time(NULL)) - packet->server_list[n].property = CST_NORMAL; - else - packet->server_list[n].property = server[i].type; - - packet->server_list[n].state = server[i].new_; - ++n; - } - WFIFOSET(sd->fd, length); - - return true; -} - void login_auth_ok(struct login_session_data* sd) { int fd = 0; @@ -1503,17 +1202,17 @@ void login_auth_ok(struct login_session_data* sd) if( core->runflag != LOGINSERVER_ST_RUNNING ) { // players can only login while running - login->connection_error(fd, 1); // 01 = server closed + lclif->connection_error(fd, 1); // 01 = server closed return; } if (login->config->group_id_to_connect >= 0 && sd->group_id != login->config->group_id_to_connect) { ShowStatus("Connection refused: the required group id for connection is %d (account: %s, group: %d).\n", login->config->group_id_to_connect, sd->userid, sd->group_id); - login->connection_error(fd, 1); // 01 = server closed + lclif->connection_error(fd, 1); // 01 = server closed return; } else if (login->config->min_group_id_to_connect >= 0 && login->config->group_id_to_connect == -1 && sd->group_id < login->config->min_group_id_to_connect) { ShowStatus("Connection refused: the minimum group id required for connection is %d (account: %s, group: %d).\n", login->config->min_group_id_to_connect, sd->userid, sd->group_id); - login->connection_error(fd, 1); // 01 = server closed + lclif->connection_error(fd, 1); // 01 = server closed return; } @@ -1528,7 +1227,7 @@ void login_auth_ok(struct login_session_data* sd) if( data->waiting_disconnect == INVALID_TIMER ) data->waiting_disconnect = timer->add(timer->gettick()+AUTH_TIMEOUT, login->waiting_disconnect_timer, sd->account_id, 0); - login->connection_error(fd, 8); // 08 = Server still recognizes your last login + lclif->connection_error(fd, 8); // 08 = Server still recognizes your last login return; } else @@ -1542,10 +1241,10 @@ void login_auth_ok(struct login_session_data* sd) } } - if (!login_send_server_list(sd)) { + if (!lclif->server_list(sd)) { // if no char-server, don't send void list of servers, just disconnect the player with proper message ShowStatus("Connection refused: there is no char-server online (account: %s).\n", sd->userid); - login->connection_error(fd, 1); // 01 = server closed + lclif->connection_error(fd, 1); // 01 = server closed return; } @@ -1624,188 +1323,7 @@ void login_auth_failed(struct login_session_data *sd, int result) if (accounts->load_str(accounts, &acc, sd->userid)) ban_time = acc.unban_time; } - login->send_auth_failed(fd, ban_time, result); -} - -void login_send_auth_failed(int fd, time_t ban, uint32 error) -{ -#if PACKETVER >= 20120000 /* not sure when this started */ - struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL; - int packet_id = PACKET_ID_AC_REFUSE_LOGIN_R2; -#else - struct packet_AC_REFUSE_LOGIN *packet = NULL; - int packet_id = PACKET_ID_AC_REFUSE_LOGIN; -#endif - WFIFOHEAD(fd, sizeof(*packet)); - packet = WP2PTR(fd); - packet->packet_id = packet_id; - packet->error_code = error; - if (error == 6) - timestamp2string(packet->block_date, sizeof(packet->block_date), ban, login->config->date_format); - else - memset(packet->block_date, '\0', sizeof(packet->block_date)); - WFIFOSET(fd, sizeof(*packet)); -} - -void login_login_error(int fd, uint8 error) -{ - struct packet_AC_REFUSE_LOGIN *packet = NULL; - WFIFOHEAD(fd, sizeof(*packet)); - packet = WP2PTR(fd); - packet->packet_id = PACKET_ID_AC_REFUSE_LOGIN; - packet->error_code = error; - memset(packet->block_date, '\0', sizeof(packet->block_date)); - WFIFOSET(fd, sizeof(*packet)); -} - -enum parsefunc_rcode login_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) -{ - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) -{ - 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; -} - -enum parsefunc_rcode login_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN2(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN3(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* sd->clientinfo = packet->clientinfo; */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN4(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - bin2hex(sd->passwd, packet->password_md5, 16); - sd->passwdenc = PASSWORDENC; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) -{ - const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); - - sd->version = packet->version; - sd->clienttype = packet->clienttype; - /* unused */ - /* safestrncpy(sd->ip, packet->ip, sizeof(sd->ip)); */ - /* safestrncpy(sd->mac_address, packet->mac_address, sizeof(sd->mac_address)); */ - /* sd->ishan = packet->is_han_game_user; */ - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->password, PASSWD_LEN); - - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - - login->client_login(fd, sd); - return PACKET_VALID; -} - -enum parsefunc_rcode login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) -{ - 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("login_parse_CA_SSO_LOGIN_REQ: Token length is not between allowed password length, kicking player ('%s')", packet->id); - sockt->eof(fd); - return PACKET_VALID; - } - - sd->clienttype = packet->clienttype; - sd->version = packet->version; - safestrncpy(sd->userid, packet->id, NAME_LENGTH); - safestrncpy(sd->passwd, packet->t1, min(tokenlen + 1, PASSWD_LEN)); // Variable-length field, don't copy more than necessary - - if (login->config->use_md5_passwds) - MD5_String(sd->passwd, sd->passwd); - sd->passwdenc = PWENC_NONE; - - login->client_login(fd, sd); - return PACKET_VALID; + lclif->auth_failed(fd, ban_time, result); } bool login_client_login(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); @@ -1832,31 +1350,6 @@ bool login_client_login(int fd, struct login_session_data *sd) return false; } -void login_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void login_send_coding_key(int fd, struct login_session_data *sd) -{ - 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_len = size; - memcpy(packet->secret, sd->md5key, sd->md5keylen); - WFIFOSET(fd, size); -} - -enum parsefunc_rcode login_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) -{ - memset(sd->md5key, '\0', sizeof(sd->md5key)); - sd->md5keylen = (uint16)(12 + rnd() % 4); - MD5_Salt(sd->md5keylen, sd->md5key); - - login->send_coding_key(fd, sd); - return PACKET_VALID; -} - void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2))); void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) { @@ -1866,18 +1359,7 @@ void login_char_server_connection_status(int fd, struct login_session_data* sd, WFIFOSET(fd,3); } -enum parsefunc_rcode login_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode login_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) -{ - char ip[16]; - uint32 ipl = sockt->session[fd]->client_addr; - sockt->ip2str(ipl, ip); - - login->parse_request_connection(fd, sd, ip, ipl); - - return PACKET_STOPPARSE; -} - +// CA_CHARSERVERCONNECT void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3))); void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) { @@ -1937,140 +1419,6 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const } } -struct login_packet_db *login_lclif_packet(int16 packet_id) -{ - if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) - return &packet_db[0]; - - if (packet_id > MAX_PACKET_DB || packet_id < MIN_PACKET_DB) - return NULL; - - return &packet_db[packet_id]; -} - -enum parsefunc_rcode login_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) -{ - int result; - result = lpd->pFunc(fd, sd); - RFIFOSKIP(fd, (lpd->len == -1) ? RFIFOW(fd, 2) : lpd->len); - return result; -} - -//---------------------------------------------------------------------------------------- -// Default packet parsing (normal players or char-server connection requests) -//---------------------------------------------------------------------------------------- -int login_parse_login(int fd) -{ - struct login_session_data *sd = NULL; - int i; - char ip[16]; - uint32 ipl = sockt->session[fd]->client_addr; - sockt->ip2str(ipl, ip); - - if (sockt->session[fd]->flag.eof) { - ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip); - sockt->close(fd); - return 0; - } - - if ((sd = sockt->session[fd]->session_data) == NULL) { - // Perform ip-ban check - if (login->config->ipban && !sockt->trusted_ip_check(ipl) && ipban_check(ipl)) { - ShowStatus("Connection refused: IP isn't authorized (deny/allow, ip: %s).\n", ip); - login_log(ipl, "unknown", -3, "ip banned"); - login->login_error(fd, 3); // 3 = Rejected from Server - sockt->eof(fd); - return 0; - } - - // create a session for this new connection - CREATE(sockt->session[fd]->session_data, struct login_session_data, 1); - sd = sockt->session[fd]->session_data; - sd->fd = fd; - } - - for (i = 0; i < MAX_PROCESSED_PACKETS; ++i) { - enum parsefunc_rcode result; - int16 packet_id = RFIFOW(fd, 0); - int packet_len = (int)RFIFOREST(fd); - - if (packet_len < 2) - return 0; - - result = login->parse_login_sub(fd, sd); - - switch (result) { - case PACKET_SKIP: - continue; - case PACKET_INCOMPLETE: - case PACKET_STOPPARSE: - return 0; - case PACKET_UNKNOWN: - ShowWarning("login_parse_login: Received unsupported packet (packet 0x%04x, %d bytes received), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); -#ifdef DUMP_INVALID_PACKET - ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); -#endif - sockt->eof(fd); - return 0; - case PACKET_INVALIDLENGTH: - ShowWarning("login_parse_login: Received packet 0x%04x specifies invalid packet_len (%d), disconnecting session #%d.\n", (unsigned int)packet_id, packet_len, fd); -#ifdef DUMP_INVALID_PACKET - ShowDump(RFIFOP(fd, 0), RFIFOREST(fd)); -#endif - sockt->eof(fd); - return 0; - } - } - return 0; -} - -enum parsefunc_rcode login_parse_login_sub(int fd, struct login_session_data *sd) -{ - int packet_len = (int)RFIFOREST(fd); - int16 packet_id = RFIFOW(fd, 0); - const struct login_packet_db *lpd; - - if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { - int result = HPM->parse_packets(fd, packet_id, hpParse_Login); - if (result == 1) - return PACKET_VALID; - if (result == 2) - return PACKET_INCOMPLETE; // Packet not completed yet - } - - lpd = login_lclif_packet(packet_id); - - if (lpd == NULL) - return PACKET_UNKNOWN; - - if (lpd->len == 0) - return PACKET_UNKNOWN; - - if (lpd->len > 0 && lpd->pFunc == NULL) - return PACKET_UNKNOWN; //This Packet is defined for length purpose ? should never be sent from client ? - - if (lpd->len == -1) { - uint16 packet_var_len = 0; //Max Variable Packet length is signed int16 size - - if (packet_len < 4) - return PACKET_INCOMPLETE; //Packet incomplete - - packet_var_len = RFIFOW(fd, 2); - - if (packet_var_len < 4 || packet_var_len > SINT16_MAX) - return PACKET_INVALIDLENGTH; //Something is wrong, close connection. - - if (RFIFOREST(fd) < packet_var_len) - return PACKET_INCOMPLETE; //Packet incomplete again. - - return login->parse_packet(lpd, fd, sd); - } else if (lpd->len <= packet_len) { - return login->parse_packet(lpd, fd, sd); - } - - return PACKET_VALID; -} - void login_config_set_defaults(void) { login->config->login_ip = INADDR_ANY; @@ -2265,6 +1613,8 @@ int do_final(void) { login->fd = -1; } + lclif->final(); + HPM_login_do_final(); aFree(login->LOGIN_CONF_NAME); @@ -2338,47 +1688,6 @@ void cmdline_args_init_local(void) CMDLINEARG_DEF2(net-config, netconfig, "Alternative subnet configuration.", CMDLINE_OPT_PARAM); } -void packetdb_loaddb(void) -{ - - int i; - struct packet { - int16 packet_id; - int16 packet_len; - int (*pFunc)(int, struct login_session_data *); - } packet[] = { -#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), login_parse_ ## name } -#define packet_def2(name, len) { PACKET_ID_ ## name, (len), login_parse_ ## name } - packet_def(CA_CONNECT_INFO_CHANGED), - packet_def(CA_EXE_HASHCHECK), - packet_def(CA_LOGIN), - packet_def(CA_LOGIN2), - packet_def(CA_LOGIN3), - packet_def(CA_LOGIN4), - packet_def(CA_LOGIN_PCBANG), - packet_def(CA_LOGIN_HAN), - packet_def2(CA_SSO_LOGIN_REQ, -1), - packet_def(CA_REQ_HASH), -#undef packet_def -#undef packet_def2 - }; - int length = ARRAYLENGTH(packet); - - memset(packet_db, '\0', sizeof(packet_db)); - - for (i = 0; i < length; ++i) { - int16 packet_id = packet[i].packet_id; - Assert_retb(packet_id >= MIN_PACKET_DB && packet_id < MAX_PACKET_DB); - packet_db[packet_id].len = packet[i].packet_len; - packet_db[packet_id].pFunc = packet[i].pFunc; - } - - //Explict case, we will save character login packet in position 0 which is unused and not valid by normal - packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); - packet_db[0].pFunc = login_parse_CA_CHARSERVERCONNECT; - -} - //------------------------------ // Login server initialization //------------------------------ @@ -2395,6 +1704,7 @@ int do_init(int argc, char** argv) } login_defaults(); + lclif_defaults(); // read login-server configuration login->config_set_defaults(); @@ -2402,6 +1712,8 @@ int do_init(int argc, char** argv) login->LOGIN_CONF_NAME = aStrdup("conf/login-server.conf"); login->NET_CONF_NAME = aStrdup("conf/network.conf"); + lclif->init(); + HPM_login_do_init(); cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT); HPM->config_read(); @@ -2411,8 +1723,6 @@ int do_init(int argc, char** argv) login_config_read(login->LOGIN_CONF_NAME); sockt->net_config_read(login->NET_CONF_NAME); - packetdb_loaddb(); - for( i = 0; i < ARRAYLENGTH(server); ++i ) chrif_server_init(i); @@ -2430,8 +1740,8 @@ int do_init(int argc, char** argv) // Interserver auth init login->auth_db = idb_alloc(DB_OPT_RELEASE_DATA); - // set default parser as login_parse_login function - sockt->set_defaultparse(login->parse_login); + // set default parser as lclif->parse function + sockt->set_defaultparse(lclif->parse); // every 10 minutes cleanup online account db. timer->add_func_list(login->online_data_cleanup, "login->online_data_cleanup"); @@ -2523,21 +1833,15 @@ void login_defaults(void) { login->fromchar_parse_accinfo = login_fromchar_parse_accinfo; login->parse_fromchar = login_parse_fromchar; - login->parse_login = login_parse_login; + login->client_login = login_client_login; + login->parse_request_connection = login_parse_request_connection; login->auth_ok = login_auth_ok; login->auth_failed = login_auth_failed; - login->send_auth_failed = login_send_auth_failed; login->char_server_connection_status = login_char_server_connection_status; - login->connection_error = login_connection_error; login->kick = login_kick; - login->login_error = login_login_error; - login->send_coding_key = login_send_coding_key; login->config_set_defaults = login_config_set_defaults; login->config_read = login_config_read; login->LOGIN_CONF_NAME = NULL; login->NET_CONF_NAME = NULL; - - login->parse_packet = login_parse_packet; - login->parse_login_sub = login_parse_login_sub; } diff --git a/src/login/login.h b/src/login/login.h index 9402dbd74..7c2e5925f 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -28,7 +28,6 @@ struct mmo_account; struct AccountDB; -struct login_packet_db; enum E_LOGINSERVER_ST { @@ -44,16 +43,6 @@ enum password_enc { PWENC_BOTH = PWENC_ENCRYPT|PWENC_ENCRYPT2, ///< both the above }; -/// Parse function return code -enum parsefunc_rcode { - PACKET_VALID = 1, - PACKET_INCOMPLETE = 0, - PACKET_UNKNOWN = -1, - PACKET_INVALIDLENGTH = -2, - PACKET_STOPPARSE = -3, - PACKET_SKIP = -4, //internal parser will skip this packet and go parser another, meant for plugins. [hemagx] -}; - #define PASSWORDENC PWENC_BOTH #define PASSWD_LEN (32+1) // 23+1 for plaintext, 32+1 for md5-ed passwords @@ -207,28 +196,16 @@ struct login_interface { bool (*fromchar_parse_wrong_pincode) (int fd); void (*fromchar_parse_accinfo) (int fd); int (*parse_fromchar) (int fd); - void (*connection_error) (int fd, uint8 error); void (*kick) (struct login_session_data* sd); void (*auth_ok) (struct login_session_data* sd); void (*auth_failed) (struct login_session_data* sd, int result); - void (*send_auth_failed) (int fd, time_t ban, uint32 error); - void (*login_error) (int fd, uint8 error); - void (*parse_ping) (int fd, struct login_session_data* sd); - void (*parse_client_md5) (int fd, struct login_session_data* sd); bool (*client_login) (int fd, struct login_session_data *sd); - void (*send_coding_key) (int fd, struct login_session_data* sd); - void (*parse_request_coding_key) (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); - int (*parse_login) (int fd); void (*config_set_defaults) (void); int (*config_read) (const char *cfgName); char *LOGIN_CONF_NAME; char *NET_CONF_NAME; ///< Network configuration filename - - // lclif - enum parsefunc_rcode (*parse_packet)(const struct login_packet_db *lpd, int fd, struct login_session_data *sd); - enum parsefunc_rcode (*parse_login_sub)(int fd, struct login_session_data *sd); }; #ifdef HERCULES_CORE diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index 7a26c8f98..f809ff4ab 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2013-2015 Hercules Dev Team + * Copyright (C) 2013-2016 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 @@ -29,6 +29,7 @@ #define HPM_HOOKS_INCLUDE "HPMHooking/HPMHooking_login.Hooks.inc" #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_login.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_login.sources.inc" +#include "login/lclif.h" #include "login/login.h" #elif defined (HPMHOOKING_CHAR) #define HPM_SERVER_TYPE SERVER_TYPE_CHAR diff --git a/vcproj-10/login-server.vcxproj b/vcproj-10/login-server.vcxproj index 5fc5c5419..32c265bae 100644 --- a/vcproj-10/login-server.vcxproj +++ b/vcproj-10/login-server.vcxproj @@ -156,6 +156,7 @@ + @@ -192,6 +193,7 @@ + diff --git a/vcproj-10/login-server.vcxproj.filters b/vcproj-10/login-server.vcxproj.filters index 29cbe05d3..8c8ed7c21 100644 --- a/vcproj-10/login-server.vcxproj.filters +++ b/vcproj-10/login-server.vcxproj.filters @@ -94,6 +94,9 @@ common + + login + @@ -237,6 +240,9 @@ config + + login + diff --git a/vcproj-11/login-server.vcxproj b/vcproj-11/login-server.vcxproj index 215fe2843..66b94b4c4 100644 --- a/vcproj-11/login-server.vcxproj +++ b/vcproj-11/login-server.vcxproj @@ -160,6 +160,7 @@ + @@ -196,6 +197,7 @@ + diff --git a/vcproj-11/login-server.vcxproj.filters b/vcproj-11/login-server.vcxproj.filters index 29cbe05d3..8c8ed7c21 100644 --- a/vcproj-11/login-server.vcxproj.filters +++ b/vcproj-11/login-server.vcxproj.filters @@ -94,6 +94,9 @@ common + + login + @@ -237,6 +240,9 @@ config + + login + diff --git a/vcproj-12/login-server.vcxproj b/vcproj-12/login-server.vcxproj index e444b709a..6f28436b8 100644 --- a/vcproj-12/login-server.vcxproj +++ b/vcproj-12/login-server.vcxproj @@ -160,6 +160,7 @@ + @@ -196,6 +197,7 @@ + diff --git a/vcproj-12/login-server.vcxproj.filters b/vcproj-12/login-server.vcxproj.filters index 29cbe05d3..8c8ed7c21 100644 --- a/vcproj-12/login-server.vcxproj.filters +++ b/vcproj-12/login-server.vcxproj.filters @@ -94,6 +94,9 @@ common + + login + @@ -237,6 +240,9 @@ config + + login + diff --git a/vcproj-14/login-server.vcxproj b/vcproj-14/login-server.vcxproj index 4fa49b2d1..cb9d8449c 100644 --- a/vcproj-14/login-server.vcxproj +++ b/vcproj-14/login-server.vcxproj @@ -158,6 +158,7 @@ + @@ -194,6 +195,7 @@ + diff --git a/vcproj-14/login-server.vcxproj.filters b/vcproj-14/login-server.vcxproj.filters index 29cbe05d3..8c8ed7c21 100644 --- a/vcproj-14/login-server.vcxproj.filters +++ b/vcproj-14/login-server.vcxproj.filters @@ -94,6 +94,9 @@ common + + login + @@ -237,6 +240,9 @@ config + + login + -- cgit v1.2.3-70-g09d2 From ceef84e730a89b9ff462862bba66e2da1c25617e Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 14 Apr 2016 13:38:12 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/common/HPMDataCheck.h | 6 + src/common/HPMSymbols.inc.h | 6 + .../HPMHooking/HPMHooking_login.HPMHooksCore.inc | 81 ++-- .../HPMHooking/HPMHooking_login.HookingPoints.inc | 21 +- src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 499 +++++++++++++-------- .../HPMHooking/HPMHooking_login.sources.inc | 1 + 6 files changed, 379 insertions(+), 235 deletions(-) (limited to 'src') diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 7e88b5a34..048855edb 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -270,6 +270,12 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define LOGIN_ACCOUNT_H #endif // LOGIN_ACCOUNT_H + #ifdef LOGIN_LCLIF_H + { "lclif_interface", sizeof(struct lclif_interface), SERVER_TYPE_LOGIN }, + { "login_packet_db", sizeof(struct login_packet_db), SERVER_TYPE_LOGIN }, + #else + #define LOGIN_LCLIF_H + #endif // LOGIN_LCLIF_H #ifdef LOGIN_LOGIN_H { "Login_Config", sizeof(struct Login_Config), SERVER_TYPE_LOGIN }, { "client_hash_node", sizeof(struct client_hash_node), SERVER_TYPE_LOGIN }, diff --git a/src/common/HPMSymbols.inc.h b/src/common/HPMSymbols.inc.h index b06c43bf8..be758a055 100644 --- a/src/common/HPMSymbols.inc.h +++ b/src/common/HPMSymbols.inc.h @@ -129,6 +129,9 @@ struct irc_bot_interface *ircbot; #ifdef MAP_ITEMDB_H /* itemdb */ struct itemdb_interface *itemdb; #endif // MAP_ITEMDB_H +#ifdef LOGIN_LCLIF_H /* lclif */ +struct lclif_interface *lclif; +#endif // LOGIN_LCLIF_H #ifdef COMMON_CONF_H /* libconfig */ struct libconfig_interface *libconfig; #endif // COMMON_CONF_H @@ -358,6 +361,9 @@ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("ircbot", ircbot)) return "ir #ifdef MAP_ITEMDB_H /* itemdb */ if ((server_type&(SERVER_TYPE_MAP)) && !HPM_SYMBOL("itemdb", itemdb)) return "itemdb"; #endif // MAP_ITEMDB_H +#ifdef LOGIN_LCLIF_H /* lclif */ +if ((server_type&(SERVER_TYPE_LOGIN)) && !HPM_SYMBOL("lclif", lclif)) return "lclif"; +#endif // LOGIN_LCLIF_H #ifdef COMMON_CONF_H /* libconfig */ if ((server_type&(SERVER_TYPE_ALL)) && !HPM_SYMBOL("libconfig", libconfig)) return "libconfig"; #endif // COMMON_CONF_H diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 67257883f..537c88936 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -90,6 +90,28 @@ struct { struct HPMHookPoint *HP_DB_init_post; struct HPMHookPoint *HP_DB_final_pre; struct HPMHookPoint *HP_DB_final_post; + struct HPMHookPoint *HP_lclif_init_pre; + struct HPMHookPoint *HP_lclif_init_post; + struct HPMHookPoint *HP_lclif_final_pre; + struct HPMHookPoint *HP_lclif_final_post; + struct HPMHookPoint *HP_lclif_connection_error_pre; + struct HPMHookPoint *HP_lclif_connection_error_post; + struct HPMHookPoint *HP_lclif_server_list_pre; + struct HPMHookPoint *HP_lclif_server_list_post; + struct HPMHookPoint *HP_lclif_auth_failed_pre; + struct HPMHookPoint *HP_lclif_auth_failed_post; + struct HPMHookPoint *HP_lclif_login_error_pre; + struct HPMHookPoint *HP_lclif_login_error_post; + struct HPMHookPoint *HP_lclif_coding_key_pre; + struct HPMHookPoint *HP_lclif_coding_key_post; + struct HPMHookPoint *HP_lclif_packet_pre; + struct HPMHookPoint *HP_lclif_packet_post; + struct HPMHookPoint *HP_lclif_parse_packet_pre; + struct HPMHookPoint *HP_lclif_parse_packet_post; + struct HPMHookPoint *HP_lclif_parse_pre; + struct HPMHookPoint *HP_lclif_parse_post; + struct HPMHookPoint *HP_lclif_parse_sub_pre; + struct HPMHookPoint *HP_lclif_parse_sub_post; struct HPMHookPoint *HP_libconfig_read_pre; struct HPMHookPoint *HP_libconfig_read_post; struct HPMHookPoint *HP_libconfig_write_pre; @@ -308,32 +330,18 @@ struct { struct HPMHookPoint *HP_login_fromchar_parse_accinfo_post; struct HPMHookPoint *HP_login_parse_fromchar_pre; struct HPMHookPoint *HP_login_parse_fromchar_post; - struct HPMHookPoint *HP_login_connection_problem_pre; - struct HPMHookPoint *HP_login_connection_problem_post; struct HPMHookPoint *HP_login_kick_pre; struct HPMHookPoint *HP_login_kick_post; struct HPMHookPoint *HP_login_auth_ok_pre; struct HPMHookPoint *HP_login_auth_ok_post; struct HPMHookPoint *HP_login_auth_failed_pre; struct HPMHookPoint *HP_login_auth_failed_post; - struct HPMHookPoint *HP_login_login_error_pre; - struct HPMHookPoint *HP_login_login_error_post; - struct HPMHookPoint *HP_login_parse_ping_pre; - struct HPMHookPoint *HP_login_parse_ping_post; - struct HPMHookPoint *HP_login_parse_client_md5_pre; - struct HPMHookPoint *HP_login_parse_client_md5_post; - struct HPMHookPoint *HP_login_parse_client_login_pre; - struct HPMHookPoint *HP_login_parse_client_login_post; - struct HPMHookPoint *HP_login_send_coding_key_pre; - struct HPMHookPoint *HP_login_send_coding_key_post; - struct HPMHookPoint *HP_login_parse_request_coding_key_pre; - struct HPMHookPoint *HP_login_parse_request_coding_key_post; + struct HPMHookPoint *HP_login_client_login_pre; + struct HPMHookPoint *HP_login_client_login_post; struct HPMHookPoint *HP_login_char_server_connection_status_pre; struct HPMHookPoint *HP_login_char_server_connection_status_post; struct HPMHookPoint *HP_login_parse_request_connection_pre; struct HPMHookPoint *HP_login_parse_request_connection_post; - struct HPMHookPoint *HP_login_parse_login_pre; - struct HPMHookPoint *HP_login_parse_login_post; struct HPMHookPoint *HP_login_config_set_defaults_pre; struct HPMHookPoint *HP_login_config_set_defaults_post; struct HPMHookPoint *HP_login_config_read_pre; @@ -691,6 +699,28 @@ struct { int HP_DB_init_post; int HP_DB_final_pre; int HP_DB_final_post; + int HP_lclif_init_pre; + int HP_lclif_init_post; + int HP_lclif_final_pre; + int HP_lclif_final_post; + int HP_lclif_connection_error_pre; + int HP_lclif_connection_error_post; + int HP_lclif_server_list_pre; + int HP_lclif_server_list_post; + int HP_lclif_auth_failed_pre; + int HP_lclif_auth_failed_post; + int HP_lclif_login_error_pre; + int HP_lclif_login_error_post; + int HP_lclif_coding_key_pre; + int HP_lclif_coding_key_post; + int HP_lclif_packet_pre; + int HP_lclif_packet_post; + int HP_lclif_parse_packet_pre; + int HP_lclif_parse_packet_post; + int HP_lclif_parse_pre; + int HP_lclif_parse_post; + int HP_lclif_parse_sub_pre; + int HP_lclif_parse_sub_post; int HP_libconfig_read_pre; int HP_libconfig_read_post; int HP_libconfig_write_pre; @@ -909,32 +939,18 @@ struct { int HP_login_fromchar_parse_accinfo_post; int HP_login_parse_fromchar_pre; int HP_login_parse_fromchar_post; - int HP_login_connection_problem_pre; - int HP_login_connection_problem_post; int HP_login_kick_pre; int HP_login_kick_post; int HP_login_auth_ok_pre; int HP_login_auth_ok_post; int HP_login_auth_failed_pre; int HP_login_auth_failed_post; - int HP_login_login_error_pre; - int HP_login_login_error_post; - int HP_login_parse_ping_pre; - int HP_login_parse_ping_post; - int HP_login_parse_client_md5_pre; - int HP_login_parse_client_md5_post; - int HP_login_parse_client_login_pre; - int HP_login_parse_client_login_post; - int HP_login_send_coding_key_pre; - int HP_login_send_coding_key_post; - int HP_login_parse_request_coding_key_pre; - int HP_login_parse_request_coding_key_post; + int HP_login_client_login_pre; + int HP_login_client_login_post; int HP_login_char_server_connection_status_pre; int HP_login_char_server_connection_status_post; int HP_login_parse_request_connection_pre; int HP_login_parse_request_connection_post; - int HP_login_parse_login_pre; - int HP_login_parse_login_post; int HP_login_config_set_defaults_pre; int HP_login_config_set_defaults_post; int HP_login_config_read_pre; @@ -1231,6 +1247,7 @@ struct { struct console_interface console; struct core_interface core; struct db_interface DB; + struct lclif_interface lclif; struct libconfig_interface libconfig; struct login_interface login; struct malloc_interface iMalloc; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index 50efba987..a5adac2d0 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -61,6 +61,18 @@ struct HookingPointData HookingPoints[] = { { HP_POP(DB->data2ptr, HP_DB_data2ptr) }, { HP_POP(DB->init, HP_DB_init) }, { HP_POP(DB->final, HP_DB_final) }, +/* lclif_interface */ + { HP_POP(lclif->init, HP_lclif_init) }, + { HP_POP(lclif->final, HP_lclif_final) }, + { HP_POP(lclif->connection_error, HP_lclif_connection_error) }, + { HP_POP(lclif->server_list, HP_lclif_server_list) }, + { HP_POP(lclif->auth_failed, HP_lclif_auth_failed) }, + { HP_POP(lclif->login_error, HP_lclif_login_error) }, + { HP_POP(lclif->coding_key, HP_lclif_coding_key) }, + { HP_POP(lclif->packet, HP_lclif_packet) }, + { HP_POP(lclif->parse_packet, HP_lclif_parse_packet) }, + { HP_POP(lclif->parse, HP_lclif_parse) }, + { HP_POP(lclif->parse_sub, HP_lclif_parse_sub) }, /* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, @@ -172,19 +184,12 @@ struct HookingPointData HookingPoints[] = { { HP_POP(login->fromchar_parse_wrong_pincode, HP_login_fromchar_parse_wrong_pincode) }, { HP_POP(login->fromchar_parse_accinfo, HP_login_fromchar_parse_accinfo) }, { HP_POP(login->parse_fromchar, HP_login_parse_fromchar) }, - { HP_POP(login->connection_problem, HP_login_connection_problem) }, { HP_POP(login->kick, HP_login_kick) }, { HP_POP(login->auth_ok, HP_login_auth_ok) }, { HP_POP(login->auth_failed, HP_login_auth_failed) }, - { HP_POP(login->login_error, HP_login_login_error) }, - { HP_POP(login->parse_ping, HP_login_parse_ping) }, - { HP_POP(login->parse_client_md5, HP_login_parse_client_md5) }, - { HP_POP(login->parse_client_login, HP_login_parse_client_login) }, - { HP_POP(login->send_coding_key, HP_login_send_coding_key) }, - { HP_POP(login->parse_request_coding_key, HP_login_parse_request_coding_key) }, + { HP_POP(login->client_login, HP_login_client_login) }, { HP_POP(login->char_server_connection_status, HP_login_char_server_connection_status) }, { HP_POP(login->parse_request_connection, HP_login_parse_request_connection) }, - { HP_POP(login->parse_login, HP_login_parse_login) }, { HP_POP(login->config_set_defaults, HP_login_config_set_defaults) }, { HP_POP(login->config_read, HP_login_config_read) }, /* malloc_interface */ diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index bd33f0d42..b7ff2b77b 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -917,6 +917,298 @@ void HP_DB_final(void) { } return; } +/* lclif_interface */ +void HP_lclif_init(void) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_init_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_init_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_init_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.init(); + } + if( HPMHooks.count.HP_lclif_init_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_init_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_init_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_lclif_final(void) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_final_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_final_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_final_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.final(); + } + if( HPMHooks.count.HP_lclif_final_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_final_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_final_post[hIndex].func; + postHookFunc(); + } + } + return; +} +void HP_lclif_connection_error(int fd, uint8 error) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_connection_error_pre ) { + void (*preHookFunc) (int *fd, uint8 *error); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_connection_error_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_connection_error_pre[hIndex].func; + preHookFunc(&fd, &error); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.connection_error(fd, error); + } + if( HPMHooks.count.HP_lclif_connection_error_post ) { + void (*postHookFunc) (int *fd, uint8 *error); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_connection_error_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_connection_error_post[hIndex].func; + postHookFunc(&fd, &error); + } + } + return; +} +bool HP_lclif_server_list(struct login_session_data *sd) { + int hIndex = 0; + bool retVal___ = false; + if( HPMHooks.count.HP_lclif_server_list_pre ) { + bool (*preHookFunc) (struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_server_list_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_server_list_pre[hIndex].func; + retVal___ = preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.lclif.server_list(sd); + } + if( HPMHooks.count.HP_lclif_server_list_post ) { + bool (*postHookFunc) (bool retVal___, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_server_list_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_server_list_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd); + } + } + return retVal___; +} +void HP_lclif_auth_failed(int fd, time_t ban, uint32 error) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_auth_failed_pre ) { + void (*preHookFunc) (int *fd, time_t *ban, uint32 *error); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_auth_failed_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_auth_failed_pre[hIndex].func; + preHookFunc(&fd, &ban, &error); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.auth_failed(fd, ban, error); + } + if( HPMHooks.count.HP_lclif_auth_failed_post ) { + void (*postHookFunc) (int *fd, time_t *ban, uint32 *error); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_auth_failed_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_auth_failed_post[hIndex].func; + postHookFunc(&fd, &ban, &error); + } + } + return; +} +void HP_lclif_login_error(int fd, uint8 error) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_login_error_pre ) { + void (*preHookFunc) (int *fd, uint8 *error); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_login_error_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_login_error_pre[hIndex].func; + preHookFunc(&fd, &error); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.login_error(fd, error); + } + if( HPMHooks.count.HP_lclif_login_error_post ) { + void (*postHookFunc) (int *fd, uint8 *error); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_login_error_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_login_error_post[hIndex].func; + postHookFunc(&fd, &error); + } + } + return; +} +void HP_lclif_coding_key(int fd, struct login_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_lclif_coding_key_pre ) { + void (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_coding_key_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_coding_key_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.lclif.coding_key(fd, sd); + } + if( HPMHooks.count.HP_lclif_coding_key_post ) { + void (*postHookFunc) (int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_coding_key_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_coding_key_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} +const struct login_packet_db* HP_lclif_packet(int16 packet_id) { + int hIndex = 0; + const struct login_packet_db* retVal___ = NULL; + if( HPMHooks.count.HP_lclif_packet_pre ) { + const struct login_packet_db* (*preHookFunc) (int16 *packet_id); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_packet_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_packet_pre[hIndex].func; + retVal___ = preHookFunc(&packet_id); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.lclif.packet(packet_id); + } + if( HPMHooks.count.HP_lclif_packet_post ) { + const struct login_packet_db* (*postHookFunc) (const struct login_packet_db* retVal___, int16 *packet_id); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_packet_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_packet_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &packet_id); + } + } + return retVal___; +} +enum parsefunc_rcode HP_lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_lclif_parse_packet_pre ) { + enum parsefunc_rcode (*preHookFunc) (const struct login_packet_db *lpd, int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_packet_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_parse_packet_pre[hIndex].func; + retVal___ = preHookFunc(lpd, &fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.lclif.parse_packet(lpd, fd, sd); + } + if( HPMHooks.count.HP_lclif_parse_packet_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, const struct login_packet_db *lpd, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_packet_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_parse_packet_post[hIndex].func; + retVal___ = postHookFunc(retVal___, lpd, &fd, sd); + } + } + return retVal___; +} +int HP_lclif_parse(int fd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_lclif_parse_pre ) { + int (*preHookFunc) (int *fd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_parse_pre[hIndex].func; + retVal___ = preHookFunc(&fd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.lclif.parse(fd); + } + if( HPMHooks.count.HP_lclif_parse_post ) { + int (*postHookFunc) (int retVal___, int *fd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_parse_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_lclif_parse_sub(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_lclif_parse_sub_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_sub_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_lclif_parse_sub_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.lclif.parse_sub(fd, sd); + } + if( HPMHooks.count.HP_lclif_parse_sub_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_sub_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_lclif_parse_sub_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} /* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; @@ -3844,32 +4136,6 @@ int HP_login_parse_fromchar(int fd) { } return retVal___; } -void HP_login_connection_problem(int fd, uint8 status) { - int hIndex = 0; - if( HPMHooks.count.HP_login_connection_problem_pre ) { - void (*preHookFunc) (int *fd, uint8 *status); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_connection_problem_pre[hIndex].func; - preHookFunc(&fd, &status); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.connection_problem(fd, status); - } - if( HPMHooks.count.HP_login_connection_problem_post ) { - void (*postHookFunc) (int *fd, uint8 *status); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_connection_problem_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_connection_problem_post[hIndex].func; - postHookFunc(&fd, &status); - } - } - return; -} void HP_login_kick(struct login_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_login_kick_pre ) { @@ -3948,93 +4214,15 @@ void HP_login_auth_failed(struct login_session_data *sd, int result) { } return; } -void HP_login_login_error(int fd, uint8 status) { - int hIndex = 0; - if( HPMHooks.count.HP_login_login_error_pre ) { - void (*preHookFunc) (int *fd, uint8 *status); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_login_error_pre[hIndex].func; - preHookFunc(&fd, &status); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.login_error(fd, status); - } - if( HPMHooks.count.HP_login_login_error_post ) { - void (*postHookFunc) (int *fd, uint8 *status); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_login_error_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_login_error_post[hIndex].func; - postHookFunc(&fd, &status); - } - } - return; -} -void HP_login_parse_ping(int fd, struct login_session_data *sd) { - int hIndex = 0; - if( HPMHooks.count.HP_login_parse_ping_pre ) { - void (*preHookFunc) (int *fd, struct login_session_data *sd); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_parse_ping_pre[hIndex].func; - preHookFunc(&fd, sd); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.parse_ping(fd, sd); - } - if( HPMHooks.count.HP_login_parse_ping_post ) { - void (*postHookFunc) (int *fd, struct login_session_data *sd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_ping_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_parse_ping_post[hIndex].func; - postHookFunc(&fd, sd); - } - } - return; -} -void HP_login_parse_client_md5(int fd, struct login_session_data *sd) { - int hIndex = 0; - if( HPMHooks.count.HP_login_parse_client_md5_pre ) { - void (*preHookFunc) (int *fd, struct login_session_data *sd); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_parse_client_md5_pre[hIndex].func; - preHookFunc(&fd, sd); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.parse_client_md5(fd, sd); - } - if( HPMHooks.count.HP_login_parse_client_md5_post ) { - void (*postHookFunc) (int *fd, struct login_session_data *sd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_md5_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_parse_client_md5_post[hIndex].func; - postHookFunc(&fd, sd); - } - } - return; -} -bool HP_login_parse_client_login(int fd, struct login_session_data *sd, const char *ip) { +bool HP_login_client_login(int fd, struct login_session_data *sd) { int hIndex = 0; bool retVal___ = false; - if( HPMHooks.count.HP_login_parse_client_login_pre ) { - bool (*preHookFunc) (int *fd, struct login_session_data *sd, const char *ip); + if( HPMHooks.count.HP_login_client_login_pre ) { + bool (*preHookFunc) (int *fd, struct login_session_data *sd); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_parse_client_login_pre[hIndex].func; - retVal___ = preHookFunc(&fd, sd, ip); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_client_login_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_login_client_login_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -4042,69 +4230,17 @@ bool HP_login_parse_client_login(int fd, struct login_session_data *sd, const ch } } { - retVal___ = HPMHooks.source.login.parse_client_login(fd, sd, ip); + retVal___ = HPMHooks.source.login.client_login(fd, sd); } - if( HPMHooks.count.HP_login_parse_client_login_post ) { - bool (*postHookFunc) (bool retVal___, int *fd, struct login_session_data *sd, const char *ip); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_client_login_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_parse_client_login_post[hIndex].func; - retVal___ = postHookFunc(retVal___, &fd, sd, ip); + if( HPMHooks.count.HP_login_client_login_post ) { + bool (*postHookFunc) (bool retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_login_client_login_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_login_client_login_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); } } return retVal___; } -void HP_login_send_coding_key(int fd, struct login_session_data *sd) { - int hIndex = 0; - if( HPMHooks.count.HP_login_send_coding_key_pre ) { - void (*preHookFunc) (int *fd, struct login_session_data *sd); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_send_coding_key_pre[hIndex].func; - preHookFunc(&fd, sd); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.send_coding_key(fd, sd); - } - if( HPMHooks.count.HP_login_send_coding_key_post ) { - void (*postHookFunc) (int *fd, struct login_session_data *sd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_send_coding_key_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_send_coding_key_post[hIndex].func; - postHookFunc(&fd, sd); - } - } - return; -} -void HP_login_parse_request_coding_key(int fd, struct login_session_data *sd) { - int hIndex = 0; - if( HPMHooks.count.HP_login_parse_request_coding_key_pre ) { - void (*preHookFunc) (int *fd, struct login_session_data *sd); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_pre[hIndex].func; - preHookFunc(&fd, sd); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return; - } - } - { - HPMHooks.source.login.parse_request_coding_key(fd, sd); - } - if( HPMHooks.count.HP_login_parse_request_coding_key_post ) { - void (*postHookFunc) (int *fd, struct login_session_data *sd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_request_coding_key_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_parse_request_coding_key_post[hIndex].func; - postHookFunc(&fd, sd); - } - } - return; -} void HP_login_char_server_connection_status(int fd, struct login_session_data *sd, uint8 status) { int hIndex = 0; if( HPMHooks.count.HP_login_char_server_connection_status_pre ) { @@ -4157,33 +4293,6 @@ void HP_login_parse_request_connection(int fd, struct login_session_data *sd, co } return; } -int HP_login_parse_login(int fd) { - int hIndex = 0; - int retVal___ = 0; - if( HPMHooks.count.HP_login_parse_login_pre ) { - int (*preHookFunc) (int *fd); - *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_login_parse_login_pre[hIndex].func; - retVal___ = preHookFunc(&fd); - } - if( *HPMforce_return ) { - *HPMforce_return = false; - return retVal___; - } - } - { - retVal___ = HPMHooks.source.login.parse_login(fd); - } - if( HPMHooks.count.HP_login_parse_login_post ) { - int (*postHookFunc) (int retVal___, int *fd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_login_parse_login_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_login_parse_login_post[hIndex].func; - retVal___ = postHookFunc(retVal___, &fd); - } - } - return retVal___; -} void HP_login_config_set_defaults(void) { int hIndex = 0; if( HPMHooks.count.HP_login_config_set_defaults_pre ) { diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index bbc1cecbc..871facdc1 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -28,6 +28,7 @@ memcpy(&HPMHooks.source.cmdline, cmdline, sizeof(struct cmdline_interface)); memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface)); memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface)); memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface)); +memcpy(&HPMHooks.source.lclif, lclif, sizeof(struct lclif_interface)); memcpy(&HPMHooks.source.libconfig, libconfig, sizeof(struct libconfig_interface)); memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface)); memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface)); -- cgit v1.2.3-70-g09d2 From 75557000f11741217adbcd0c1cebf45c661da1c4 Mon Sep 17 00:00:00 2001 From: hemagx Date: Mon, 28 Mar 2016 21:54:46 +0200 Subject: Rewrite client interface for login server (part 7) Added private interface in lclif.p.h Signed-off-by: Haru --- Hercules.xcodeproj/project.pbxproj | 2 + src/login/HPMlogin.c | 1 + src/login/Makefile.in | 2 +- src/login/lclif.c | 240 +----------------------------- src/login/lclif.h | 4 +- src/login/lclif.p.h | 264 +++++++++++++++++++++++++++++++++ src/plugins/HPMHooking.c | 1 + vcproj-10/login-server.vcxproj | 1 + vcproj-10/login-server.vcxproj.filters | 3 + vcproj-11/login-server.vcxproj | 1 + vcproj-11/login-server.vcxproj.filters | 3 + vcproj-12/login-server.vcxproj | 1 + vcproj-12/login-server.vcxproj.filters | 3 + vcproj-14/login-server.vcxproj | 1 + vcproj-14/login-server.vcxproj.filters | 3 + 15 files changed, 296 insertions(+), 234 deletions(-) create mode 100644 src/login/lclif.p.h (limited to 'src') diff --git a/Hercules.xcodeproj/project.pbxproj b/Hercules.xcodeproj/project.pbxproj index 4055a64b2..66d46e7f5 100644 --- a/Hercules.xcodeproj/project.pbxproj +++ b/Hercules.xcodeproj/project.pbxproj @@ -221,6 +221,7 @@ /* Begin PBXFileReference section */ A5296FCA1CAC40CF001ABCAC /* lclif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lclif.c; path = src/login/lclif.c; sourceTree = SOURCE_ROOT; }; A5296FCB1CAC40CF001ABCAC /* lclif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lclif.h; path = src/login/lclif.h; sourceTree = SOURCE_ROOT; }; + A5296FCC1CAC40CF001ABCAC /* lclif.p.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lclif.p.h; path = src/login/lclif.p.h; sourceTree = SOURCE_ROOT; }; A5380CCD1856CE180090CBC4 /* mapcache */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mapcache; sourceTree = BUILT_PRODUCTS_DIR; }; A5380CD61856CE3C0090CBC4 /* mapcache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mapcache.c; path = src/tool/mapcache.c; sourceTree = ""; }; A5467AD11A16FCB4008AFAA6 /* loginif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = loginif.c; path = src/char/loginif.c; sourceTree = SOURCE_ROOT; }; @@ -555,6 +556,7 @@ children = ( A5296FCA1CAC40CF001ABCAC /* lclif.c */, A5296FCB1CAC40CF001ABCAC /* lclif.h */, + A5296FCC1CAC40CF001ABCAC /* lclif.p.h */, A5B894A81A03CDD4005AD22E /* HPMlogin.c */, A5B894A91A03CDD4005AD22E /* HPMlogin.h */, A56CC68118564387009EB79C /* account_sql.c */, diff --git a/src/login/HPMlogin.c b/src/login/HPMlogin.c index e3f580341..472cba3c9 100644 --- a/src/login/HPMlogin.c +++ b/src/login/HPMlogin.c @@ -26,6 +26,7 @@ #include "login/account.h" #include "login/lclif.h" +#include "login/lclif.p.h" #include "login/login.h" #include "common/HPMi.h" #include "common/conf.h" diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 222c87e2a..274a82fc8 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -43,7 +43,7 @@ MT19937AR_H = $(MT19937AR_D)/mt19937ar.h LOGIN_C = account_sql.c HPMlogin.c ipban_sql.c lclif.c login.c loginlog_sql.c LOGIN_OBJ = $(addprefix obj_sql/, $(patsubst %.c,%.o,$(LOGIN_C))) LOGIN_H = login.h account.h HPMlogin.h ipban.h lclif.h loginlog.h -LOGIN_PH = +LOGIN_PH = lclif.p.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) diff --git a/src/login/lclif.c b/src/login/lclif.c index 203b0cbbc..9e672bab9 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -19,7 +19,7 @@ */ #define HERCULES_CORE -#include "lclif.h" +#include "lclif.p.h" #include "login/ipban.h" #include "login/login.h" @@ -38,236 +38,9 @@ #include "common/utils.h" struct lclif_interface lclif_s; +struct lclif_interface_private lclif_p; struct lclif_interface *lclif; -/* Definitions and macros */ -/// Maximum amount of packets processed at once from the same client -#define MAX_PROCESSED_PACKETS (3) - -// Packet DB -#define MIN_PACKET_DB 0x0064 -#define MAX_PACKET_DB 0x08ff - -/* 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_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_REFUSE_LOGIN = 0x006a, - PACKET_ID_SC_NOTIFY_BAN = 0x0081, - PACKET_ID_AC_ACK_HASH = 0x01dc, - PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, -}; - -/* 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; ///< Client Version - uint8 clienttype; ///< Client Type - 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 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)); - -struct packet_CA_CHARSERVERCONNECT { - int16 packet_id; - char userid[24]; - char password[24]; - int32 unknown; - int32 ip; - int16 port; - char name[20]; - int16 unknown2; - int16 type; - int16 new; -} __attribute__((packed)); - -struct packet_SC_NOTIFY_BAN { - int16 packet_id; - uint8 error_code; -} __attribute__((packed)); - -struct packet_AC_REFUSE_LOGIN { - int16 packet_id; - uint8 error_code; - char block_date[20]; -} __attribute__((packed)); - -struct packet_AC_REFUSE_LOGIN_R2 { - int16 packet_id; - uint32 error_code; - char block_date[20]; -} __attribute__((packed)); - -struct packet_AC_ACCEPT_LOGIN { - int16 packet_id; - int16 packet_len; - int32 auth_code; - uint32 aid; - uint32 user_level; - uint32 last_login_ip; - char last_login_time[26]; - uint8 sex; - struct { - uint32 ip; - int16 port; - char name[20]; - uint16 usercount; - uint16 state; - uint16 property; - } server_list[]; -} __attribute__((packed)); - -struct packet_AC_ACK_HASH { - int16 packet_id; - int16 packet_len; - uint8 secret[]; -} __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 - struct login_packet_db packet_db[MAX_PACKET_DB + 1]; void lclif_connection_error(int fd, uint8 error) @@ -589,7 +362,7 @@ int lclif_parse(int fd) if (packet_len < 2) return 0; - result = lclif->parse_sub(fd, sd); + result = lclif->p->parse_sub(fd, sd); switch (result) { case PACKET_SKIP: @@ -723,7 +496,7 @@ void packetdb_loaddb(void) void lclif_init(void) { - packetdb_loaddb(); + lclif->p->packetdb_loaddb(); } void lclif_final(void) @@ -733,6 +506,7 @@ void lclif_final(void) void lclif_defaults(void) { lclif = &lclif_s; + lclif->p = &lclif_p; lclif->init = lclif_init; lclif->final = lclif_final; @@ -746,5 +520,7 @@ void lclif_defaults(void) lclif->packet = lclif_packet; lclif->parse_packet = lclif_parse_packet; lclif->parse = lclif_parse; - lclif->parse_sub = lclif_parse_sub; + + lclif->p->packetdb_loaddb = packetdb_loaddb; + lclif->p->parse_sub = lclif_parse_sub; } diff --git a/src/login/lclif.h b/src/login/lclif.h index b6dac5d35..cf6314fc8 100644 --- a/src/login/lclif.h +++ b/src/login/lclif.h @@ -24,6 +24,7 @@ /* Forward Declarations */ struct login_session_data; +struct lclif_interface_private; /* Enums */ /// Parse function return code @@ -47,6 +48,8 @@ struct login_packet_db { }; struct lclif_interface { + struct lclif_interface_private *p; ///< Private interface + void (*init)(void); void (*final)(void); @@ -58,7 +61,6 @@ struct lclif_interface { const struct login_packet_db *(*packet)(int16 packet_id); enum parsefunc_rcode (*parse_packet)(const struct login_packet_db *lpd, int fd, struct login_session_data *sd); int (*parse)(int fd); - enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); }; #ifdef HERCULES_CORE diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h new file mode 100644 index 000000000..ad9a08e4d --- /dev/null +++ b/src/login/lclif.p.h @@ -0,0 +1,264 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 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 . + */ +#ifndef LOGIN_LCLIF_P_H +#define LOGIN_LCLIF_P_H + +#include "login/lclif.h" + +#include "common/hercules.h" +#include "common/mmo.h" + +/* Definitions and macros */ +/// Maximum amount of packets processed at once from the same client +#define MAX_PROCESSED_PACKETS (3) + +// Packet DB +#define MIN_PACKET_DB 0x0064 +#define MAX_PACKET_DB 0x08ff + +/* 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_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_REFUSE_LOGIN = 0x006a, + PACKET_ID_SC_NOTIFY_BAN = 0x0081, + PACKET_ID_AC_ACK_HASH = 0x01dc, + PACKET_ID_AC_REFUSE_LOGIN_R2 = 0x083e, +}; + +/* 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)); + +#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)); + +struct packet_CA_CHARSERVERCONNECT { + int16 packet_id; + char userid[24]; + char password[24]; + int32 unknown; + int32 ip; + int16 port; + char name[20]; + int16 unknown2; + int16 type; + int16 new; +} __attribute__((packed)); + +struct packet_SC_NOTIFY_BAN { + int16 packet_id; + uint8 error_code; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN { + int16 packet_id; + uint8 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_REFUSE_LOGIN_R2 { + int16 packet_id; + uint32 error_code; + char block_date[20]; +} __attribute__((packed)); + +struct packet_AC_ACCEPT_LOGIN { + int16 packet_id; + int16 packet_len; + int32 auth_code; + uint32 aid; + uint32 user_level; + uint32 last_login_ip; + char last_login_time[26]; + uint8 sex; + struct { + uint32 ip; + int16 port; + char name[20]; + uint16 usercount; + uint16 state; + uint16 property; + } server_list[]; +} __attribute__((packed)); + +struct packet_AC_ACK_HASH { + int16 packet_id; + int16 packet_len; + uint8 secret[]; +} __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 Private Interface + */ +struct lclif_interface_private { + void (*packetdb_loaddb)(void); + enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); +}; + +#endif // LOGIN_LCLIF_P_H diff --git a/src/plugins/HPMHooking.c b/src/plugins/HPMHooking.c index f809ff4ab..6530035b9 100644 --- a/src/plugins/HPMHooking.c +++ b/src/plugins/HPMHooking.c @@ -30,6 +30,7 @@ #define HPM_POINTS_INCLUDE "HPMHooking/HPMHooking_login.HookingPoints.inc" #define HPM_SOURCES_INCLUDE "HPMHooking/HPMHooking_login.sources.inc" #include "login/lclif.h" +#include "login/lclif.p.h" #include "login/login.h" #elif defined (HPMHOOKING_CHAR) #define HPM_SERVER_TYPE SERVER_TYPE_CHAR diff --git a/vcproj-10/login-server.vcxproj b/vcproj-10/login-server.vcxproj index 32c265bae..a491ea140 100644 --- a/vcproj-10/login-server.vcxproj +++ b/vcproj-10/login-server.vcxproj @@ -157,6 +157,7 @@ + diff --git a/vcproj-10/login-server.vcxproj.filters b/vcproj-10/login-server.vcxproj.filters index 8c8ed7c21..a5beedc71 100644 --- a/vcproj-10/login-server.vcxproj.filters +++ b/vcproj-10/login-server.vcxproj.filters @@ -243,6 +243,9 @@ login + + login + diff --git a/vcproj-11/login-server.vcxproj b/vcproj-11/login-server.vcxproj index 66b94b4c4..a715ff5e2 100644 --- a/vcproj-11/login-server.vcxproj +++ b/vcproj-11/login-server.vcxproj @@ -161,6 +161,7 @@ + diff --git a/vcproj-11/login-server.vcxproj.filters b/vcproj-11/login-server.vcxproj.filters index 8c8ed7c21..a5beedc71 100644 --- a/vcproj-11/login-server.vcxproj.filters +++ b/vcproj-11/login-server.vcxproj.filters @@ -243,6 +243,9 @@ login + + login + diff --git a/vcproj-12/login-server.vcxproj b/vcproj-12/login-server.vcxproj index 6f28436b8..49d35a400 100644 --- a/vcproj-12/login-server.vcxproj +++ b/vcproj-12/login-server.vcxproj @@ -161,6 +161,7 @@ + diff --git a/vcproj-12/login-server.vcxproj.filters b/vcproj-12/login-server.vcxproj.filters index 8c8ed7c21..a5beedc71 100644 --- a/vcproj-12/login-server.vcxproj.filters +++ b/vcproj-12/login-server.vcxproj.filters @@ -243,6 +243,9 @@ login + + login + diff --git a/vcproj-14/login-server.vcxproj b/vcproj-14/login-server.vcxproj index cb9d8449c..d376a9903 100644 --- a/vcproj-14/login-server.vcxproj +++ b/vcproj-14/login-server.vcxproj @@ -159,6 +159,7 @@ + diff --git a/vcproj-14/login-server.vcxproj.filters b/vcproj-14/login-server.vcxproj.filters index 8c8ed7c21..a5beedc71 100644 --- a/vcproj-14/login-server.vcxproj.filters +++ b/vcproj-14/login-server.vcxproj.filters @@ -243,6 +243,9 @@ login + + login + -- cgit v1.2.3-70-g09d2 From 37cc46c5e02bc62a8b510fb53f5c2ed0f2ee5d5f Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 31 Mar 2016 00:16:48 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/common/HPMDataCheck.h | 19 ++++++++++ .../HPMHooking/HPMHooking_login.HPMHooksCore.inc | 13 +++++-- .../HPMHooking/HPMHooking_login.HookingPoints.inc | 4 +- src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 43 ++++++++++++++++++---- .../HPMHooking/HPMHooking_login.sources.inc | 1 + 5 files changed, 67 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index 048855edb..d68fa117a 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -276,6 +276,25 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #else #define LOGIN_LCLIF_H #endif // LOGIN_LCLIF_H + #ifdef LOGIN_LCLIF_P_H + { "lclif_interface_private", sizeof(struct lclif_interface_private), SERVER_TYPE_LOGIN }, + { "packet_AC_ACCEPT_LOGIN", sizeof(struct packet_AC_ACCEPT_LOGIN), SERVER_TYPE_LOGIN }, + { "packet_AC_REFUSE_LOGIN", sizeof(struct packet_AC_REFUSE_LOGIN), SERVER_TYPE_LOGIN }, + { "packet_AC_REFUSE_LOGIN_R2", sizeof(struct packet_AC_REFUSE_LOGIN_R2), SERVER_TYPE_LOGIN }, + { "packet_CA_CHARSERVERCONNECT", sizeof(struct packet_CA_CHARSERVERCONNECT), SERVER_TYPE_LOGIN }, + { "packet_CA_CONNECT_INFO_CHANGED", sizeof(struct packet_CA_CONNECT_INFO_CHANGED), SERVER_TYPE_LOGIN }, + { "packet_CA_EXE_HASHCHECK", sizeof(struct packet_CA_EXE_HASHCHECK), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN", sizeof(struct packet_CA_LOGIN), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN2", sizeof(struct packet_CA_LOGIN2), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN3", sizeof(struct packet_CA_LOGIN3), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN4", sizeof(struct packet_CA_LOGIN4), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN_HAN", sizeof(struct packet_CA_LOGIN_HAN), SERVER_TYPE_LOGIN }, + { "packet_CA_LOGIN_PCBANG", sizeof(struct packet_CA_LOGIN_PCBANG), SERVER_TYPE_LOGIN }, + { "packet_CA_SSO_LOGIN_REQ", sizeof(struct packet_CA_SSO_LOGIN_REQ), SERVER_TYPE_LOGIN }, + { "packet_SC_NOTIFY_BAN", sizeof(struct packet_SC_NOTIFY_BAN), SERVER_TYPE_LOGIN }, + #else + #define LOGIN_LCLIF_P_H + #endif // LOGIN_LCLIF_P_H #ifdef LOGIN_LOGIN_H { "Login_Config", sizeof(struct Login_Config), SERVER_TYPE_LOGIN }, { "client_hash_node", sizeof(struct client_hash_node), SERVER_TYPE_LOGIN }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 537c88936..9775b94e4 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -110,8 +110,10 @@ struct { struct HPMHookPoint *HP_lclif_parse_packet_post; struct HPMHookPoint *HP_lclif_parse_pre; struct HPMHookPoint *HP_lclif_parse_post; - struct HPMHookPoint *HP_lclif_parse_sub_pre; - struct HPMHookPoint *HP_lclif_parse_sub_post; + struct HPMHookPoint *HP_PRIV__lclif_packetdb_loaddb_pre; + struct HPMHookPoint *HP_PRIV__lclif_packetdb_loaddb_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_sub_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_sub_post; struct HPMHookPoint *HP_libconfig_read_pre; struct HPMHookPoint *HP_libconfig_read_post; struct HPMHookPoint *HP_libconfig_write_pre; @@ -719,8 +721,10 @@ struct { int HP_lclif_parse_packet_post; int HP_lclif_parse_pre; int HP_lclif_parse_post; - int HP_lclif_parse_sub_pre; - int HP_lclif_parse_sub_post; + int HP_PRIV__lclif_packetdb_loaddb_pre; + int HP_PRIV__lclif_packetdb_loaddb_post; + int HP_PRIV__lclif_parse_sub_pre; + int HP_PRIV__lclif_parse_sub_post; int HP_libconfig_read_pre; int HP_libconfig_read_post; int HP_libconfig_write_pre; @@ -1248,6 +1252,7 @@ struct { struct core_interface core; struct db_interface DB; struct lclif_interface lclif; + struct lclif_interface_private PRIV__lclif; struct libconfig_interface libconfig; struct login_interface login; struct malloc_interface iMalloc; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index a5adac2d0..bcfebf443 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -72,7 +72,9 @@ struct HookingPointData HookingPoints[] = { { HP_POP(lclif->packet, HP_lclif_packet) }, { HP_POP(lclif->parse_packet, HP_lclif_parse_packet) }, { HP_POP(lclif->parse, HP_lclif_parse) }, - { HP_POP(lclif->parse_sub, HP_lclif_parse_sub) }, +/* lclif_interface_private */ + { HP_POP(lclif->p->packetdb_loaddb, HP_PRIV__lclif_packetdb_loaddb) }, + { HP_POP(lclif->p->parse_sub, HP_PRIV__lclif_parse_sub) }, /* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index b7ff2b77b..81d31c99e 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -1182,14 +1182,41 @@ int HP_lclif_parse(int fd) { } return retVal___; } -enum parsefunc_rcode HP_lclif_parse_sub(int fd, struct login_session_data *sd) { +/* lclif_interface_private */ +void HP_PRIV__lclif_packetdb_loaddb(void) { + int hIndex = 0; + if( HPMHooks.count.HP_PRIV__lclif_packetdb_loaddb_pre ) { + void (*preHookFunc) (void); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_packetdb_loaddb_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_packetdb_loaddb_pre[hIndex].func; + preHookFunc(); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.PRIV__lclif.packetdb_loaddb(); + } + if( HPMHooks.count.HP_PRIV__lclif_packetdb_loaddb_post ) { + void (*postHookFunc) (void); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_packetdb_loaddb_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_packetdb_loaddb_post[hIndex].func; + postHookFunc(); + } + } + return; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_sub(int fd, struct login_session_data *sd) { int hIndex = 0; enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; - if( HPMHooks.count.HP_lclif_parse_sub_pre ) { + if( HPMHooks.count.HP_PRIV__lclif_parse_sub_pre ) { enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); *HPMforce_return = false; - for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_sub_pre; hIndex++ ) { - preHookFunc = HPMHooks.list.HP_lclif_parse_sub_pre[hIndex].func; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_sub_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_sub_pre[hIndex].func; retVal___ = preHookFunc(&fd, sd); } if( *HPMforce_return ) { @@ -1198,12 +1225,12 @@ enum parsefunc_rcode HP_lclif_parse_sub(int fd, struct login_session_data *sd) { } } { - retVal___ = HPMHooks.source.lclif.parse_sub(fd, sd); + retVal___ = HPMHooks.source.PRIV__lclif.parse_sub(fd, sd); } - if( HPMHooks.count.HP_lclif_parse_sub_post ) { + if( HPMHooks.count.HP_PRIV__lclif_parse_sub_post ) { enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); - for(hIndex = 0; hIndex < HPMHooks.count.HP_lclif_parse_sub_post; hIndex++ ) { - postHookFunc = HPMHooks.list.HP_lclif_parse_sub_post[hIndex].func; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_sub_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_sub_post[hIndex].func; retVal___ = postHookFunc(retVal___, &fd, sd); } } diff --git a/src/plugins/HPMHooking/HPMHooking_login.sources.inc b/src/plugins/HPMHooking/HPMHooking_login.sources.inc index 871facdc1..1c1927619 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.sources.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.sources.inc @@ -29,6 +29,7 @@ memcpy(&HPMHooks.source.console, console, sizeof(struct console_interface)); memcpy(&HPMHooks.source.core, core, sizeof(struct core_interface)); memcpy(&HPMHooks.source.DB, DB, sizeof(struct db_interface)); memcpy(&HPMHooks.source.lclif, lclif, sizeof(struct lclif_interface)); +memcpy(&HPMHooks.source.PRIV__lclif, lclif->p, sizeof(struct lclif_interface_private)); memcpy(&HPMHooks.source.libconfig, libconfig, sizeof(struct libconfig_interface)); memcpy(&HPMHooks.source.login, login, sizeof(struct login_interface)); memcpy(&HPMHooks.source.iMalloc, iMalloc, sizeof(struct malloc_interface)); -- cgit v1.2.3-70-g09d2 From fb262785af40bfb07918d1ef61641ec88175d559 Mon Sep 17 00:00:00 2001 From: Haru Date: Fri, 15 Apr 2016 20:14:43 +0200 Subject: Added lclif packet handlers to the lclif interface Signed-off-by: Haru --- src/login/lclif.c | 22 +++++++++++++++++----- src/login/lclif.h | 4 ++-- src/login/lclif.p.h | 12 ++++++++++++ tools/HPMHookGen/HPMHookGen.pl | 7 ++++++- 4 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/login/lclif.c b/src/login/lclif.c index 9e672bab9..c869282c9 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -450,7 +450,7 @@ const struct login_packet_db *lclif_packet(int16 packet_id) enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) { int result; - result = lpd->pFunc(fd, sd); + result = (*lpd->pFunc)(fd, sd); RFIFOSKIP(fd, (lpd->len == -1) ? RFIFOW(fd, 2) : lpd->len); return result; } @@ -461,10 +461,10 @@ void packetdb_loaddb(void) struct packet { int16 packet_id; int16 packet_len; - int (*pFunc)(int, struct login_session_data *); + LoginParseFunc **pFunc; } packet[] = { -#define packet_def(name) { PACKET_ID_ ## name, sizeof(struct packet_ ## name), lclif_parse_ ## name } -#define packet_def2(name, len) { PACKET_ID_ ## name, (len), lclif_parse_ ## name } +#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 } packet_def(CA_CONNECT_INFO_CHANGED), packet_def(CA_EXE_HASHCHECK), packet_def(CA_LOGIN), @@ -491,7 +491,7 @@ void packetdb_loaddb(void) //Explict case, we will save character login packet in position 0 which is unused and not valid by normal packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); - packet_db[0].pFunc = lclif_parse_CA_CHARSERVERCONNECT; + packet_db[0].pFunc = &lclif->p->parse_CA_CHARSERVERCONNECT; } void lclif_init(void) @@ -523,4 +523,16 @@ void lclif_defaults(void) lclif->p->packetdb_loaddb = packetdb_loaddb; lclif->p->parse_sub = lclif_parse_sub; + + lclif->p->parse_CA_CONNECT_INFO_CHANGED = lclif_parse_CA_CONNECT_INFO_CHANGED; + lclif->p->parse_CA_EXE_HASHCHECK = lclif_parse_CA_EXE_HASHCHECK; + lclif->p->parse_CA_LOGIN = lclif_parse_CA_LOGIN; + lclif->p->parse_CA_LOGIN2 = lclif_parse_CA_LOGIN2; + lclif->p->parse_CA_LOGIN3 = lclif_parse_CA_LOGIN3; + lclif->p->parse_CA_LOGIN4 = lclif_parse_CA_LOGIN4; + lclif->p->parse_CA_LOGIN_PCBANG = lclif_parse_CA_LOGIN_PCBANG; + 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_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 cf6314fc8..5eb5a75aa 100644 --- a/src/login/lclif.h +++ b/src/login/lclif.h @@ -43,8 +43,8 @@ typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data /* Structs */ /// Login packet DB entry struct login_packet_db { - int16 len; ///< Packet length - LoginParseFunc *pFunc; ///< Packet parsing function + int16 len; ///< Packet length + LoginParseFunc **pFunc; ///< Packet parsing function }; struct lclif_interface { diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h index ad9a08e4d..b0811c7c6 100644 --- a/src/login/lclif.p.h +++ b/src/login/lclif.p.h @@ -259,6 +259,18 @@ struct packet_AC_ACK_HASH { struct lclif_interface_private { void (*packetdb_loaddb)(void); enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); + + LoginParseFunc *parse_CA_CONNECT_INFO_CHANGED; + LoginParseFunc *parse_CA_EXE_HASHCHECK; + LoginParseFunc *parse_CA_LOGIN; + LoginParseFunc *parse_CA_LOGIN2; + LoginParseFunc *parse_CA_LOGIN3; + LoginParseFunc *parse_CA_LOGIN4; + LoginParseFunc *parse_CA_LOGIN_PCBANG; + LoginParseFunc *parse_CA_LOGIN_HAN; + LoginParseFunc *parse_CA_SSO_LOGIN_REQ; + LoginParseFunc *parse_CA_REQ_HASH; + LoginParseFunc *parse_CA_CHARSERVERCONNECT; }; #endif // LOGIN_LCLIF_P_H diff --git a/tools/HPMHookGen/HPMHookGen.pl b/tools/HPMHookGen/HPMHookGen.pl index 74cc0f863..0e33fd002 100755 --- a/tools/HPMHookGen/HPMHookGen.pl +++ b/tools/HPMHookGen/HPMHookGen.pl @@ -361,9 +361,14 @@ foreach my $file (@files) { # Loop through the xml files $astart <=> $bstart } @$memberdef) { # Loop through the members my $t = $f->{argsstring}->[0]; + my $def = $f->{definition}->[0]; + if ($f->{type}->[0] =~ /^\s*LoginParseFunc\s*\*\s*$/) { + $t = ')(int fd, struct login_session_data *sd)'; # typedef LoginParseFunc + $def =~ s/^LoginParseFunc\s*\*\s*(.*)$/enum parsefunc_rcode(* $1) (int fd, struct login_session_data *sd)/; + } next unless ref $t ne 'HASH' and $t =~ /^[^\[]/; # If it's not a string, or if it starts with an array subscript, we can skip it - my $if = parse($t, $f->{definition}->[0]); + my $if = parse($t, $def); next unless scalar keys %$if; # If it returns an empty hash reference, an error must've occurred # Skip variadic functions, we only allow hooks on their arglist equivalents. -- cgit v1.2.3-70-g09d2 From 6de2242304fa8077aa3d1a359d768733a53a9c45 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 16 Apr 2016 03:33:20 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- .../HPMHooking/HPMHooking_login.HPMHooksCore.inc | 44 +++ .../HPMHooking/HPMHooking_login.HookingPoints.inc | 11 + src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 297 +++++++++++++++++++++ 3 files changed, 352 insertions(+) (limited to 'src') diff --git a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc index 9775b94e4..88e4f51dd 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HPMHooksCore.inc @@ -114,6 +114,28 @@ struct { struct HPMHookPoint *HP_PRIV__lclif_packetdb_loaddb_post; struct HPMHookPoint *HP_PRIV__lclif_parse_sub_pre; struct HPMHookPoint *HP_PRIV__lclif_parse_sub_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN2_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN2_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN3_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN3_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN4_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN4_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_HAN_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_LOGIN_HAN_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_REQ_HASH_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_REQ_HASH_post; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_pre; + struct HPMHookPoint *HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_post; struct HPMHookPoint *HP_libconfig_read_pre; struct HPMHookPoint *HP_libconfig_read_post; struct HPMHookPoint *HP_libconfig_write_pre; @@ -725,6 +747,28 @@ struct { int HP_PRIV__lclif_packetdb_loaddb_post; int HP_PRIV__lclif_parse_sub_pre; int HP_PRIV__lclif_parse_sub_post; + int HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_pre; + int HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_post; + int HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_pre; + int HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_post; + int HP_PRIV__lclif_parse_CA_LOGIN_pre; + int HP_PRIV__lclif_parse_CA_LOGIN_post; + int HP_PRIV__lclif_parse_CA_LOGIN2_pre; + int HP_PRIV__lclif_parse_CA_LOGIN2_post; + int HP_PRIV__lclif_parse_CA_LOGIN3_pre; + int HP_PRIV__lclif_parse_CA_LOGIN3_post; + int HP_PRIV__lclif_parse_CA_LOGIN4_pre; + int HP_PRIV__lclif_parse_CA_LOGIN4_post; + int HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_pre; + int HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_post; + int HP_PRIV__lclif_parse_CA_LOGIN_HAN_pre; + int HP_PRIV__lclif_parse_CA_LOGIN_HAN_post; + int HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_pre; + int HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_post; + int HP_PRIV__lclif_parse_CA_REQ_HASH_pre; + int HP_PRIV__lclif_parse_CA_REQ_HASH_post; + int HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_pre; + int HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_post; int HP_libconfig_read_pre; int HP_libconfig_read_post; int HP_libconfig_write_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc index bcfebf443..a558b16c5 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.HookingPoints.inc @@ -75,6 +75,17 @@ struct HookingPointData HookingPoints[] = { /* lclif_interface_private */ { HP_POP(lclif->p->packetdb_loaddb, HP_PRIV__lclif_packetdb_loaddb) }, { HP_POP(lclif->p->parse_sub, HP_PRIV__lclif_parse_sub) }, + { HP_POP(lclif->p->parse_CA_CONNECT_INFO_CHANGED, HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED) }, + { HP_POP(lclif->p->parse_CA_EXE_HASHCHECK, HP_PRIV__lclif_parse_CA_EXE_HASHCHECK) }, + { HP_POP(lclif->p->parse_CA_LOGIN, HP_PRIV__lclif_parse_CA_LOGIN) }, + { HP_POP(lclif->p->parse_CA_LOGIN2, HP_PRIV__lclif_parse_CA_LOGIN2) }, + { HP_POP(lclif->p->parse_CA_LOGIN3, HP_PRIV__lclif_parse_CA_LOGIN3) }, + { HP_POP(lclif->p->parse_CA_LOGIN4, HP_PRIV__lclif_parse_CA_LOGIN4) }, + { HP_POP(lclif->p->parse_CA_LOGIN_PCBANG, HP_PRIV__lclif_parse_CA_LOGIN_PCBANG) }, + { HP_POP(lclif->p->parse_CA_LOGIN_HAN, HP_PRIV__lclif_parse_CA_LOGIN_HAN) }, + { HP_POP(lclif->p->parse_CA_SSO_LOGIN_REQ, HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ) }, + { HP_POP(lclif->p->parse_CA_REQ_HASH, HP_PRIV__lclif_parse_CA_REQ_HASH) }, + { HP_POP(lclif->p->parse_CA_CHARSERVERCONNECT, HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT) }, /* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index 81d31c99e..91909b819 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -1236,6 +1236,303 @@ enum parsefunc_rcode HP_PRIV__lclif_parse_sub(int fd, struct login_session_data } return retVal___; } +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_CONNECT_INFO_CHANGED(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_CONNECT_INFO_CHANGED_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_EXE_HASHCHECK(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_EXE_HASHCHECK_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN2_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN2_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN2_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN2(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN2_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN2_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN2_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN3_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN3_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN3_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN3(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN3_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN3_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN3_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN4_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN4_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN4_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN4(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN4_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN4_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN4_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN_PCBANG(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_PCBANG_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_HAN_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_HAN_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_HAN_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_LOGIN_HAN(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_HAN_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_LOGIN_HAN_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_LOGIN_HAN_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_SSO_LOGIN_REQ(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_SSO_LOGIN_REQ_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_REQ_HASH_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_REQ_HASH_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_REQ_HASH_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_REQ_HASH(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_REQ_HASH_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_REQ_HASH_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_REQ_HASH_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} +enum parsefunc_rcode HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) { + int hIndex = 0; + enum parsefunc_rcode retVal___ = PACKET_UNKNOWN; + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_pre ) { + enum parsefunc_rcode (*preHookFunc) (int *fd, struct login_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_pre[hIndex].func; + retVal___ = preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.PRIV__lclif.parse_CA_CHARSERVERCONNECT(fd, sd); + } + if( HPMHooks.count.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_post ) { + enum parsefunc_rcode (*postHookFunc) (enum parsefunc_rcode retVal___, int *fd, struct login_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_PRIV__lclif_parse_CA_CHARSERVERCONNECT_post[hIndex].func; + retVal___ = postHookFunc(retVal___, &fd, sd); + } + } + return retVal___; +} /* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; -- cgit v1.2.3-70-g09d2 From 45bbb3de140b0403d36ba5d2168c0a776869db44 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 16 Apr 2016 03:33:31 +0200 Subject: Added missing documentation Signed-off-by: Haru --- src/login/lclif.c | 30 +++++++++++- src/login/lclif.h | 78 +++++++++++++++++++++++++++++++ src/login/lclif.p.h | 129 ++++++++++++++++++++++++++++++++++------------------ src/login/login.c | 4 ++ src/login/login.h | 4 ++ 5 files changed, 199 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/login/lclif.c b/src/login/lclif.c index c869282c9..07193ac0f 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -37,12 +37,17 @@ #include "common/strlib.h" #include "common/utils.h" +/** @file + * Implementation of the login client interface. + */ + struct lclif_interface lclif_s; struct lclif_interface_private lclif_p; struct lclif_interface *lclif; -struct login_packet_db packet_db[MAX_PACKET_DB + 1]; +struct login_packet_db packet_db[MAX_PACKET_DB + 1]; ///< Packet database. +/// @copydoc lclif_interface::connection_error() void lclif_connection_error(int fd, uint8 error) { struct packet_SC_NOTIFY_BAN *packet = NULL; @@ -53,12 +58,14 @@ void lclif_connection_error(int fd, uint8 error) WFIFOSET(fd, sizeof(*packet)); } +/// @copydoc lclif_interface_private::parse_CA_CONNECT_INFO_CHANGED() enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) { return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_EXE_HASHCHECK() enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) { @@ -68,6 +75,7 @@ enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_d return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN() enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) { @@ -86,6 +94,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN2() enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) { @@ -101,6 +110,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN3() enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) { @@ -118,6 +128,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN4() enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) { @@ -135,6 +146,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN_PCBANG() enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) { @@ -156,6 +168,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_da return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_LOGIN_HAN() enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) { @@ -178,6 +191,7 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_SSO_LOGIN_REQ() enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) { @@ -203,6 +217,7 @@ enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_d return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_REQ_HASH() enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) { @@ -214,6 +229,7 @@ enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data * return PACKET_VALID; } +/// @copydoc lclif_interface_private::parse_CA_CHARSERVERCONNECT() enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) { @@ -226,6 +242,7 @@ enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_sessi return PACKET_STOPPARSE; } +/// @copydoc lclif_interface::server_list() bool lclif_send_server_list(struct login_session_data *sd) { int server_num = 0, i, n, length; @@ -279,6 +296,7 @@ bool lclif_send_server_list(struct login_session_data *sd) return true; } +/// @copydoc lclif_interface::auth_failed() void lclif_send_auth_failed(int fd, time_t ban, uint32 error) { #if PACKETVER >= 20120000 /* not sure when this started */ @@ -299,6 +317,7 @@ void lclif_send_auth_failed(int fd, time_t ban, uint32 error) WFIFOSET(fd, sizeof(*packet)); } +/// @copydoc lclif_interface::login_error() void lclif_send_login_error(int fd, uint8 error) { struct packet_AC_REFUSE_LOGIN *packet = NULL; @@ -310,6 +329,7 @@ void lclif_send_login_error(int fd, uint8 error) WFIFOSET(fd, sizeof(*packet)); } +/// @copydoc lclif_interface::coding_key() void lclif_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); void lclif_send_coding_key(int fd, struct login_session_data *sd) { @@ -324,6 +344,7 @@ void lclif_send_coding_key(int fd, struct login_session_data *sd) WFIFOSET(fd, size); } +/// @copydoc lclif_interface::parse() int lclif_parse(int fd) { struct login_session_data *sd = NULL; @@ -389,6 +410,7 @@ int lclif_parse(int fd) return 0; } +/// @copydoc lclif_interface_private::parse_sub() enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) { int packet_len = (int)RFIFOREST(fd); @@ -436,6 +458,7 @@ enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) return PACKET_VALID; } +/// @copydoc lclif_interface::packet() const struct login_packet_db *lclif_packet(int16 packet_id) { if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) @@ -447,6 +470,7 @@ const struct login_packet_db *lclif_packet(int16 packet_id) return &packet_db[packet_id]; } +/// @copydoc lclif_interface::parse_packet() enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) { int result; @@ -455,6 +479,7 @@ enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int f return result; } +/// @copydoc lclif_interface_private::packetdb_loaddb() void packetdb_loaddb(void) { int i; @@ -494,15 +519,18 @@ void packetdb_loaddb(void) packet_db[0].pFunc = &lclif->p->parse_CA_CHARSERVERCONNECT; } +/// @copydoc lclif_interface::init() void lclif_init(void) { lclif->p->packetdb_loaddb(); } +/// @copydoc lclif_interface::final() void lclif_final(void) { } +/// Interface base initialization. void lclif_defaults(void) { lclif = &lclif_s; diff --git a/src/login/lclif.h b/src/login/lclif.h index 5eb5a75aa..d1e4317a2 100644 --- a/src/login/lclif.h +++ b/src/login/lclif.h @@ -22,6 +22,10 @@ #include "common/hercules.h" +/** @file + * Login Client Interface. + **/ + /* Forward Declarations */ struct login_session_data; struct lclif_interface_private; @@ -41,25 +45,99 @@ enum parsefunc_rcode { typedef enum parsefunc_rcode (LoginParseFunc)(int fd, struct login_session_data *sd); /* Structs */ + /// Login packet DB entry struct login_packet_db { int16 len; ///< Packet length LoginParseFunc **pFunc; ///< Packet parsing function }; +/// The login clif (client interface) interface. struct lclif_interface { struct lclif_interface_private *p; ///< Private interface + /// Interface initialization. void (*init)(void); + + /// Interface finalization. void (*final)(void); + /** + * Reports a connection error to the client. + * + * @param fd Client connection file descriptor. + * @param error Error code. + * @see #PACKET_SC_NOTIFY_BAN. + */ void (*connection_error)(int fd, uint8 error); + + /** + * Sends the character server list to the client. + * + * @param sd The client to send to. + * @return Success status. + * @retval false in case of failure (no server available). + * @see #PACKET_AC_ACCEPT_LOGIN. + */ bool (*server_list)(struct login_session_data *sd); + + /** + * Reports an authentication failure to the client. + * + * @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. + */ void (*auth_failed)(int fd, time_t ban, uint32 error); + + /** + * Reports a login error to the client. + * + * @param fd Client connection file descriptor. + * @param error Error code. + * @see #PACKET_AC_REFUSE_LOGIN. + */ void (*login_error)(int fd, uint8 error); + + /** + * Sends an authentication challenge to the client. + * + * @param fd Client connection file descriptor. + * @param sd The client to send to. + * @see #PACKET_AC_ACK_HASH. + */ void (*coding_key)(int fd, struct login_session_data *sd); + + /** + * Retrieves a packet's data from the packet db. + * + * @param packet_id The packet id. + * @return The packet data. + * @retval NULL if the packet doesn't exist. + */ const struct login_packet_db *(*packet)(int16 packet_id); + + /** + * Parses a packet. + * + * @param lpd Packet database entry. + * @param fd Client connection file descriptor. + * @param sd Session data. + * @return Parse result error code. + */ enum parsefunc_rcode (*parse_packet)(const struct login_packet_db *lpd, int fd, struct login_session_data *sd); + + /** + * Packet parser loop function. + * + * Parses packets received from a client. + * + * @param fd Client connection file descriptor. + * @return error code. + * @retval 0 in case of success. + */ int (*parse)(int fd); }; diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h index b0811c7c6..e57c5e50d 100644 --- a/src/login/lclif.p.h +++ b/src/login/lclif.p.h @@ -20,6 +20,10 @@ #ifndef LOGIN_LCLIF_P_H #define LOGIN_LCLIF_P_H +/** @file + * Private header for the login client interface. + */ + #include "login/lclif.h" #include "common/hercules.h" @@ -194,59 +198,83 @@ 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; - char userid[24]; - char password[24]; + int16 packet_id; ///< Packet ID (#PACKET_ID_CA_CHARSERVERCONNECT) + char userid[24]; ///< Username + char password[24]; ///< Password int32 unknown; - int32 ip; - int16 port; - char name[20]; + int32 ip; ///< Charserver IP + int16 port; ///< Charserver port + char name[20]; ///< Charserver name int16 unknown2; - int16 type; - int16 new; + 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; - uint8 error_code; + 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; - uint8 error_code; - char block_date[20]; + 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; - uint32 error_code; - char block_date[20]; + 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; - int16 packet_len; - int32 auth_code; - uint32 aid; - uint32 user_level; - uint32 last_login_ip; - char last_login_time[26]; - uint8 sex; + 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 struct { - uint32 ip; - int16 port; - char name[20]; - uint16 usercount; - uint16 state; - uint16 property; - } server_list[]; + 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 + } server_list[]; ///< List of charservers } __attribute__((packed)); +/** + * Packet structure for AC_ACK_HASH. + * + * Variable-length packet + */ struct packet_AC_ACK_HASH { - int16 packet_id; - int16 packet_len; - uint8 secret[]; + 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 @@ -257,20 +285,31 @@ struct packet_AC_ACK_HASH { * Login Client Interface Private Interface */ struct lclif_interface_private { + /** + * Populates the packet database. + */ void (*packetdb_loaddb)(void); + + /** + * Attempts to validate and parse a received packet. + * + * @param fd Client connection file descriptor. + * @param sd Session data. + * @return Parse result error code. + */ enum parsefunc_rcode (*parse_sub)(int fd, struct login_session_data *sd); - LoginParseFunc *parse_CA_CONNECT_INFO_CHANGED; - LoginParseFunc *parse_CA_EXE_HASHCHECK; - LoginParseFunc *parse_CA_LOGIN; - LoginParseFunc *parse_CA_LOGIN2; - LoginParseFunc *parse_CA_LOGIN3; - LoginParseFunc *parse_CA_LOGIN4; - LoginParseFunc *parse_CA_LOGIN_PCBANG; - LoginParseFunc *parse_CA_LOGIN_HAN; - LoginParseFunc *parse_CA_SSO_LOGIN_REQ; - LoginParseFunc *parse_CA_REQ_HASH; - LoginParseFunc *parse_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_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 38e2651c5..d7c7321d8 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -44,6 +44,10 @@ #include #include +/** @file + * Implementation of the login interface. + */ + struct login_interface login_s; struct login_interface *login; struct Login_Config login_config_; diff --git a/src/login/login.h b/src/login/login.h index 7c2e5925f..36085ae91 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -26,6 +26,10 @@ #include "common/db.h" #include "common/mmo.h" // NAME_LENGTH,SEX_* +/** @file + * Login interface. + */ + struct mmo_account; struct AccountDB; -- cgit v1.2.3-70-g09d2 From 15c9710832c5a4d734559c5e1b0bb9b4a92cf73a Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 16 Apr 2016 15:21:18 +0200 Subject: Moved packet_db to the private interface of lclif Signed-off-by: Haru --- src/login/lclif.c | 18 +++++++++--------- src/login/lclif.p.h | 9 +++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/login/lclif.c b/src/login/lclif.c index 07193ac0f..9515c5940 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -43,10 +43,9 @@ struct lclif_interface lclif_s; struct lclif_interface_private lclif_p; +struct lclif_interface_dbs lclif_dbs; struct lclif_interface *lclif; -struct login_packet_db packet_db[MAX_PACKET_DB + 1]; ///< Packet database. - /// @copydoc lclif_interface::connection_error() void lclif_connection_error(int fd, uint8 error) { @@ -462,12 +461,12 @@ enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) const struct login_packet_db *lclif_packet(int16 packet_id) { if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) - return &packet_db[0]; + return &lclif->p->dbs->packet_db[0]; if (packet_id > MAX_PACKET_DB || packet_id < MIN_PACKET_DB) return NULL; - return &packet_db[packet_id]; + return &lclif->p->dbs->packet_db[packet_id]; } /// @copydoc lclif_interface::parse_packet() @@ -505,18 +504,18 @@ void packetdb_loaddb(void) }; int length = ARRAYLENGTH(packet); - memset(packet_db, '\0', sizeof(packet_db)); + memset(lclif->p->dbs->packet_db, '\0', sizeof(lclif->p->dbs->packet_db)); for (i = 0; i < length; ++i) { int16 packet_id = packet[i].packet_id; Assert_retb(packet_id >= MIN_PACKET_DB && packet_id < MAX_PACKET_DB); - packet_db[packet_id].len = packet[i].packet_len; - packet_db[packet_id].pFunc = packet[i].pFunc; + lclif->p->dbs->packet_db[packet_id].len = packet[i].packet_len; + lclif->p->dbs->packet_db[packet_id].pFunc = packet[i].pFunc; } //Explict case, we will save character login packet in position 0 which is unused and not valid by normal - packet_db[0].len = sizeof(struct packet_CA_CHARSERVERCONNECT); - packet_db[0].pFunc = &lclif->p->parse_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; } /// @copydoc lclif_interface::init() @@ -535,6 +534,7 @@ void lclif_defaults(void) { lclif = &lclif_s; lclif->p = &lclif_p; + lclif->p->dbs = &lclif_dbs; lclif->init = lclif_init; lclif->final = lclif_final; diff --git a/src/login/lclif.p.h b/src/login/lclif.p.h index e57c5e50d..ae9d1bc14 100644 --- a/src/login/lclif.p.h +++ b/src/login/lclif.p.h @@ -281,10 +281,19 @@ struct packet_AC_ACK_HASH { #pragma pack(pop) #endif // not NetBSD < 6 / Solaris +/** + * Login Client Interface additional data + */ +struct lclif_interface_dbs { + struct login_packet_db packet_db[MAX_PACKET_DB + 1]; ///< Packet database. +}; + /** * Login Client Interface Private Interface */ struct lclif_interface_private { + struct lclif_interface_dbs *dbs; + /** * Populates the packet database. */ -- cgit v1.2.3-70-g09d2 From 8448e3f8cdcbf820e304a68c7507a0ed96d53544 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 16 Apr 2016 15:22:21 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/common/HPMDataCheck.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h index d68fa117a..e5f482686 100644 --- a/src/common/HPMDataCheck.h +++ b/src/common/HPMDataCheck.h @@ -277,6 +277,7 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = { #define LOGIN_LCLIF_H #endif // LOGIN_LCLIF_H #ifdef LOGIN_LCLIF_P_H + { "lclif_interface_dbs", sizeof(struct lclif_interface_dbs), SERVER_TYPE_LOGIN }, { "lclif_interface_private", sizeof(struct lclif_interface_private), SERVER_TYPE_LOGIN }, { "packet_AC_ACCEPT_LOGIN", sizeof(struct packet_AC_ACCEPT_LOGIN), SERVER_TYPE_LOGIN }, { "packet_AC_REFUSE_LOGIN", sizeof(struct packet_AC_REFUSE_LOGIN), SERVER_TYPE_LOGIN }, -- cgit v1.2.3-70-g09d2