shill: Allow hostname setting via DHCP

Allow shill to optionally allow a Device to (a) request the hostname
parameter and (b) accept this hostname from a dhcp config and
apply it locally.

BUG=chromium:475699
TEST=None
CQ-DEPEND=CL:266519

Change-Id: I56140831768255b04c6f5c558feec4a9119f349b
Reviewed-on: https://chromium-review.googlesource.com/266647
Reviewed-by: Matthew Wein <mattwein@chromium.org>
Tested-by: Matthew Wein <mattwein@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
diff --git a/manager.h b/manager.h
index 7a47093..33e8659 100644
--- a/manager.h
+++ b/manager.h
@@ -472,6 +472,10 @@
   // Set the list of prepended DNS servers to |prepend_dns_servers|.
   void SetPrependDNSServers(const std::string &prepend_dns_servers);
 
+  // Accept hostname from DHCP server for devices matching |hostname_from|.
+  void SetAcceptHostnameFrom(const std::string &hostname_from);
+  bool ShouldAcceptHostnameFrom(const std::string &device_name);
+
   // 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|.
@@ -779,6 +783,10 @@
   Properties props_;
   PropertyStore store_;
 
+  // Accept hostname supplied by the DHCP server from the specified devices.
+  // eg. eth0 or eth*
+  std::string accept_hostname_from_;
+
   base::CancelableClosure sort_services_task_;
 
   // Task for periodically checking various device status.