diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index 79b1451a0..66a74befa 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -173,6 +173,13 @@ ELSE() #set (FTGL_LINK_TARGETS ) ENDIF(USE_FTGL) +IF(MINIUPNPC_VERSION_PRE1_5) + ADD_DEFINITIONS(-DMINIUPNPC_VERSION_PRE1_5) +ENDIF() +IF(MINIUPNPC_VERSION_PRE1_6) + ADD_DEFINITIONS(-DMINIUPNPC_VERSION_PRE1_6) +ENDIF() + ######################################################################################### # megaglest lib diff --git a/source/shared_lib/include/platform/miniupnpc/miniupnpc.h b/source/shared_lib/include/platform/miniupnpc/miniupnpc.h index 50df01777..e8a89469f 100644 --- a/source/shared_lib/include/platform/miniupnpc/miniupnpc.h +++ b/source/shared_lib/include/platform/miniupnpc/miniupnpc.h @@ -8,6 +8,10 @@ #ifndef __MINIUPNPC_H__ #define __MINIUPNPC_H__ +//#define MEGAGLEST_EMBEDDED_MINIUPNPC +//#define MINIUPNPC_VERSION_PRE1_5 +//#define MINIUPNPC_VERSION_PRE1_6 + #include "declspec.h" #include "igd_desc_parse.h" diff --git a/source/shared_lib/include/platform/miniupnpc/miniupnpcstrings.h b/source/shared_lib/include/platform/miniupnpc/miniupnpcstrings.h index 10ceac48d..08fca5ba3 100644 --- a/source/shared_lib/include/platform/miniupnpc/miniupnpcstrings.h +++ b/source/shared_lib/include/platform/miniupnpc/miniupnpcstrings.h @@ -20,7 +20,7 @@ #define OS_STRING "Other/unknown" #endif -#define MINIUPNPC_VERSION_STRING "1.4" +#define MINIUPNPC_VERSION_STRING "1.6" #endif diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index d383cebff..c5b450edd 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -2148,7 +2148,11 @@ int UPNP_Tools::upnp_init(void *param) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Searching for UPnP devices for automatic port forwarding...\n"); int ipv6 = 0; +#ifndef MINIUPNPC_VERSION_PRE1_6 devlist = upnpDiscover(2000, NULL, NULL, 0, ipv6, NULL); +#else + devlist = upnpDiscover(2000, NULL, NULL, 0); +#endif if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"UPnP device search finished.\n"); if (devlist) { @@ -2185,7 +2189,7 @@ int UPNP_Tools::upnp_init(void *param) { } char externalIP[16] = ""; -#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC +#ifndef MINIUPNPC_VERSION_PRE1_5 UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); #else UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); @@ -2232,7 +2236,7 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2]) { if (!urls.controlURL || urls.controlURL[0] == '\0') { return false; } -#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC +#ifndef MINIUPNPC_VERSION_PRE1_5 UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIP); #else UPNP_GetExternalIPAddress(urls.controlURL, data.servicetype, externalIP); @@ -2241,10 +2245,14 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2]) { sprintf(ext_port_str, "%d", ports[0]); sprintf(int_port_str, "%d", ports[1]); -#ifndef MEGAGLEST_EMBEDDED_MINIUPNPC - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL); +#ifndef MINIUPNPC_VERSION_PRE1_5 + #ifndef MINIUPNPC_VERSION_PRE1_6 + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL); + #else + r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0); + #endif #else - r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL); + r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0); #endif if (r != UPNPCOMMAND_SUCCESS) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] AddPortMapping(%s, %s, %s) failed\n",__FILE__,__FUNCTION__,__LINE__,ext_port_str, int_port_str, lanaddr); @@ -2264,7 +2272,7 @@ void UPNP_Tools::upnp_rem_redirect(int ext_port) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\n#1 DEBUGGUNG urls.controlURL [%s]\n",urls.controlURL); - #ifndef MEGAGLEST_EMBEDDED_MINIUPNPC + #ifndef MINIUPNPC_VERSION_PRE1_5 if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\n#1 DEBUGGUNG data.first.servicetype [%s]\n",data.first.servicetype); UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, ext_port_str, "TCP", 0); #else