From 973ecb7058325931d14a9537e5e3e57595347a10 Mon Sep 17 00:00:00 2001 From: Adam- Date: Thu, 8 Apr 2010 20:23:00 +0000 Subject: Rewrote sockets. This adds support for IPv6 and makes Anope capable of reconnecting if it loses connection to the uplink. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2862 5417fbe8-f217-4b02-8779-1006273d7864 --- include/services.h | 155 +++++++++++++++++++++++------------------------------ 1 file changed, 67 insertions(+), 88 deletions(-) (limited to 'include/services.h') diff --git a/include/services.h b/include/services.h index 7e6783404..ea6b89364 100644 --- a/include/services.h +++ b/include/services.h @@ -19,28 +19,23 @@ #include "sysconf.h" #include "config.h" -#ifndef MAX_CMD_HASH -#define MAX_CMD_HASH 1024 -#endif - /* Some SUN fixs */ #ifdef __sun -/* Solaris specific code, types that do not exist in Solaris' - * sys/types.h - **/ -#undef u_int8_t -#undef u_int16_t -#undef u_int32_t -#undef u_int_64_t -#define u_int8_t uint8_t -#define u_int16_t uint16_t -#define u_int32_t uint32_t -#define u_int64_t uint64_t - -#ifndef INADDR_NONE -#define INADDR_NONE (-1) -#endif - + /* Solaris specific code, types that do not exist in Solaris' + * sys/types.h + **/ +# undef u_int8_t +# undef u_int16_t +# undef u_int32_t +# undef u_int_64_t +# define u_int8_t uint8_t +# define u_int16_t uint16_t +# define u_int32_t uint32_t +# define u_int64_t uint64_t + +# ifndef INADDR_NONE +# define INADDR_NONE (-1) +# endif #endif @@ -49,63 +44,57 @@ #include #include -/* Windows does not have: unistd.h, grp.h, netdb.h, netinet/in.h, sys/socket.h, sys/time.h - * Windows requires: winsock.h - * -- codemastr - */ - -#ifndef _WIN32 -#include -#endif - #include #include #include - -#ifndef _WIN32 -#include -#endif - #include -#ifndef _WIN32 -#include -#include -#include -#include -#else -#include -#include -#endif - -#include /* for umask() on some systems */ +#include /* for umask() on some systems */ #include -#ifdef HAVE_GETTIMEOFDAY -#include -#endif - -#ifdef _WIN32 -#include -#include -#include -#endif - #include #ifndef _WIN32 -#ifdef HAVE_BACKTRACE -#include -#endif -#endif - -#ifndef _WIN32 -#include +# include +# include +# include +# include +# include +# include +# include +# ifdef HAVE_BACKTRACE +# include +# endif +# define DllExport +# define CoreExport +# define MARK_DEPRECATED __attribute((deprecated)) +#else +# include +# include +# include +# include +# include +# include +# ifdef MODULE_COMPILE +# define CoreExport __declspec(dllimport) +# define DllExport __declspec(dllexport) +# else +# define CoreExport __declspec(dllexport) +# define DllExport __declspec(dllimport) +# endif +/* VS2008 hates having this define before its own */ +# define vsnprintf _vsnprintf +/* We have our own inet_pton and inet_ntop (Windows doesn't have its own) */ +# define inet_pton inet_pton_ +# define inet_ntop inet_ntop_ +# define MARK_DEPRECATED + +extern CoreExport int inet_pton(int af, const char *src, void *dst); +extern CoreExport const char *inet_ntop(int af, const void *src, char *dst, size_t size); #endif -#ifdef _WIN32 -/* VS2008 hates having this define before its own */ -#define vsnprintf _vsnprintf +#ifdef HAVE_GETTIMEOFDAY +# include #endif #if HAVE_STRINGS_H @@ -116,8 +105,6 @@ # include #endif -#include "sockets.h" - #ifndef va_copy # ifdef __va_copy # define VA_COPY(DEST,SRC) __va_copy((DEST),(SRC)) @@ -168,25 +155,6 @@ extern int strncasecmp(const char *, const char *, size_t); # undef int32 #endif -#ifndef _WIN32 - #define MARK_DEPRECATED __attribute((deprecated)) -#else - #define MARK_DEPRECATED -#endif - -#ifdef _WIN32 -# ifdef MODULE_COMPILE -# define CoreExport __declspec(dllimport) -# define DllExport __declspec(dllexport) -# else -# define CoreExport __declspec(dllexport) -# define DllExport __declspec(dllimport) -# endif -#else -# define DllExport -# define CoreExport -#endif - /** This definition is used as shorthand for the various classes * and functions needed to make a module loadable by the OS. * It defines the class factory and external init_module function. @@ -230,7 +198,7 @@ extern int strncasecmp(const char *, const char *, size_t); #include "defs.h" #include "slist.h" -/* pull in the various bits of STL to pull in */ +/* Pull in the various bits of STL */ #include #include #include @@ -239,6 +207,7 @@ extern int strncasecmp(const char *, const char *, size_t); #include #include #include +#include /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or @@ -302,6 +271,13 @@ class ModuleException : public CoreException virtual ~ModuleException() throw() {} }; + +/*************************************************************************/ + +#include "sockets.h" + +/*************************************************************************/ + /** Class with the ability to keep flags on items, they should extend from this * where T is an enum. */ @@ -1107,11 +1083,14 @@ struct Uplink { char *host; unsigned port; char *password; - Uplink(const char *_host, int _port, const char *_password) + bool ipv6; + + Uplink(const char *_host, int _port, const char *_password, bool _ipv6) { host = sstrdup(_host); port = _port; password = sstrdup(_password); + ipv6 = _ipv6; } ~Uplink() { -- cgit