Browse Source

[Net] Fix miniupnpc UWP build.

The patch has already been upstreamed, and custom patching won't be
needed during next version update.

(cherry picked from commit 8d5df826cb861eb1abc75fb7cea24ee4eaa2582d)
Fabio Alessandrelli 4 years ago
parent
commit
6daa1643b0
2 changed files with 13 additions and 0 deletions
  1. 3 0
      thirdparty/README.md
  2. 10 0
      thirdparty/miniupnpc/miniupnpc/minissdpc.c

+ 3 - 0
thirdparty/README.md

@@ -298,6 +298,9 @@ The only modified file is `miniupnpcstrings.h`, which was created for Godot
 (it is usually autogenerated by cmake). Bump the version number for miniupnpc in that
 (it is usually autogenerated by cmake). Bump the version number for miniupnpc in that
 file when upgrading.
 file when upgrading.
 
 
+Note: The following upstream patch has been applied, remove this notice on next update.
+https://github.com/miniupnp/miniupnp/commit/3a08dd4b89af2e9effa22a136bac86f2f306fd79
+
 
 
 ## minizip
 ## minizip
 
 

+ 10 - 0
thirdparty/miniupnpc/miniupnpc/minissdpc.c

@@ -576,7 +576,17 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
  * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
  * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */
 	if(!ipv6) {
 	if(!ipv6) {
 		DWORD ifbestidx;
 		DWORD ifbestidx;
+#if _WIN32_WINNT >= 0x0600 // _WIN32_WINNT_VISTA
+		// While we don't need IPv6 support, the IPv4 only funciton is not available in UWP apps.
+		SOCKADDR_IN destAddr;
+		memset(&destAddr, 0, sizeof(destAddr));
+		destAddr.sin_family = AF_INET;
+		destAddr.sin_addr.s_addr = inet_addr("223.255.255.255");
+		destAddr.sin_port = 0;
+		if (GetBestInterfaceEx((struct sockaddr *)&destAddr, &ifbestidx) == NO_ERROR) {
+#else
 		if (GetBestInterface(inet_addr("223.255.255.255"), &ifbestidx) == NO_ERROR) {
 		if (GetBestInterface(inet_addr("223.255.255.255"), &ifbestidx) == NO_ERROR) {
+#endif
 			DWORD dwRetVal = NO_ERROR;
 			DWORD dwRetVal = NO_ERROR;
 			PIP_ADAPTER_ADDRESSES pAddresses = NULL;
 			PIP_ADAPTER_ADDRESSES pAddresses = NULL;
 			ULONG outBufLen = 15360;
 			ULONG outBufLen = 15360;