Merge "Move private headers out of /include folder"
diff --git a/DnsProxyListener.cpp b/DnsProxyListener.cpp
index 0b31b95..ac4a09e 100644
--- a/DnsProxyListener.cpp
+++ b/DnsProxyListener.cpp
@@ -54,10 +54,10 @@
#include "ResolverEventReporter.h"
#include "getaddrinfo.h"
#include "gethnamaddr.h"
-#include "netd_resolv/stats.h" // RCODE_TIMEOUT
#include "res_send.h"
#include "resolv_cache.h"
#include "resolv_private.h"
+#include "stats.h" // RCODE_TIMEOUT
#include "stats.pb.h"
using aidl::android::net::metrics::INetdEventListener;
diff --git a/DnsTlsServer.h b/DnsTlsServer.h
index dd66868..82d1a45 100644
--- a/DnsTlsServer.h
+++ b/DnsTlsServer.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef _DNS_DNSTLSSERVER_H
-#define _DNS_DNSTLSSERVER_H
+#pragma once
#include <chrono>
#include <set>
@@ -24,7 +23,7 @@
#include <netinet/in.h>
-#include <netd_resolv/params.h>
+#include <params.h>
namespace android {
namespace net {
@@ -80,5 +79,3 @@
} // namespace net
} // namespace android
-
-#endif // _DNS_DNSTLSSERVER_H
diff --git a/ResolverController.cpp b/ResolverController.cpp
index 513353e..df3f457 100644
--- a/ResolverController.cpp
+++ b/ResolverController.cpp
@@ -34,8 +34,8 @@
#include "PrivateDnsConfiguration.h"
#include "ResolverEventReporter.h"
#include "ResolverStats.h"
-#include "netd_resolv/stats.h"
#include "resolv_cache.h"
+#include "stats.h"
using aidl::android::net::ResolverParamsParcel;
diff --git a/include/netd_resolv/resolv.h b/include/netd_resolv/resolv.h
index 1ab6138..596a022 100644
--- a/include/netd_resolv/resolv.h
+++ b/include/netd_resolv/resolv.h
@@ -28,8 +28,6 @@
#pragma once
-#include "params.h"
-
#include <arpa/nameser.h>
#include <netinet/in.h>
@@ -120,6 +118,8 @@
#define TAG_SYSTEM_DNS 0xFFFFFF82
+#define LIBNETD_RESOLV_PUBLIC extern "C" [[gnu::visibility("default")]]
+
LIBNETD_RESOLV_PUBLIC bool resolv_has_nameservers(unsigned netid);
// Set callbacks and bring DnsResolver up.
diff --git a/include/netd_resolv/resolv_stub.h b/include/netd_resolv/resolv_stub.h
index 4166ed5..52ddf75 100644
--- a/include/netd_resolv/resolv_stub.h
+++ b/include/netd_resolv/resolv_stub.h
@@ -26,11 +26,9 @@
* SUCH DAMAGE.
*/
-#ifndef NETD_RESOLV_RESOLV_STUB_H
-#define NETD_RESOLV_RESOLV_STUB_H
+#pragma once
#include "resolv.h"
-#include "stats.h"
// Struct containing function pointers for every function exported by libnetd_resolv.
extern struct ResolvStub {
@@ -44,5 +42,3 @@
} RESOLV_STUB;
int resolv_stub_init();
-
-#endif // NETD_RESOLV_RESOLV_STUB_H
diff --git a/include/netd_resolv/stats.h b/include/netd_resolv/stats.h
deleted file mode 100644
index 7bfe845..0000000
--- a/include/netd_resolv/stats.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef NETD_RES_STATS_H
-#define NETD_RES_STATS_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/socket.h>
-#include <time.h>
-
-#include "params.h"
-
-#define RCODE_INTERNAL_ERROR 254
-#define RCODE_TIMEOUT 255
-
-struct res_sample {
- time_t at; // time in s at which the sample was recorded
- uint16_t rtt; // round-trip time in ms
- uint8_t rcode; // the DNS rcode or RCODE_XXX defined above
-};
-
-// Resolver reachability statistics and run-time parameters.
-struct res_stats {
- // Stats of the last <sample_count> queries.
- res_sample samples[MAXNSSAMPLES];
- // The number of samples stored.
- uint8_t sample_count;
- // The next sample to modify.
- uint8_t sample_next;
-};
-
-// Aggregates the reachability statistics for the given server based on on the stored samples.
-LIBNETD_RESOLV_PUBLIC void android_net_res_stats_aggregate(res_stats* stats, int* successes,
- int* errors, int* timeouts,
- int* internal_errors, int* rtt_avg,
- time_t* last_sample_time);
-
-LIBNETD_RESOLV_PUBLIC int android_net_res_stats_get_info_for_net(
- unsigned netid, int* nscount, sockaddr_storage servers[MAXNS], int* dcount,
- char domains[MAXDNSRCH][MAXDNSRCHPATH], res_params* params, res_stats stats[MAXNS],
- int* wait_for_pending_req_timeout_count);
-
-// Returns an array of bools indicating which servers are considered good
-LIBNETD_RESOLV_PUBLIC int android_net_res_stats_get_usable_servers(const res_params* params,
- res_stats stats[], int nscount,
- bool valid_servers[]);
-
-#endif // NETD_RES_STATS_H
diff --git a/include/netd_resolv/params.h b/params.h
similarity index 89%
rename from include/netd_resolv/params.h
rename to params.h
index 93e6287..82cd058 100644
--- a/include/netd_resolv/params.h
+++ b/params.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef NETD_RESOLV_PARAMS_H
-#define NETD_RESOLV_PARAMS_H
+#pragma once
#include <stdint.h>
@@ -34,7 +33,3 @@
int base_timeout_msec; // base query retry timeout (if 0, use RES_TIMEOUT)
int retry_count; // number of retries
};
-
-#define LIBNETD_RESOLV_PUBLIC extern "C" [[gnu::visibility("default")]]
-
-#endif // NETD_RESOLV_PARAMS_H
diff --git a/res_send.cpp b/res_send.cpp
index dba7232..60c63c3 100644
--- a/res_send.cpp
+++ b/res_send.cpp
@@ -103,11 +103,11 @@
#include "DnsTlsTransport.h"
#include "PrivateDnsConfiguration.h"
#include "netd_resolv/resolv.h"
-#include "netd_resolv/stats.h"
#include "private/android_filesystem_config.h"
#include "res_debug.h"
#include "res_init.h"
#include "resolv_cache.h"
+#include "stats.h"
#include "stats.pb.h"
#include "util.h"
diff --git a/res_stats.cpp b/res_stats.cpp
index 5faf7ca..36dde6b 100644
--- a/res_stats.cpp
+++ b/res_stats.cpp
@@ -21,8 +21,7 @@
#include <android-base/logging.h>
-#include "netd_resolv/stats.h"
-
+#include "stats.h"
// Calculate the round-trip-time from start time t0 and end time t1.
int _res_stats_calculate_rtt(const timespec* t1, const timespec* t0) {
diff --git a/resolv_cache.h b/resolv_cache.h
index 5c443a8..c838345 100644
--- a/resolv_cache.h
+++ b/resolv_cache.h
@@ -36,7 +36,7 @@
#include <stats.pb.h>
#include "ResolverStats.h"
-#include "netd_resolv/params.h"
+#include "params.h"
// Sets the name server addresses to the provided ResState.
// The name servers are retrieved from the cache which is associated
diff --git a/resolv_cache_unit_test.cpp b/resolv_cache_unit_test.cpp
index 900b8f5..cdefb35 100644
--- a/resolv_cache_unit_test.cpp
+++ b/resolv_cache_unit_test.cpp
@@ -30,10 +30,10 @@
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
-#include "netd_resolv/stats.h"
#include "res_init.h"
#include "resolv_cache.h"
#include "resolv_private.h"
+#include "stats.h"
#include "tests/dns_responder/dns_responder.h"
using namespace std::chrono_literals;
diff --git a/resolv_integration_test.cpp b/resolv_integration_test.cpp
index 3f37c29..76b2344 100644
--- a/resolv_integration_test.cpp
+++ b/resolv_integration_test.cpp
@@ -58,8 +58,8 @@
#include "ResolverStats.h"
#include "android/net/IDnsResolver.h"
#include "binder/IServiceManager.h"
-#include "netd_resolv/params.h" // MAXNS
#include "netid_client.h" // NETID_UNSET
+#include "params.h" // MAXNS
#include "test_utils.h"
#include "tests/dns_metrics_listener/dns_metrics_listener.h"
#include "tests/dns_responder/dns_responder.h"
diff --git a/resolv_private.h b/resolv_private.h
index 5cbde1a..4a45902 100644
--- a/resolv_private.h
+++ b/resolv_private.h
@@ -46,13 +46,7 @@
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/*
- * @(#)resolv.h 8.1 (Berkeley) 6/2/93
- * Id: resolv.h,v 1.7.2.11.4.2 2004/06/25 00:41:05 marka Exp
- */
-
-#ifndef NETD_RESOLV_PRIVATE_H
-#define NETD_RESOLV_PRIVATE_H
+#pragma once
#include <android-base/logging.h>
#include <net/if.h>
@@ -62,9 +56,9 @@
#include <vector>
#include "DnsResolver.h"
-#include "netd_resolv/params.h"
#include "netd_resolv/resolv.h"
-#include "netd_resolv/stats.h"
+#include "params.h"
+#include "stats.h"
#include "stats.pb.h"
// Linux defines MAXHOSTNAMELEN as 64, while the domain name limit in
@@ -202,5 +196,3 @@
NI_NUMERICHOST);
return std::string(out);
}
-
-#endif // NETD_RESOLV_PRIVATE_H
diff --git a/stats.h b/stats.h
new file mode 100644
index 0000000..cc7de9f
--- /dev/null
+++ b/stats.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <sys/socket.h>
+#include <time.h>
+
+#include "params.h"
+
+#define RCODE_INTERNAL_ERROR 254
+#define RCODE_TIMEOUT 255
+
+struct res_sample {
+ time_t at; // time in s at which the sample was recorded
+ uint16_t rtt; // round-trip time in ms
+ uint8_t rcode; // the DNS rcode or RCODE_XXX defined above
+};
+
+// Resolver reachability statistics and run-time parameters.
+struct res_stats {
+ // Stats of the last <sample_count> queries.
+ res_sample samples[MAXNSSAMPLES];
+ // The number of samples stored.
+ uint8_t sample_count;
+ // The next sample to modify.
+ uint8_t sample_next;
+};
+
+// Aggregates the reachability statistics for the given server based on on the stored samples.
+void android_net_res_stats_aggregate(res_stats* stats, int* successes, int* errors, int* timeouts,
+ int* internal_errors, int* rtt_avg, time_t* last_sample_time);
+
+int android_net_res_stats_get_info_for_net(unsigned netid, int* nscount,
+ sockaddr_storage servers[MAXNS], int* dcount,
+ char domains[MAXDNSRCH][MAXDNSRCHPATH],
+ res_params* params, res_stats stats[MAXNS],
+ int* wait_for_pending_req_timeout_count);
+
+// Returns an array of bools indicating which servers are considered good
+int android_net_res_stats_get_usable_servers(const res_params* params, res_stats stats[],
+ int nscount, bool valid_servers[]);
diff --git a/tests/resolv_stress_test.cpp b/tests/resolv_stress_test.cpp
index f3b6126..6f7ee9d 100644
--- a/tests/resolv_stress_test.cpp
+++ b/tests/resolv_stress_test.cpp
@@ -27,7 +27,7 @@
#include "ResolverStats.h"
#include "dns_responder/dns_responder_client.h"
-#include "netd_resolv/params.h" // MAX_NS
+#include "params.h" // MAX_NS
#include "resolv_test_utils.h"
using android::base::StringPrintf;
diff --git a/tests/resolv_test_utils.h b/tests/resolv_test_utils.h
index 0cbf2fa..954e4c9 100644
--- a/tests/resolv_test_utils.h
+++ b/tests/resolv_test_utils.h
@@ -29,7 +29,7 @@
#include "android/net/IDnsResolver.h"
#include "dns_responder/dns_responder.h"
-#include "netd_resolv/params.h"
+#include "params.h"
// TODO: make this dynamic and stop depending on implementation details.
constexpr int TEST_NETID = 30;