From 322dfac85fcc031d00154caaf7b62fbc1b554727 Mon Sep 17 00:00:00 2001 From: Logan-A Date: Sat, 30 Dec 2023 18:00:21 -0500 Subject: [PATCH] update SRB2 to use miniUPnPc API version 17 update miniUPnPc function calls to API version 17 update include statements for miniUPnPcc use PKGCONFIG to find lib and inc forminiUPnPc --- src/Makefile.d/features.mk | 9 ++++++--- src/Makefile.d/win32.mk | 10 +++++----- src/i_tcp.c | 18 ++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index 20963adac..2275754b7 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -49,10 +49,13 @@ CURLCONFIG?=curl-config $(eval $(call Configure,CURL,$(CURLCONFIG))) opts+=-DHAVE_CURL endif -endif -ifdef HAVE_MINIUPNPC -libs+=-lminiupnpc +ifndef NOUPNP +MINIUPNPC_PKGCONFIG?=miniupnpc +$(eval $(call Use_pkg_config,MINIUPNPC)) +HAVE_MINIUPNPC=1 +opts+=-DHAVE_MINIUPNP +endif endif # (Valgrind is a memory debugger.) diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index b02276cfc..3e60e2416 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -33,11 +33,6 @@ libs+=-lws2_32 endif endif -ifndef NONET -opts+=-I../libs -DSTATIC_MINIUPNPC -libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi -endif - ifndef MINGW64 32=32 x86=x86 @@ -100,3 +95,8 @@ lib:=../libs/curl CURL_opts:=-I$(lib)/include CURL_libs:=-L$(lib)/lib$(32) -lcurl $(eval $(call _set,CURL)) + +lib:=../libs/miniupnpc +MINIUPNPC_opts:=-I$(lib)/include -DMINIUPNP_STATICLIB +MINIUPNPC_libs:=-L$(lib)/mingw$(32) -lminiupnpc -lws2_32 -liphlpapi +$(eval $(call _set,MINIUPNPC)) diff --git a/src/i_tcp.c b/src/i_tcp.c index d95b381f4..bd960f2ca 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -117,13 +117,9 @@ } 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 + #include "miniwget.h" + #include "miniupnpc.h" + #include "upnpcommands.h" static UINT8 UPNP_support = TRUE; #endif // HAVE_MINIUPNC @@ -279,8 +275,10 @@ static inline void I_InitUPnP(void) { struct UPNPDev * devlist = NULL; int upnp_error = -2; + int scope_id = 0; + int status_code = 0; CONS_Printf(M_GetText("Looking for UPnP Internet Gateway Device\n")); - devlist = upnpDiscover(2000, NULL, NULL, 0, false, &upnp_error); + devlist = upnpDiscover(2000, NULL, NULL, 0, false, 2, &upnp_error); if (devlist) { struct UPNPDev *dev = devlist; @@ -300,7 +298,7 @@ static inline void I_InitUPnP(void) UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); CONS_Printf(M_GetText("Local LAN IP address: %s\n"), lanaddr); - descXML = miniwget(dev->descURL, &descXMLsize); + descXML = miniwget(dev->descURL, &descXMLsize, scope_id, &status_code); if (descXML) { parserootdesc(descXML, descXMLsize, &data); @@ -308,7 +306,7 @@ static inline void I_InitUPnP(void) descXML = NULL; memset(&urls, 0, sizeof(struct UPNPUrls)); memset(&data, 0, sizeof(struct IGDdatas)); - GetUPNPUrls(&urls, &data, dev->descURL); + GetUPNPUrls(&urls, &data, dev->descURL, status_code); I_AddExitFunc(I_ShutdownUPnP); } freeUPNPDevlist(devlist);