summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-30 18:31:05 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-30 18:31:05 +0000
commit7aa5e059a8f66d91bd8b69c58c657ceb70b4baff (patch)
tree3c846a54d4391ff662d0339fd7854a1c215ba7e5 /include
parent4a64082e31c3c3dfa97a1edfb8a3c97fe8d32ea7 (diff)
Remove include/inspircd_se_config.h and socketengine-specific headers
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11784 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/socketengine.h2
-rw-r--r--include/socketengines/socketengine_epoll.h59
-rw-r--r--include/socketengines/socketengine_iocp.h237
-rw-r--r--include/socketengines/socketengine_kqueue.h64
-rw-r--r--include/socketengines/socketengine_poll.h74
-rw-r--r--include/socketengines/socketengine_ports.h64
-rw-r--r--include/socketengines/socketengine_select.h55
7 files changed, 2 insertions, 553 deletions
diff --git a/include/socketengine.h b/include/socketengine.h
index 1a0a61670..662bd8e05 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -473,5 +473,7 @@ public:
void GetStats(float &kbitpersec_in, float &kbitpersec_out, float &kbitpersec_total);
};
+SocketEngine* CreateSocketEngine();
+
#endif
diff --git a/include/socketengines/socketengine_epoll.h b/include/socketengines/socketengine_epoll.h
deleted file mode 100644
index 08a9b1bcc..000000000
--- a/include/socketengines/socketengine_epoll.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_EPOLL__
-#define __SOCKETENGINE_EPOLL__
-
-#include <vector>
-#include <string>
-#include <map>
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "socketengine.h"
-#include <sys/epoll.h>
-#define EP_DELAY 5
-
-/** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
- */
-class EPollEngine : public SocketEngine
-{
-private:
- /** These are used by epoll() to hold socket events
- */
- struct epoll_event* events;
- int EngineHandle;
-public:
- /** Create a new EPollEngine
- */
- EPollEngine();
- /** Delete an EPollEngine
- */
- virtual ~EPollEngine();
- virtual bool AddFd(EventHandler* eh, int event_mask);
- virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
- virtual bool DelFd(EventHandler* eh, bool force = false);
- virtual int DispatchEvents();
- virtual std::string GetName();
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
-public:
- /** Create a new instance of SocketEngine based on EpollEngine
- */
- SocketEngine* Create() { return new EPollEngine; }
-};
-
-#endif
diff --git a/include/socketengines/socketengine_iocp.h b/include/socketengines/socketengine_iocp.h
deleted file mode 100644
index 0f4f6bdf5..000000000
--- a/include/socketengines/socketengine_iocp.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_IOCP__
-#define __SOCKETENGINE_IOCP__
-
-#define READ_BUFFER_SIZE 600
-#define USING_IOCP 1
-
-#include "inspircd_config.h"
-#include "inspircd_win32wrapper.h"
-#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];
- unsigned long udp_len;
- sockaddr udp_sockaddr[2];
- 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.
- * This is a little slow, but it isnt called too much. We'll fix it
- * in a future release.
- * @return -1 if there are no free slots, and an integer if it finds one.
- */
- __inline int GenerateFd(int RealFd)
- {
- int index_hash = RealFd % MAX_DESCRIPTORS;
- if(ref[index_hash] == 0)
- return index_hash;
- else
- {
- register int i = 0;
- for(; i < MAX_DESCRIPTORS; ++i)
- if(ref[i] == 0)
- return i;
- }
- return -1;
- }
-
- /** Global I/O completion port that sockets attach to.
- */
- HANDLE m_completionPort;
-
- /** This is kinda shitty... :/ for getting an address from a real fd.
- */
- std::map<int, EventHandler*> m_binding;
-
-public:
- /** Holds the preallocated buffer passed to WSARecvFrom
- * function. Yes, I know, it's a dirty hack.
- */
- udp_overlap * udp_ov;
-
- /** Creates an IOCP Socket Engine
- * @param Instance The creator of this object
- */
- IOCPEngine();
-
- /** Deletes an IOCP socket engine and all the attached sockets
- */
- ~IOCPEngine();
-
- /** Adds an event handler to the completion port, and sets up initial events.
- * @param eh EventHandler to add
- * @return True if success, false if no room
- */
- bool AddFd(EventHandler* eh, int event_mask);
-
- /** Gets the maximum number of file descriptors that this engine can handle.
- * @return The number of file descriptors
- */
- __inline int GetMaxFds() { return MAX_DESCRIPTORS; }
-
- /** Gets the number of free/remaining file descriptors under this engine.
- * @return Remaining count
- */
- __inline int GetRemainingFds()
- {
- register int count = 0;
- register int i = 0;
- for(; i < MAX_DESCRIPTORS; ++i)
- if(ref[i] == 0)
- ++count;
- return count;
- }
-
- /** Removes a file descriptor from the set, preventing it from receiving any more events
- * @return True if remove was successful, false otherwise
- */
- bool DelFd(EventHandler* eh, bool force = false);
-
- /** Called every loop to handle input/output events for all sockets under this engine
- * @return The number of "changed" sockets.
- */
- int DispatchEvents();
-
- /** Gets the name of this socket engine as a string.
- * @return string of socket engine name
- */
- std::string GetName();
-
- void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
-
- /** Posts a completion event on the specified socket.
- * @param eh EventHandler for message
- * @param type Event Type
- * @param param Event Parameter
- * @return True if added, false if not
- */
- bool PostCompletionEvent(EventHandler* eh, SocketIOEvent type, int param);
-
- /** Posts a read event on the specified socket
- * @param eh EventHandler (socket)
- */
- void PostReadEvent(EventHandler* eh);
-
- /** Posts an accept event on the specified socket
- * @param eh EventHandler (socket)
- */
- void PostAcceptEvent(EventHandler* eh);
-
- /** Returns the EventHandler attached to a specific fd.
- * If the fd isnt in the socketengine, returns NULL.
- * @param fd The event handler to look for
- * @return A pointer to the event handler, or NULL
- */
- EventHandler* GetRef(int fd);
-
- /** Returns true if a file descriptor exists in
- * the socket engine's list.
- * @param fd The event handler to look for
- * @return True if this fd has an event handler
- */
- bool HasFd(int fd);
-
- /** Returns the EventHandler attached to a specific fd.
- * If the fd isnt in the socketengine, returns NULL.
- * @param fd The event handler to look for
- * @return A pointer to the event handler, or NULL
- */
- EventHandler* GetIntRef(int fd);
-
- bool BoundsCheckFd(EventHandler* eh);
-
- virtual int Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen);
-
- virtual int RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
-
- virtual int Blocking(int fd);
-
- virtual int NonBlocking(int fd);
-
- virtual int GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen);
-
- virtual int Close(int fd);
-
- virtual int Close(EventHandler* fd);
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
-public:
- /** Create a new instance of SocketEngine based on IOCPEngine
- */
- SocketEngine* Create() { return new IOCPEngine; }
-};
-
-#endif
diff --git a/include/socketengines/socketengine_kqueue.h b/include/socketengines/socketengine_kqueue.h
deleted file mode 100644
index 01621c1de..000000000
--- a/include/socketengines/socketengine_kqueue.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_KQUEUE__
-#define __SOCKETENGINE_KQUEUE__
-
-#include <vector>
-#include <string>
-#include <map>
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/time.h>
-#include "socketengine.h"
-
-/** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue().
- */
-class KQueueEngine : public SocketEngine
-{
-private:
- int EngineHandle;
- /** These are used by kqueue() to hold socket events
- */
- struct kevent* ke_list;
- /** This is a specialised time value used by kqueue()
- */
- struct timespec ts;
-public:
- /** Create a new KQueueEngine
- */
- KQueueEngine();
- /** Delete a KQueueEngine
- */
- virtual ~KQueueEngine();
- bool AddFd(EventHandler* eh, int event_mask);
- void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
- virtual bool DelFd(EventHandler* eh, bool force = false);
- virtual int DispatchEvents();
- virtual std::string GetName();
- virtual void RecoverFromFork();
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
- public:
- /** Create a new instance of SocketEngine based on KQueueEngine
- */
- SocketEngine* Create() { return new KQueueEngine; }
-};
-
-#endif
diff --git a/include/socketengines/socketengine_poll.h b/include/socketengines/socketengine_poll.h
deleted file mode 100644
index a99ce915c..000000000
--- a/include/socketengines/socketengine_poll.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_POLL__
-#define __SOCKETENGINE_POLL__
-
-#include <vector>
-#include <string>
-#include <map>
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "socketengine.h"
-
-#ifndef WINDOWS
- #ifndef __USE_XOPEN
- #define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/
- #endif
- #include <poll.h>
- #include <sys/poll.h>
-#else
- /* *grumble* */
- #define struct pollfd WSAPOLLFD
- #define poll WSAPoll
-#endif
-
-class InspIRCd;
-
-/** A specialisation of the SocketEngine class, designed to use poll().
- */
-class PollEngine : public SocketEngine
-{
-private:
- /** These are used by poll() to hold socket events
- */
- struct pollfd *events;
- /** This map maps fds to an index in the events array.
- */
- std::map<int, unsigned int> fd_mappings;
-public:
- /** Create a new PollEngine
- */
- PollEngine();
- /** Delete a PollEngine
- */
- virtual ~PollEngine();
- virtual bool AddFd(EventHandler* eh, int event_mask);
- virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
- virtual EventHandler* GetRef(int fd);
- virtual bool DelFd(EventHandler* eh, bool force = false);
- virtual int DispatchEvents();
- virtual std::string GetName();
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
-public:
- /** Create a new instance of SocketEngine based on PollEngine
- */
- SocketEngine* Create() { return new PollEngine; }
-};
-
-#endif
diff --git a/include/socketengines/socketengine_ports.h b/include/socketengines/socketengine_ports.h
deleted file mode 100644
index be8c4bad2..000000000
--- a/include/socketengines/socketengine_ports.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_PORTS__
-#define __SOCKETENGINE_PORTS__
-
-#ifndef __sun
-# error You need Solaris 10 or later to make use of this code.
-#endif
-
-#include <vector>
-#include <string>
-#include <map>
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "socketengine.h"
-#include <port.h>
-
-/** A specialisation of the SocketEngine class, designed to use solaris 10 I/O completion ports
- */
-class PortsEngine : public SocketEngine
-{
-private:
- /** These are used by epoll() to hold socket events
- */
- port_event_t* events;
-public:
- /** Create a new PortsEngine
- * @param Instance The creator of this object
- */
- PortsEngine();
- /** Delete a PortsEngine
- */
- virtual ~PortsEngine();
- virtual bool AddFd(EventHandler* eh, int event_mask);
- void OnSetEvent(EventHandler* eh, int old_event, int new_event);
- virtual bool DelFd(EventHandler* eh, bool force = false);
- virtual int DispatchEvents();
- virtual std::string GetName();
- virtual void WantWrite(EventHandler* eh);
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
-public:
- /** Create a new instance of SocketEngine based on PortsEngine
- */
- SocketEngine* Create() { return new PortsEngine; }
-};
-
-#endif
-
diff --git a/include/socketengines/socketengine_select.h b/include/socketengines/socketengine_select.h
deleted file mode 100644
index 5a4aee86b..000000000
--- a/include/socketengines/socketengine_select.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
- *
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
- *
- * This program is free but copyrighted software; see
- * the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __SOCKETENGINE_SELECT__
-#define __SOCKETENGINE_SELECT__
-
-#include <vector>
-#include <string>
-#include <map>
-#ifndef WINDOWS
-#include <sys/select.h>
-#endif // WINDOWS
-#include "inspircd_config.h"
-#include "inspircd.h"
-#include "socketengine.h"
-
-/** A specialisation of the SocketEngine class, designed to use traditional select().
- */
-class SelectEngine : public SocketEngine
-{
-public:
- /** Create a new SelectEngine
- */
- SelectEngine();
- /** Delete a SelectEngine
- */
- virtual ~SelectEngine();
- virtual bool AddFd(EventHandler* eh, int event_mask);
- virtual bool DelFd(EventHandler* eh, bool force = false);
- void OnSetEvent(EventHandler* eh, int, int);
- virtual int DispatchEvents();
- virtual std::string GetName();
-};
-
-/** Creates a SocketEngine
- */
-class SocketEngineFactory
-{
-public:
- /** Create a new instance of SocketEngine based on SelectEngine
- */
- SocketEngine* Create() { return new SelectEngine; }
-};
-
-#endif