blob: ad581a2c229362ccff8c0b9148ad40854fbd1f36 [file] [log] [blame]
mukesh agrawal8a3188d2011-12-01 20:56:44 +00001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
mukesh agrawalaf571952011-07-14 14:31:12 -07002// 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/supplicant_interface_proxy.h"
6
7#include <map>
8#include <string>
9
mukesh agrawalaf571952011-07-14 14:31:12 -070010#include <dbus-c++/dbus.h>
11
Christopher Wileyb691efd2012-08-09 13:51:51 -070012#include "shill/logging.h"
mukesh agrawalaf571952011-07-14 14:31:12 -070013#include "shill/wifi.h"
14
15using std::map;
16using std::string;
17
18namespace shill {
19
20SupplicantInterfaceProxy::SupplicantInterfaceProxy(
21 const WiFiRefPtr &wifi,
Darin Petkovaceede32011-07-18 15:32:38 -070022 DBus::Connection *bus,
mukesh agrawalaf571952011-07-14 14:31:12 -070023 const ::DBus::Path &object_path,
24 const char *dbus_addr)
Darin Petkovaceede32011-07-18 15:32:38 -070025 : proxy_(wifi, bus, object_path, dbus_addr) {}
mukesh agrawalaf571952011-07-14 14:31:12 -070026
27SupplicantInterfaceProxy::~SupplicantInterfaceProxy() {}
28
29::DBus::Path SupplicantInterfaceProxy::AddNetwork(
30 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -070031 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070032 try {
33 return proxy_.AddNetwork(args);
34 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070035 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -070036 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -070037 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070038 }
mukesh agrawalaf571952011-07-14 14:31:12 -070039}
40
Paul Stewart66c86002012-01-30 18:00:52 -080041void SupplicantInterfaceProxy::ClearCachedCredentials() {
mukesh agrawal06175d72012-04-23 16:46:01 -070042 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070043 try {
44 return proxy_.ClearCachedCredentials();
45 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070046 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
47 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070048 }
Paul Stewart66c86002012-01-30 18:00:52 -080049}
50
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000051void SupplicantInterfaceProxy::Disconnect() {
mukesh agrawal06175d72012-04-23 16:46:01 -070052 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070053 try {
54 return proxy_.Disconnect();
55 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -070056 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
57 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070058 }
mukesh agrawal0ed0f2e2011-12-05 20:36:17 +000059}
60
mukesh agrawalaf571952011-07-14 14:31:12 -070061void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) {
mukesh agrawal06175d72012-04-23 16:46:01 -070062 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070063 try {
64 return proxy_.FlushBSS(age);
65 } catch (const DBus::Error &e) {
66 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what()
67 << " age: " << age;
68 }
mukesh agrawalaf571952011-07-14 14:31:12 -070069}
70
Paul Stewart3c508e12012-08-09 11:40:06 -070071void SupplicantInterfaceProxy::Reassociate() {
72 SLOG(DBus, 2) << __func__;
73 try {
74 return proxy_.Reassociate();
75 } catch (const DBus::Error &e) {
76 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
77 throw; // Re-throw the exception.
78 }
79}
80
mukesh agrawalaf571952011-07-14 14:31:12 -070081void SupplicantInterfaceProxy::RemoveAllNetworks() {
mukesh agrawal06175d72012-04-23 16:46:01 -070082 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070083 try {
84 return proxy_.RemoveAllNetworks();
85 } catch (const DBus::Error &e) {
86 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
87 }
mukesh agrawalaf571952011-07-14 14:31:12 -070088}
89
mukesh agrawal15908392011-11-16 18:29:25 +000090void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -070091 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -070092 try {
93 return proxy_.RemoveNetwork(network);
94 } catch (const DBus::Error &e) {
Paul Stewart71f6ecd2012-09-13 14:52:18 -070095 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
96 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -070097 }
mukesh agrawal15908392011-11-16 18:29:25 +000098}
99
mukesh agrawalaf571952011-07-14 14:31:12 -0700100void SupplicantInterfaceProxy::Scan(
101 const std::map<std::string, ::DBus::Variant> &args) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700102 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700103 try {
104 return proxy_.Scan(args);
105 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700106 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700107 << " args keys are: " << DBusProperties::KeysToString(args);
Gary Morainba919ac2012-05-08 11:30:20 -0700108 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700109 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700110}
111
112void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700113 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700114 try {
115 return proxy_.SelectNetwork(network);
116 } catch (const DBus::Error &e) {
117 LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what();
118 }
mukesh agrawalaf571952011-07-14 14:31:12 -0700119}
120
Paul Stewart2987dcf2012-01-30 15:47:42 -0800121void SupplicantInterfaceProxy::SetFastReauth(bool enabled) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700122 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700123 try {
124 return proxy_.FastReauth(enabled);
125 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700126 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700127 << "enabled: " << enabled;
Gary Morainba919ac2012-05-08 11:30:20 -0700128 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700129 }
Paul Stewart2987dcf2012-01-30 15:47:42 -0800130}
131
mukesh agrawalf2028172012-03-13 14:20:22 -0700132void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700133 SLOG(DBus, 2) << __func__;
Gary Morain610977f2012-05-04 16:03:52 -0700134 try {
135 return proxy_.ScanInterval(scan_interval);
136 } catch (const DBus::Error &e) {
Gary Morainba919ac2012-05-08 11:30:20 -0700137 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
Gary Morain610977f2012-05-04 16:03:52 -0700138 << " scan interval: " << scan_interval;
Gary Morainba919ac2012-05-08 11:30:20 -0700139 throw; // Re-throw the exception.
Gary Morain610977f2012-05-04 16:03:52 -0700140 }
mukesh agrawalf2028172012-03-13 14:20:22 -0700141}
142
mukesh agrawalaf571952011-07-14 14:31:12 -0700143// definitions for private class SupplicantInterfaceProxy::Proxy
144
145SupplicantInterfaceProxy::Proxy::Proxy(
146 const WiFiRefPtr &wifi, DBus::Connection *bus,
147 const DBus::Path &dbus_path, const char *dbus_addr)
148 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr),
149 wifi_(wifi) {}
150
151SupplicantInterfaceProxy::Proxy::~Proxy() {}
152
mukesh agrawal1830fa12011-09-26 14:31:40 -0700153void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700154 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700155 // XXX
156}
157
mukesh agrawal1830fa12011-09-26 14:31:40 -0700158void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700159 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700160 // XXX
161}
162
163void SupplicantInterfaceProxy::Proxy::BSSAdded(
164 const ::DBus::Path &BSS,
165 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700166 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700167 wifi_->BSSAdded(BSS, properties);
168}
169
Paul Stewartbc6e7392012-05-24 07:07:48 -0700170void SupplicantInterfaceProxy::Proxy::Certification(
171 const std::map<string, ::DBus::Variant> &properties) {
172 SLOG(DBus, 2) << __func__;
173 wifi_->Certification(properties);
174}
175
mukesh agrawal261daca2011-12-02 18:56:56 +0000176void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700177 SLOG(DBus, 2) << __func__;
mukesh agrawal261daca2011-12-02 18:56:56 +0000178 wifi_->BSSRemoved(BSS);
mukesh agrawalaf571952011-07-14 14:31:12 -0700179}
180
181void SupplicantInterfaceProxy::Proxy::NetworkAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700182 const ::DBus::Path &/*network*/,
183 const std::map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700184 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700185 // XXX
186}
187
188void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700189 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700190 SLOG(DBus, 2) << __func__;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000191 // TODO(quiche): Pass this up to WiFi, so that it can clean its
192 // rpcid_by_service_ map. crosbug.com/24699
mukesh agrawalaf571952011-07-14 14:31:12 -0700193}
194
195void SupplicantInterfaceProxy::Proxy::NetworkSelected(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700196 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700197 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700198 // XXX
199}
200
201void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
mukesh agrawal7ec71312011-11-10 02:08:26 +0000202 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700203 SLOG(DBus, 2) << __func__;
mukesh agrawal7ec71312011-11-10 02:08:26 +0000204 wifi_->PropertiesChanged(properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700205}
206
207void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700208 SLOG(DBus, 2) << __func__ << ": " << success;
mukesh agrawalaf571952011-07-14 14:31:12 -0700209 if (success) {
210 wifi_->ScanDone();
211 }
212}
213
214} // namespace shill