From: Guus Sliepen Date: Mon, 14 Sep 2009 22:24:31 +0000 (+0200) Subject: Allow compiling for Windows XP and higher. X-Git-Tag: release-1.0.10~29 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=fa9bedd47cf8c143e801889c78f0a0979ac4d2fc;p=tinc Allow compiling for Windows XP and higher. This allows us to use getaddrinfo(), getnameinfo() and related functions, which allow tinc to make connections over existing IPv6 networks. These functions are not available on Windows 2000 however. By default, support is enabled, but when compiling for Windows 2000 the configure switch --with-windows2000 should be used. Since getaddrinfo() et al. are not functions but macros on Windows, we have to use AC_CHECK_DECLS() instead of AC_CHECK_FUNCS() in configure.in. --- diff --git a/configure.in b/configure.in index eff93a08..1ff36b3f 100644 --- a/configure.in +++ b/configure.in @@ -82,6 +82,11 @@ AC_ARG_ENABLE(tunemu, ] ) +AC_ARG_WITH(windows2000, + AS_HELP_STRING([--with-windows2000], [compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks.]), + [AC_DEFINE(WITH_WINDOWS2000, 1, [Compile with support for Windows 2000])] +) + AM_CONDITIONAL(TUNEMU, test "$tunemu" = true) AC_CACHE_SAVE @@ -143,7 +148,7 @@ AC_CHECK_FUNC(gethostbyname, [], [ AC_CHECK_LIB(nsl, gethostbyname) ]) -AC_CHECK_FUNCS([freeaddrinfo gai_strerror getaddrinfo getnameinfo inet_aton], +AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo], [], [], [#include "have.h"] ) diff --git a/have.h b/have.h index 8a58af33..7e2930dc 100644 --- a/have.h +++ b/have.h @@ -31,6 +31,17 @@ #include #include +#ifdef HAVE_MINGW +#ifdef WITH_WINDOWS2000 +#define WINVER Windows2000 +#else +#define WINVER WindowsXP +#endif +#include +#include +#include +#endif + #ifdef HAVE_STDBOOL_H #include #endif @@ -160,9 +171,4 @@ #include #endif -#ifdef HAVE_MINGW -#include -#include -#endif - #endif /* __TINC_SYSTEM_H__ */ diff --git a/lib/dropin.h b/lib/dropin.h index 72109c84..4db7d7e0 100644 --- a/lib/dropin.h +++ b/lib/dropin.h @@ -39,11 +39,6 @@ extern int asprintf(char **, const char *, ...); extern int vasprintf(char **, const char *, va_list ap); #endif -#ifndef HAVE_GETNAMEINFO -extern int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, - size_t hostlen, char *serv, size_t servlen, int flags); -#endif - #ifndef HAVE_GETTIMEOFDAY extern int gettimeofday(struct timeval *, void *); #endif diff --git a/lib/fake-getaddrinfo.c b/lib/fake-getaddrinfo.c index 14420b58..10672b7e 100644 --- a/lib/fake-getaddrinfo.c +++ b/lib/fake-getaddrinfo.c @@ -16,7 +16,7 @@ #include "fake-getaddrinfo.h" #include "xalloc.h" -#ifndef HAVE_GAI_STRERROR +#if !HAVE_DECL_GAI_STRERROR char *gai_strerror(int ecode) { switch (ecode) { @@ -32,7 +32,7 @@ char *gai_strerror(int ecode) } #endif /* !HAVE_GAI_STRERROR */ -#ifndef HAVE_FREEADDRINFO +#if !HAVE_DECL_FREEADDRINFO void freeaddrinfo(struct addrinfo *ai) { struct addrinfo *next; @@ -45,7 +45,7 @@ void freeaddrinfo(struct addrinfo *ai) } #endif /* !HAVE_FREEADDRINFO */ -#ifndef HAVE_GETADDRINFO +#if !HAVE_DECL_GETADDRINFO static struct addrinfo *malloc_ai(uint16_t port, uint32_t addr) { struct addrinfo *ai; diff --git a/lib/fake-getaddrinfo.h b/lib/fake-getaddrinfo.h index d2b46f62..d31a89a1 100644 --- a/lib/fake-getaddrinfo.h +++ b/lib/fake-getaddrinfo.h @@ -33,16 +33,16 @@ struct addrinfo { }; #endif /* !HAVE_STRUCT_ADDRINFO */ -#ifndef HAVE_GETADDRINFO +#if !HAVE_DECL_GETADDRINFO int getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res); #endif /* !HAVE_GETADDRINFO */ -#ifndef HAVE_GAI_STRERROR +#if !HAVE_DECL_GAI_STRERROR char *gai_strerror(int ecode); #endif /* !HAVE_GAI_STRERROR */ -#ifndef HAVE_FREEADDRINFO +#if !HAVE_DECL_FREEADDRINFO void freeaddrinfo(struct addrinfo *ai); #endif /* !HAVE_FREEADDRINFO */ diff --git a/lib/fake-getnameinfo.c b/lib/fake-getnameinfo.c index 796efdf8..80471730 100644 --- a/lib/fake-getnameinfo.c +++ b/lib/fake-getnameinfo.c @@ -14,7 +14,7 @@ #include "fake-getnameinfo.h" #include "fake-getaddrinfo.h" -#ifndef HAVE_GETNAMEINFO +#if !HAVE_DECL_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { diff --git a/lib/fake-getnameinfo.h b/lib/fake-getnameinfo.h index 0f0b4bcc..02ac77a1 100644 --- a/lib/fake-getnameinfo.h +++ b/lib/fake-getnameinfo.h @@ -3,7 +3,7 @@ #ifndef _FAKE_GETNAMEINFO_H #define _FAKE_GETNAMEINFO_H -#ifndef HAVE_GETNAMEINFO +#if !HAVE_DECL_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); #endif /* !HAVE_GETNAMEINFO */