Query libnetd_client for the appropriate netId for host resolution.

If libnetd_client can't be found, operate as before and use the default netId
potentially overriden by a more specific netId passed in to
android_get*fornet().

(cherry picked from commit 559c7842cc6862568d9b5799fc0bcf74d58b596b)

Change-Id: I42ef3293172651870fb46d2de22464c4f03e8e0b
diff --git a/libc/dns/gethnamaddr.c b/libc/dns/gethnamaddr.c
index 4da99b2..1afad6d 100644
--- a/libc/dns/gethnamaddr.c
+++ b/libc/dns/gethnamaddr.c
@@ -60,6 +60,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
+#include "NetdClientDispatch.h"
 #include "resolv_netid.h"
 #include "resolv_private.h"
 #include "resolv_cache.h"
@@ -760,6 +761,8 @@
 	proxy = android_open_proxy();
 	if (proxy == NULL) goto exit;
 
+	netid = __netdClientDispatch.netIdForResolv(netid);
+
 	/* This is writing to system/netd/DnsProxyListener.cpp and changes
 	 * here need to be matched there */
 	if (fprintf(proxy, "gethostbyname %u %s %d",
@@ -796,6 +799,8 @@
 	const char * addrStr = inet_ntop(af, addr, buf, sizeof(buf));
 	if (addrStr == NULL) goto exit;
 
+	netid = __netdClientDispatch.netIdForResolv(netid);
+
 	if (fprintf(proxy, "gethostbyaddr %s %d %d %u",
 			addrStr, len, af, netid) < 0) {
 		goto exit;