diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-10-17 20:24:48 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-10-17 20:24:48 +0000 |
commit | 5f6a6a2557a90573a504b541a3234f0dc566bf6a (patch) | |
tree | 4e4522d1c1c7411a2c7672af9af7887333dcdc50 /src/common/socket.h | |
parent | 724babffe10a6908d1510c941e5abfbe840fd271 (diff) | |
download | hercules-5f6a6a2557a90573a504b541a3234f0dc566bf6a.tar.gz hercules-5f6a6a2557a90573a504b541a3234f0dc566bf6a.tar.bz2 hercules-5f6a6a2557a90573a504b541a3234f0dc566bf6a.tar.xz hercules-5f6a6a2557a90573a504b541a3234f0dc566bf6a.zip |
* Merged do_sendrecv() and do_parse() into do_sockets()
* Fixed subnet check message displaying incorrect ip addresses
* client_addr will now be properly set to 0 for server connections
* Removed socket code that attempts to cope with code bugs at runtime
* Removed outdated copyright and version number from startup logo
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11503 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/socket.h')
-rw-r--r-- | src/common/socket.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/common/socket.h b/src/common/socket.h index 4015fed97..cdbac8f00 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -68,18 +68,23 @@ typedef int (*RecvFunc)(int fd); typedef int (*SendFunc)(int fd); typedef int (*ParseFunc)(int fd); -struct socket_data { +struct socket_data +{ unsigned char eof; + unsigned char *rdata, *wdata; size_t max_rdata, max_wdata; size_t rdata_size, wdata_size; size_t rdata_pos; - time_t rdata_tick; // time of last receive (for detecting timeouts) - uint32 client_addr; // remote client address (zero for s2s connections) - void* session_data; + time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled + + uint32 client_addr; // remote client address (0 for server connections) + RecvFunc func_recv; SendFunc func_send; ParseFunc func_parse; + + void* session_data; // stores application-specific data related to the session }; @@ -94,8 +99,8 @@ extern time_t stall_time; ////////////////////////////////// // some checking on sockets -extern int session_isValid(int fd); -extern int session_isActive(int fd); +extern bool session_isValid(int fd); +extern bool session_isActive(int fd); ////////////////////////////////// // Function prototype declaration @@ -107,8 +112,7 @@ int realloc_writefifo(int fd, size_t addition); int WFIFOSET(int fd, size_t len); int RFIFOSKIP(int fd, size_t len); -int do_sendrecv(int next); -int do_parsepacket(void); +int do_sockets(int next); void do_close(int fd); void socket_init(void); void socket_final(void); @@ -123,7 +127,7 @@ void set_defaultparse(ParseFunc defaultparse); uint32 host2ip(const char* hostname); const char* ip2str(uint32 ip, char ip_str[16]); uint32 str2ip(const char* ip_str); -#define CONVIP(ip) (ip>>24)&0xFF,(ip>>16)&0xFF,(ip>>8)&0xFF,(ip>>0)&0xFF +#define CONVIP(ip) ((ip)>>24)&0xFF,((ip)>>16)&0xFF,((ip)>>8)&0xFF,((ip)>>0)&0xFF uint16 ntows(uint16 netshort); int socket_getips(uint32* ips, int max); |