From f0a87e4f7f5377498960429e96be5dff183c8326 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 9 Jan 2013 00:18:53 -0800 Subject: Make incoming packets read-only --- src/common/socket.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/socket.cpp') diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 023a856..f2e6df6 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -24,11 +24,30 @@ int fd_max; static int currentuse; +static const uint32_t RFIFO_SIZE = 65536; +static const uint32_t WFIFO_SIZE = 65536; struct socket_data *session[FD_SETSIZE]; +/// clean up by discarding handled bytes +inline +void RFIFOFLUSH(int fd) +{ + memmove(session[fd]->rdata, RFIFOP(fd, 0), RFIFOREST(fd)); + session[fd]->rdata_size = RFIFOREST(fd); + session[fd]->rdata_pos = 0; +} + +/// how much room there is to read more data +inline +size_t RFIFOSPACE(int fd) +{ + return session[fd]->max_rdata - session[fd]->rdata_size; +} + + /// Discard all input static void null_parse(int fd); -- cgit v1.2.3-60-g2f50