diff options
-rw-r--r-- | include/socket.h | 21 | ||||
-rw-r--r-- | include/socketengine.h | 14 | ||||
-rw-r--r-- | include/socketengine_iocp.h | 26 | ||||
-rw-r--r-- | include/socketengine_ports.h | 8 | ||||
-rw-r--r-- | include/timer.h | 1 | ||||
-rw-r--r-- | include/typedefs.h | 14 |
6 files changed, 69 insertions, 15 deletions
diff --git a/include/socket.h b/include/socket.h index db0aa7f92..57725b95f 100644 --- a/include/socket.h +++ b/include/socket.h @@ -39,15 +39,22 @@ /* Accept Define */ #ifdef CONFIG_USE_IOCP +/* IOCP wrapper for accept() */ #define _accept(s, addr, addrlen) __accept_socket(s, addr, addrlen, m_acceptEvent) +/* IOCP wrapper for getsockname() */ #define _getsockname(fd, sockptr, socklen) __getsockname(fd, sockptr, socklen, m_acceptEvent) +/* IOCP wrapper for recvfrom() */ #define _recvfrom(s, buf, len, flags, from, fromlen) __recvfrom(s, buf, len, flags, from, fromlen, ((IOCPEngine*)ServerInstance->SE)->udp_ov) #else +/* No wrapper for recvfrom() */ #define _recvfrom recvfrom +/* No wrapper for accept() */ #define _accept accept +/* No wrapper for getsockname() */ #define _getsockname getsockname #endif +/* Contains irc-specific definitions */ namespace irc { /** This namespace contains various protocol-independent helper classes. @@ -170,9 +177,13 @@ class CoreExport ListenSocket : public EventHandler /** The creator/owner of this object */ InspIRCd* ServerInstance; + /** Socket description (shown in stats p) */ std::string desc; + /** Socket address family */ int family; + /** Address socket is bound to */ std::string bind_addr; + /** Port socket is bound to */ int bind_port; public: /** Create a new listening socket @@ -190,17 +201,20 @@ class CoreExport ListenSocket : public EventHandler { desc = description; } - + /** Get description for socket + */ const std::string& GetDescription() { return desc; } - + /** Get port number for socket + */ int GetPort() { return bind_port; } - + /** Get IP address socket is bound to + */ std::string &GetIP() { return bind_addr; @@ -208,3 +222,4 @@ class CoreExport ListenSocket : public EventHandler }; #endif + diff --git a/include/socketengine.h b/include/socketengine.h index 330e3911c..ce701beff 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -29,8 +29,11 @@ */ enum EventType { + /** Read event */ EVENT_READ = 0, + /** Write event */ EVENT_WRITE = 1, + /** Error event */ EVENT_ERROR = 2 }; @@ -139,9 +142,13 @@ class CoreExport EventHandler : public Extensible /** Pointer to read event. We delete this so the buffer can't be used * after the socket is deleted, and so it doesn't leak memory */ - void * m_readEvent; - void * m_writeEvent; - void * m_acceptEvent; + void* m_readEvent; + /** Pointer to a write event. + */ + void* m_writeEvent; + /** Pointer to an accept event. + */ + void* m_acceptEvent; #endif }; @@ -286,3 +293,4 @@ public: }; #endif + diff --git a/include/socketengine_iocp.h b/include/socketengine_iocp.h index 5de7af03f..01c764088 100644 --- a/include/socketengine_iocp.h +++ b/include/socketengine_iocp.h @@ -23,32 +23,48 @@ #include "inspircd.h" #include "socketengine.h" +/** Socket overlapped event types + */ enum SocketIOEvent { + /** Read ready */ SOCKET_IO_EVENT_READ_READY = 0, + /** Write ready */ SOCKET_IO_EVENT_WRITE_READY = 1, + /** Accept ready */ SOCKET_IO_EVENT_ACCEPT = 2, + /** Error occured */ SOCKET_IO_EVENT_ERROR = 3, + /** Number of events */ NUM_SOCKET_IO_EVENTS = 4, }; +/** Represents a windows overlapped IO event + */ class Overlapped { public: + /** Overlap event */ OVERLAPPED m_overlap; + /** Type of event */ SocketIOEvent m_event; #ifdef WIN64 + /** Parameters */ unsigned __int64 m_params; #else + /** Parameters */ unsigned long m_params; #endif - + /** Create an overlapped event + */ Overlapped(SocketIOEvent ev, int params) : m_event(ev), m_params(params) { memset(&m_overlap, 0, sizeof(OVERLAPPED)); } }; +/** Specific to UDP sockets with overlapped IO + */ struct udp_overlap { unsigned char udp_buffer[600]; @@ -57,12 +73,16 @@ struct udp_overlap unsigned long udp_sockaddr_len; }; +/** Specific to accepting sockets with overlapped IO + */ struct accept_overlap { int socket; char buf[1024]; }; +/** Implementation of SocketEngine that implements windows IO Completion Ports + */ class IOCPEngine : public SocketEngine { /** Creates a "fake" file descriptor for use with an IOCP socket. @@ -192,10 +212,6 @@ public: udp_overlap * udp_ov;
}; -//typedef void(*OpHandler)(EventHandler) -/** Event Handler Array - */ - /** Creates a SocketEngine */ class SocketEngineFactory diff --git a/include/socketengine_ports.h b/include/socketengine_ports.h index 84b57e3fd..a5951a138 100644 --- a/include/socketengine_ports.h +++ b/include/socketengine_ports.h @@ -26,11 +26,10 @@ #include "inspircd.h" #include "socketengine.h" #include <port.h> -#define EP_DELAY 5 class InspIRCd; -/** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll(). +/** A specialisation of the SocketEngine class, designed to use solaris 10 I/O completion ports */ class PortsEngine : public SocketEngine { @@ -39,11 +38,11 @@ private: */ port_event_t events[MAX_DESCRIPTORS]; public: - /** Create a new EPollEngine + /** Create a new PortsEngine * @param Instance The creator of this object */ PortsEngine(InspIRCd* Instance); - /** Delete an EPollEngine + /** Delete a PortsEngine */ virtual ~PortsEngine(); virtual bool AddFd(EventHandler* eh); @@ -66,3 +65,4 @@ public: }; #endif + diff --git a/include/timer.h b/include/timer.h index 3fb2ed32b..ef8b82e31 100644 --- a/include/timer.h +++ b/include/timer.h @@ -153,3 +153,4 @@ class CoreExport TimerManager : public Extensible }; #endif + diff --git a/include/typedefs.h b/include/typedefs.h index d59c6ad7f..f101e1615 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -26,14 +26,28 @@ #include "globals.h" #ifndef WIN32 +/** User hash (POSIX systems with GCC) + */ typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash; +/** Channel hash (POSIX systems with GCC) + */ typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash; #else +/** User hash (windows systems with visual studio) + */ typedef nspace::hash_map<std::string, userrec*, nspace::hash_compare<string, less<string> > > user_hash; +/** Channel hash (windows systems with visual studio) + */ typedef nspace::hash_map<std::string, chanrec*, nspace::hash_compare<string, less<string> > > chan_hash; #endif +/** Server name cache + */ typedef std::vector<std::string*> servernamelist; + +/** A cached text file stored line by line. + */ typedef std::deque<std::string> file_cache; #endif + |