Add control flags in asynchronous DNS query API
This commit should change no functionality.
Test: built, flashed, booted
Change-Id: If9d2b030ced95a2d15a16b01c3d5317d3e13d704
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp
index 68aa3c3..5586347 100644
--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -385,15 +385,16 @@
return FwmarkClient().send(&command, -1, nullptr);
}
-extern "C" int resNetworkQuery(unsigned netId, const char* dname, int ns_class, int ns_type) {
+extern "C" int resNetworkQuery(unsigned netId, const char* dname, int ns_class, int ns_type,
+ uint32_t flags) {
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.data(), len);
+ return resNetworkSend(netId, buf.data(), len, flags);
}
-extern "C" int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen) {
+extern "C" int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen, uint32_t) {
// Encode
// Base 64 encodes every 3 bytes into 4 characters, but then adds padding to the next
// multiple of 4 and a \0
diff --git a/include/NetdClient.h b/include/NetdClient.h
index c361802..7d7a0e8 100644
--- a/include/NetdClient.h
+++ b/include/NetdClient.h
@@ -49,11 +49,11 @@
int deleteTagData(uint32_t tag, uid_t uid);
-int resNetworkQuery(unsigned netId, const char* dname, int classType, int type);
+int resNetworkQuery(unsigned netId, const char* dname, int classType, int type, uint32_t flags);
int resNetworkResult(int query_fd, int* rcode, uint8_t* answer, size_t anslen);
-int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen);
+int resNetworkSend(unsigned netId, const uint8_t* msg, size_t msglen, uint32_t flags);
void resNetworkCancel(int nsend_fd);
__END_DECLS
diff --git a/resolv/resolver_test.cpp b/resolv/resolver_test.cpp
index 287c2eb..8696a41 100644
--- a/resolv/resolver_test.cpp
+++ b/resolv/resolver_test.cpp
@@ -1636,8 +1636,8 @@
ASSERT_TRUE(SetResolversForNetwork(servers, mDefaultSearchDomains, mDefaultParams_Binder));
dns.clearQueries();
- int fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1); // Type A 1
- int fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28); // Type AAAA 28
+ int fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1, 0); // Type A 1
+ int fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28, 0); // Type AAAA 28
EXPECT_TRUE(fd1 != -1);
EXPECT_TRUE(fd2 != -1);
@@ -1654,8 +1654,8 @@
EXPECT_EQ(2U, GetNumQueries(dns, host_name));
// Re-query verify cache works
- fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1); // Type A 1
- fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28); // Type AAAA 28
+ fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1, 0); // Type A 1
+ fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28, 0); // Type AAAA 28
EXPECT_TRUE(fd1 != -1);
EXPECT_TRUE(fd2 != -1);
@@ -1698,7 +1698,7 @@
for (auto& td : kTestData) {
SCOPED_TRACE(td.dname);
- td.fd = resNetworkQuery(TEST_NETID, td.dname, 1, td.queryType);
+ td.fd = resNetworkQuery(TEST_NETID, td.dname, 1, td.queryType, 0);
EXPECT_TRUE(td.fd != -1);
}
@@ -1733,17 +1733,17 @@
{
std::unique_lock lk(cvMutex);
// A 1 AAAA 28
- fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28);
+ fd1 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 28, 0);
EXPECT_TRUE(fd1 != -1);
EXPECT_EQ(std::cv_status::no_timeout, cv.wait_for(lk, std::chrono::seconds(1)));
}
dns.setResponseProbability(0.0);
- int fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1);
+ int fd2 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1, 0);
EXPECT_TRUE(fd2 != -1);
- int fd3 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1);
+ int fd3 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1, 0);
EXPECT_TRUE(fd3 != -1);
uint8_t buf[MAXPACKET] = {};
@@ -1760,7 +1760,7 @@
dns.setResponseProbability(1.0);
- int fd4 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1);
+ int fd4 = resNetworkQuery(TEST_NETID, "howdy.example.com", 1, 1, 0);
EXPECT_TRUE(fd4 != -1);
memset(buf, 0, MAXPACKET);