Clean up DNS proxying.

Remove code duplication and fall back to trying directly if the proxy
isn't available. With this, tests still work if netd is dead (perhaps
because you've run "adb shell stop", or because you're running on the host).

Bug: 18547878
Change-Id: Ia4a9aa18b1fc79e09735107246989fa7fc6c8455
This commit is contained in:
Elliott Hughes
2014-12-10 14:56:46 -08:00
parent fec605294e
commit 9773fa3ffd
4 changed files with 80 additions and 118 deletions

View File

@@ -34,6 +34,7 @@
*/
#include <sys/cdefs.h>
#include <netinet/in.h>
#include <stdio.h>
/*
* Passing NETID_UNSET as the netId causes system/netd/server/DnsProxyListener.cpp to
@@ -68,9 +69,9 @@ extern void _resolv_flush_cache_for_net(unsigned netid) __used_in_netd;
extern void _resolv_delete_cache_for_net(unsigned netid) __used_in_netd;
/* Internal use only. */
struct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int , unsigned);
int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t,
int, unsigned, unsigned);
struct hostent *android_gethostbyaddrfornet_proxy(const void *, socklen_t, int , unsigned, unsigned) __LIBC_HIDDEN__;
int android_getnameinfofornet(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int, unsigned, unsigned) __LIBC_HIDDEN__;
FILE* android_open_proxy(void) __LIBC_HIDDEN__;
/* delete the cache associated with a certain network */
extern void _resolv_delete_cache_for_net(unsigned netid);