Wiped out the poorly written parse code from r2211
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9819 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
f96bd44c5a
commit
3e4bef37b7
@ -7,6 +7,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
* Cleaning up of the socket code [ultramage]
|
||||
- Shuffled includes around for files that were leeching off of socket.h
|
||||
- Added code that enforces standard shutdown behavior for sockets
|
||||
- Wiped out the poorly written parse code from r2211
|
||||
* Removed old script bonuses bMatk, bMatk1, bMatk2.
|
||||
* Fixed char-server not sending online notification when a party member
|
||||
logs in.
|
||||
|
@ -337,7 +337,6 @@ void plugins_init(void)
|
||||
register_plugin_func(EVENT_ATHENA_FINAL);
|
||||
|
||||
// networking
|
||||
export_symbol(func_parse_table, SYMBOL_FUNC_PARSE_TABLE);
|
||||
export_symbol(RFIFOSKIP, SYMBOL_RFIFOSKIP);
|
||||
export_symbol(WFIFOSET, SYMBOL_WFIFOSET);
|
||||
export_symbol(delete_session, SYMBOL_DELETE_SESSION);
|
||||
|
@ -282,7 +282,6 @@ static int connect_client(int listen_fd)
|
||||
session[fd]->func_parse = (session[listen_fd]->func_parse) ? session[listen_fd]->func_parse : default_func_parse;
|
||||
session[fd]->client_addr = client_address;
|
||||
session[fd]->rdata_tick = last_tick;
|
||||
session[fd]->type = SESSION_UNKNOWN; // undefined type
|
||||
|
||||
//ShowMessage("new_session : %d %d\n",fd,session[fd]->eof);
|
||||
return fd;
|
||||
@ -339,31 +338,6 @@ int make_listen_port(int port)
|
||||
return make_listen_bind(INADDR_ANY,port);
|
||||
}
|
||||
|
||||
// function parse table
|
||||
// To-do: -- use dynamic arrays
|
||||
// -- add a register_parse_func();
|
||||
struct func_parse_table func_parse_table[SESSION_MAX];
|
||||
|
||||
int default_func_check (struct socket_data *sd) { return 1; }
|
||||
|
||||
void func_parse_check (struct socket_data *sd)
|
||||
{
|
||||
int i;
|
||||
for (i = SESSION_HTTP; i < SESSION_MAX; i++) {
|
||||
if (func_parse_table[i].func &&
|
||||
func_parse_table[i].check &&
|
||||
func_parse_table[i].check(sd) != 0)
|
||||
{
|
||||
sd->type = i;
|
||||
sd->func_parse = func_parse_table[i].func;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// undefined -- treat as raw socket (using default parse)
|
||||
sd->type = SESSION_RAW;
|
||||
}
|
||||
|
||||
int make_connection(long ip,int port)
|
||||
{
|
||||
struct sockaddr_in server_address;
|
||||
@ -675,10 +649,7 @@ int do_parsepacket(void)
|
||||
}
|
||||
if(sd->rdata_size == 0 && sd->eof == 0)
|
||||
continue;
|
||||
if(sd->func_parse){
|
||||
if(sd->type == SESSION_UNKNOWN)
|
||||
func_parse_check(sd);
|
||||
if(sd->type != SESSION_UNKNOWN)
|
||||
if(sd->func_parse) {
|
||||
sd->func_parse(i);
|
||||
if(!session[i])
|
||||
continue;
|
||||
@ -1201,10 +1172,6 @@ void socket_init(void)
|
||||
session[0]->max_rdata = 2*rfifo_size;
|
||||
session[0]->max_wdata = 2*wfifo_size;
|
||||
|
||||
memset(func_parse_table, 0, sizeof(func_parse_table));
|
||||
func_parse_table[SESSION_RAW].check = default_func_check;
|
||||
func_parse_table[SESSION_RAW].func = default_func_parse;
|
||||
|
||||
#ifndef MINICORE
|
||||
// Delete old connection history every 5 minutes
|
||||
memset(connect_history, 0, sizeof(connect_history));
|
||||
|
@ -69,15 +69,6 @@
|
||||
#define TOL(n) ((uint32)((n)&UINT32_MAX))
|
||||
|
||||
|
||||
// Session type
|
||||
enum SessionType {
|
||||
SESSION_UNKNOWN = -1,
|
||||
SESSION_RAW = 0,
|
||||
SESSION_HTTP = 1,
|
||||
//-----------------
|
||||
SESSION_MAX = 2
|
||||
};
|
||||
|
||||
// Struct declaration
|
||||
|
||||
struct socket_data {
|
||||
@ -93,16 +84,8 @@ struct socket_data {
|
||||
int (*func_parse)(int);
|
||||
void* session_data;
|
||||
void* session_data2;
|
||||
enum SessionType type;
|
||||
};
|
||||
|
||||
// Parse functions table
|
||||
struct func_parse_table {
|
||||
int (*func)(int);
|
||||
int (*check)(struct socket_data *);
|
||||
};
|
||||
extern struct func_parse_table func_parse_table[SESSION_MAX];
|
||||
|
||||
|
||||
// Data prototype declaration
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user