diff --git a/compat.c b/compat.c index 8bd22685..3ed8045a 100644 --- a/compat.c +++ b/compat.c @@ -190,3 +190,11 @@ void openconnect__unsetenv(const char *name) putenv(buf); } #endif + +#ifndef HAVE_INET_ATON +int openconnect__inet_aton(const char *cp, struct in_addr *addr) +{ + addr->s_addr = inet_addr(cp); + return (addr->s_addr == 0xffffffff) ? 0 : 1; +} +#endif diff --git a/configure.ac b/configure.ac index 93c14e2e..d2605ffe 100644 --- a/configure.ac +++ b/configure.ac @@ -141,7 +141,13 @@ AS_COMPILER_FLAGS(WFLAGS, AC_SUBST(WFLAGS, [$WFLAGS]) AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, [], AC_ERROR(Cannot find socket() function))) -AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], AC_ERROR(Cannot find inet_aton() function))) + +have_inet_aton=yes +AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], have_inet_aton=no)) +if test "$have_inet_aton" = "yes"; then + AC_DEFINE(HAVE_INET_ATON, 1) +fi + AC_CHECK_FUNC(__android_log_vprint, [], AC_CHECK_LIB(log, __android_log_vprint, [], [])) AC_CHECK_FUNCS(setenv unsetenv) diff --git a/openconnect-internal.h b/openconnect-internal.h index fcaee243..231a2347 100644 --- a/openconnect-internal.h +++ b/openconnect-internal.h @@ -364,6 +364,11 @@ int openconnect__setenv(const char *name, const char *value, int overwrite); void openconnect__unsetenv(const char *name); #endif +#ifndef HAVE_INET_ATON +#define inet_aton openconnect__inet_aton +int openconnect__inet_aton(const char *cp, struct in_addr *addr); +#endif + /* I always coded as if it worked like this. Now it does. */ #define realloc_inplace(p, size) do { \ void *__realloc_old = p; \