blob: 379e1737165fc3e37bf868b4623b5561b9ed3836 [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 Masone3bd3c8c2011-06-13 08:20:26 -070030 const std::string& link,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070031 int interface_index);
mukesh agrawalab87ea42011-05-18 11:44:49 -070032 virtual ~WiFi();
33 virtual void Start();
34 virtual void Stop();
35 virtual bool TechnologyIs(const Technology type);
36
37 // called by SupplicantInterfaceProxy, in response to events from
38 // wpa_supplicant.
39 void BSSAdded(const ::DBus::Path &BSS,
Chris Masonea82b7112011-05-25 15:16:29 -070040 const std::map<std::string, ::DBus::Variant> &properties);
mukesh agrawalab87ea42011-05-18 11:44:49 -070041 void ScanDone();
42
mukesh agrawal445e72c2011-06-22 11:13:50 -070043 // called by WiFiService
44 void ConnectTo(const WiFiService &service);
mukesh agrawalb54601c2011-06-07 17:39:22 -070045
Paul Stewartb50f0b92011-05-16 16:31:42 -070046 private:
mukesh agrawalb54601c2011-06-07 17:39:22 -070047 typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap;
mukesh agrawal31950242011-07-14 11:53:38 -070048 typedef std::map<const std::string, WiFiServiceRefPtr> ServiceMap;
mukesh agrawalb54601c2011-06-07 17:39:22 -070049
mukesh agrawalab87ea42011-05-18 11:44:49 -070050 static const char kSupplicantPath[];
51 static const char kSupplicantDBusAddr[];
52 static const char kSupplicantWiFiDriver[];
mukesh agrawalc7426a42011-06-03 13:04:28 -070053 static const char kSupplicantErrorInterfaceExists[];
mukesh agrawal445e72c2011-06-22 11:13:50 -070054 static const char kSupplicantPropertySSID[];
55 static const char kSupplicantPropertyNetworkMode[];
56 static const char kSupplicantPropertyKeyMode[];
mukesh agrawalb54601c2011-06-07 17:39:22 -070057 static const char kSupplicantKeyModeNone[];
mukesh agrawalab87ea42011-05-18 11:44:49 -070058
mukesh agrawaldc42bb32011-07-28 10:40:26 -070059 void ScanDoneTask();
mukesh agrawalb54601c2011-06-07 17:39:22 -070060
61 static unsigned int service_id_serial_;
62 ScopedRunnableMethodFactory<WiFi> task_factory_;
63 ControlInterface *control_interface_;
64 EventDispatcher *dispatcher_;
mukesh agrawalaf571952011-07-14 14:31:12 -070065 scoped_ptr<SupplicantProcessProxyInterface> supplicant_process_proxy_;
66 scoped_ptr<SupplicantInterfaceProxyInterface> supplicant_interface_proxy_;
mukesh agrawalb54601c2011-06-07 17:39:22 -070067 EndpointMap endpoint_by_bssid_;
68 ServiceMap service_by_private_id_;
mukesh agrawalab87ea42011-05-18 11:44:49 -070069
Chris Masone853b81b2011-06-24 14:11:41 -070070 // Properties
71 std::string bgscan_method_;
72 uint16 bgscan_short_interval_;
73 int32 bgscan_signal_threshold_;
74 bool scan_pending_;
75 uint16 scan_interval_;
76
mukesh agrawal31950242011-07-14 11:53:38 -070077 friend class WiFiMainTest; // access to supplicant_*_proxy_ fields
Paul Stewartb50f0b92011-05-16 16:31:42 -070078 DISALLOW_COPY_AND_ASSIGN(WiFi);
79};
80
81} // namespace shill
82
83#endif // SHILL_WIFI_