Merge pull request #47028 from Faless/net/3.x_upnp_null_fixes
[3.2] [Net] Fix miniupnpc when no interface is specified
This commit is contained in:
commit
3ddab1c9d1
4 changed files with 8 additions and 19 deletions
|
@ -53,10 +53,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() : NULL;
|
||||
if (is_common_device(device_filter)) {
|
||||
devlist = upnpDiscover(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error);
|
||||
devlist = upnpDiscover(timeout, m_if, NULL, discover_local_port, discover_ipv6, ttl, &error);
|
||||
} else {
|
||||
devlist = upnpDiscoverAll(timeout, discover_multicast_if.utf8().get_data(), NULL, discover_local_port, discover_ipv6, ttl, &error);
|
||||
devlist = upnpDiscoverAll(timeout, m_if, NULL, discover_local_port, discover_ipv6, ttl, &error);
|
||||
}
|
||||
|
||||
if (error != UPNPDISCOVER_SUCCESS) {
|
||||
|
|
1
thirdparty/README.md
vendored
1
thirdparty/README.md
vendored
|
@ -292,7 +292,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).
|
||||
|
||||
|
|
4
thirdparty/miniupnpc/miniupnpc/minissdpc.c
vendored
4
thirdparty/miniupnpc/miniupnpc/minissdpc.c
vendored
|
@ -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;
|
||||
|
|
16
thirdparty/miniupnpc/windows_fix.diff
vendored
16
thirdparty/miniupnpc/windows_fix.diff
vendored
|
@ -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;
|
Loading…
Reference in a new issue