blob: f9169714e26f673d714df8fae7efdaee7f8f4073 [file] [log] [blame]
Darin Petkov50308cd2011-06-01 18:25:07 -07001// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SHILL_DHCP_CONFIG_
6#define SHILL_DHCP_CONFIG_
7
Darin Petkovd1b715b2011-06-02 21:21:22 -07008#include <base/memory/scoped_ptr.h>
9#include <dbus-c++/connection.h>
10
Darin Petkov50308cd2011-06-01 18:25:07 -070011#include "shill/ipconfig.h"
12
13namespace shill {
14
Darin Petkovd1b715b2011-06-02 21:21:22 -070015class DHCPConfig;
16class DHCPProvider;
17class DHCPProxyInterface;
18
19typedef scoped_refptr<DHCPConfig> DHCPConfigRefPtr;
20
Darin Petkov50308cd2011-06-01 18:25:07 -070021class DHCPConfig : public IPConfig {
22 public:
Darin Petkovd1b715b2011-06-02 21:21:22 -070023 DHCPConfig(DHCPProvider *provider, const Device &device);
Darin Petkov50308cd2011-06-01 18:25:07 -070024 virtual ~DHCPConfig();
25
Darin Petkovd1b715b2011-06-02 21:21:22 -070026 // Inherited from IPConfig.
27 virtual bool Request();
28 virtual bool Renew();
29
30 // If |proxy_| is not initialized already, sets it to a new D-Bus proxy to
31 // |service|.
32 void InitProxy(DBus::Connection *connection, const char *service);
33
Darin Petkov50308cd2011-06-01 18:25:07 -070034 private:
Darin Petkovd1b715b2011-06-02 21:21:22 -070035 static const char kDHCPCDPath[];
36
37 // Starts dhcpcd, returns true on success and false otherwise.
38 bool Start();
39
40 DHCPProvider *provider_;
41
42 // The PID of the spawned DHCP client. May be 0 if no client has been spawned
43 // yet or the client has died.
44 unsigned int pid_;
45
46 // The proxy for communicating with the DHCP client.
47 scoped_ptr<DHCPProxyInterface> proxy_;
48
Darin Petkov50308cd2011-06-01 18:25:07 -070049 DISALLOW_COPY_AND_ASSIGN(DHCPConfig);
50};
51
52} // namespace shill
53
54#endif // SHILL_DHCP_CONFIG_