mukesh agrawal | 8a3188d | 2011-12-01 20:56:44 +0000 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 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/supplicant_interface_proxy.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 10 | #include <dbus-c++/dbus.h> |
| 11 | |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 12 | #include "shill/logging.h" |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 13 | #include "shill/supplicant_event_delegate_interface.h" |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 14 | |
| 15 | using std::map; |
| 16 | using std::string; |
| 17 | |
| 18 | namespace shill { |
| 19 | |
| 20 | SupplicantInterfaceProxy::SupplicantInterfaceProxy( |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 21 | SupplicantEventDelegateInterface *delegate, |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 22 | DBus::Connection *bus, |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 23 | const ::DBus::Path &object_path, |
| 24 | const char *dbus_addr) |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 25 | : proxy_(delegate, bus, object_path, dbus_addr) {} |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 26 | |
| 27 | SupplicantInterfaceProxy::~SupplicantInterfaceProxy() {} |
| 28 | |
| 29 | ::DBus::Path SupplicantInterfaceProxy::AddNetwork( |
| 30 | const std::map<std::string, ::DBus::Variant> &args) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 31 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 32 | try { |
| 33 | return proxy_.AddNetwork(args); |
| 34 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 35 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 36 | << " args keys are: " << DBusProperties::KeysToString(args); |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 37 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 38 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Christopher Wiley | 5519e9e | 2013-01-08 16:55:56 -0800 | [diff] [blame] | 41 | void 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 | |
Paul Stewart | be9abfd | 2013-04-22 12:18:48 -0700 | [diff] [blame] | 51 | void SupplicantInterfaceProxy::EAPLogoff() { |
| 52 | SLOG(DBus, 2) << __func__; |
| 53 | try { |
| 54 | return proxy_.EAPLogoff(); |
| 55 | } catch (const DBus::Error &e) { |
| 56 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what(); |
| 57 | throw; // Re-throw the exception. |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | void SupplicantInterfaceProxy::EAPLogon() { |
| 62 | SLOG(DBus, 2) << __func__; |
| 63 | try { |
| 64 | return proxy_.EAPLogon(); |
| 65 | } catch (const DBus::Error &e) { |
| 66 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what(); |
| 67 | throw; // Re-throw the exception. |
| 68 | } |
| 69 | } |
| 70 | |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 71 | void SupplicantInterfaceProxy::Disconnect() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 72 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 73 | try { |
| 74 | return proxy_.Disconnect(); |
| 75 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 76 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what(); |
| 77 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 78 | } |
mukesh agrawal | 0ed0f2e | 2011-12-05 20:36:17 +0000 | [diff] [blame] | 79 | } |
| 80 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 81 | void SupplicantInterfaceProxy::FlushBSS(const uint32_t &age) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 82 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 83 | try { |
| 84 | return proxy_.FlushBSS(age); |
| 85 | } catch (const DBus::Error &e) { |
| 86 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what() |
| 87 | << " age: " << age; |
| 88 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Paul Stewart | 3c508e1 | 2012-08-09 11:40:06 -0700 | [diff] [blame] | 91 | void SupplicantInterfaceProxy::Reassociate() { |
| 92 | SLOG(DBus, 2) << __func__; |
| 93 | try { |
| 94 | return proxy_.Reassociate(); |
| 95 | } catch (const DBus::Error &e) { |
| 96 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what(); |
| 97 | throw; // Re-throw the exception. |
| 98 | } |
| 99 | } |
| 100 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 101 | void SupplicantInterfaceProxy::RemoveAllNetworks() { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 102 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 103 | try { |
| 104 | return proxy_.RemoveAllNetworks(); |
| 105 | } catch (const DBus::Error &e) { |
| 106 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 107 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 108 | } |
| 109 | |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 110 | void SupplicantInterfaceProxy::RemoveNetwork(const ::DBus::Path &network) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 111 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 112 | try { |
| 113 | return proxy_.RemoveNetwork(network); |
| 114 | } catch (const DBus::Error &e) { |
Paul Stewart | 71f6ecd | 2012-09-13 14:52:18 -0700 | [diff] [blame] | 115 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what(); |
| 116 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 117 | } |
mukesh agrawal | 1590839 | 2011-11-16 18:29:25 +0000 | [diff] [blame] | 118 | } |
| 119 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 120 | void SupplicantInterfaceProxy::Scan( |
| 121 | const std::map<std::string, ::DBus::Variant> &args) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 122 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 123 | try { |
| 124 | return proxy_.Scan(args); |
| 125 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 126 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 127 | << " args keys are: " << DBusProperties::KeysToString(args); |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 128 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 129 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | void SupplicantInterfaceProxy::SelectNetwork(const ::DBus::Path &network) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 133 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 134 | try { |
| 135 | return proxy_.SelectNetwork(network); |
| 136 | } catch (const DBus::Error &e) { |
| 137 | LOG(FATAL) << "DBus exception: " << e.name() << ": " << e.what(); |
| 138 | } |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Paul Stewart | 2987dcf | 2012-01-30 15:47:42 -0800 | [diff] [blame] | 141 | void SupplicantInterfaceProxy::SetFastReauth(bool enabled) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 142 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 143 | try { |
| 144 | return proxy_.FastReauth(enabled); |
| 145 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 146 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 147 | << "enabled: " << enabled; |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 148 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 149 | } |
Paul Stewart | 2987dcf | 2012-01-30 15:47:42 -0800 | [diff] [blame] | 150 | } |
| 151 | |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 152 | void SupplicantInterfaceProxy::SetScanInterval(int32 scan_interval) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 153 | SLOG(DBus, 2) << __func__; |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 154 | try { |
| 155 | return proxy_.ScanInterval(scan_interval); |
| 156 | } catch (const DBus::Error &e) { |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 157 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 158 | << " scan interval: " << scan_interval; |
Gary Morain | ba919ac | 2012-05-08 11:30:20 -0700 | [diff] [blame] | 159 | throw; // Re-throw the exception. |
Gary Morain | 610977f | 2012-05-04 16:03:52 -0700 | [diff] [blame] | 160 | } |
mukesh agrawal | f202817 | 2012-03-13 14:20:22 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Christopher Wiley | 5519e9e | 2013-01-08 16:55:56 -0800 | [diff] [blame] | 163 | void SupplicantInterfaceProxy::SetDisableHighBitrates( |
| 164 | bool disable_high_bitrates) { |
| 165 | SLOG(DBus, 2) << __func__; |
| 166 | try { |
| 167 | return proxy_.DisableHighBitrates(disable_high_bitrates); |
| 168 | } catch (const DBus::Error &e) { |
| 169 | LOG(ERROR) << "DBus exception: " << e.name() << ": " << e.what() |
| 170 | << "disable_high_bitrates: " << disable_high_bitrates; |
| 171 | throw; // Re-throw the exception. |
| 172 | } |
| 173 | } |
| 174 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 175 | // definitions for private class SupplicantInterfaceProxy::Proxy |
| 176 | |
| 177 | SupplicantInterfaceProxy::Proxy::Proxy( |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 178 | SupplicantEventDelegateInterface *delegate, DBus::Connection *bus, |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 179 | const DBus::Path &dbus_path, const char *dbus_addr) |
| 180 | : DBus::ObjectProxy(*bus, dbus_path, dbus_addr), |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 181 | delegate_(delegate) {} |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 182 | |
| 183 | SupplicantInterfaceProxy::Proxy::~Proxy() {} |
| 184 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 185 | void SupplicantInterfaceProxy::Proxy::BlobAdded(const string &/*blobname*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 186 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 187 | // XXX |
| 188 | } |
| 189 | |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 190 | void SupplicantInterfaceProxy::Proxy::BlobRemoved(const string &/*blobname*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 191 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 192 | // XXX |
| 193 | } |
| 194 | |
| 195 | void SupplicantInterfaceProxy::Proxy::BSSAdded( |
| 196 | const ::DBus::Path &BSS, |
| 197 | const std::map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 198 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 199 | delegate_->BSSAdded(BSS, properties); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 202 | void SupplicantInterfaceProxy::Proxy::Certification( |
| 203 | const std::map<string, ::DBus::Variant> &properties) { |
| 204 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 205 | delegate_->Certification(properties); |
Paul Stewart | bc6e739 | 2012-05-24 07:07:48 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Paul Stewart | db0f917 | 2012-11-30 16:48:09 -0800 | [diff] [blame] | 208 | void SupplicantInterfaceProxy::Proxy::EAP( |
| 209 | const string &status, const string ¶meter) { |
| 210 | SLOG(DBus, 2) << __func__ << ": status " << status |
| 211 | << ", parameter " << parameter; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 212 | delegate_->EAPEvent(status, parameter); |
Paul Stewart | db0f917 | 2012-11-30 16:48:09 -0800 | [diff] [blame] | 213 | } |
| 214 | |
mukesh agrawal | 261daca | 2011-12-02 18:56:56 +0000 | [diff] [blame] | 215 | void SupplicantInterfaceProxy::Proxy::BSSRemoved(const ::DBus::Path &BSS) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 216 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 217 | delegate_->BSSRemoved(BSS); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | void SupplicantInterfaceProxy::Proxy::NetworkAdded( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 221 | const ::DBus::Path &/*network*/, |
| 222 | const std::map<string, ::DBus::Variant> &/*properties*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 223 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 224 | // XXX |
| 225 | } |
| 226 | |
| 227 | void SupplicantInterfaceProxy::Proxy::NetworkRemoved( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 228 | const ::DBus::Path &/*network*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 229 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 230 | // TODO(quiche): Pass this up to the delegate, so that it can clean its |
Paul Stewart | ee6b3d7 | 2013-07-12 16:07:51 -0700 | [diff] [blame] | 231 | // rpcid_by_service_ map. crbug.com/207648 |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void SupplicantInterfaceProxy::Proxy::NetworkSelected( |
mukesh agrawal | 1830fa1 | 2011-09-26 14:31:40 -0700 | [diff] [blame] | 235 | const ::DBus::Path &/*network*/) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 236 | SLOG(DBus, 2) << __func__; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 237 | // XXX |
| 238 | } |
| 239 | |
| 240 | void SupplicantInterfaceProxy::Proxy::PropertiesChanged( |
mukesh agrawal | 7ec7131 | 2011-11-10 02:08:26 +0000 | [diff] [blame] | 241 | const std::map<string, ::DBus::Variant> &properties) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 242 | SLOG(DBus, 2) << __func__; |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 243 | delegate_->PropertiesChanged(properties); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | void SupplicantInterfaceProxy::Proxy::ScanDone(const bool& success) { |
mukesh agrawal | 06175d7 | 2012-04-23 16:46:01 -0700 | [diff] [blame] | 247 | SLOG(DBus, 2) << __func__ << ": " << success; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 248 | if (success) { |
Paul Stewart | 196f50f | 2013-03-27 18:02:11 -0700 | [diff] [blame] | 249 | delegate_->ScanDone(); |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | |
| 253 | } // namespace shill |