summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Luke Huang <huangluke@google.com> 2018-11-20 11:38:23 +0800
committer Luke Huang <huangluke@google.com> 2018-12-12 04:17:41 +0800
commitc17821cc111a86574a0edacf9a78f38b5078c0b7 (patch)
tree4c58ee9bfb502a2d290c9a362bd9ae7a81c058b5
parentaff267369c2acd92ff0640637e17c2deef9142c4 (diff)
Add asynchronous DNS query API
Adds support for asynchronous "raw" DNS API for clients. API allows apps to use multinetworking capability correctly and also allows other query types than A/AAAA. Test: built, flashed, booted cts test: NativeDnsAsyncTest Change-Id: I4701b76bd8f0094ef1bdd7c5371b54387914a91b
-rw-r--r--native/android/libandroid.map.txt4
-rw-r--r--native/android/libandroid_net.map.txt9
-rw-r--r--native/android/net.c28
3 files changed, 39 insertions, 2 deletions
diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt
index ac5ded60bf6b..f840d5e2f968 100644
--- a/native/android/libandroid.map.txt
+++ b/native/android/libandroid.map.txt
@@ -218,6 +218,10 @@ LIBANDROID {
android_getaddrinfofornetwork; # introduced=23
android_setprocnetwork; # introduced=23
android_setsocknetwork; # introduced=23
+ android_res_cancel; # introduced=29
+ android_res_nquery; # introduced=29
+ android_res_nresult; # introduced=29
+ android_res_nsend; # introduced=29
local:
*;
};
diff --git a/native/android/libandroid_net.map.txt b/native/android/libandroid_net.map.txt
index 9b5a5a1f4b52..be3531da462d 100644
--- a/native/android/libandroid_net.map.txt
+++ b/native/android/libandroid_net.map.txt
@@ -1,10 +1,15 @@
-# These functions have been part of the NDK since API 24.
# They are also all available to vendor code.
LIBANDROID_NET {
global:
+ # These functions have been part of the NDK since API 24.
+ android_getaddrinfofornetwork; # vndk
android_setsocknetwork; # vndk
android_setprocnetwork; # vndk
- android_getaddrinfofornetwork; # vndk
+ # These functions have been part of the NDK since API 29.
+ android_res_cancel; # vndk
+ android_res_nquery; # vndk
+ android_res_nresult; # vndk
+ android_res_nsend; # vndk
local:
*;
};
diff --git a/native/android/net.c b/native/android/net.c
index 60296a7bd00c..e32b7875b4e7 100644
--- a/native/android/net.c
+++ b/native/android/net.c
@@ -83,3 +83,31 @@ int android_getaddrinfofornetwork(net_handle_t network,
return android_getaddrinfofornet(node, service, hints, netid, 0, res);
}
+
+int android_res_nquery(net_handle_t network,
+ const char *dname, int ns_class, int ns_type) {
+ unsigned netid;
+ if (!getnetidfromhandle(network, &netid)) {
+ return -ENONET;
+ }
+
+ return resNetworkQuery(netid, dname, ns_class, ns_type);
+}
+
+int android_res_nresult(int fd, int *rcode, unsigned char *answer, int anslen) {
+ return resNetworkResult(fd, rcode, answer, anslen);
+}
+
+int android_res_nsend(net_handle_t network,
+ const unsigned char *msg, int msglen) {
+ unsigned netid;
+ if (!getnetidfromhandle(network, &netid)) {
+ return -ENONET;
+ }
+
+ return resNetworkSend(netid, msg, msglen);
+}
+
+void android_res_cancel(int nsend_fd) {
+ resNetworkCancel(nsend_fd);
+}