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 | #include "shill/dhcp_provider.h" |
| 6 | |
| 7 | #include <base/logging.h> |
| 8 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 9 | #include "shill/dhcpcd_proxy.h" |
| 10 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 11 | namespace shill { |
| 12 | |
| 13 | DHCPProvider::DHCPProvider() { |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 14 | VLOG(2) << __func__; |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | DHCPProvider::~DHCPProvider() { |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 18 | VLOG(2) << __func__; |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | DHCPProvider* DHCPProvider::GetInstance() { |
| 22 | return Singleton<DHCPProvider>::get(); |
| 23 | } |
| 24 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 25 | void DHCPProvider::Init(DBus::Connection *connection) { |
| 26 | VLOG(2) << __func__; |
| 27 | listener_.reset(new DHCPCDListener(this, connection)); |
| 28 | } |
| 29 | |
Chris Masone | c1e5041 | 2011-06-07 13:04:53 -0700 | [diff] [blame] | 30 | DHCPConfigRefPtr DHCPProvider::CreateConfig(DeviceConstRefPtr device) { |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 31 | VLOG(2) << __func__; |
| 32 | return DHCPConfigRefPtr(new DHCPConfig(this, device)); |
| 33 | } |
| 34 | |
| 35 | DHCPConfigRefPtr 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 | |
| 44 | void DHCPProvider::BindPID(unsigned int pid, DHCPConfigRefPtr config) { |
| 45 | VLOG(2) << __func__ << " pid: " << pid; |
| 46 | configs_[pid] = config; |
| 47 | } |
| 48 | |
| 49 | void DHCPProvider::UnbindPID(unsigned int pid) { |
| 50 | VLOG(2) << __func__ << " pid: " << pid; |
| 51 | configs_.erase(pid); |
| 52 | } |
| 53 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 54 | } // namespace shill |