summaryrefslogtreecommitdiff
path: root/dhcpcd_proxy.h
blob: 576c004771cb40aeb1d7a6b58df108d87e6ca2b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SHILL_DHCPCD_PROXY_
#define SHILL_DHCPCD_PROXY_

#include <base/basictypes.h>

#include "shill/dhcp_proxy_interface.h"
#include "shill/dhcpcd.h"

namespace shill {

// The DHCPCD listener is a singleton proxy that listens to signals from all
// DHCP clients and dispatches them through the DHCP provider to the appropriate
// client based on the PID.
class DHCPCDListener : public DHCPListenerInterface,
                       public DBus::InterfaceProxy,
                       public DBus::ObjectProxy {
 public:
  explicit DHCPCDListener(DBus::Connection *connection);

 private:
  void EventSignal(const DBus::SignalMessage &signal);
  void StatusChangedSignal(const DBus::SignalMessage &signal);

  DISALLOW_COPY_AND_ASSIGN(DHCPCDListener);
};

// There's a single DHCPCD proxy per DHCP client identified by its process id
// and service name.
class DHCPCDProxy : public DHCPProxyInterface,
                    public org::chromium::dhcpcd_proxy,
                    public DBus::ObjectProxy {
 public:
  static const char kDBusInterfaceName[];
  static const char kDBusPath[];

  DHCPCDProxy(unsigned int pid,
              DBus::Connection *connection,
              const char *service);

  // Signal callbacks inherited from dhcpcd_proxy.
  virtual void Event(
      const uint32_t& pid,
      const std::string& reason,
      const std::map< std::string, DBus::Variant >& configuration);
  virtual void StatusChanged(const uint32_t& pid, const std::string& status);

 private:
  // Process ID of the associated dhcpcd process used for verification purposes
  // only.
  unsigned int pid_;

  DISALLOW_COPY_AND_ASSIGN(DHCPCDProxy);
};

}  // namespace shill

#endif  // SHILL_DHCPCD_PROXY_