blob: a9d4f1f0d10dac794df126cf88e800489d20f858 [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
Christopher Wiley5519e9e2013-01-08 16:55:56 -080041void SupplicantInterfaceProxy::EnableHighBitrates() {
42 SLOG(DBus, 2) << __func__;
43 try {
44 return proxy_.EnableHighBitrates();
45 } catch (const DBus::Error &e) {
46 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what();
47 throw; // Re-throw the exception.
48 }
49}
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
Christopher Wiley5519e9e2013-01-08 16:55:56 -0800143void SupplicantInterfaceProxy::SetDisableHighBitrates(
144 bool disable_high_bitrates) {
145 SLOG(DBus, 2) << __func__;
146 try {
147 return proxy_.DisableHighBitrates(disable_high_bitrates);
148 } catch (const DBus::Error &e) {
149 LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what()
150 << "disable_high_bitrates: " << disable_high_bitrates;
151 throw; // Re-throw the exception.
152 }
153}
154
mukesh agrawalaf571952011-07-14 14:31:12 -0700155// definitions for private class SupplicantInterfaceProxy::Proxy
156
157SupplicantInterfaceProxy::Proxy::Proxy(
158 const WiFiRefPtr &wifi, DBus::Connection *bus,
159 const DBus::Path &dbus_path, const char *dbus_addr)
160 : DBus::ObjectProxy(*bus, dbus_path, dbus_addr),
161 wifi_(wifi) {}
162
163SupplicantInterfaceProxy::Proxy::~Proxy() {}
164
mukesh agrawal1830fa12011-09-26 14:31:40 -0700165void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700166 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700167 // XXX
168}
169
mukesh agrawal1830fa12011-09-26 14:31:40 -0700170void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700171 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700172 // XXX
173}
174
175void SupplicantInterfaceProxy::Proxy::BSSAdded(
176 const ::DBus::Path &BSS,
177 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700178 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700179 wifi_->BSSAdded(BSS, properties);
180}
181
Paul Stewartbc6e7392012-05-24 07:07:48 -0700182void SupplicantInterfaceProxy::Proxy::Certification(
183 const std::map<string, ::DBus::Variant> &properties) {
184 SLOG(DBus, 2) << __func__;
185 wifi_->Certification(properties);
186}
187
Paul Stewartdb0f9172012-11-30 16:48:09 -0800188void SupplicantInterfaceProxy::Proxy::EAP(
189 const string &status, const string &parameter) {
190 SLOG(DBus, 2) << __func__ << ": status " << status
191 << ", parameter " << parameter;
192 wifi_->EAPEvent(status, parameter);
193}
194
mukesh agrawal261daca2011-12-02 18:56:56 +0000195void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700196 SLOG(DBus, 2) << __func__;
mukesh agrawal261daca2011-12-02 18:56:56 +0000197 wifi_->BSSRemoved(BSS);
mukesh agrawalaf571952011-07-14 14:31:12 -0700198}
199
200void SupplicantInterfaceProxy::Proxy::NetworkAdded(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700201 const ::DBus::Path &/*network*/,
202 const std::map<string, ::DBus::Variant> &/*properties*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700203 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700204 // XXX
205}
206
207void SupplicantInterfaceProxy::Proxy::NetworkRemoved(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700208 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700209 SLOG(DBus, 2) << __func__;
mukesh agrawal8a3188d2011-12-01 20:56:44 +0000210 // TODO(quiche): Pass this up to WiFi, so that it can clean its
211 // rpcid_by_service_ map. crosbug.com/24699
mukesh agrawalaf571952011-07-14 14:31:12 -0700212}
213
214void SupplicantInterfaceProxy::Proxy::NetworkSelected(
mukesh agrawal1830fa12011-09-26 14:31:40 -0700215 const ::DBus::Path &/*network*/) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700216 SLOG(DBus, 2) << __func__;
mukesh agrawalaf571952011-07-14 14:31:12 -0700217 // XXX
218}
219
220void SupplicantInterfaceProxy::Proxy::PropertiesChanged(
mukesh agrawal7ec71312011-11-10 02:08:26 +0000221 const std::map<string, ::DBus::Variant> &properties) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700222 SLOG(DBus, 2) << __func__;
mukesh agrawal7ec71312011-11-10 02:08:26 +0000223 wifi_->PropertiesChanged(properties);
mukesh agrawalaf571952011-07-14 14:31:12 -0700224}
225
226void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) {
mukesh agrawal06175d72012-04-23 16:46:01 -0700227 SLOG(DBus, 2) << __func__ << ": " << success;
mukesh agrawalaf571952011-07-14 14:31:12 -0700228 if (success) {
229 wifi_->ScanDone();
230 }
231}
232
233} // namespace shill