Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -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/ipconfig.h" |
| 6 | |
| 7 | #include <base/logging.h> |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 8 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 9 | |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 10 | #include "shill/adaptor_interfaces.h" |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 11 | #include "shill/error.h" |
Chris Masone | c6c6c13 | 2011-06-30 11:29:52 -0700 | [diff] [blame] | 12 | |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 13 | using std::string; |
| 14 | |
| 15 | namespace shill { |
| 16 | |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 17 | IPConfig::IPConfig(const std::string &device_name) : device_name_(device_name) { |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 18 | // Address might be R/O or not, depending on the type of IPconfig, so |
| 19 | // we'll leave this up to the subclasses. |
| 20 | // Register(Const?)String(flimflam::kAddressProperty, &properties_.address); |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 21 | store_.RegisterString(flimflam::kBroadcastProperty, |
| 22 | &properties_.broadcast_address); |
| 23 | store_.RegisterString(flimflam::kDomainNameProperty, |
| 24 | &properties_.domain_name); |
| 25 | store_.RegisterString(flimflam::kGatewayProperty, &properties_.gateway); |
| 26 | store_.RegisterConstString(flimflam::kMethodProperty, &properties_.method); |
| 27 | store_.RegisterInt32(flimflam::kMtuProperty, &properties_.mtu); |
| 28 | store_.RegisterStrings(flimflam::kNameServersProperty, |
| 29 | &properties_.dns_servers); |
| 30 | store_.RegisterString(flimflam::kPeerAddressProperty, |
| 31 | &properties_.peer_address); |
| 32 | store_.RegisterInt32(flimflam::kPrefixlenProperty, &properties_.subnet_cidr); |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 33 | // TODO(cmasone): Does anyone use this? |
Chris Masone | 27c4aa5 | 2011-07-02 13:10:14 -0700 | [diff] [blame] | 34 | // store_.RegisterStrings(flimflam::kSearchDomainsProperty, |
| 35 | // &properties_.domain_search); |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 36 | VLOG(2) << __func__ << " device: " << device_name; |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | IPConfig::~IPConfig() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 40 | VLOG(2) << __func__ << " device: " << device_name(); |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Chris Masone | 4e85161 | 2011-07-01 10:46:53 -0700 | [diff] [blame] | 43 | string IPConfig::GetRpcIdentifier() { |
| 44 | return adaptor_->GetRpcIdentifier(); |
| 45 | } |
| 46 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 47 | bool IPConfig::RequestIP() { |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 48 | return false; |
| 49 | } |
| 50 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 51 | bool IPConfig::RenewIP() { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | bool IPConfig::ReleaseIP() { |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 56 | return false; |
| 57 | } |
| 58 | |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 59 | void IPConfig::UpdateProperties(const Properties &properties, bool success) { |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 60 | properties_ = properties; |
Darin Petkov | efb09c3 | 2011-06-07 20:24:17 -0700 | [diff] [blame] | 61 | if (update_callback_.get()) { |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 62 | update_callback_->Run(this, success); |
Darin Petkov | efb09c3 | 2011-06-07 20:24:17 -0700 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
| 66 | void IPConfig::RegisterUpdateCallback( |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 67 | Callback2<const IPConfigRefPtr&, bool>::Type *callback) { |
Darin Petkov | efb09c3 | 2011-06-07 20:24:17 -0700 | [diff] [blame] | 68 | update_callback_.reset(callback); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 69 | } |
| 70 | |
Darin Petkov | e02b3ca | 2011-05-31 16:00:44 -0700 | [diff] [blame] | 71 | } // namespace shill |