blob: ebb61b5ca98855cb391bcc04523be836999cbc54 [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_DHCPCD_PROXY_
6#define SHILL_DHCPCD_PROXY_
7
8#include <base/basictypes.h>
9
Darin Petkovd1b715b2011-06-02 21:21:22 -070010#include "shill/dhcp_config.h"
Darin Petkov50308cd2011-06-01 18:25:07 -070011#include "shill/dhcp_proxy_interface.h"
12#include "shill/dhcpcd.h"
13
14namespace shill {
15
Darin Petkovd1b715b2011-06-02 21:21:22 -070016class DHCPProvider;
17
Darin Petkov50308cd2011-06-01 18:25:07 -070018// 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.
21class DHCPCDListener : public DHCPListenerInterface,
22 public DBus::InterfaceProxy,
23 public DBus::ObjectProxy {
24 public:
Darin Petkovd1b715b2011-06-02 21:21:22 -070025 explicit DHCPCDListener(DHCPProvider *provider,
26 DBus::Connection *connection);
Darin Petkov50308cd2011-06-01 18:25:07 -070027
28 private:
29 void EventSignal(const DBus::SignalMessage &signal);
30 void StatusChangedSignal(const DBus::SignalMessage &signal);
31
Darin Petkovd1b715b2011-06-02 21:21:22 -070032 DHCPProvider *provider_;
33
Darin Petkov50308cd2011-06-01 18:25:07 -070034 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.
39class 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 Petkovd1b715b2011-06-02 21:21:22 -070046 DHCPCDProxy(DBus::Connection *connection, const char *service);
Darin Petkov50308cd2011-06-01 18:25:07 -070047
Darin Petkovd1b715b2011-06-02 21:21:22 -070048 // Inherited from DHCPProxyInterface.
49 virtual void DoRebind(const std::string &interface);
Darin Petkov98dd6a02011-06-10 15:12:57 -070050 virtual void DoRelease(const std::string &interface);
Darin Petkovd1b715b2011-06-02 21:21:22 -070051
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 Petkov50308cd2011-06-01 18:25:07 -070055 virtual void Event(
Darin Petkove7cb7f82011-06-03 13:21:51 -070056 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 Petkov50308cd2011-06-01 18:25:07 -070060
61 private:
Darin Petkov50308cd2011-06-01 18:25:07 -070062 DISALLOW_COPY_AND_ASSIGN(DHCPCDProxy);
63};
64
65} // namespace shill
66
67#endif // SHILL_DHCPCD_PROXY_