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.
This commit is contained in:
Guus Sliepen 2009-09-15 00:24:31 +02:00
parent f80bf14f28
commit fa9bedd47c
7 changed files with 25 additions and 19 deletions

View file

@ -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"]
)

16
have.h
View file

@ -31,6 +31,17 @@
#include <fcntl.h>
#include <unistd.h>
#ifdef HAVE_MINGW
#ifdef WITH_WINDOWS2000
#define WINVER Windows2000
#else
#define WINVER WindowsXP
#endif
#include <w32api.h>
#include <windows.h>
#include <ws2tcpip.h>
#endif
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#endif
@ -160,9 +171,4 @@
#include <netinet/if_ether.h>
#endif
#ifdef HAVE_MINGW
#include <windows.h>
#include <winsock2.h>
#endif
#endif /* __TINC_SYSTEM_H__ */

View file

@ -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

View file

@ -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;

View file

@ -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 */

View file

@ -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)
{

View file

@ -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 */