blob: d962de43d5a73e01faa455159fa5f37b03738412 [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
Paul Stewartb50f0b92011-05-16 16:31:42 -070012#include "shill/device.h"
13#include "shill/shill_event.h"
mukesh agrawalab87ea42011-05-18 11:44:49 -070014#include "shill/supplicant-process.h"
15#include "shill/supplicant-interface.h"
Paul Stewartb50f0b92011-05-16 16:31:42 -070016
17namespace shill {
18
mukesh agrawalab87ea42011-05-18 11:44:49 -070019// WiFi class. Specialization of Device for WiFi.
Paul Stewartb50f0b92011-05-16 16:31:42 -070020class WiFi : public Device {
21 public:
Paul Stewartf1ce5d22011-05-19 13:10:20 -070022 WiFi(ControlInterface *control_interface,
23 EventDispatcher *dispatcher,
24 Manager *manager,
25 const std::string& link_name,
26 int interface_index);
mukesh agrawalab87ea42011-05-18 11:44:49 -070027 virtual ~WiFi();
28 virtual void Start();
29 virtual void Stop();
30 virtual bool TechnologyIs(const Technology type);
31
32 // called by SupplicantInterfaceProxy, in response to events from
33 // wpa_supplicant.
34 void BSSAdded(const ::DBus::Path &BSS,
35 const std::map<std::string, ::DBus::Variant>
36 &properties);
37 void ScanDone();
38
Paul Stewartb50f0b92011-05-16 16:31:42 -070039 private:
mukesh agrawalab87ea42011-05-18 11:44:49 -070040 // SupplicantProcessProxy. provides access to wpa_supplicant's
41 // process-level D-Bus APIs.
42 class SupplicantProcessProxy :
43 public fi::w1::wpa_supplicant1_proxy,
44 private ::DBus::ObjectProxy // used by dbus-c++, not WiFi
45 {
46 public:
47 explicit SupplicantProcessProxy(DBus::Connection *bus);
48
49 private:
50 // called by dbus-c++, via wpa_supplicant1_proxy interface,
51 // in response to signals from wpa_supplicant. not exposed
52 // to WiFi.
53 virtual void InterfaceAdded(
54 const ::DBus::Path &path,
55 const std::map<std::string, ::DBus::Variant> &properties);
56 virtual void InterfaceRemoved(const ::DBus::Path &path);
57 virtual void PropertiesChanged(
58 const std::map<std::string, ::DBus::Variant> &properties);
59 };
60
61 // SupplicantInterfaceProxy. provides access to wpa_supplicant's
62 // network-interface D-Bus APIs.
63 class SupplicantInterfaceProxy :
64 public fi::w1::wpa_supplicant1::Interface_proxy,
65 private ::DBus::ObjectProxy // used by dbus-c++, not WiFi
66 {
67 public:
68 SupplicantInterfaceProxy(WiFi *wifi, DBus::Connection *bus,
69 const ::DBus::Path &object_path);
70
71 private:
72 // called by dbus-c++, via Interface_proxy interface,
73 // in response to signals from wpa_supplicant. not exposed
74 // to WiFi.
75 virtual void ScanDone(const bool &success);
76 virtual void BSSAdded(const ::DBus::Path &BSS,
77 const std::map<std::string, ::DBus::Variant>
78 &properties);
79 virtual void BSSRemoved(const ::DBus::Path &BSS);
80 virtual void BlobAdded(const std::string &blobname);
81 virtual void BlobRemoved(const std::string &blobname);
82 virtual void NetworkAdded(const ::DBus::Path &network,
83 const std::map<std::string, ::DBus::Variant>
84 &properties);
85 virtual void NetworkRemoved(const ::DBus::Path &network);
86 virtual void NetworkSelected(const ::DBus::Path &network);
87 virtual void PropertiesChanged(const std::map<std::string, ::DBus::Variant>
88 &properties);
89
90 WiFi &wifi_;
91 };
92
93 static const char kSupplicantPath[];
94 static const char kSupplicantDBusAddr[];
95 static const char kSupplicantWiFiDriver[];
96
97 DBus::Connection dbus_;
98 scoped_ptr<SupplicantProcessProxy> supplicant_process_proxy_;
99 scoped_ptr<SupplicantInterfaceProxy> supplicant_interface_proxy_;
100 bool scan_pending_;
101 std::vector<std::string> ssids_;
102
103 // provide WiFiTest access to scan_pending_, so it can determine
104 // if the scan completed, or timed out.
105 friend class WiFiTest;
Paul Stewartb50f0b92011-05-16 16:31:42 -0700106 DISALLOW_COPY_AND_ASSIGN(WiFi);
107};
108
109} // namespace shill
110
111#endif // SHILL_WIFI_