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_DHCPCD_PROXY_ |
| 6 | #define SHILL_DHCPCD_PROXY_ |
| 7 | |
| 8 | #include <base/basictypes.h> |
| 9 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 10 | #include "shill/dhcp_config.h" |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 11 | #include "shill/dhcp_proxy_interface.h" |
| 12 | #include "shill/dhcpcd.h" |
| 13 | |
| 14 | namespace shill { |
| 15 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 16 | class DHCPProvider; |
| 17 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 18 | // The DHCPCD listener is a singleton proxy that listens to signals from all |
| 19 | // DHCP clients and dispatches them through the DHCP provider to the appropriate |
| 20 | // client based on the PID. |
| 21 | class DHCPCDListener : public DHCPListenerInterface, |
| 22 | public DBus::InterfaceProxy, |
| 23 | public DBus::ObjectProxy { |
| 24 | public: |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 25 | explicit DHCPCDListener(DHCPProvider *provider, |
| 26 | DBus::Connection *connection); |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 27 | |
| 28 | private: |
| 29 | void EventSignal(const DBus::SignalMessage &signal); |
| 30 | void StatusChangedSignal(const DBus::SignalMessage &signal); |
| 31 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 32 | DHCPProvider *provider_; |
| 33 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 34 | DISALLOW_COPY_AND_ASSIGN(DHCPCDListener); |
| 35 | }; |
| 36 | |
| 37 | // There's a single DHCPCD proxy per DHCP client identified by its process id |
| 38 | // and service name. |
| 39 | class DHCPCDProxy : public DHCPProxyInterface, |
| 40 | public org::chromium::dhcpcd_proxy, |
| 41 | public DBus::ObjectProxy { |
| 42 | public: |
| 43 | static const char kDBusInterfaceName[]; |
| 44 | static const char kDBusPath[]; |
| 45 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 46 | DHCPCDProxy(DBus::Connection *connection, const char *service); |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 47 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 48 | // Inherited from DHCPProxyInterface. |
| 49 | virtual void DoRebind(const std::string &interface); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame^] | 50 | virtual void DoRelease(const std::string &interface); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 51 | |
| 52 | // Signal callbacks inherited from dhcpcd_proxy. Note that these callbacks are |
| 53 | // unused because signals are dispatched directly to the DHCP configuration |
| 54 | // instance by the signal listener. |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 55 | virtual void Event( |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 56 | const uint32_t &pid, |
| 57 | const std::string &reason, |
| 58 | const DHCPConfig::Configuration &configuration); |
| 59 | virtual void StatusChanged(const uint32_t &pid, const std::string &status); |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 60 | |
| 61 | private: |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 62 | DISALLOW_COPY_AND_ASSIGN(DHCPCDProxy); |
| 63 | }; |
| 64 | |
| 65 | } // namespace shill |
| 66 | |
| 67 | #endif // SHILL_DHCPCD_PROXY_ |