Huw Davies : iphlpapi: Add a version of get_dns_servers for Android.
Alexandre Julliard
julliard at winehq.org
Tue Sep 17 15:25:54 CDT 2013
Module: wine
Branch: master
Commit: 208eae73ae8fda6ffd34688a0f64c3456d2010ba
URL: http://source.winehq.org/git/wine.git/?a=commit;h=208eae73ae8fda6ffd34688a0f64c3456d2010ba
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Sep 17 13:09:16 2013 +0100
iphlpapi: Add a version of get_dns_servers for Android.
---
configure | 2 +
configure.ac | 2 +
dlls/iphlpapi/iphlpapi_main.c | 49 +++++++++++++++++++++++++++++++++++++++++
include/config.h.in | 6 +++++
4 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index a01bee0..e6f6971 100755
--- a/configure
+++ b/configure
@@ -13370,6 +13370,8 @@ esac
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $BUILTINFLAG"
for ac_func in \
+ __res_get_state \
+ __res_getservers \
_finite \
_isnan \
_pclose \
diff --git a/configure.ac b/configure.ac
index b69c379..e03928c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1997,6 +1997,8 @@ dnl **** Check for functions ****
ac_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $BUILTINFLAG"
AC_CHECK_FUNCS(\
+ __res_get_state \
+ __res_getservers \
_finite \
_isnan \
_pclose \
diff --git a/dlls/iphlpapi/iphlpapi_main.c b/dlls/iphlpapi/iphlpapi_main.c
index 6ce2c94..f84c700 100644
--- a/dlls/iphlpapi/iphlpapi_main.c
+++ b/dlls/iphlpapi/iphlpapi_main.c
@@ -978,7 +978,56 @@ static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
}
return addr - servers;
}
+#elif defined(HAVE___RES_GET_STATE) && defined(HAVE___RES_GETSERVERS)
+
+static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
+{
+ extern struct res_state *__res_get_state( void );
+ extern int __res_getservers( struct res_state *, struct sockaddr_storage *, int );
+ struct res_state *state = __res_get_state();
+ int i, found = 0, total = __res_getservers( state, NULL, 0 );
+ SOCKADDR_STORAGE *addr = servers;
+ struct sockaddr_storage *buf;
+
+ if ((!servers || !num) && !ip4_only) return total;
+
+ buf = HeapAlloc( GetProcessHeap(), 0, total * sizeof(struct sockaddr_storage) );
+ total = __res_getservers( state, buf, total );
+
+ for (i = 0; i < total; i++)
+ {
+ if (buf[i].ss_family == AF_INET6 && ip4_only) continue;
+ if (buf[i].ss_family != AF_INET && buf[i].ss_family != AF_INET6) continue;
+
+ found++;
+ if (!servers || !num) continue;
+
+ if (buf[i].ss_family == AF_INET6)
+ {
+ SOCKADDR_IN6 *s = (SOCKADDR_IN6 *)addr;
+ struct sockaddr_in6 *ptr = (struct sockaddr_in6 *)(buf + i);
+ s->sin6_family = WS_AF_INET6;
+ s->sin6_port = ptr->sin6_port;
+ s->sin6_flowinfo = ptr->sin6_flowinfo;
+ memcpy( &s->sin6_addr, &ptr->sin6_addr, sizeof(IN6_ADDR) );
+ s->sin6_scope_id = ptr->sin6_scope_id;
+ memset( (char *)s + sizeof(SOCKADDR_IN6), 0,
+ sizeof(SOCKADDR_STORAGE) - sizeof(SOCKADDR_IN6) );
+ }
+ else
+ {
+ *(struct sockaddr_in *)addr = *(struct sockaddr_in *)(buf + i);
+ memset( (char *)addr + sizeof(struct sockaddr_in), 0,
+ sizeof(SOCKADDR_STORAGE) - sizeof(struct sockaddr_in) );
+ }
+ if (++addr >= servers + num) break;
+ }
+
+ HeapFree( GetProcessHeap(), 0, buf );
+ return found;
+}
#else
+
static int get_dns_servers( SOCKADDR_STORAGE *servers, int num, BOOL ip4_only )
{
FIXME("Unimplemented on this system\n");
diff --git a/include/config.h.in b/include/config.h.in
index 505dd28..62bee90 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1233,6 +1233,12 @@
/* Define to 1 if you have the `_vsnprintf' function. */
#undef HAVE__VSNPRINTF
+/* Define to 1 if you have the `__res_getservers' function. */
+#undef HAVE___RES_GETSERVERS
+
+/* Define to 1 if you have the `__res_get_state' function. */
+#undef HAVE___RES_GET_STATE
+
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
More information about the wine-cvs
mailing list