shill: add new --prepend-dns-servers flag

The --prepend-dns-servers flag causes every Device to prepend resolvers
of the same address family as their local address to their list of
resolvers before setting it.  It is guaranteed that the same resolver
will not appear more than once in the output list.

BUG=chrome-os-partner:36696
TEST=amd64-generic unit tests and ASAN profile unit tests
CQ-DEPEND=CL:250873

Change-Id: I052f6bb8bd222880e1b18097c72a96f11cd50559
Reviewed-on: https://chromium-review.googlesource.com/250877
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Garret Kelly <gdk@chromium.org>
Tested-by: Garret Kelly <gdk@chromium.org>
diff --git a/manager.h b/manager.h
index 1c99b7e..61bb20a 100644
--- a/manager.h
+++ b/manager.h
@@ -26,6 +26,7 @@
 #include "shill/geolocation_info.h"
 #include "shill/hook_table.h"
 #include "shill/metrics.h"
+#include "shill/net/ip_address.h"
 #include "shill/power_manager.h"
 #include "shill/profile.h"
 #include "shill/property_store.h"
@@ -79,6 +80,8 @@
     std::string prohibited_technologies;
     // Comma-separated list of DNS search paths to be ignored.
     std::string ignored_dns_search_paths;
+    // Comma-separated list of DNS servers to prepend to resolver list.
+    std::string prepend_dns_servers;
     // Salt value use for calculating network connection ID.
     int connection_id_salt;
   };
@@ -434,6 +437,16 @@
   void SetIgnoreUnknownEthernet(bool ignore);
   bool ignore_unknown_ethernet() const { return ignore_unknown_ethernet_; }
 
+  // Set the list of prepended DNS servers to |prepend_dns_servers|.
+  void SetPrependDNSServers(const std::string &prepend_dns_servers);
+
+  // Filter the list of prepended DNS servers, copying only those that match
+  // |family| into |dns_servers|.  |dns_servers| is cleared, regardless of
+  // whether or not there are any addresses that match |family|.
+  virtual void FilterPrependDNSServersByFamily(
+      const IPAddress::Family family,
+      std::vector<std::string> *dns_servers);
+
  private:
   friend class CellularTest;
   friend class DeviceInfoTest;