Add new info functions to resolver for use by Netd.
android_net_res_stats_get_info_for_net returns the current name servers, search
domains, parameters and stats for the given network ID.
android_net_res_stats_aggregate provides statistics such as errors counts from
the raw stats data reported by android_net_res_stats_get_info_for_net.
android_net_res_stats_get_usable_servers uses the data returned by
android_net_res_stats_aggregate to determine which of the servers are
considered valid or broken by the resolver.
BUG: 25731675
Change-Id: I6059b68e5e8b809027a4d3135f6081588bee8a7d
diff --git a/libc/dns/include/resolv_stats.h b/libc/dns/include/resolv_stats.h
index aaf6bd8..c7901d7 100644
--- a/libc/dns/include/resolv_stats.h
+++ b/libc/dns/include/resolv_stats.h
@@ -17,6 +17,7 @@
#ifndef _RES_STATS_H
#define _RES_STATS_H
+#include <sys/socket.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
@@ -46,18 +47,13 @@
};
/* Calculate the round-trip-time from start time t0 and end time t1. */
-int
+extern int
_res_stats_calculate_rtt(const struct timespec* t1, const struct timespec* t0);
/* Initialize a sample for calculating server reachability statistics. */
extern void
_res_stats_set_sample(struct __res_sample* sample, time_t now, int rcode, int rtt);
-/* Aggregates the reachability statistics for the given server based on on the stored samples. */
-extern void
-_res_stats_aggregate(struct __res_stats* stats, int* successes, int* errors, int* timeouts,
- int* internal_errors, int* rtt_avg, time_t* last_sample_time);
-
/* Returns true if the server is considered unusable, i.e. if the success rate is not lower than the
* threshold for the stored stored samples. If not enough samples are stored, the server is
* considered usable.
@@ -65,9 +61,24 @@
extern bool
_res_stats_usable_server(const struct __res_params* params, struct __res_stats* stats);
+__BEGIN_DECLS
+/* Aggregates the reachability statistics for the given server based on on the stored samples. */
+extern void
+android_net_res_stats_aggregate(struct __res_stats* stats, int* successes, int* errors,
+ int* timeouts, int* internal_errors, int* rtt_avg, time_t* last_sample_time)
+ __attribute__((visibility ("default")));
+
+extern int
+android_net_res_stats_get_info_for_net(unsigned netid, int* nscount,
+ struct sockaddr_storage servers[MAXNS], int* dcount, char domains[MAXDNSRCH][MAXDNSRCHPATH],
+ struct __res_params* params, struct __res_stats stats[MAXNS])
+ __attribute__((visibility ("default")));
+
/* Returns an array of bools indicating which servers are considered good */
extern void
-_res_stats_get_usable_servers(const struct __res_params* params, struct __res_stats stats[],
- int nscount, bool valid_servers[]);
+android_net_res_stats_get_usable_servers(const struct __res_params* params,
+ struct __res_stats stats[], int nscount, bool valid_servers[])
+ __attribute__((visibility ("default")));
+__END_DECLS
#endif // _RES_STATS_H