Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chromeos/network/onc/onc_translation_tables.cc

Issue 402953004: Correctly translate Cellular Device properties to ONC (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore cellular_with_state signature, add nested ShillToONCTranslator constructor, update tests Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/logging.h"
10 #include "components/onc/onc_constants.h" 10 #include "components/onc/onc_constants.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // { ::onc::wifi::kSSID, shill::kWifiHexSsid}, 115 // { ::onc::wifi::kSSID, shill::kWifiHexSsid},
116 // This field is converted during translation, see onc_translator_*. 116 // This field is converted during translation, see onc_translator_*.
117 // { ::onc::wifi::kSecurity, shill::kSecurityProperty }, 117 // { ::onc::wifi::kSecurity, shill::kSecurityProperty },
118 { ::onc::wifi::kSignalStrength, shill::kSignalStrengthProperty}, 118 { ::onc::wifi::kSignalStrength, shill::kSignalStrengthProperty},
119 {NULL}}; 119 {NULL}};
120 120
121 const FieldTranslationEntry cellular_apn_fields[] = { 121 const FieldTranslationEntry cellular_apn_fields[] = {
122 { ::onc::cellular_apn::kName, shill::kApnProperty}, 122 { ::onc::cellular_apn::kName, shill::kApnProperty},
123 { ::onc::cellular_apn::kUsername, shill::kApnUsernameProperty}, 123 { ::onc::cellular_apn::kUsername, shill::kApnUsernameProperty},
124 { ::onc::cellular_apn::kPassword, shill::kApnPasswordProperty}, 124 { ::onc::cellular_apn::kPassword, shill::kApnPasswordProperty},
125 { ::onc::cellular_apn::kLocalizedName, shill::kApnLocalizedNameProperty},
126 { ::onc::cellular_apn::kLanguage, shill::kApnLanguageProperty},
127 {NULL}};
128
129 const FieldTranslationEntry cellular_found_network_fields[] = {
130 { ::onc::cellular_found_network::kNetworkId, shill::kNetworkIdProperty},
131 { ::onc::cellular_found_network::kStatus, shill::kStatusProperty},
132 { ::onc::cellular_found_network::kTechnology, shill::kTechnologyProperty},
133 { ::onc::cellular_found_network::kShortName, shill::kShortNameProperty},
134 { ::onc::cellular_found_network::kLongName, shill::kLongNameProperty},
125 {NULL}}; 135 {NULL}};
126 136
127 const FieldTranslationEntry cellular_provider_fields[] = { 137 const FieldTranslationEntry cellular_provider_fields[] = {
128 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey}, 138 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey},
129 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey}, 139 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey},
130 { ::onc::cellular_provider::kName, shill::kOperatorNameKey}, 140 { ::onc::cellular_provider::kName, shill::kOperatorNameKey},
131 {NULL}}; 141 {NULL}};
132 142
143 const FieldTranslationEntry sim_lock_status_fields[] = {
144 { ::onc::sim_lock_status::kLockEnabled, shill::kSIMLockEnabledProperty},
145 { ::onc::sim_lock_status::kLockType, shill::kSIMLockTypeProperty},
146 { ::onc::sim_lock_status::kRetriesLeft, shill::kSIMLockRetriesLeftProperty},
147 {NULL}};
148
133 // This must only contain Service properties and not Device properties. 149 // This must only contain Service properties and not Device properties.
134 // For Device properties see kCellularDeviceTable. 150 // For Device properties see kCellularDeviceTable.
135 const FieldTranslationEntry cellular_fields[] = { 151 const FieldTranslationEntry cellular_fields[] = {
136 { ::onc::cellular::kActivateOverNonCellularNetwork, 152 { ::onc::cellular::kActivateOverNonCellularNetwork,
137 shill::kActivateOverNonCellularNetworkProperty}, 153 shill::kActivateOverNonCellularNetworkProperty},
138 { ::onc::cellular::kActivationState, shill::kActivationStateProperty}, 154 { ::onc::cellular::kActivationState, shill::kActivationStateProperty},
139 { ::onc::cellular::kNetworkTechnology, shill::kNetworkTechnologyProperty}, 155 { ::onc::cellular::kNetworkTechnology, shill::kNetworkTechnologyProperty},
140 { ::onc::cellular::kRoamingState, shill::kRoamingStateProperty}, 156 { ::onc::cellular::kRoamingState, shill::kRoamingStateProperty},
141 {NULL}}; 157 {NULL}};
142 158
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 { &kEAPSignature, eap_fields }, 194 { &kEAPSignature, eap_fields },
179 { &kIPsecSignature, ipsec_fields }, 195 { &kIPsecSignature, ipsec_fields },
180 { &kL2TPSignature, l2tp_fields }, 196 { &kL2TPSignature, l2tp_fields },
181 { &kXAUTHSignature, xauth_fields }, 197 { &kXAUTHSignature, xauth_fields },
182 { &kOpenVPNSignature, openvpn_fields }, 198 { &kOpenVPNSignature, openvpn_fields },
183 { &kVerifyX509Signature, verify_x509_fields }, 199 { &kVerifyX509Signature, verify_x509_fields },
184 { &kVPNSignature, vpn_fields }, 200 { &kVPNSignature, vpn_fields },
185 { &kWiFiSignature, wifi_fields }, 201 { &kWiFiSignature, wifi_fields },
186 { &kWiFiWithStateSignature, wifi_fields }, 202 { &kWiFiWithStateSignature, wifi_fields },
187 { &kCellularApnSignature, cellular_apn_fields }, 203 { &kCellularApnSignature, cellular_apn_fields },
204 { &kCellularFoundNetworkSignature, cellular_found_network_fields },
188 { &kCellularProviderSignature, cellular_provider_fields }, 205 { &kCellularProviderSignature, cellular_provider_fields },
206 { &kSIMLockStatusSignature, sim_lock_status_fields },
189 { &kCellularSignature, cellular_fields }, 207 { &kCellularSignature, cellular_fields },
190 { &kCellularWithStateSignature, cellular_fields }, 208 { &kCellularWithStateSignature, cellular_fields },
191 { &kNetworkWithStateSignature, network_fields }, 209 { &kNetworkWithStateSignature, network_fields },
192 { &kNetworkConfigurationSignature, network_fields }, 210 { &kNetworkConfigurationSignature, network_fields },
193 { &kIPConfigSignature, ipconfig_fields }, 211 { &kIPConfigSignature, ipconfig_fields },
194 { NULL } 212 { NULL }
195 }; 213 };
196 214
197 struct NestedShillDictionaryEntry { 215 struct NestedShillDictionaryEntry {
198 const OncValueSignature* onc_signature; 216 const OncValueSignature* onc_signature;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS 269 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS
252 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { 270 const StringTranslationEntry kEAP_TTLS_InnerTable[] = {
253 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5}, 271 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5},
254 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2}, 272 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2},
255 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP}, 273 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP},
256 {NULL}}; 274 {NULL}};
257 275
258 // This must contain only Shill Device properties and no Service properties. 276 // This must contain only Shill Device properties and no Service properties.
259 // For Service properties see cellular_fields. 277 // For Service properties see cellular_fields.
260 const FieldTranslationEntry kCellularDeviceTable[] = { 278 const FieldTranslationEntry kCellularDeviceTable[] = {
279 // This field is converted during translation, see onc_translator_*.
280 // { ::onc::cellular::kAPNList, shill::kCellularApnListProperty},
261 { ::onc::cellular::kAllowRoaming, shill::kCellularAllowRoamingProperty}, 281 { ::onc::cellular::kAllowRoaming, shill::kCellularAllowRoamingProperty},
262 { ::onc::cellular::kCarrier, shill::kCarrierProperty}, 282 { ::onc::cellular::kCarrier, shill::kCarrierProperty},
263 { ::onc::cellular::kESN, shill::kEsnProperty}, 283 { ::onc::cellular::kESN, shill::kEsnProperty},
264 { ::onc::cellular::kFamily, shill::kTechnologyFamilyProperty}, 284 { ::onc::cellular::kFamily, shill::kTechnologyFamilyProperty},
265 { ::onc::cellular::kFirmwareRevision, shill::kFirmwareRevisionProperty}, 285 { ::onc::cellular::kFirmwareRevision, shill::kFirmwareRevisionProperty},
266 { ::onc::cellular::kFoundNetworks, shill::kFoundNetworksProperty}, 286 // This field is converted during translation, see onc_translator_*.
287 // { ::onc::cellular::kFoundNetworks, shill::kFoundNetworksProperty},
267 { ::onc::cellular::kHardwareRevision, shill::kHardwareRevisionProperty}, 288 { ::onc::cellular::kHardwareRevision, shill::kHardwareRevisionProperty},
268 { ::onc::cellular::kHomeProvider, shill::kHomeProviderProperty}, 289 { ::onc::cellular::kHomeProvider, shill::kHomeProviderProperty},
269 { ::onc::cellular::kICCID, shill::kIccidProperty}, 290 { ::onc::cellular::kICCID, shill::kIccidProperty},
270 { ::onc::cellular::kIMEI, shill::kImeiProperty}, 291 { ::onc::cellular::kIMEI, shill::kImeiProperty},
271 { ::onc::cellular::kIMSI, shill::kImsiProperty}, 292 { ::onc::cellular::kIMSI, shill::kImsiProperty},
272 { ::onc::cellular::kManufacturer, shill::kManufacturerProperty}, 293 { ::onc::cellular::kManufacturer, shill::kManufacturerProperty},
273 { ::onc::cellular::kMDN, shill::kMdnProperty}, 294 { ::onc::cellular::kMDN, shill::kMdnProperty},
274 { ::onc::cellular::kMEID, shill::kMeidProperty}, 295 { ::onc::cellular::kMEID, shill::kMeidProperty},
275 { ::onc::cellular::kMIN, shill::kMinProperty}, 296 { ::onc::cellular::kMIN, shill::kMinProperty},
276 { ::onc::cellular::kModelID, shill::kModelIDProperty}, 297 { ::onc::cellular::kModelID, shill::kModelIDProperty},
277 { ::onc::cellular::kPRLVersion, shill::kPRLVersionProperty}, 298 { ::onc::cellular::kPRLVersion, shill::kPRLVersionProperty},
278 { ::onc::cellular::kProviderRequiresRoaming, 299 { ::onc::cellular::kProviderRequiresRoaming,
279 shill::kProviderRequiresRoamingProperty}, 300 shill::kProviderRequiresRoamingProperty},
280 { ::onc::cellular::kSelectedNetwork, shill::kSelectedNetworkProperty}, 301 { ::onc::cellular::kSelectedNetwork, shill::kSelectedNetworkProperty},
281 { ::onc::cellular::kSIMLockEnabled, shill::kSIMLockEnabledProperty}, 302 // This field is converted during translation, see onc_translator_*.
282 { ::onc::cellular::kSIMLockStatus, shill::kSIMLockStatusProperty}, 303 // { ::onc::cellular::kSIMLockStatus, shill::kSIMLockStatusProperty},
283 { ::onc::cellular::kSIMLockType, shill::kSIMLockTypeProperty},
284 { ::onc::cellular::kSIMPresent, shill::kSIMPresentProperty}, 304 { ::onc::cellular::kSIMPresent, shill::kSIMPresentProperty},
285 { ::onc::cellular::kSupportedCarriers, shill::kSupportedCarriersProperty}, 305 { ::onc::cellular::kSupportedCarriers, shill::kSupportedCarriersProperty},
286 { ::onc::cellular::kSupportNetworkScan, shill::kSupportNetworkScanProperty}, 306 { ::onc::cellular::kSupportNetworkScan, shill::kSupportNetworkScanProperty},
287 {NULL}}; 307 {NULL}};
288 308
289 const FieldTranslationEntry* GetFieldTranslationTable( 309 const FieldTranslationEntry* GetFieldTranslationTable(
290 const OncValueSignature& onc_signature) { 310 const OncValueSignature& onc_signature) {
291 for (const OncValueTranslationEntry* it = onc_value_translation_table; 311 for (const OncValueTranslationEntry* it = onc_value_translation_table;
292 it->onc_signature != NULL; ++it) { 312 it->onc_signature != NULL; ++it) {
293 if (it->onc_signature == &onc_signature) 313 if (it->onc_signature == &onc_signature)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 continue; 366 continue;
347 *onc_value = table[i].onc_value; 367 *onc_value = table[i].onc_value;
348 return true; 368 return true;
349 } 369 }
350 LOG(ERROR) << "Value '" << shill_value << "' cannot be translated to ONC"; 370 LOG(ERROR) << "Value '" << shill_value << "' cannot be translated to ONC";
351 return false; 371 return false;
352 } 372 }
353 373
354 } // namespace onc 374 } // namespace onc
355 } // namespace chromeos 375 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698