blob: 1940494ed16c551c23332c0288e03d7ac59c3bbc [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"
Paul Stewart26b327e2011-10-19 11:38:09 -070015#include "shill/event_dispatcher.h"
Chris Masone2b105542011-06-22 10:58:09 -070016#include "shill/refptr_types.h"
Paul Stewartb50f0b92011-05-16 16:31:42 -070017
18namespace shill {
19
mukesh agrawal7a4e4002011-09-06 11:26:05 -070020class Error;
21class KeyValueStore;
Darin Petkovab565bb2011-10-06 02:55:51 -070022class ProxyFactory;
mukesh agrawalaf571952011-07-14 14:31:12 -070023class SupplicantInterfaceProxyInterface;
24class SupplicantProcessProxyInterface;
mukesh agrawal445e72c2011-06-22 11:13:50 -070025class WiFiService;
mukesh agrawalb54601c2011-06-07 17:39:22 -070026
mukesh agrawalab87ea42011-05-18 11:44:49 -070027// WiFi class. Specialization of Device for WiFi.
Paul Stewartb50f0b92011-05-16 16:31:42 -070028class WiFi : public Device {
29 public:
Paul Stewartf1ce5d22011-05-19 13:10:20 -070030 WiFi(ControlInterface *control_interface,
31 EventDispatcher *dispatcher,
32 Manager *manager,
Chris Masone626719f2011-08-18 16:58:48 -070033 const std::string &link,
34 const std::string &address,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070035 int interface_index);
mukesh agrawalab87ea42011-05-18 11:44:49 -070036 virtual ~WiFi();
Darin Petkovc0865312011-09-16 15:31:20 -070037
mukesh agrawalab87ea42011-05-18 11:44:49 -070038 virtual void Start();
39 virtual void Stop();
Darin Petkovc0865312011-09-16 15:31:20 -070040 virtual void Scan(Error *error);
Paul Stewartfdd16072011-09-16 12:41:35 -070041 virtual bool TechnologyIs(const Technology::Identifier type) const;
mukesh agrawalf2f68a52011-09-01 12:15:48 -070042 virtual void LinkEvent(unsigned int flags, unsigned int change);
mukesh agrawalab87ea42011-05-18 11:44:49 -070043
44 // called by SupplicantInterfaceProxy, in response to events from
45 // wpa_supplicant.
46 void BSSAdded(const ::DBus::Path &BSS,
Chris Masonea82b7112011-05-25 15:16:29 -070047 const std::map<std::string, ::DBus::Variant> &properties);
mukesh agrawalab87ea42011-05-18 11:44:49 -070048 void ScanDone();
49
mukesh agrawal445e72c2011-06-22 11:13:50 -070050 // called by WiFiService
mukesh agrawal6e277772011-09-29 15:04:23 -070051 virtual void ConnectTo(
52 WiFiService *service,
53 const std::map<std::string, ::DBus::Variant> &service_params);
mukesh agrawalb54601c2011-06-07 17:39:22 -070054
mukesh agrawal7a4e4002011-09-06 11:26:05 -070055 // called by Manager
56 virtual WiFiServiceRefPtr GetService(const KeyValueStore &args, Error *error);
57
Paul Stewartb50f0b92011-05-16 16:31:42 -070058 private:
mukesh agrawalb54601c2011-06-07 17:39:22 -070059 typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap;
mukesh agrawal31950242011-07-14 11:53:38 -070060 typedef std::map<const std::string, WiFiServiceRefPtr> ServiceMap;
mukesh agrawalb54601c2011-06-07 17:39:22 -070061
mukesh agrawal7a4e4002011-09-06 11:26:05 -070062 static const char kManagerErrorPassphraseRequired[];
63 static const char kManagerErrorSSIDTooLong[];
64 static const char kManagerErrorSSIDTooShort[];
65 static const char kManagerErrorSSIDRequired[];
66 static const char kManagerErrorTypeRequired[];
67 static const char kManagerErrorUnsupportedSecurityMode[];
68 static const char kManagerErrorUnsupportedServiceType[];
69 static const char kManagerErrorUnsupportedServiceMode[];
mukesh agrawalab87ea42011-05-18 11:44:49 -070070
mukesh agrawaldc42bb32011-07-28 10:40:26 -070071 void ScanDoneTask();
mukesh agrawal32399322011-09-01 10:53:43 -070072 void ScanTask();
mukesh agrawalb54601c2011-06-07 17:39:22 -070073
Darin Petkovab565bb2011-10-06 02:55:51 -070074 // Store cached copies of singletons for speed/ease of testing.
75 ProxyFactory *proxy_factory_;
76
mukesh agrawalb54601c2011-06-07 17:39:22 -070077 ScopedRunnableMethodFactory<WiFi> task_factory_;
mukesh agrawalaf571952011-07-14 14:31:12 -070078 scoped_ptr<SupplicantProcessProxyInterface> supplicant_process_proxy_;
79 scoped_ptr<SupplicantInterfaceProxyInterface> supplicant_interface_proxy_;
mukesh agrawalb54601c2011-06-07 17:39:22 -070080 EndpointMap endpoint_by_bssid_;
81 ServiceMap service_by_private_id_;
mukesh agrawalab87ea42011-05-18 11:44:49 -070082
Chris Masone853b81b2011-06-24 14:11:41 -070083 // Properties
84 std::string bgscan_method_;
85 uint16 bgscan_short_interval_;
86 int32 bgscan_signal_threshold_;
87 bool scan_pending_;
88 uint16 scan_interval_;
mukesh agrawalf2f68a52011-09-01 12:15:48 -070089 bool link_up_;
Chris Masone853b81b2011-06-24 14:11:41 -070090
mukesh agrawalf2f68a52011-09-01 12:15:48 -070091 friend class WiFiMainTest; // access to supplicant_*_proxy_, link_up_
Paul Stewartb50f0b92011-05-16 16:31:42 -070092 DISALLOW_COPY_AND_ASSIGN(WiFi);
93};
94
95} // namespace shill
96
97#endif // SHILL_WIFI_