Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 1 | // 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 Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame^] | 8 | #include <base/memory/scoped_ptr.h> |
| 9 | #include <dbus-c++/connection.h> |
| 10 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 11 | #include "shill/ipconfig.h" |
| 12 | |
| 13 | namespace shill { |
| 14 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame^] | 15 | class DHCPConfig; |
| 16 | class DHCPProvider; |
| 17 | class DHCPProxyInterface; |
| 18 | |
| 19 | typedef scoped_refptr<DHCPConfig> DHCPConfigRefPtr; |
| 20 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 21 | class DHCPConfig : public IPConfig { |
| 22 | public: |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame^] | 23 | DHCPConfig(DHCPProvider *provider, const Device &device); |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 24 | virtual ~DHCPConfig(); |
| 25 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame^] | 26 | // 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 Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 34 | private: |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame^] | 35 | 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 Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 49 | DISALLOW_COPY_AND_ASSIGN(DHCPConfig); |
| 50 | }; |
| 51 | |
| 52 | } // namespace shill |
| 53 | |
| 54 | #endif // SHILL_DHCP_CONFIG_ |