blob: a79067891b6f82bc1e9cc42345f42fa4b550d5ee [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"
mukesh agrawalaf571952011-07-14 14:31:12 -070017#include "shill/supplicant_proxy_factory.h"
Paul Stewartb50f0b92011-05-16 16:31:42 -070018
19namespace shill {
20
mukesh agrawalaf571952011-07-14 14:31:12 -070021class SupplicantInterfaceProxyInterface;
22class SupplicantProcessProxyInterface;
mukesh agrawal445e72c2011-06-22 11:13:50 -070023class WiFiService;
mukesh agrawalb54601c2011-06-07 17:39:22 -070024
mukesh agrawalab87ea42011-05-18 11:44:49 -070025// WiFi class. Specialization of Device for WiFi.
Paul Stewartb50f0b92011-05-16 16:31:42 -070026class WiFi : public Device {
27 public:
Paul Stewartf1ce5d22011-05-19 13:10:20 -070028 WiFi(ControlInterface *control_interface,
29 EventDispatcher *dispatcher,
30 Manager *manager,
Chris Masone3bd3c8c2011-06-13 08:20:26 -070031 const std::string& link,
Paul Stewartf1ce5d22011-05-19 13:10:20 -070032 int interface_index);
mukesh agrawalab87ea42011-05-18 11:44:49 -070033 virtual ~WiFi();
34 virtual void Start();
35 virtual void Stop();
36 virtual bool TechnologyIs(const Technology type);
37
38 // called by SupplicantInterfaceProxy, in response to events from
39 // wpa_supplicant.
40 void BSSAdded(const ::DBus::Path &BSS,
Chris Masonea82b7112011-05-25 15:16:29 -070041 const std::map<std::string, ::DBus::Variant> &properties);
mukesh agrawalab87ea42011-05-18 11:44:49 -070042 void ScanDone();
43
mukesh agrawal445e72c2011-06-22 11:13:50 -070044 // called by WiFiService
45 void ConnectTo(const WiFiService &service);
mukesh agrawalb54601c2011-06-07 17:39:22 -070046
mukesh agrawalaf571952011-07-14 14:31:12 -070047 static void set_proxy_factory(SupplicantProxyFactory *factory);
48
Paul Stewartb50f0b92011-05-16 16:31:42 -070049 private:
mukesh agrawalb54601c2011-06-07 17:39:22 -070050 typedef std::map<const std::string, WiFiEndpointRefPtr> EndpointMap;
51 typedef std::map<const std::string, ServiceRefPtr> ServiceMap;
52
mukesh agrawalab87ea42011-05-18 11:44:49 -070053 static const char kSupplicantPath[];
54 static const char kSupplicantDBusAddr[];
55 static const char kSupplicantWiFiDriver[];
mukesh agrawalc7426a42011-06-03 13:04:28 -070056 static const char kSupplicantErrorInterfaceExists[];
mukesh agrawal445e72c2011-06-22 11:13:50 -070057 static const char kSupplicantPropertySSID[];
58 static const char kSupplicantPropertyNetworkMode[];
59 static const char kSupplicantPropertyKeyMode[];
mukesh agrawalb54601c2011-06-07 17:39:22 -070060 static const char kSupplicantKeyModeNone[];
mukesh agrawalab87ea42011-05-18 11:44:49 -070061
mukesh agrawalb54601c2011-06-07 17:39:22 -070062 void RealScanDone();
63
mukesh agrawalaf571952011-07-14 14:31:12 -070064 static SupplicantProxyFactory *proxy_factory;
mukesh agrawalb54601c2011-06-07 17:39:22 -070065 static unsigned int service_id_serial_;
66 ScopedRunnableMethodFactory<WiFi> task_factory_;
67 ControlInterface *control_interface_;
68 EventDispatcher *dispatcher_;
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_;
80
Paul Stewartb50f0b92011-05-16 16:31:42 -070081 DISALLOW_COPY_AND_ASSIGN(WiFi);
82};
83
84} // namespace shill
85
86#endif // SHILL_WIFI_