OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/network/onc/onc_translation_tables.h" | 5 #include "chromeos/network/onc/onc_translation_tables.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
| 9 #include "base/logging.h" |
9 #include "chromeos/network/onc/onc_constants.h" | 10 #include "chromeos/network/onc/onc_constants.h" |
10 #include "third_party/cros_system_api/dbus/service_constants.h" | 11 #include "third_party/cros_system_api/dbus/service_constants.h" |
11 | 12 |
12 namespace chromeos { | 13 namespace chromeos { |
13 namespace onc { | 14 namespace onc { |
14 | 15 |
15 const StringTranslationEntry kNetworkTypeTable[] = { | 16 const StringTranslationEntry kNetworkTypeTable[] = { |
16 { kEthernet, flimflam::kTypeEthernet }, | 17 { network_type::kEthernet, flimflam::kTypeEthernet }, |
17 { kWiFi, flimflam::kTypeWifi }, | 18 { network_type::kWiFi, flimflam::kTypeWifi }, |
18 { kCellular, flimflam::kTypeCellular }, | 19 { network_type::kCellular, flimflam::kTypeCellular }, |
19 { kVPN, flimflam::kTypeVPN }, | 20 { network_type::kVPN, flimflam::kTypeVPN }, |
20 { NULL } | 21 { NULL } |
21 }; | 22 }; |
22 | 23 |
23 const StringTranslationEntry kVPNTypeTable[] = { | 24 const StringTranslationEntry kVPNTypeTable[] = { |
24 { vpn::kTypeL2TP_IPsec, flimflam::kProviderL2tpIpsec }, | 25 { vpn::kTypeL2TP_IPsec, flimflam::kProviderL2tpIpsec }, |
25 { vpn::kOpenVPN, flimflam::kProviderOpenVpn }, | 26 { vpn::kOpenVPN, flimflam::kProviderOpenVpn }, |
26 { NULL } | 27 { NULL } |
27 }; | 28 }; |
28 | 29 |
29 const StringTranslationEntry kWiFiSecurityTable[] = { | 30 const StringTranslationEntry kWiFiSecurityTable[] = { |
(...skipping 20 matching lines...) Expand all Loading... |
50 }; | 51 }; |
51 | 52 |
52 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS | 53 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS |
53 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { | 54 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { |
54 { eap::kMD5, flimflam::kEapPhase2AuthTTLSMD5 }, | 55 { eap::kMD5, flimflam::kEapPhase2AuthTTLSMD5 }, |
55 { eap::kMSCHAPv2, flimflam::kEapPhase2AuthTTLSMSCHAPV2 }, | 56 { eap::kMSCHAPv2, flimflam::kEapPhase2AuthTTLSMSCHAPV2 }, |
56 { eap::kPAP, flimflam::kEapPhase2AuthTTLSPAP }, | 57 { eap::kPAP, flimflam::kEapPhase2AuthTTLSPAP }, |
57 { NULL } | 58 { NULL } |
58 }; | 59 }; |
59 | 60 |
| 61 bool TranslateStringToShill(const StringTranslationEntry table[], |
| 62 const std::string& onc_value, |
| 63 std::string* shill_value) { |
| 64 for (int i = 0; table[i].onc_value != NULL; ++i) { |
| 65 if (onc_value != table[i].onc_value) |
| 66 continue; |
| 67 *shill_value = table[i].shill_value; |
| 68 return true; |
| 69 } |
| 70 LOG(ERROR) << "Value '" << onc_value << "cannot be translated to Shill"; |
| 71 return false; |
| 72 } |
| 73 |
| 74 bool TranslateStringToONC(const StringTranslationEntry table[], |
| 75 const std::string& shill_value, |
| 76 std::string* onc_value) { |
| 77 for (int i = 0; table[i].shill_value != NULL; ++i) { |
| 78 if (shill_value != table[i].shill_value) |
| 79 continue; |
| 80 *onc_value = table[i].onc_value; |
| 81 return true; |
| 82 } |
| 83 LOG(ERROR) << "Value '" << shill_value << "cannot be translated to ONC"; |
| 84 return false; |
| 85 } |
60 | 86 |
61 } // namespace onc | 87 } // namespace onc |
62 } // namespace chromeos | 88 } // namespace chromeos |
OLD | NEW |