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_config.h b/dhcp_config.h
index 735fa9c..f916971 100644
--- a/dhcp_config.h
+++ b/dhcp_config.h
@@ -5,16 +5,47 @@
#ifndef SHILL_DHCP_CONFIG_
#define SHILL_DHCP_CONFIG_
+#include <base/memory/scoped_ptr.h>
+#include <dbus-c++/connection.h>
+
#include "shill/ipconfig.h"
namespace shill {
+class DHCPConfig;
+class DHCPProvider;
+class DHCPProxyInterface;
+
+typedef scoped_refptr<DHCPConfig> DHCPConfigRefPtr;
+
class DHCPConfig : public IPConfig {
public:
- explicit DHCPConfig(const Device &device);
+ DHCPConfig(DHCPProvider *provider, const Device &device);
virtual ~DHCPConfig();
+ // Inherited from IPConfig.
+ virtual bool Request();
+ virtual bool Renew();
+
+ // If |proxy_| is not initialized already, sets it to a new D-Bus proxy to
+ // |service|.
+ void InitProxy(DBus::Connection *connection, const char *service);
+
private:
+ static const char kDHCPCDPath[];
+
+ // Starts dhcpcd, returns true on success and false otherwise.
+ bool Start();
+
+ DHCPProvider *provider_;
+
+ // The PID of the spawned DHCP client. May be 0 if no client has been spawned
+ // yet or the client has died.
+ unsigned int pid_;
+
+ // The proxy for communicating with the DHCP client.
+ scoped_ptr<DHCPProxyInterface> proxy_;
+
DISALLOW_COPY_AND_ASSIGN(DHCPConfig);
};