diff options
author | Haru <haru@dotalux.com> | 2018-11-15 04:01:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-15 04:01:03 +0100 |
commit | 47d6523817646f2d4f081b93ec44a971a01fce25 (patch) | |
tree | 39f5f62367fed1efe1dd734a2f3a588f2e44a9f4 /src/common/socket.h | |
parent | 3b93418544f84f142ea2a6e2bcdf1621267ff989 (diff) | |
parent | 1f237031a63567d8c96bca4a28ab9557ebe1459e (diff) | |
download | hercules-47d6523817646f2d4f081b93ec44a971a01fce25.tar.gz hercules-47d6523817646f2d4f081b93ec44a971a01fce25.tar.bz2 hercules-47d6523817646f2d4f081b93ec44a971a01fce25.tar.xz hercules-47d6523817646f2d4f081b93ec44a971a01fce25.zip |
Merge pull request #2321 from 4144/packetlen
Add complete packet len table
Diffstat (limited to 'src/common/socket.h')
-rw-r--r-- | src/common/socket.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/socket.h b/src/common/socket.h index 3c082e718..5e4251989 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -41,11 +41,7 @@ struct config_setting_t; // socket I/O macros #define RFIFOHEAD(fd) -#define WFIFOHEAD(fd, size) \ - do{ \ - if ((fd) && sockt->session[fd]->wdata_size + (size) > sockt->session[fd]->max_wdata) \ - sockt->realloc_writefifo((fd), (size)); \ - } while(0) +#define WFIFOHEAD(fd, size) sockt->wfifohead(fd, size) #define RFIFOP(fd,pos) ((const void *)(sockt->session[fd]->rdata + sockt->session[fd]->rdata_pos + (pos))) #define WFIFOP(fd,pos) ((void *)(sockt->session[fd]->wdata + sockt->session[fd]->wdata_size + (pos))) @@ -73,7 +69,8 @@ struct config_setting_t; } \ } while(0) -#define WFIFOSET(fd, len) (sockt->wfifoset(fd, len)) +#define WFIFOSET(fd, len) (sockt->wfifoset(fd, len, true)) +#define WFIFOSET2(fd, len) (sockt->wfifoset(fd, len, false)) #define RFIFOSKIP(fd, len) (sockt->rfifoskip(fd, len)) /* [Ind/Hercules] */ @@ -122,6 +119,7 @@ struct socket_data { unsigned char eof : 1; unsigned char server : 1; unsigned char ping : 2; + unsigned char validate : 1; } flag; uint32 client_addr; // remote client address @@ -130,6 +128,7 @@ struct socket_data { size_t max_rdata, max_wdata; size_t rdata_size, wdata_size; size_t rdata_pos; + uint32 last_head_size; time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled RecvFunc func_recv; @@ -178,9 +177,11 @@ struct socket_interface { /* */ time_t stall_time; time_t last_tick; + /* */ uint32 addr_[16]; // ip addresses of local host (host byte order) int naddr_; // # of ip addresses + bool validate; struct socket_data **session; @@ -200,9 +201,11 @@ struct socket_interface { int (*make_connection) (uint32 ip, uint16 port, struct hSockOpt *opt); int (*realloc_fifo) (int fd, unsigned int rfifo_size, unsigned int wfifo_size); int (*realloc_writefifo) (int fd, size_t addition); - int (*wfifoset) (int fd, size_t len); + int (*wfifoset) (int fd, size_t len, bool validate); + void (*wfifohead) (int fd, size_t len); int (*rfifoskip) (int fd, size_t len); void (*close) (int fd); + void (*validateWfifo) (int fd, size_t len); /* */ bool (*session_is_valid) (int fd); bool (*session_is_active) (int fd); |