| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" | 
| 6 | 6 | 
| 7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> | 
| 8 #include <objbase.h> | 8 #include <objbase.h> | 
| 9 #include <wlanapi.h> | 9 #include <wlanapi.h> | 
| 10 | 10 | 
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1249 std::string WiFiServiceImpl::SecurityFromDot11AuthAlg( | 1249 std::string WiFiServiceImpl::SecurityFromDot11AuthAlg( | 
| 1250     DOT11_AUTH_ALGORITHM alg) const { | 1250     DOT11_AUTH_ALGORITHM alg) const { | 
| 1251   switch (alg) { | 1251   switch (alg) { | 
| 1252     case DOT11_AUTH_ALGO_RSNA: | 1252     case DOT11_AUTH_ALGO_RSNA: | 
| 1253       return onc::wifi::kWPA_EAP; | 1253       return onc::wifi::kWPA_EAP; | 
| 1254     case DOT11_AUTH_ALGO_RSNA_PSK: | 1254     case DOT11_AUTH_ALGO_RSNA_PSK: | 
| 1255       return onc::wifi::kWPA_PSK; | 1255       return onc::wifi::kWPA_PSK; | 
| 1256     case DOT11_AUTH_ALGO_80211_SHARED_KEY: | 1256     case DOT11_AUTH_ALGO_80211_SHARED_KEY: | 
| 1257       return onc::wifi::kWEP_PSK; | 1257       return onc::wifi::kWEP_PSK; | 
| 1258     case DOT11_AUTH_ALGO_80211_OPEN: | 1258     case DOT11_AUTH_ALGO_80211_OPEN: | 
| 1259       return onc::wifi::kNone; | 1259       return onc::wifi::kSecurityNone; | 
| 1260     default: | 1260     default: | 
| 1261       return onc::wifi::kWPA_EAP; | 1261       return onc::wifi::kWPA_EAP; | 
| 1262   } | 1262   } | 
| 1263 } | 1263 } | 
| 1264 | 1264 | 
| 1265 std::string WiFiServiceImpl::ConnectionStateFromInterfaceState( | 1265 std::string WiFiServiceImpl::ConnectionStateFromInterfaceState( | 
| 1266     WLAN_INTERFACE_STATE wlan_state) const { | 1266     WLAN_INTERFACE_STATE wlan_state) const { | 
| 1267   switch (wlan_state) { | 1267   switch (wlan_state) { | 
| 1268     case wlan_interface_state_connected: | 1268     case wlan_interface_state_connected: | 
| 1269       // TODO(mef): Even if |wlan_state| is connected, the network may still | 1269       // TODO(mef): Even if |wlan_state| is connected, the network may still | 
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1593       // If network is available, but is not open security, then it cannot be | 1593       // If network is available, but is not open security, then it cannot be | 
| 1594       // connected without profile, so return 'access denied' error. | 1594       // connected without profile, so return 'access denied' error. | 
| 1595       scoped_ptr<base::DictionaryValue> properties (new base::DictionaryValue); | 1595       scoped_ptr<base::DictionaryValue> properties (new base::DictionaryValue); | 
| 1596       const base::DictionaryValue* wifi; | 1596       const base::DictionaryValue* wifi; | 
| 1597       std::string wifi_security; | 1597       std::string wifi_security; | 
| 1598       std::string error_string; | 1598       std::string error_string; | 
| 1599       GetProperties(network_guid, properties.get(), &error_string); | 1599       GetProperties(network_guid, properties.get(), &error_string); | 
| 1600       if (error_string.empty() && | 1600       if (error_string.empty() && | 
| 1601           properties->GetDictionary(onc::network_type::kWiFi, &wifi) && | 1601           properties->GetDictionary(onc::network_type::kWiFi, &wifi) && | 
| 1602           wifi->GetString(onc::wifi::kSecurity, &wifi_security) && | 1602           wifi->GetString(onc::wifi::kSecurity, &wifi_security) && | 
| 1603           wifi_security != onc::wifi::kNone) { | 1603           wifi_security != onc::wifi::kSecurityNone) { | 
| 1604         error = ERROR_ACCESS_DENIED; | 1604         error = ERROR_ACCESS_DENIED; | 
| 1605         LOG(ERROR) << error; | 1605         LOG(ERROR) << error; | 
| 1606         return error; | 1606         return error; | 
| 1607       } | 1607       } | 
| 1608       WLAN_CONNECTION_PARAMETERS wlan_params = { | 1608       WLAN_CONNECTION_PARAMETERS wlan_params = { | 
| 1609           wlan_connection_mode_discovery_unsecure, | 1609           wlan_connection_mode_discovery_unsecure, | 
| 1610           NULL, | 1610           NULL, | 
| 1611           &ssid, | 1611           &ssid, | 
| 1612           desired_bss_list.get(), | 1612           desired_bss_list.get(), | 
| 1613           dot11_BSS_type_infrastructure, | 1613           dot11_BSS_type_infrastructure, | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1736     return kEncryptionTKIP; | 1736     return kEncryptionTKIP; | 
| 1737   return kEncryptionAES; | 1737   return kEncryptionAES; | 
| 1738 } | 1738 } | 
| 1739 | 1739 | 
| 1740 bool WiFiServiceImpl::AuthEncryptionFromSecurity( | 1740 bool WiFiServiceImpl::AuthEncryptionFromSecurity( | 
| 1741     const std::string& security, | 1741     const std::string& security, | 
| 1742     EncryptionType encryption_type, | 1742     EncryptionType encryption_type, | 
| 1743     std::string* authentication, | 1743     std::string* authentication, | 
| 1744     std::string* encryption, | 1744     std::string* encryption, | 
| 1745     std::string* key_type) const { | 1745     std::string* key_type) const { | 
| 1746   if (security == onc::wifi::kNone) { | 1746   if (security == onc::wifi::kSecurityNone) { | 
| 1747     *authentication = kAuthenticationOpen; | 1747     *authentication = kAuthenticationOpen; | 
| 1748     *encryption = kEncryptionNone; | 1748     *encryption = kEncryptionNone; | 
| 1749   } else if (security == onc::wifi::kWEP_PSK) { | 1749   } else if (security == onc::wifi::kWEP_PSK) { | 
| 1750     *authentication = kAuthenticationOpen; | 1750     *authentication = kAuthenticationOpen; | 
| 1751     *encryption = kEncryptionWEP; | 1751     *encryption = kEncryptionWEP; | 
| 1752     *key_type = kKeyTypeNetwork; | 1752     *key_type = kKeyTypeNetwork; | 
| 1753   } else if (security == onc::wifi::kWPA_PSK) { | 1753   } else if (security == onc::wifi::kWPA_PSK) { | 
| 1754     *authentication = kAuthenticationWpaPsk; | 1754     *authentication = kAuthenticationWpaPsk; | 
| 1755     *encryption = WpaEncryptionFromEncryptionType(encryption_type); | 1755     *encryption = WpaEncryptionFromEncryptionType(encryption_type); | 
| 1756     *key_type = kKeyTypePassphrase; | 1756     *key_type = kKeyTypePassphrase; | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1840     NetworkGuidList changed_networks(1, network_guid); | 1840     NetworkGuidList changed_networks(1, network_guid); | 
| 1841     message_loop_proxy_->PostTask( | 1841     message_loop_proxy_->PostTask( | 
| 1842         FROM_HERE, | 1842         FROM_HERE, | 
| 1843         base::Bind(networks_changed_observer_, changed_networks)); | 1843         base::Bind(networks_changed_observer_, changed_networks)); | 
| 1844   } | 1844   } | 
| 1845 } | 1845 } | 
| 1846 | 1846 | 
| 1847 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 1847 WiFiService* WiFiService::Create() { return new WiFiServiceImpl(); } | 
| 1848 | 1848 | 
| 1849 }  // namespace wifi | 1849 }  // namespace wifi | 
| OLD | NEW | 
|---|