summaryrefslogtreecommitdiff
path: root/src/common/socket.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-01-09 00:18:53 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-01-09 00:43:27 -0800
commitf0a87e4f7f5377498960429e96be5dff183c8326 (patch)
tree2661728f73f3c163e971d94cd123ef6e378264aa /src/common/socket.cpp
parentf2fd4885c2a906414e0f36acf95d252e5a9d5805 (diff)
downloadtmwa-f0a87e4f7f5377498960429e96be5dff183c8326.tar.gz
tmwa-f0a87e4f7f5377498960429e96be5dff183c8326.tar.bz2
tmwa-f0a87e4f7f5377498960429e96be5dff183c8326.tar.xz
tmwa-f0a87e4f7f5377498960429e96be5dff183c8326.zip
Make incoming packets read-only
Diffstat (limited to 'src/common/socket.cpp')
-rw-r--r--src/common/socket.cpp19
1 files changed, 19 insertions, 0 deletions
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);