blob: 00934258b9b9b2ff89e279f110edc815eb4777df [file] [log] [blame]
mukesh agrawalb54601c2011-06-07 17:39:22 -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_ENDPOINT_
6#define SHILL_WIFI_ENDPOINT_
7
8#include <map>
mukesh agrawal6e277772011-09-29 15:04:23 -07009#include <set>
mukesh agrawalb54601c2011-06-07 17:39:22 -070010#include <string>
11#include <vector>
12
13#include <base/memory/ref_counted.h>
14#include <dbus-c++/dbus.h>
mukesh agrawal6e277772011-09-29 15:04:23 -070015#include <gtest/gtest_prod.h> // for FRIEND_TEST
mukesh agrawalb54601c2011-06-07 17:39:22 -070016
17#include "shill/endpoint.h"
Paul Stewart26b327e2011-10-19 11:38:09 -070018#include "shill/event_dispatcher.h"
mukesh agrawalb54601c2011-06-07 17:39:22 -070019
20namespace shill {
21
22class WiFiEndpoint : public Endpoint {
23 public:
24 WiFiEndpoint(const std::map<std::string, ::DBus::Variant> &properties);
25 virtual ~WiFiEndpoint();
Chris Masone092df3e2011-08-22 09:41:39 -070026
27 // Maps mode strings from flimflam's nomenclature, as defined
28 // in chromeos/dbus/service_constants.h, to uints used by supplicant
29 static uint32_t ModeStringToUint(const std::string &mode_string);
30
mukesh agrawalb54601c2011-06-07 17:39:22 -070031 const std::vector<uint8_t> &ssid() const;
32 const std::string &ssid_string() const;
33 const std::string &ssid_hex() const;
34 const std::string &bssid_string() const;
35 const std::string &bssid_hex() const;
36 int16_t signal_strength() const;
Chris Masone092df3e2011-08-22 09:41:39 -070037 const std::string &network_mode() const;
mukesh agrawal6e277772011-09-29 15:04:23 -070038 const std::string &security_mode() const;
mukesh agrawalb54601c2011-06-07 17:39:22 -070039
40 private:
mukesh agrawal6e277772011-09-29 15:04:23 -070041 friend class WiFiEndpointTest;
42 // these test cases need access to the KeyManagement enum
43 FRIEND_TEST(WiFiEndpointTest, ParseKeyManagementMethodsEAP);
44 FRIEND_TEST(WiFiEndpointTest, ParseKeyManagementMethodsPSK);
45 FRIEND_TEST(WiFiEndpointTest, ParseKeyManagementMethodsEAPAndPSK);
mukesh agrawalb54601c2011-06-07 17:39:22 -070046
mukesh agrawal6e277772011-09-29 15:04:23 -070047 enum KeyManagement {
48 kKeyManagement802_1x,
49 kKeyManagementPSK
50 };
mukesh agrawalb54601c2011-06-07 17:39:22 -070051
Chris Masone092df3e2011-08-22 09:41:39 -070052 // Maps mode strings from supplicant into flimflam's nomenclature, as defined
53 // in chromeos/dbus/service_constants.h
54 static const char *ParseMode(const std::string &mode_string);
mukesh agrawal6e277772011-09-29 15:04:23 -070055 // Parses an Endpoint's properties to identify approprirate flimflam
56 // security property value, as defined in chromeos/dbus/service_constants.h
57 static const char *ParseSecurity(
58 const std::map<std::string, ::DBus::Variant> &properties);
59 // Parses and Endpoint's properties' "RSN" or "WPA" sub-dictionary, to
60 // identify supported key management methods (802.1x or PSK).
61 static void ParseKeyManagementMethods(
62 const std::map<std::string, ::DBus::Variant> &security_method_properties,
63 std::set<KeyManagement> *key_management_methods);
mukesh agrawalb54601c2011-06-07 17:39:22 -070064
mukesh agrawal6e277772011-09-29 15:04:23 -070065 // TODO(quiche): make const?
mukesh agrawalb54601c2011-06-07 17:39:22 -070066 std::vector<uint8_t> ssid_;
67 std::vector<uint8_t> bssid_;
68 std::string ssid_string_;
69 std::string ssid_hex_;
70 std::string bssid_string_;
71 std::string bssid_hex_;
72 int16_t signal_strength_;
mukesh agrawal6e277772011-09-29 15:04:23 -070073 // network_mode_ and security_mode_ are represented as flimflam names
74 // (not necessarily the same as wpa_supplicant names)
Chris Masone092df3e2011-08-22 09:41:39 -070075 std::string network_mode_;
mukesh agrawal6e277772011-09-29 15:04:23 -070076 std::string security_mode_;
mukesh agrawalb54601c2011-06-07 17:39:22 -070077
78 DISALLOW_COPY_AND_ASSIGN(WiFiEndpoint);
79};
80
81} // namespace shill
82
83#endif // SHILL_WIFI_ENDPOINT_