shill: Connect Ethernet Device to DHCPConfig.

Most of the implementation is in the base Device class.

BUG=chromium-os:16794
TEST=unit test

Change-Id: I583761f7e54c88b043ce4343cb43f8298aaedf8b
Reviewed-on: http://gerrit.chromium.org/gerrit/2949
Reviewed-by: Darin Petkov <petkov@chromium.org>
Tested-by: Darin Petkov <petkov@chromium.org>
diff --git a/ethernet.cc b/ethernet.cc
index 0d10ee7..2ae07c8 100644
--- a/ethernet.cc
+++ b/ethernet.cc
@@ -24,10 +24,11 @@
 using std::string;
 
 namespace shill {
+
 Ethernet::Ethernet(ControlInterface *control_interface,
                    EventDispatcher *dispatcher,
                    Manager *manager,
-                   const std::string& link_name,
+                   const string &link_name,
                    int interface_index)
     : Device(control_interface,
              dispatcher,
@@ -40,7 +41,7 @@
                                    "service-" + link_name)),
       link_up_(false),
       service_registered_(false) {
-  VLOG(2) << "Ethernet device " << link_name_ << " initialized.";
+  VLOG(2) << "Ethernet device " << link_name << " initialized.";
 }
 
 Ethernet::~Ethernet() {
@@ -54,7 +55,8 @@
 }
 
 void Ethernet::Stop() {
-  manager_->DeregisterService(service_.get());
+  manager_->DeregisterService(service_);
+  DestroyIPConfig();
   Device::Stop();
   RTNLHandler::GetInstance()->SetInterfaceFlags(interface_index_, 0, IFF_UP);
 }
@@ -63,15 +65,19 @@
   return type == Device::kEthernet;
 }
 
-void Ethernet::LinkEvent(unsigned flags, unsigned change) {
+void Ethernet::LinkEvent(unsigned int flags, unsigned int change) {
   Device::LinkEvent(flags, change);
   if ((flags & IFF_LOWER_UP) != 0 && !link_up_) {
-    LOG(INFO) << link_name_ << " is up; should start L3!";
+    LOG(INFO) << link_name() << " is up; should start L3!";
     link_up_ = true;
-    manager_->RegisterService(service_.get());
+    manager_->RegisterService(service_);
+    if (service_->auto_connect()) {
+      LOG_IF(ERROR, !AcquireDHCPConfig()) << "Unable to acquire DHCP config.";
+    }
   } else if ((flags & IFF_LOWER_UP) == 0 && link_up_) {
     link_up_ = false;
-    manager_->DeregisterService(service_.get());
+    manager_->DeregisterService(service_);
+    DestroyIPConfig();
   }
 }