summaryrefslogtreecommitdiff
path: root/src/common/socket.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-08-09 02:17:43 +0200
committerHaru <haru@dotalux.com>2015-08-15 00:51:41 +0200
commitf8edb93a6a26cd81eeaad0eac23e33da7740c8b4 (patch)
treee1d6ef1a867613be7d8d0384c93c9767867a91a3 /src/common/socket.h
parentb0210e25675b0b3e950a0ee13ae8652360d84386 (diff)
downloadhercules-f8edb93a6a26cd81eeaad0eac23e33da7740c8b4.tar.gz
hercules-f8edb93a6a26cd81eeaad0eac23e33da7740c8b4.tar.bz2
hercules-f8edb93a6a26cd81eeaad0eac23e33da7740c8b4.tar.xz
hercules-f8edb93a6a26cd81eeaad0eac23e33da7740c8b4.zip
Moved session array into the socket interface
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/socket.h')
-rw-r--r--src/common/socket.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index e7046b0d1..18bf25178 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -23,9 +23,14 @@ struct HPluginData;
// socket I/O macros
#define RFIFOHEAD(fd)
-#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) sockt->realloc_writefifo((fd), (size)); }while(0)
-#define RFIFOP(fd,pos) (session[fd]->rdata + session[fd]->rdata_pos + (pos))
-#define WFIFOP(fd,pos) (session[fd]->wdata + session[fd]->wdata_size + (pos))
+#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 RFIFOP(fd,pos) (sockt->session[fd]->rdata + sockt->session[fd]->rdata_pos + (pos))
+#define WFIFOP(fd,pos) (sockt->session[fd]->wdata + sockt->session[fd]->wdata_size + (pos))
#define RFIFOB(fd,pos) (*(uint8*)RFIFOP((fd),(pos)))
#define WFIFOB(fd,pos) (*(uint8*)WFIFOP((fd),(pos)))
@@ -35,18 +40,18 @@ struct HPluginData;
#define WFIFOL(fd,pos) (*(uint32*)WFIFOP((fd),(pos)))
#define RFIFOQ(fd,pos) (*(uint64*)RFIFOP((fd),(pos)))
#define WFIFOQ(fd,pos) (*(uint64*)WFIFOP((fd),(pos)))
-#define RFIFOSPACE(fd) (session[fd]->max_rdata - session[fd]->rdata_size)
-#define WFIFOSPACE(fd) (session[fd]->max_wdata - session[fd]->wdata_size)
+#define RFIFOSPACE(fd) (sockt->session[fd]->max_rdata - sockt->session[fd]->rdata_size)
+#define WFIFOSPACE(fd) (sockt->session[fd]->max_wdata - sockt->session[fd]->wdata_size)
-#define RFIFOREST(fd) (session[fd]->flag.eof ? 0 : session[fd]->rdata_size - session[fd]->rdata_pos)
+#define RFIFOREST(fd) (sockt->session[fd]->flag.eof ? 0 : sockt->session[fd]->rdata_size - sockt->session[fd]->rdata_pos)
#define RFIFOFLUSH(fd) \
do { \
- if(session[fd]->rdata_size == session[fd]->rdata_pos){ \
- session[fd]->rdata_size = session[fd]->rdata_pos = 0; \
+ if(sockt->session[fd]->rdata_size == sockt->session[fd]->rdata_pos){ \
+ sockt->session[fd]->rdata_size = sockt->session[fd]->rdata_pos = 0; \
} else { \
- session[fd]->rdata_size -= session[fd]->rdata_pos; \
- memmove(session[fd]->rdata, session[fd]->rdata+session[fd]->rdata_pos, session[fd]->rdata_size); \
- session[fd]->rdata_pos = 0; \
+ sockt->session[fd]->rdata_size -= sockt->session[fd]->rdata_pos; \
+ memmove(sockt->session[fd]->rdata, sockt->session[fd]->rdata+sockt->session[fd]->rdata_pos, sockt->session[fd]->rdata_size); \
+ sockt->session[fd]->rdata_pos = 0; \
} \
} while(0)
@@ -54,7 +59,7 @@ struct HPluginData;
#define RFIFOSKIP(fd, len) (sockt->rfifoskip(fd, len))
/* [Ind/Hercules] */
-#define RFIFO2PTR(fd) (void*)(session[fd]->rdata + session[fd]->rdata_pos)
+#define RFIFO2PTR(fd) (void*)(sockt->session[fd]->rdata + sockt->session[fd]->rdata_pos)
// buffer I/O macros
#define RBUFP(p,pos) (((uint8*)(p)) + (pos))
@@ -127,11 +132,6 @@ struct s_subnet {
#define MAKEIP(a,b,c,d) ((uint32)( ( ( (a)&0xFF ) << 24 ) | ( ( (b)&0xFF ) << 16 ) | ( ( (c)&0xFF ) << 8 ) | ( ( (d)&0xFF ) << 0 ) ))
/**
- * This stays out of the interface.
- **/
-struct socket_data **session;
-
-/**
* Socket.c interface, mostly for reading however.
**/
struct socket_interface {
@@ -143,6 +143,8 @@ struct socket_interface {
uint32 addr_[16]; // ip addresses of local host (host byte order)
int naddr_; // # of ip addresses
+ struct socket_data **session;
+
struct s_subnet *lan_subnet; ///< LAN subnets array
int lan_subnet_count; ///< LAN subnets count
struct s_subnet *trusted_ip; ///< Trusted IP ranges array