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 | |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 12 | #include <dbus-c++/dbus.h> |
| 13 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 14 | #include "shill/device.h" |
Chris Masone | 2b10554 | 2011-06-22 10:58:09 -0700 | [diff] [blame] | 15 | #include "shill/refptr_types.h" |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 16 | #include "shill/shill_event.h" |
| 17 | |
| 18 | namespace shill { |
| 19 | |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 20 | class Error; |
| 21 | class KeyValueStore; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 22 | class SupplicantInterfaceProxyInterface; |
| 23 | class SupplicantProcessProxyInterface; |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 24 | class WiFiService; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 25 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 26 | // WiFi class. Specialization of Device for WiFi. |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 27 | class WiFi : public Device { |
| 28 | public: |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 29 | WiFi(ControlInterface *control_interface, |
| 30 | EventDispatcher *dispatcher, |
| 31 | Manager *manager, |
Chris Masone | 626719f | 2011-08-18 16:58:48 -0700 | [diff] [blame] | 32 | const std::string &link, |
| 33 | const std::string &address, |
Paul Stewart | f1ce5d2 | 2011-05-19 13:10:20 -0700 | [diff] [blame] | 34 | int interface_index); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 35 | virtual ~WiFi(); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 36 | |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 37 | virtual void Start(); |
| 38 | virtual void Stop(); |
Darin Petkov | c086531 | 2011-09-16 15:31:20 -0700 | [diff] [blame] | 39 | virtual void Scan(Error *error); |
Paul Stewart | fdd1607 | 2011-09-16 12:41:35 -0700 | [diff] [blame] | 40 | virtual bool TechnologyIs(const Technology::Identifier type) const; |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 41 | virtual void LinkEvent(unsigned int flags, unsigned int change); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 42 | |
| 43 | // called by SupplicantInterfaceProxy, in response to events from |
| 44 | // wpa_supplicant. |
| 45 | void BSSAdded(const ::DBus::Path &BSS, |
Chris Masone | a82b711 | 2011-05-25 15:16:29 -0700 | [diff] [blame] | 46 | const std::map<std::string, ::DBus::Variant> &properties); |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 47 | void ScanDone(); |
| 48 | |
mukesh agrawal | 445e72c | 2011-06-22 11:13:50 -0700 | [diff] [blame] | 49 | // called by WiFiService |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 50 | virtual void ConnectTo( |
| 51 | WiFiService *service, |
| 52 | const std::map<std::string, ::DBus::Variant> &service_params); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 53 | |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 54 | // called by Manager |
| 55 | virtual WiFiServiceRefPtr GetService(const KeyValueStore &args, Error *error); |
| 56 | |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 57 | private: |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 58 | typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap; |
mukesh agrawal | 3195024 | 2011-07-14 11:53:38 -0700 | [diff] [blame] | 59 | typedef std::map<const std::string, WiFiServiceRefPtr> ServiceMap; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 60 | |
mukesh agrawal | 7a4e400 | 2011-09-06 11:26:05 -0700 | [diff] [blame] | 61 | static const char kManagerErrorPassphraseRequired[]; |
| 62 | static const char kManagerErrorSSIDTooLong[]; |
| 63 | static const char kManagerErrorSSIDTooShort[]; |
| 64 | static const char kManagerErrorSSIDRequired[]; |
| 65 | static const char kManagerErrorTypeRequired[]; |
| 66 | static const char kManagerErrorUnsupportedSecurityMode[]; |
| 67 | static const char kManagerErrorUnsupportedServiceType[]; |
| 68 | static const char kManagerErrorUnsupportedServiceMode[]; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 69 | |
mukesh agrawal | dc42bb3 | 2011-07-28 10:40:26 -0700 | [diff] [blame] | 70 | void ScanDoneTask(); |
mukesh agrawal | 3239932 | 2011-09-01 10:53:43 -0700 | [diff] [blame] | 71 | void ScanTask(); |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 72 | |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 73 | ScopedRunnableMethodFactory<WiFi> task_factory_; |
mukesh agrawal | af57195 | 2011-07-14 14:31:12 -0700 | [diff] [blame] | 74 | scoped_ptr<SupplicantProcessProxyInterface> supplicant_process_proxy_; |
| 75 | scoped_ptr<SupplicantInterfaceProxyInterface> supplicant_interface_proxy_; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 76 | EndpointMap endpoint_by_bssid_; |
| 77 | ServiceMap service_by_private_id_; |
mukesh agrawal | ab87ea4 | 2011-05-18 11:44:49 -0700 | [diff] [blame] | 78 | |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 79 | // Properties |
| 80 | std::string bgscan_method_; |
| 81 | uint16 bgscan_short_interval_; |
| 82 | int32 bgscan_signal_threshold_; |
| 83 | bool scan_pending_; |
| 84 | uint16 scan_interval_; |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 85 | bool link_up_; |
Chris Masone | 853b81b | 2011-06-24 14:11:41 -0700 | [diff] [blame] | 86 | |
mukesh agrawal | f2f68a5 | 2011-09-01 12:15:48 -0700 | [diff] [blame] | 87 | friend class WiFiMainTest; // access to supplicant_*_proxy_, link_up_ |
Paul Stewart | b50f0b9 | 2011-05-16 16:31:42 -0700 | [diff] [blame] | 88 | DISALLOW_COPY_AND_ASSIGN(WiFi); |
| 89 | }; |
| 90 | |
| 91 | } // namespace shill |
| 92 | |
| 93 | #endif // SHILL_WIFI_ |