diff --git a/libretroshare/src/scripts/config-linux.mk b/libretroshare/src/scripts/config-linux.mk index 9915de316..e27185145 100644 --- a/libretroshare/src/scripts/config-linux.mk +++ b/libretroshare/src/scripts/config-linux.mk @@ -16,6 +16,10 @@ PQI_USE_XPGP = 1 SSL_DIR=../../../../../src/openssl-0.9.7g-xpgp-0.1c UPNPC_DIR=../../../../../src/miniupnpc-1.0 +# Need to define miniupnpc version because API changed a little between v1.0 and 1.2 +# put 10 for 1.0 and 12 for 1.2 +DEFINES += -DMINIUPNPC_VERSION=10 + include $(RS_TOP_DIR)/scripts/checks.mk ############ ENFORCE DIRECTORY NAMING ######################## @@ -30,6 +34,7 @@ LIBRS = $(LIBDIR)/libretroshare.a INCLUDE = -I $(RS_TOP_DIR) #-I$(KADC_DIR) CFLAGS = -Wall -g $(INCLUDE) +CFLAGS += ${DEFINES} ifdef PQI_USE_XPGP INCLUDE += -I $(SSL_DIR)/include @@ -61,7 +66,7 @@ RSCFLAGS = -Wall -g $(INCLUDE) BIOCC = gcc # Linux flags -BIOCFLAGS = -I $(SSL_DIR)/include -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i686 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM +BIOCFLAGS = -I $(SSL_DIR)/include ${DEFINES} -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DOPENSSL_NO_KRB5 -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -march=i686 -Wall -DSHA1_ASM -DMD5_ASM -DRMD160_ASM ######################################################################### # OS specific Linking. diff --git a/libretroshare/src/upnp/upnphandler.cc b/libretroshare/src/upnp/upnphandler.cc index ba9ed38b3..a95218d84 100644 --- a/libretroshare/src/upnp/upnphandler.cc +++ b/libretroshare/src/upnp/upnphandler.cc @@ -32,7 +32,13 @@ bool upnphandler::initUPnPState() /* allocate memory */ uPnPConfigData *upcd = new uPnPConfigData; +#if MINIUPNPC_VERSION >= 11 + /* Starting from version 1.1, miniupnpc api has a new parameter (int sameport) */ + upcd->devlist = upnpDiscover(2000, NULL, NULL, 0); +#else upcd->devlist = upnpDiscover(2000, NULL, NULL); +#endif + if(upcd->devlist) { struct UPNPDev * device; diff --git a/libretroshare/src/upnp/upnputil.c b/libretroshare/src/upnp/upnputil.c index e6aba078a..c10b202d6 100644 --- a/libretroshare/src/upnp/upnputil.c +++ b/libretroshare/src/upnp/upnputil.c @@ -141,8 +141,14 @@ bool SetRedirectAndTest(struct UPNPUrls * urls, printf("GetExternalIPAddress failed.\n"); // Unix at the moment! +#if MINIUPNPC_VERSION >= 12 + /* Starting from miniupnpc version 1.2, lease duration parameter is gone */ + r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, + eport, iport, iaddr, 0, proto); +#else r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, eport, iport, iaddr, 0, 0, proto); +#endif // r = UPNP_AddPortMapping(urls->controlURL, data->servicetype, // eport, iport, iaddr, 0, leaseDuration, proto);