blob: 913890ba8cf8e87c8697826d0204ec4d8d71f062 [file] [log] [blame]
Darin Petkove02b3ca2011-05-31 16:00:44 -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/ipconfig.h"
6
7#include <base/logging.h>
Chris Masone43b48a12011-07-01 13:37:07 -07008#include <chromeos/dbus/service_constants.h>
Darin Petkove02b3ca2011-05-31 16:00:44 -07009
Chris Masonec6c6c132011-06-30 11:29:52 -070010#include "shill/adaptor_interfaces.h"
Chris Masone43b48a12011-07-01 13:37:07 -070011#include "shill/error.h"
Chris Masonec6c6c132011-06-30 11:29:52 -070012
Darin Petkove02b3ca2011-05-31 16:00:44 -070013using std::string;
14
15namespace shill {
16
Darin Petkovf65e9282011-06-21 14:29:56 -070017IPConfig::IPConfig(const std::string &device_name) : device_name_(device_name) {
Chris Masone43b48a12011-07-01 13:37:07 -070018 // 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 Masone27c4aa52011-07-02 13:10:14 -070021 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 Masone43b48a12011-07-01 13:37:07 -070033 // TODO(cmasone): Does anyone use this?
Chris Masone27c4aa52011-07-02 13:10:14 -070034 // store_.RegisterStrings(flimflam::kSearchDomainsProperty,
35 // &properties_.domain_search);
Darin Petkovf65e9282011-06-21 14:29:56 -070036 VLOG(2) << __func__ << " device: " << device_name;
Darin Petkove02b3ca2011-05-31 16:00:44 -070037}
38
39IPConfig::~IPConfig() {
Darin Petkovf65e9282011-06-21 14:29:56 -070040 VLOG(2) << __func__ << " device: " << device_name();
Darin Petkove02b3ca2011-05-31 16:00:44 -070041}
42
Chris Masone4e851612011-07-01 10:46:53 -070043string IPConfig::GetRpcIdentifier() {
44 return adaptor_->GetRpcIdentifier();
45}
46
Darin Petkov92c43902011-06-09 20:46:06 -070047bool IPConfig::RequestIP() {
Darin Petkove7cb7f82011-06-03 13:21:51 -070048 return false;
49}
50
Darin Petkov92c43902011-06-09 20:46:06 -070051bool IPConfig::RenewIP() {
52 return false;
53}
54
55bool IPConfig::ReleaseIP() {
Darin Petkove7cb7f82011-06-03 13:21:51 -070056 return false;
57}
58
Darin Petkovf9b0ca82011-06-20 12:10:23 -070059void IPConfig::UpdateProperties(const Properties &properties, bool success) {
Darin Petkove7cb7f82011-06-03 13:21:51 -070060 properties_ = properties;
Darin Petkovefb09c32011-06-07 20:24:17 -070061 if (update_callback_.get()) {
Darin Petkovf9b0ca82011-06-20 12:10:23 -070062 update_callback_->Run(this, success);
Darin Petkovefb09c32011-06-07 20:24:17 -070063 }
64}
65
66void IPConfig::RegisterUpdateCallback(
Chris Masone2b105542011-06-22 10:58:09 -070067 Callback2<const IPConfigRefPtr&, bool>::Type *callback) {
Darin Petkovefb09c32011-06-07 20:24:17 -070068 update_callback_.reset(callback);
Darin Petkove7cb7f82011-06-03 13:21:51 -070069}
70
Darin Petkove02b3ca2011-05-31 16:00:44 -070071} // namespace shill