diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-15 18:32:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-15 18:32:04 +0100 |
commit | da15867b8c743205f4a3c598bc539cd8fdd12a96 (patch) | |
tree | 4dbd44f65a0892f6108832abe1074d5033050fd7 | |
parent | 6eef187a81cbdd3cd314776de372e753f79f9831 (diff) | |
parent | 163fc125cda09289feb6342215440358ed2163b6 (diff) |
Merge pull request #47027 from Faless/net/4.x_upnp_null_fixes
[Net] Fix miniupnpc when no interface is specified
-rw-r--r-- | modules/upnp/upnp.cpp | 6 | ||||
-rw-r--r-- | thirdparty/README.md | 1 | ||||
-rw-r--r-- | thirdparty/miniupnpc/miniupnpc/minissdpc.c | 4 | ||||
-rw-r--r-- | thirdparty/miniupnpc/windows_fix.diff | 16 |
4 files changed, 8 insertions, 19 deletions
diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index cff13251ce..8e4e833d45 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -52,10 +52,12 @@ int UPNP::discover(int timeout, int ttl, const String &device_filter) { int error = 0; struct UPNPDev *devlist; + CharString cs = discover_multicast_if.utf8(); + const char *m_if = cs.length() ? cs.get_data() : nullptr; if (is_common_device(device_filter)) { - devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscover(timeout, m_if, nullptr, discover_local_port, discover_ipv6, ttl, &error); } else { - devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), nullptr, discover_local_port, discover_ipv6, ttl, &error); + devlist = upnpDiscoverAll(timeout, m_if, nullptr, discover_local_port, discover_ipv6, ttl, &error); } if (error != UPNPDISCOVER_SUCCESS) { diff --git a/thirdparty/README.md b/thirdparty/README.md index efeefedbdd..0eb227d0f9 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -364,7 +364,6 @@ Files extracted from upstream source: - All `*.c` and `*.h` files from `miniupnpc` to `thirdparty/miniupnpc/miniupnpc` - Remove `test*`, `minihttptestserver.c` and `wingenminiupnpcstrings.c` -The patch `windows_fix.diff` is applied to `minissdpc.c` to fix an upstream issue. The only modified file is miniupnpcstrings.h, which was created for Godot (it is usually autogenerated by cmake). diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/miniupnpc/minissdpc.c index 36244dedec..a3b1283da5 100644 --- a/thirdparty/miniupnpc/miniupnpc/minissdpc.c +++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.c @@ -683,7 +683,11 @@ ssdpDiscoverDevices(const char * const deviceTypes[], #endif } else { struct in_addr mc_if; +#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) + InetPtonA(AF_INET, multicastif, &mc_if); +#else mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */ +#endif if(mc_if.s_addr != INADDR_NONE) { ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr; diff --git a/thirdparty/miniupnpc/windows_fix.diff b/thirdparty/miniupnpc/windows_fix.diff deleted file mode 100644 index 460b596888..0000000000 --- a/thirdparty/miniupnpc/windows_fix.diff +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/thirdparty/miniupnpc/miniupnpc/minissdpc.c b/thirdparty/miniupnpc/miniupnpc/minissdpc.c -index 29f8110155..ea9af02e1f 100644 ---- a/thirdparty/miniupnpc/miniupnpc/minissdpc.c -+++ b/thirdparty/miniupnpc/miniupnpc/minissdpc.c -@@ -683,11 +683,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], - #endif - } else { - struct in_addr mc_if; --#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) -- InetPtonA(AF_INET, multicastif, &mc_if); --#else - mc_if.s_addr = inet_addr(multicastif); /* ex: 192.168.x.x */ --#endif - if(mc_if.s_addr != INADDR_NONE) - { - ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr; |