mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-08 17:22:18 +00:00
Remove the old :broken: UPnP code
This commit is contained in:
parent
81e9b662b5
commit
924278cdfc
3 changed files with 1 additions and 127 deletions
12
src/Makefile
12
src/Makefile
|
@ -328,18 +328,6 @@ ifdef STATIC
|
||||||
LIBS:=-static $(LIBS)
|
LIBS:=-static $(LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef HAVE_MINIUPNPC
|
|
||||||
ifdef NONET
|
|
||||||
HAVE_MINIUPNPC=''
|
|
||||||
else
|
|
||||||
LIBS+=-lminiupnpc
|
|
||||||
ifdef MINGW
|
|
||||||
LIBS+=-lws2_32 -liphlpapi
|
|
||||||
endif
|
|
||||||
CFLAGS+=-DHAVE_MINIUPNPC
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef NO_LUA
|
ifndef NO_LUA
|
||||||
include blua/Makefile.cfg
|
include blua/Makefile.cfg
|
||||||
endif
|
endif
|
||||||
|
|
101
src/i_tcp.c
101
src/i_tcp.c
|
@ -42,9 +42,7 @@
|
||||||
//#define NONET
|
//#define NONET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NONET
|
#ifndef NONET
|
||||||
#undef HAVE_MINIUPNPC
|
|
||||||
#else
|
|
||||||
#ifdef USE_WINSOCK1
|
#ifdef USE_WINSOCK1
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#elif !defined (SCOUW2) && !defined (SCOUW7)
|
#elif !defined (SCOUW2) && !defined (SCOUW7)
|
||||||
|
@ -131,17 +129,6 @@ typedef union
|
||||||
#endif
|
#endif
|
||||||
} mysockaddr_t;
|
} 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
|
||||||
|
|
||||||
#define MAXBANS 100
|
#define MAXBANS 100
|
||||||
|
@ -303,79 +290,6 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
|
||||||
#define HAVE_NTOP
|
#define HAVE_NTOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MINIUPNPC // based on old XChat patch
|
|
||||||
static struct UPNPUrls urls;
|
|
||||||
static struct IGDdatas data;
|
|
||||||
static char lanaddr[64];
|
|
||||||
|
|
||||||
static void I_ShutdownUPnP(void)
|
|
||||||
{
|
|
||||||
FreeUPNPUrls(&urls);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void I_InitUPnP(void)
|
|
||||||
{
|
|
||||||
struct UPNPDev * devlist = NULL;
|
|
||||||
int upnp_error = -2;
|
|
||||||
CONS_Printf(M_GetText("Looking for UPnP Internet Gateway Device\n"));
|
|
||||||
devlist = upnpDiscover(2000, NULL, NULL, 0, false, &upnp_error);
|
|
||||||
if (devlist)
|
|
||||||
{
|
|
||||||
struct UPNPDev *dev = devlist;
|
|
||||||
char * descXML;
|
|
||||||
int descXMLsize = 0;
|
|
||||||
while (dev)
|
|
||||||
{
|
|
||||||
if (strstr (dev->st, "InternetGatewayDevice"))
|
|
||||||
break;
|
|
||||||
dev = dev->pNext;
|
|
||||||
}
|
|
||||||
if (!dev)
|
|
||||||
dev = devlist; /* defaulting to first device */
|
|
||||||
|
|
||||||
CONS_Printf(M_GetText("Found UPnP device:\n desc: %s\n st: %s\n"),
|
|
||||||
dev->descURL, dev->st);
|
|
||||||
|
|
||||||
UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
|
|
||||||
CONS_Printf(M_GetText("Local LAN IP address: %s\n"), lanaddr);
|
|
||||||
descXML = miniwget(dev->descURL, &descXMLsize);
|
|
||||||
if (descXML)
|
|
||||||
{
|
|
||||||
parserootdesc(descXML, descXMLsize, &data);
|
|
||||||
free(descXML);
|
|
||||||
descXML = NULL;
|
|
||||||
memset(&urls, 0, sizeof(struct UPNPUrls));
|
|
||||||
memset(&data, 0, sizeof(struct IGDdatas));
|
|
||||||
GetUPNPUrls(&urls, &data, dev->descURL);
|
|
||||||
I_AddExitFunc(I_ShutdownUPnP);
|
|
||||||
}
|
|
||||||
freeUPNPDevlist(devlist);
|
|
||||||
}
|
|
||||||
else if (upnp_error == UPNPDISCOVER_SOCKET_ERROR)
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("No UPnP devices discovered\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void I_UPnP_add(const char * addr, const char *port, const char * servicetype)
|
|
||||||
{
|
|
||||||
if (addr == NULL)
|
|
||||||
addr = lanaddr;
|
|
||||||
if (!urls.controlURL || urls.controlURL[0] == '\0')
|
|
||||||
return;
|
|
||||||
UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
|
||||||
port, port, addr, "SRB2", servicetype, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void I_UPnP_rem(const char *port, const char * servicetype)
|
|
||||||
{
|
|
||||||
if (!urls.controlURL || urls.controlURL[0] == '\0')
|
|
||||||
return;
|
|
||||||
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype,
|
|
||||||
port, servicetype, NULL);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||||
{
|
{
|
||||||
static char s[64]; // 255.255.255.255:65535 or IPv6:65535
|
static char s[64]; // 255.255.255.255:65535 or IPv6:65535
|
||||||
|
@ -946,13 +860,6 @@ static boolean UDP_Socket(void)
|
||||||
FD_SET(mysockets[s], &masterset);
|
FD_SET(mysockets[s], &masterset);
|
||||||
myfamily[s] = hints.ai_family;
|
myfamily[s] = hints.ai_family;
|
||||||
s++;
|
s++;
|
||||||
#ifdef HAVE_MINIUPNPC
|
|
||||||
if (UPNP_support)
|
|
||||||
{
|
|
||||||
I_UPnP_rem(serverport_name, "UDP");
|
|
||||||
I_UPnP_add(NULL, serverport_name, "UDP");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
runp = runp->ai_next;
|
runp = runp->ai_next;
|
||||||
}
|
}
|
||||||
|
@ -1204,12 +1111,6 @@ boolean I_InitTcpDriver(void)
|
||||||
if (!tcp_was_up && init_tcp_driver)
|
if (!tcp_was_up && init_tcp_driver)
|
||||||
{
|
{
|
||||||
I_AddExitFunc(I_ShutdownTcpDriver);
|
I_AddExitFunc(I_ShutdownTcpDriver);
|
||||||
#ifdef HAVE_MINIUPNPC
|
|
||||||
if (M_CheckParm("-useUPnP"))
|
|
||||||
I_InitUPnP();
|
|
||||||
else
|
|
||||||
UPNP_support = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return init_tcp_driver;
|
return init_tcp_driver;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,6 @@ ifndef NOASM
|
||||||
USEASM=1
|
USEASM=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef NONET
|
|
||||||
ifndef MINGW64 #miniupnc is broken with MINGW64
|
|
||||||
HAVE_MINIUPNPC=1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
OPTS=-DSTDC_HEADERS
|
OPTS=-DSTDC_HEADERS
|
||||||
|
|
||||||
ifndef GCC44
|
ifndef GCC44
|
||||||
|
@ -145,12 +139,3 @@ else
|
||||||
LIBS+=-lintl.dll
|
LIBS+=-lintl.dll
|
||||||
endif #STATIC_GETTEXT
|
endif #STATIC_GETTEXT
|
||||||
endif #GETTEXT
|
endif #GETTEXT
|
||||||
|
|
||||||
ifdef HAVE_MINIUPNPC
|
|
||||||
CPPFLAGS+=-I../libs/ -DSTATIC_MINIUPNPC
|
|
||||||
ifdef MINGW64
|
|
||||||
LDFLAGS+=-L../libs/miniupnpc/mingw64
|
|
||||||
else
|
|
||||||
LDFLAGS+=-L../libs/miniupnpc/mingw32
|
|
||||||
endif #MINGW64
|
|
||||||
endif
|
|
||||||
|
|
Loading…
Reference in a new issue