mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 1 | // 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 agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 9 | #include <set> |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | #include <base/memory/ref_counted.h> |
| 14 | #include <dbus-c++/dbus.h> |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 15 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 16 | |
| 17 | #include "shill/endpoint.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 18 | #include "shill/event_dispatcher.h" |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 19 | |
| 20 | namespace shill { |
| 21 | |
| 22 | class WiFiEndpoint : public Endpoint { |
| 23 | public: |
| 24 | WiFiEndpoint(const std::map<std::string, ::DBus::Variant> &properties); |
| 25 | virtual ~WiFiEndpoint(); |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame] | 26 | |
| 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 agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 31 | 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 Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame] | 37 | const std::string &network_mode() const; |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 38 | const std::string &security_mode() const; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 39 | |
| 40 | private: |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 41 | 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 agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 46 | |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 47 | enum KeyManagement { |
| 48 | kKeyManagement802_1x, |
| 49 | kKeyManagementPSK |
| 50 | }; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 51 | |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame] | 52 | // 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 agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 55 | // 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 agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 64 | |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 65 | // TODO(quiche): make const? |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 66 | 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 agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 73 | // network_mode_ and security_mode_ are represented as flimflam names |
| 74 | // (not necessarily the same as wpa_supplicant names) |
Chris Masone | 092df3e | 2011-08-22 09:41:39 -0700 | [diff] [blame] | 75 | std::string network_mode_; |
mukesh agrawal | 6e27777 | 2011-09-29 15:04:23 -0700 | [diff] [blame] | 76 | std::string security_mode_; |
mukesh agrawal | b54601c | 2011-06-07 17:39:22 -0700 | [diff] [blame] | 77 | |
| 78 | DISALLOW_COPY_AND_ASSIGN(WiFiEndpoint); |
| 79 | }; |
| 80 | |
| 81 | } // namespace shill |
| 82 | |
| 83 | #endif // SHILL_WIFI_ENDPOINT_ |