From 23f492fd1bf83aa54fafea8c5c0f159c3d56efea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 4 Nov 2020 23:57:43 +0100 Subject: [PATCH 1/3] Fix compilation when _WIN32_WINNT_VISTA macro is not defined Older version of i586-mingw32msvc-gcc compiler does not define _WIN32_WINNT_VISTA macro. Therefore preprocessor #if condition is incorrectly evaluated. --- miniupnpc/addr_is_reserved.c | 2 +- miniupnpc/minissdpc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/miniupnpc/addr_is_reserved.c b/miniupnpc/addr_is_reserved.c index 9d84d49..046380e 100644 --- a/miniupnpc/addr_is_reserved.c +++ b/miniupnpc/addr_is_reserved.c @@ -56,7 +56,7 @@ int addr_is_reserved(const char * addr_str) uint32_t addr_n, address; size_t i; -#if defined(_WIN32) && (_WIN32_WINNT < _WIN32_WINNT_VISTA) +#if defined(_WIN32) && (!defined(_WIN32_WINNT_VISTA) || (_WIN32_WINNT < _WIN32_WINNT_VISTA)) addr_n = inet_addr(addr_str); if (addr_n == INADDR_NONE) return 1; diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index 1e99a04..cb12c59 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -454,7 +454,7 @@ parseMSEARCHReply(const char * reply, int size, static int upnp_gettimeofday(struct timeval * tv) { #if defined(_WIN32) -#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#if defined(_WIN32_WINNT_VISTA) && (_WIN32_WINNT >= _WIN32_WINNT_VISTA) ULONGLONG ts = GetTickCount64(); #else DWORD ts = GetTickCount(); @@ -714,7 +714,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], } else { struct in_addr mc_if; #if defined(_WIN32) -#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#if defined(_WIN32_WINNT_VISTA) && (_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() */ From 26e8f7831a981439b95920c55865bb9e29903703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 4 Nov 2020 23:59:03 +0100 Subject: [PATCH 2/3] Use GetBestInterface() instead of GetBestInterfaceEx() GetBestInterfaceEx() is not supported by older i586-mingw32msvc-gcc compiler. GetBestInterface() works only with IPv4 addresses but in this case it is enough as it is needed only for IP address 223.255.255.255. --- miniupnpc/minissdpc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/miniupnpc/minissdpc.c b/miniupnpc/minissdpc.c index cb12c59..7f68fc5 100644 --- a/miniupnpc/minissdpc.c +++ b/miniupnpc/minissdpc.c @@ -570,12 +570,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[], * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */ if(!ipv6) { DWORD ifbestidx; - 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) { + if (GetBestInterface(inet_addr("223.255.255.255"), &ifbestidx) == NO_ERROR) { DWORD dwRetVal = NO_ERROR; PIP_ADAPTER_ADDRESSES pAddresses = NULL; ULONG outBufLen = 15360; From d60349a9b1ca9fa98291a30ef8476bc916b2b766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Thu, 5 Nov 2020 00:01:04 +0100 Subject: [PATCH 3/3] Add different mingw cross-compile builds via Makefile.mingw for Travis CI Include also build via i586-mingw32msvc-gcc cross compiler. --- .travis.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.travis.yml b/.travis.yml index fb3beaa..287cf65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,39 @@ jobs: env: PROJECT=miniupnpd - os: osx compiler: gcc + include: + - os: linux + dist: trusty + env: PROJECT=miniupnpc + compiler: i586-mingw32msvc-gcc + addons: + apt: + packages: + - mingw32 + before_install: true + after_success: true + before_script: i586-mingw32msvc-gcc -v 2>&1 | grep -q -x 'Target: i586-mingw32msvc' + script: make -C miniupnpc -f Makefile.mingw CC=i586-mingw32msvc-gcc DLLWRAP=i586-mingw32msvc-dllwrap AR=i586-mingw32msvc-ar + - os: linux + env: PROJECT=miniupnpc + compiler: i686-w64-mingw32-gcc + addons: + apt: + packages: + - gcc-mingw-w64-i686 + before_install: true + after_success: true + script: make -C miniupnpc -f Makefile.mingw CC=i686-w64-mingw32-gcc DLLWRAP=i686-w64-mingw32-dllwrap AR=i686-w64-mingw32-ar + - os: linux + env: PROJECT=miniupnpc + compiler: x86_64-w64-mingw32-gcc + addons: + apt: + packages: + - gcc-mingw-w64-x86-64 + before_install: true + after_success: true + script: make -C miniupnpc -f Makefile.mingw CC=x86_64-w64-mingw32-gcc DLLWRAP=x86_64-w64-mingw32-dllwrap AR=x86_64-w64-mingw32-ar compiler: - gcc