shill -- connect dhcp config to proxies and provider.

In addition, spawn dhcpcd on request.

Cleanup the Makefile a bit. Don't do lazy initialization of dbus_control so that
the connection can be passed to DHCPProvider.

BUG=chromium-os:16013
TEST=modified device_info to request a DHCPConfig for a DeviceStub.

Change-Id: Ib3b032b25bd5b071635816635bf6066cc3b386d5
Reviewed-on: http://gerrit.chromium.org/gerrit/2024
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
diff --git a/dhcp_provider.cc b/dhcp_provider.cc
index abb97bd..35f9ca1 100644
--- a/dhcp_provider.cc
+++ b/dhcp_provider.cc
@@ -6,18 +6,49 @@
 
 #include <base/logging.h>
 
+#include "shill/dhcpcd_proxy.h"
+
 namespace shill {
 
 DHCPProvider::DHCPProvider() {
-  VLOG(2) << "DHCPProvider created.";
+  VLOG(2) << __func__;
 }
 
 DHCPProvider::~DHCPProvider() {
-  VLOG(2) << "DHCPProvider destroyed.";
+  VLOG(2) << __func__;
 }
 
 DHCPProvider* DHCPProvider::GetInstance() {
   return Singleton<DHCPProvider>::get();
 }
 
+void DHCPProvider::Init(DBus::Connection *connection) {
+  VLOG(2) << __func__;
+  listener_.reset(new DHCPCDListener(this, connection));
+}
+
+DHCPConfigRefPtr DHCPProvider::CreateConfig(const Device &device) {
+  VLOG(2) << __func__;
+  return DHCPConfigRefPtr(new DHCPConfig(this, device));
+}
+
+DHCPConfigRefPtr DHCPProvider::GetConfig(unsigned int pid) {
+  VLOG(2) << __func__;
+  PIDConfigMap::iterator it = configs_.find(pid);
+  if (it == configs_.end()) {
+    return DHCPConfigRefPtr(NULL);
+  }
+  return it->second;
+}
+
+void DHCPProvider::BindPID(unsigned int pid, DHCPConfigRefPtr config) {
+  VLOG(2) << __func__ << " pid: " << pid;
+  configs_[pid] = config;
+}
+
+void DHCPProvider::UnbindPID(unsigned int pid) {
+  VLOG(2) << __func__ << " pid: " << pid;
+  configs_.erase(pid);
+}
+
 }  // namespace shill