Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -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 | #ifndef SHILL_WIFI_ |
| 6 | #define SHILL_WIFI_ |
| 7 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 8 | #include <map> |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 9 | #include <string> |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 10 | #include <vector> |
Chris Masone | 46eaaf5 | 2011-05-24 13:08:30 -0700 | [diff] [blame] | 11 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 12 | #include "shill/device.h" |
| 13 | #include "shill/shill_event.h" |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 14 | #include "shill/supplicant-process.h" |
| 15 | #include "shill/supplicant-interface.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 16 | |
| 17 | namespace shill { |
| 18 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 19 | // WiFi class. Specialization of Device for WiFi. |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 20 | class WiFi : public Device { |
| 21 | public: |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 22 | WiFi(ControlInterface *control_interface, |
| 23 | EventDispatcher *dispatcher, |
| 24 | Manager *manager, |
| 25 | const std::string& link_name, |
| 26 | int interface_index); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 27 | virtual ~WiFi(); |
| 28 | virtual void Start(); |
| 29 | virtual void Stop(); |
| 30 | virtual bool TechnologyIs(const Technology type); |
| 31 | |
| 32 | // called by SupplicantInterfaceProxy, in response to events from |
| 33 | // wpa_supplicant. |
| 34 | void BSSAdded(const ::DBus::Path &BSS, |
| 35 | const std::map<std::string, ::DBus::Variant> |
| 36 | &properties); |
| 37 | void ScanDone(); |
| 38 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 39 | private: |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame^] | 40 | // SupplicantProcessProxy. provides access to wpa_supplicant's |
| 41 | // process-level D-Bus APIs. |
| 42 | class SupplicantProcessProxy : |
| 43 | public fi::w1::wpa_supplicant1_proxy, |
| 44 | private ::DBus::ObjectProxy // used by dbus-c++, not WiFi |
| 45 | { |
| 46 | public: |
| 47 | explicit SupplicantProcessProxy(DBus::Connection *bus); |
| 48 | |
| 49 | private: |
| 50 | // called by dbus-c++, via wpa_supplicant1_proxy interface, |
| 51 | // in response to signals from wpa_supplicant. not exposed |
| 52 | // to WiFi. |
| 53 | virtual void InterfaceAdded( |
| 54 | const ::DBus::Path &path, |
| 55 | const std::map<std::string, ::DBus::Variant> &properties); |
| 56 | virtual void InterfaceRemoved(const ::DBus::Path &path); |
| 57 | virtual void PropertiesChanged( |
| 58 | const std::map<std::string, ::DBus::Variant> &properties); |
| 59 | }; |
| 60 | |
| 61 | // SupplicantInterfaceProxy. provides access to wpa_supplicant's |
| 62 | // network-interface D-Bus APIs. |
| 63 | class SupplicantInterfaceProxy : |
| 64 | public fi::w1::wpa_supplicant1::Interface_proxy, |
| 65 | private ::DBus::ObjectProxy // used by dbus-c++, not WiFi |
| 66 | { |
| 67 | public: |
| 68 | SupplicantInterfaceProxy(WiFi *wifi, DBus::Connection *bus, |
| 69 | const ::DBus::Path &object_path); |
| 70 | |
| 71 | private: |
| 72 | // called by dbus-c++, via Interface_proxy interface, |
| 73 | // in response to signals from wpa_supplicant. not exposed |
| 74 | // to WiFi. |
| 75 | virtual void ScanDone(const bool &success); |
| 76 | virtual void BSSAdded(const ::DBus::Path &BSS, |
| 77 | const std::map<std::string, ::DBus::Variant> |
| 78 | &properties); |
| 79 | virtual void BSSRemoved(const ::DBus::Path &BSS); |
| 80 | virtual void BlobAdded(const std::string &blobname); |
| 81 | virtual void BlobRemoved(const std::string &blobname); |
| 82 | virtual void NetworkAdded(const ::DBus::Path &network, |
| 83 | const std::map<std::string, ::DBus::Variant> |
| 84 | &properties); |
| 85 | virtual void NetworkRemoved(const ::DBus::Path &network); |
| 86 | virtual void NetworkSelected(const ::DBus::Path &network); |
| 87 | virtual void PropertiesChanged(const std::map<std::string, ::DBus::Variant> |
| 88 | &properties); |
| 89 | |
| 90 | WiFi &wifi_; |
| 91 | }; |
| 92 | |
| 93 | static const char kSupplicantPath[]; |
| 94 | static const char kSupplicantDBusAddr[]; |
| 95 | static const char kSupplicantWiFiDriver[]; |
| 96 | |
| 97 | DBus::Connection dbus_; |
| 98 | scoped_ptr<SupplicantProcessProxy> supplicant_process_proxy_; |
| 99 | scoped_ptr<SupplicantInterfaceProxy> supplicant_interface_proxy_; |
| 100 | bool scan_pending_; |
| 101 | std::vector<std::string> ssids_; |
| 102 | |
| 103 | // provide WiFiTest access to scan_pending_, so it can determine |
| 104 | // if the scan completed, or timed out. |
| 105 | friend class WiFiTest; |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 106 | DISALLOW_COPY_AND_ASSIGN(WiFi); |
| 107 | }; |
| 108 | |
| 109 | } // namespace shill |
| 110 | |
| 111 | #endif // SHILL_WIFI_ |