blob: 04b1d09e0a07bb6c163f347a4902170f103bd80d [file] [log] [blame]
Paul Stewartb50f0b92011-05-16 16:31:42 -07001// 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 agrawalab87ea42011-05-18 11:44:49 -07008#include <map>
Chris Masone46eaaf52011-05-24 13:08:30 -07009#include <string>
mukesh agrawalab87ea42011-05-18 11:44:49 -070010#include <vector>
Chris Masone46eaaf52011-05-24 13:08:30 -070011
mukesh agrawalaf571952011-07-14 14:31:12 -070012#include <dbus-c++/dbus.h>
13
Paul Stewartb50f0b92011-05-16 16:31:42 -070014#include "shill/device.h"
Chris Masone2b105542011-06-22 10:58:09 -070015#include "shill/refptr_types.h"
Paul Stewartb50f0b92011-05-16 16:31:42 -070016#include "shill/shill_event.h"
17
18namespace shill {
19
mukesh agrawalaf571952011-07-14 14:31:12 -070020class SupplicantInterfaceProxyInterface;
21class SupplicantProcessProxyInterface;
mukesh agrawal445e72c2011-06-22 11:13:50 -070022class WiFiService;
mukesh agrawalb54601c2011-06-07 17:39:22 -070023
mukesh agrawalab87ea42011-05-18 11:44:49 -070024// WiFi class. Specialization of Device for WiFi.
Paul Stewartb50f0b92011-05-16 16:31:42 -070025class WiFi : public Device {
26 public:
Paul Stewartf1ce5d22011-05-19 13:10:20 -070027 WiFi(ControlInterface *control_interface,
28 EventDispatcher *dispatcher,
29 Manager *manager,
Chris Masone626719f2011-08-18 16:58:48 -070030 const std::string &link,
31 const std::string &address,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070032 int interface_index);
mukesh agrawalab87ea42011-05-18 11:44:49 -070033 virtual ~WiFi();
Darin Petkovc0865312011-09-16 15:31:20 -070034
mukesh agrawalab87ea42011-05-18 11:44:49 -070035 virtual void Start();
36 virtual void Stop();
Darin Petkovc0865312011-09-16 15:31:20 -070037 virtual void Scan(Error *error);
Darin Petkov6f9eaa32011-08-09 15:26:44 -070038 virtual bool TechnologyIs(const Technology type) const;
mukesh agrawalf2f68a52011-09-01 12:15:48 -070039 virtual void LinkEvent(unsigned int flags, unsigned int change);
mukesh agrawalab87ea42011-05-18 11:44:49 -070040
41 // called by SupplicantInterfaceProxy, in response to events from
42 // wpa_supplicant.
43 void BSSAdded(const ::DBus::Path &BSS,
Chris Masonea82b7112011-05-25 15:16:29 -070044 const std::map<std::string, ::DBus::Variant> &properties);
mukesh agrawalab87ea42011-05-18 11:44:49 -070045 void ScanDone();
46
mukesh agrawal445e72c2011-06-22 11:13:50 -070047 // called by WiFiService
mukesh agrawal32399322011-09-01 10:53:43 -070048 void ConnectTo(WiFiService *service);
mukesh agrawalb54601c2011-06-07 17:39:22 -070049
Paul Stewartb50f0b92011-05-16 16:31:42 -070050 private:
mukesh agrawalb54601c2011-06-07 17:39:22 -070051 typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap;
mukesh agrawal31950242011-07-14 11:53:38 -070052 typedef std::map<const std::string, WiFiServiceRefPtr> ServiceMap;
mukesh agrawalb54601c2011-06-07 17:39:22 -070053
mukesh agrawalab87ea42011-05-18 11:44:49 -070054 static const char kSupplicantPath[];
55 static const char kSupplicantDBusAddr[];
56 static const char kSupplicantWiFiDriver[];
mukesh agrawalc7426a42011-06-03 13:04:28 -070057 static const char kSupplicantErrorInterfaceExists[];
mukesh agrawal445e72c2011-06-22 11:13:50 -070058 static const char kSupplicantPropertySSID[];
59 static const char kSupplicantPropertyNetworkMode[];
60 static const char kSupplicantPropertyKeyMode[];
mukesh agrawal32399322011-09-01 10:53:43 -070061 static const char kSupplicantPropertyScanType[];
mukesh agrawalb54601c2011-06-07 17:39:22 -070062 static const char kSupplicantKeyModeNone[];
mukesh agrawal32399322011-09-01 10:53:43 -070063 static const char kSupplicantScanTypeActive[];
mukesh agrawalab87ea42011-05-18 11:44:49 -070064
mukesh agrawaldc42bb32011-07-28 10:40:26 -070065 void ScanDoneTask();
mukesh agrawal32399322011-09-01 10:53:43 -070066 void ScanTask();
mukesh agrawalb54601c2011-06-07 17:39:22 -070067
mukesh agrawalb54601c2011-06-07 17:39:22 -070068 ScopedRunnableMethodFactory<WiFi> task_factory_;
mukesh agrawalaf571952011-07-14 14:31:12 -070069 scoped_ptr<SupplicantProcessProxyInterface> supplicant_process_proxy_;
70 scoped_ptr<SupplicantInterfaceProxyInterface> supplicant_interface_proxy_;
mukesh agrawalb54601c2011-06-07 17:39:22 -070071 EndpointMap endpoint_by_bssid_;
72 ServiceMap service_by_private_id_;
mukesh agrawalab87ea42011-05-18 11:44:49 -070073
Chris Masone853b81b2011-06-24 14:11:41 -070074 // Properties
75 std::string bgscan_method_;
76 uint16 bgscan_short_interval_;
77 int32 bgscan_signal_threshold_;
78 bool scan_pending_;
79 uint16 scan_interval_;
mukesh agrawalf2f68a52011-09-01 12:15:48 -070080 bool link_up_;
Chris Masone853b81b2011-06-24 14:11:41 -070081
mukesh agrawalf2f68a52011-09-01 12:15:48 -070082 friend class WiFiMainTest; // access to supplicant_*_proxy_, link_up_
Paul Stewartb50f0b92011-05-16 16:31:42 -070083 DISALLOW_COPY_AND_ASSIGN(WiFi);
84};
85
86} // namespace shill
87
88#endif // SHILL_WIFI_