Following commit for asynchronous DNS query API
Test: built, flashed, booted
system/netd/tests/runtests.sh passes
atest CtsNativeNetDnsTestCases
Change-Id: I2b796ba50d42981d295fc4b00654916f67ca346e
diff --git a/client/Android.bp b/client/Android.bp
index db3ac69..4c27117 100644
--- a/client/Android.bp
+++ b/client/Android.bp
@@ -20,7 +20,7 @@
],
header_libs: [
"libnetd_client_headers",
- "libbase_headers",
+ "libbase_headers", // for unique_fd.h
],
export_header_lib_headers: ["libnetd_client_headers"],
include_dirs: [
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp
index de9b0f5..68aa3c3 100644
--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -386,18 +386,19 @@
}
extern "C" int resNetworkQuery(unsigned netId, const char* dname, int ns_class, int ns_type) {
- u_char buf[MAX_CMD_SIZE] = {};
- int len = res_mkquery(QUERY, dname, ns_class, ns_type, NULL, 0, NULL, buf, sizeof(buf));
+ std::vector<uint8_t> buf(MAX_CMD_SIZE, 0);
+ int len = res_mkquery(ns_o_query, dname, ns_class, ns_type, nullptr, 0, nullptr, buf.data(),
+ MAX_CMD_SIZE);
- return resNetworkSend(netId, buf, len);
+ return resNetworkSend(netId, buf.data(), len);
}
-extern "C" int resNetworkSend(unsigned netId, const uint8_t* msg, int msglen) {
+extern "C" int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen) {
// Encode
// Base 64 encodes every 3 bytes into 4 characters, but then adds padding to the next
// multiple of 4 and a \0
const size_t encodedLen = divCeil(msglen, 3) * 4 + 1;
- auto encodedQuery = std::string(encodedLen - 1, 0);
+ std::string encodedQuery(encodedLen - 1, 0);
int enLen = b64_ntop(msg, msglen, encodedQuery.data(), encodedLen);
if (enLen < 0) {
@@ -425,7 +426,7 @@
return fd;
}
-extern "C" int resNetworkResult(int fd, int* rcode, uint8_t* answer, int anslen) {
+extern "C" int resNetworkResult(int fd, int* rcode, uint8_t* answer, size_t anslen) {
int32_t result = 0;
unique_fd ufd(fd);
// Read -errno/rcode
@@ -446,7 +447,7 @@
// Unexpected behavior, read ans len fail
return -EREMOTEIO;
}
- if (anslen < size) {
+ if (anslen < static_cast<size_t>(size)) {
// Answer buffer is too small
return -EMSGSIZE;
}