Merge branch 'what-is-a-standard'
This commit is contained in:
commit
e4cf8ebcf5
236
src/i_tcp.c
236
src/i_tcp.c
|
@ -20,127 +20,121 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_IPV6
|
#ifndef NO_IPV6
|
||||||
#define HAVE_IPV6
|
#define HAVE_IPV6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define USE_WINSOCK
|
#define USE_WINSOCK
|
||||||
#if defined (_WIN64) || defined (HAVE_IPV6)
|
#if defined (_WIN64) || defined (HAVE_IPV6)
|
||||||
#define USE_WINSOCK2
|
#define USE_WINSOCK2
|
||||||
#else //_WIN64/HAVE_IPV6
|
#else //_WIN64/HAVE_IPV6
|
||||||
#define USE_WINSOCK1
|
#define USE_WINSOCK1
|
||||||
#endif
|
#endif
|
||||||
#endif //WIN32 OS
|
#endif //WIN32 OS
|
||||||
|
|
||||||
#ifdef USE_WINSOCK2
|
#ifdef USE_WINSOCK2
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
|
|
||||||
#if defined (NOMD5) && !defined (NONET)
|
#if defined (NOMD5) && !defined (NONET)
|
||||||
//#define NONET
|
//#define NONET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NONET
|
#ifdef NONET
|
||||||
#undef HAVE_MINIUPNPC
|
#undef HAVE_MINIUPNPC
|
||||||
#else
|
#else
|
||||||
#ifdef USE_WINSOCK1
|
#ifdef USE_WINSOCK1
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#elif !defined (SCOUW2) && !defined (SCOUW7)
|
#else
|
||||||
#ifndef USE_WINSOCK
|
#ifndef USE_WINSOCK
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#endif //normal BSD API
|
#ifdef __APPLE_CC__
|
||||||
|
#ifndef _BSD_SOCKLEN_T_
|
||||||
|
#define _BSD_SOCKLEN_T_
|
||||||
|
#endif //_BSD_SOCKLEN_T_
|
||||||
|
#endif //__APPLE_CC__
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#endif //normal BSD API
|
||||||
|
|
||||||
#ifndef USE_WINSOCK
|
#include <errno.h>
|
||||||
#ifdef __APPLE_CC__
|
#include <time.h>
|
||||||
#ifndef _BSD_SOCKLEN_T_
|
|
||||||
#define _BSD_SOCKLEN_T_
|
|
||||||
#endif //_BSD_SOCKLEN_T_
|
|
||||||
#endif //__APPLE_CC__
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif //normal BSD API
|
|
||||||
|
|
||||||
#ifndef USE_WINSOCK
|
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
|
||||||
#include <netdb.h>
|
#include <sys/time.h>
|
||||||
#include <sys/ioctl.h>
|
#endif // UNIXCOMMON
|
||||||
#endif //normal BSD API
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#ifdef USE_WINSOCK
|
||||||
#include <time.h>
|
// some undefined under win32
|
||||||
|
#undef errno
|
||||||
|
//#define errno WSAGetLastError() //Alam_GBC: this is the correct way, right?
|
||||||
|
#define errno h_errno // some very strange things happen when not using h_error?!?
|
||||||
|
#ifdef EWOULDBLOCK
|
||||||
|
#undef EWOULDBLOCK
|
||||||
|
#endif
|
||||||
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
|
#ifdef EMSGSIZE
|
||||||
|
#undef EMSGSIZE
|
||||||
|
#endif
|
||||||
|
#define EMSGSIZE WSAEMSGSIZE
|
||||||
|
#ifdef ECONNREFUSED
|
||||||
|
#undef ECONNREFUSED
|
||||||
|
#endif
|
||||||
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
|
#ifdef ETIMEDOUT
|
||||||
|
#undef ETIMEDOUT
|
||||||
|
#endif
|
||||||
|
#define ETIMEDOUT WSAETIMEDOUT
|
||||||
|
#ifndef IOC_VENDOR
|
||||||
|
#define IOC_VENDOR 0x18000000
|
||||||
|
#endif
|
||||||
|
#ifndef _WSAIOW
|
||||||
|
#define _WSAIOW(x,y) (IOC_IN|(x)|(y))
|
||||||
|
#endif
|
||||||
|
#ifndef SIO_UDP_CONNRESET
|
||||||
|
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
|
||||||
|
#endif
|
||||||
|
#ifndef AI_ADDRCONFIG
|
||||||
|
#define AI_ADDRCONFIG 0x00000400
|
||||||
|
#endif
|
||||||
|
#ifndef STATUS_INVALID_PARAMETER
|
||||||
|
#define STATUS_INVALID_PARAMETER 0xC000000D
|
||||||
|
#endif
|
||||||
|
#endif // USE_WINSOCK
|
||||||
|
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)
|
#ifdef __DJGPP__
|
||||||
#include <sys/time.h>
|
#ifdef WATTCP // Alam_GBC: Wattcp may need this
|
||||||
#endif // UNIXCOMMON
|
#include <tcp.h>
|
||||||
#endif // !NONET
|
#define strerror strerror_s
|
||||||
|
#else // wattcp
|
||||||
|
#include <lsck/lsck.h>
|
||||||
|
#endif // libsocket
|
||||||
|
#endif // djgpp
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
typedef union
|
||||||
// some undefined under win32
|
{
|
||||||
#undef errno
|
struct sockaddr any;
|
||||||
//#define errno WSAGetLastError() //Alam_GBC: this is the correct way, right?
|
struct sockaddr_in ip4;
|
||||||
#define errno h_errno // some very strange things happen when not using h_error?!?
|
#ifdef HAVE_IPV6
|
||||||
#ifdef EWOULDBLOCK
|
struct sockaddr_in6 ip6;
|
||||||
#undef EWOULDBLOCK
|
|
||||||
#endif
|
#endif
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
} mysockaddr_t;
|
||||||
#ifdef EMSGSIZE
|
|
||||||
#undef EMSGSIZE
|
|
||||||
#endif
|
|
||||||
#define EMSGSIZE WSAEMSGSIZE
|
|
||||||
#ifdef ECONNREFUSED
|
|
||||||
#undef ECONNREFUSED
|
|
||||||
#endif
|
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
|
||||||
#ifdef ETIMEDOUT
|
|
||||||
#undef ETIMEDOUT
|
|
||||||
#endif
|
|
||||||
#define ETIMEDOUT WSAETIMEDOUT
|
|
||||||
#ifndef IOC_VENDOR
|
|
||||||
#define IOC_VENDOR 0x18000000
|
|
||||||
#endif
|
|
||||||
#ifndef _WSAIOW
|
|
||||||
#define _WSAIOW(x,y) (IOC_IN|(x)|(y))
|
|
||||||
#endif
|
|
||||||
#ifndef SIO_UDP_CONNRESET
|
|
||||||
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
|
|
||||||
#endif
|
|
||||||
#ifndef AI_ADDRCONFIG
|
|
||||||
#define AI_ADDRCONFIG 0x00000400
|
|
||||||
#endif
|
|
||||||
#ifndef STATUS_INVALID_PARAMETER
|
|
||||||
#define STATUS_INVALID_PARAMETER 0xC000000D
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __DJGPP__
|
#ifdef HAVE_MINIUPNPC
|
||||||
#ifdef WATTCP // Alam_GBC: Wattcp may need this
|
#ifdef STATIC_MINIUPNPC
|
||||||
#include <tcp.h>
|
#define STATICLIB
|
||||||
#define strerror strerror_s
|
#endif
|
||||||
#else // wattcp
|
#include "miniupnpc/miniwget.h"
|
||||||
#include <lsck/lsck.h>
|
#include "miniupnpc/miniupnpc.h"
|
||||||
#endif // libsocket
|
#include "miniupnpc/upnpcommands.h"
|
||||||
#endif // djgpp
|
#undef STATICLIB
|
||||||
|
static UINT8 UPNP_support = TRUE;
|
||||||
typedef union
|
#endif // HAVE_MINIUPNC
|
||||||
{
|
|
||||||
struct sockaddr any;
|
|
||||||
struct sockaddr_in ip4;
|
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
struct sockaddr_in6 ip6;
|
|
||||||
#endif
|
|
||||||
} mysockaddr_t;
|
|
||||||
|
|
||||||
#ifdef HAVE_MINIUPNPC
|
|
||||||
#ifdef STATIC_MINIUPNPC
|
|
||||||
#define STATICLIB
|
|
||||||
#endif
|
|
||||||
#include "miniupnpc/miniwget.h"
|
|
||||||
#include "miniupnpc/miniupnpc.h"
|
|
||||||
#include "miniupnpc/upnpcommands.h"
|
|
||||||
#undef STATICLIB
|
|
||||||
static UINT8 UPNP_support = TRUE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // !NONET
|
#endif // !NONET
|
||||||
|
|
||||||
|
@ -177,32 +171,32 @@ static UINT8 UPNP_support = TRUE;
|
||||||
#define DEFAULTPORT "5029"
|
#define DEFAULTPORT "5029"
|
||||||
|
|
||||||
#if defined (USE_WINSOCK) && !defined (NONET)
|
#if defined (USE_WINSOCK) && !defined (NONET)
|
||||||
typedef SOCKET SOCKET_TYPE;
|
typedef SOCKET SOCKET_TYPE;
|
||||||
#define ERRSOCKET (SOCKET_ERROR)
|
#define ERRSOCKET (SOCKET_ERROR)
|
||||||
#else
|
#else
|
||||||
#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__)
|
#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__)
|
||||||
typedef int SOCKET_TYPE;
|
typedef int SOCKET_TYPE;
|
||||||
#else
|
#else
|
||||||
typedef unsigned long SOCKET_TYPE;
|
typedef unsigned long SOCKET_TYPE;
|
||||||
#endif
|
#endif
|
||||||
#define ERRSOCKET (-1)
|
#define ERRSOCKET (-1)
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1)
|
|
||||||
typedef int socklen_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static SOCKET_TYPE mysockets[MAXNETNODES+1] = {ERRSOCKET};
|
// define socklen_t in DOS/Windows if it is not already defined
|
||||||
static size_t mysocketses = 0;
|
#if (defined (WATTCP) && !defined (__libsocket_socklen_t)) || defined (USE_WINSOCK1)
|
||||||
static int myfamily[MAXNETNODES+1] = {0};
|
typedef int socklen_t;
|
||||||
static SOCKET_TYPE nodesocket[MAXNETNODES+1] = {ERRSOCKET};
|
#endif
|
||||||
static mysockaddr_t clientaddress[MAXNETNODES+1];
|
static SOCKET_TYPE mysockets[MAXNETNODES+1] = {ERRSOCKET};
|
||||||
static mysockaddr_t broadcastaddress[MAXNETNODES+1];
|
static size_t mysocketses = 0;
|
||||||
static size_t broadcastaddresses = 0;
|
static int myfamily[MAXNETNODES+1] = {0};
|
||||||
static boolean nodeconnected[MAXNETNODES+1];
|
static SOCKET_TYPE nodesocket[MAXNETNODES+1] = {ERRSOCKET};
|
||||||
static mysockaddr_t banned[MAXBANS];
|
static mysockaddr_t clientaddress[MAXNETNODES+1];
|
||||||
static UINT8 bannedmask[MAXBANS];
|
static mysockaddr_t broadcastaddress[MAXNETNODES+1];
|
||||||
|
static size_t broadcastaddresses = 0;
|
||||||
|
static boolean nodeconnected[MAXNETNODES+1];
|
||||||
|
static mysockaddr_t banned[MAXBANS];
|
||||||
|
static UINT8 bannedmask[MAXBANS];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static size_t numbans = 0;
|
static size_t numbans = 0;
|
||||||
|
|
Loading…
Reference in New Issue