blob: 35f9ca18eccd6f6b748bd41c90e7985ce3c847a2 [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#include "shill/dhcp_provider.h"
6
7#include <base/logging.h>
8
Darin Petkovd1b715b2011-06-02 21:21:22 -07009#include "shill/dhcpcd_proxy.h"
10
Darin Petkov50308cd2011-06-01 18:25:07 -070011namespace shill {
12
13DHCPProvider::DHCPProvider() {
Darin Petkovd1b715b2011-06-02 21:21:22 -070014 VLOG(2) << __func__;
Darin Petkov50308cd2011-06-01 18:25:07 -070015}
16
17DHCPProvider::~DHCPProvider() {
Darin Petkovd1b715b2011-06-02 21:21:22 -070018 VLOG(2) << __func__;
Darin Petkov50308cd2011-06-01 18:25:07 -070019}
20
21DHCPProvider* DHCPProvider::GetInstance() {
22 return Singleton<DHCPProvider>::get();
23}
24
Darin Petkovd1b715b2011-06-02 21:21:22 -070025void DHCPProvider::Init(DBus::Connection *connection) {
26 VLOG(2) << __func__;
27 listener_.reset(new DHCPCDListener(this, connection));
28}
29
30DHCPConfigRefPtr DHCPProvider::CreateConfig(const Device &device) {
31 VLOG(2) << __func__;
32 return DHCPConfigRefPtr(new DHCPConfig(this, device));
33}
34
35DHCPConfigRefPtr DHCPProvider::GetConfig(unsigned int pid) {
36 VLOG(2) << __func__;
37 PIDConfigMap::iterator it = configs_.find(pid);
38 if (it == configs_.end()) {
39 return DHCPConfigRefPtr(NULL);
40 }
41 return it->second;
42}
43
44void DHCPProvider::BindPID(unsigned int pid, DHCPConfigRefPtr config) {
45 VLOG(2) << __func__ << " pid: " << pid;
46 configs_[pid] = config;
47}
48
49void DHCPProvider::UnbindPID(unsigned int pid) {
50 VLOG(2) << __func__ << " pid: " << pid;
51 configs_.erase(pid);
52}
53
Darin Petkov50308cd2011-06-01 18:25:07 -070054} // namespace shill