From 138b4ff3aa52f3c5ab96576da4825e4b75c6b789 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 17 Oct 2020 22:03:22 +0200 Subject: [PATCH] Fix for compiling with old windows SDK --- miniupnpc/addr_is_reserved.c | 10 +++++++--- miniupnpc/minissdpc.c | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/miniupnpc/addr_is_reserved.c b/miniupnpc/addr_is_reserved.c index 8fc9f0b..c4ca2e5 100644 --- a/miniupnpc/addr_is_reserved.c +++ b/miniupnpc/addr_is_reserved.c @@ -55,13 +55,17 @@ int addr_is_reserved(const char * addr_str) uint32_t addr_n, address; size_t i; +#if defined(_WIN32) && (_WIN32_WINNT < _WIN32_WINNT_VISTA) + addr_n = inet_addr(addr_str); + if (addr_n == INADDR_NONE) + return 1; +#else /* was : addr_n = inet_addr(addr_str); */ if (inet_pton(AF_INET, addr_str, &addr_n) < 0) { /* error */ - return 0; - } - if (addr_n == INADDR_NONE) return 1; + } +#endif address = ntohl(addr_n); diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index db8f4b3..048cd25 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -717,8 +717,12 @@ ssdpDiscoverDevices(const char * const deviceTypes[], #endif } else { struct in_addr mc_if; -#if defined(_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#if defined(_WIN32) +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) InetPtonA(AF_INET, multicastif, &mc_if); +#else + mc_if.s_addr = inet_addr(multicastif); /* old Windows SDK do not support InetPtoA() */ +#endif #else /* was : mc_if.s_addr = inet_addr(multicastif); */ /* ex: 192.168.x.x */ if (inet_pton(AF_INET, multicastif, &mc_if.s_addr) < 0) {