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 | |
| 10 | #include "shill/dhcp_proxy_interface.h" |
| 11 | #include "shill/dhcpcd.h" |
| 12 | |
| 13 | namespace shill { |
| 14 | |
| 15 | // The DHCPCD listener is a singleton proxy that listens to signals from all |
| 16 | // DHCP clients and dispatches them through the DHCP provider to the appropriate |
| 17 | // client based on the PID. |
| 18 | class DHCPCDListener : public DHCPListenerInterface, |
| 19 | public DBus::InterfaceProxy, |
| 20 | public DBus::ObjectProxy { |
| 21 | public: |
| 22 | explicit DHCPCDListener(DBus::Connection *connection); |
| 23 | |
| 24 | private: |
| 25 | void EventSignal(const DBus::SignalMessage &signal); |
| 26 | void StatusChangedSignal(const DBus::SignalMessage &signal); |
| 27 | |
| 28 | DISALLOW_COPY_AND_ASSIGN(DHCPCDListener); |
| 29 | }; |
| 30 | |
| 31 | // There's a single DHCPCD proxy per DHCP client identified by its process id |
| 32 | // and service name. |
| 33 | class DHCPCDProxy : public DHCPProxyInterface, |
| 34 | public org::chromium::dhcpcd_proxy, |
| 35 | public DBus::ObjectProxy { |
| 36 | public: |
| 37 | static const char kDBusInterfaceName[]; |
| 38 | static const char kDBusPath[]; |
| 39 | |
| 40 | DHCPCDProxy(unsigned int pid, |
| 41 | DBus::Connection *connection, |
| 42 | const char *service); |
| 43 | |
| 44 | // Signal callbacks inherited from dhcpcd_proxy. |
| 45 | virtual void Event( |
| 46 | const uint32_t& pid, |
| 47 | const std::string& reason, |
| 48 | const std::map< std::string, DBus::Variant >& configuration); |
| 49 | virtual void StatusChanged(const uint32_t& pid, const std::string& status); |
| 50 | |
| 51 | private: |
| 52 | // Process ID of the associated dhcpcd process used for verification purposes |
| 53 | // only. |
| 54 | unsigned int pid_; |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(DHCPCDProxy); |
| 57 | }; |
| 58 | |
| 59 | } // namespace shill |
| 60 | |
| 61 | #endif // SHILL_DHCPCD_PROXY_ |