| 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 "base/logging.h" |
| 10 #include "components/onc/onc_constants.h" | 10 #include "components/onc/onc_constants.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 {NULL}}; | 125 {NULL}}; |
| 126 | 126 |
| 127 const FieldTranslationEntry cellular_provider_fields[] = { | 127 const FieldTranslationEntry cellular_provider_fields[] = { |
| 128 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey}, | 128 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey}, |
| 129 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey}, | 129 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey}, |
| 130 { ::onc::cellular_provider::kName, shill::kOperatorNameKey}, | 130 { ::onc::cellular_provider::kName, shill::kOperatorNameKey}, |
| 131 {NULL}}; | 131 {NULL}}; |
| 132 | 132 |
| 133 const FieldTranslationEntry sim_lock_status_fields[] = { |
| 134 { ::onc::sim_lock_status::kLockEnabled, shill::kSIMLockEnabledProperty}, |
| 135 { ::onc::sim_lock_status::kLockType, shill::kSIMLockTypeProperty}, |
| 136 { ::onc::sim_lock_status::kRetriesLeft, shill::kSIMLockRetriesLeftProperty}, |
| 137 {NULL}}; |
| 138 |
| 133 // This must only contain Service properties and not Device properties. | 139 // This must only contain Service properties and not Device properties. |
| 134 // For Device properties see kCellularDeviceTable. | |
| 135 const FieldTranslationEntry cellular_fields[] = { | 140 const FieldTranslationEntry cellular_fields[] = { |
| 136 { ::onc::cellular::kActivateOverNonCellularNetwork, | 141 { ::onc::cellular::kActivateOverNonCellularNetwork, |
| 137 shill::kActivateOverNonCellularNetworkProperty}, | 142 shill::kActivateOverNonCellularNetworkProperty}, |
| 138 { ::onc::cellular::kActivationState, shill::kActivationStateProperty}, | 143 { ::onc::cellular::kActivationState, shill::kActivationStateProperty}, |
| 139 { ::onc::cellular::kNetworkTechnology, shill::kNetworkTechnologyProperty}, | 144 { ::onc::cellular::kNetworkTechnology, shill::kNetworkTechnologyProperty}, |
| 140 { ::onc::cellular::kRoamingState, shill::kRoamingStateProperty}, | 145 { ::onc::cellular::kRoamingState, shill::kRoamingStateProperty}, |
| 141 {NULL}}; | 146 {NULL}}; |
| 142 | 147 |
| 148 // This must contain only Shill Device properties and no Service properties. |
| 149 const FieldTranslationEntry cellular_device_fields[] = { |
| 150 { ::onc::cellular::kAllowRoaming, shill::kCellularAllowRoamingProperty}, |
| 151 { ::onc::cellular::kCarrier, shill::kCarrierProperty}, |
| 152 { ::onc::cellular::kESN, shill::kEsnProperty}, |
| 153 { ::onc::cellular::kFamily, shill::kTechnologyFamilyProperty}, |
| 154 { ::onc::cellular::kFirmwareRevision, shill::kFirmwareRevisionProperty}, |
| 155 { ::onc::cellular::kFoundNetworks, shill::kFoundNetworksProperty}, |
| 156 { ::onc::cellular::kHardwareRevision, shill::kHardwareRevisionProperty}, |
| 157 { ::onc::cellular::kHomeProvider, shill::kHomeProviderProperty}, |
| 158 { ::onc::cellular::kICCID, shill::kIccidProperty}, |
| 159 { ::onc::cellular::kIMEI, shill::kImeiProperty}, |
| 160 { ::onc::cellular::kIMSI, shill::kImsiProperty}, |
| 161 { ::onc::cellular::kManufacturer, shill::kManufacturerProperty}, |
| 162 { ::onc::cellular::kMDN, shill::kMdnProperty}, |
| 163 { ::onc::cellular::kMEID, shill::kMeidProperty}, |
| 164 { ::onc::cellular::kMIN, shill::kMinProperty}, |
| 165 { ::onc::cellular::kModelID, shill::kModelIDProperty}, |
| 166 { ::onc::cellular::kPRLVersion, shill::kPRLVersionProperty}, |
| 167 { ::onc::cellular::kProviderRequiresRoaming, |
| 168 shill::kProviderRequiresRoamingProperty}, |
| 169 { ::onc::cellular::kSelectedNetwork, shill::kSelectedNetworkProperty}, |
| 170 // This field is converted during translation, see onc_translator_*. |
| 171 // { ::onc::cellular::kSIMLockStatus, shill::kSIMLockStatusProperty}, |
| 172 { ::onc::cellular::kSIMPresent, shill::kSIMPresentProperty}, |
| 173 { ::onc::cellular::kSupportedCarriers, shill::kSupportedCarriersProperty}, |
| 174 { ::onc::cellular::kSupportNetworkScan, shill::kSupportNetworkScanProperty}, |
| 175 {NULL}}; |
| 176 |
| 143 const FieldTranslationEntry network_fields[] = { | 177 const FieldTranslationEntry network_fields[] = { |
| 144 { ::onc::network_config::kGUID, shill::kGuidProperty}, | 178 { ::onc::network_config::kGUID, shill::kGuidProperty}, |
| 145 { ::onc::network_config::kConnectable, shill::kConnectableProperty }, | 179 { ::onc::network_config::kConnectable, shill::kConnectableProperty }, |
| 146 { ::onc::network_config::kErrorState, shill::kErrorProperty }, | 180 { ::onc::network_config::kErrorState, shill::kErrorProperty }, |
| 147 | 181 |
| 148 // Shill doesn't allow setting the name for non-VPN networks. | 182 // Shill doesn't allow setting the name for non-VPN networks. |
| 149 // Name is conditionally translated, see onc_translator_*. | 183 // Name is conditionally translated, see onc_translator_*. |
| 150 // { ::onc::network_config::kName, shill::kNameProperty }, | 184 // { ::onc::network_config::kName, shill::kNameProperty }, |
| 151 | 185 |
| 152 // Type is converted during translation, see onc_translator_*. | 186 // Type is converted during translation, see onc_translator_*. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 179 { &kIPsecSignature, ipsec_fields }, | 213 { &kIPsecSignature, ipsec_fields }, |
| 180 { &kL2TPSignature, l2tp_fields }, | 214 { &kL2TPSignature, l2tp_fields }, |
| 181 { &kXAUTHSignature, xauth_fields }, | 215 { &kXAUTHSignature, xauth_fields }, |
| 182 { &kOpenVPNSignature, openvpn_fields }, | 216 { &kOpenVPNSignature, openvpn_fields }, |
| 183 { &kVerifyX509Signature, verify_x509_fields }, | 217 { &kVerifyX509Signature, verify_x509_fields }, |
| 184 { &kVPNSignature, vpn_fields }, | 218 { &kVPNSignature, vpn_fields }, |
| 185 { &kWiFiSignature, wifi_fields }, | 219 { &kWiFiSignature, wifi_fields }, |
| 186 { &kWiFiWithStateSignature, wifi_fields }, | 220 { &kWiFiWithStateSignature, wifi_fields }, |
| 187 { &kCellularApnSignature, cellular_apn_fields }, | 221 { &kCellularApnSignature, cellular_apn_fields }, |
| 188 { &kCellularProviderSignature, cellular_provider_fields }, | 222 { &kCellularProviderSignature, cellular_provider_fields }, |
| 223 { &kSIMLockStatusSignature, sim_lock_status_fields }, |
| 189 { &kCellularSignature, cellular_fields }, | 224 { &kCellularSignature, cellular_fields }, |
| 190 { &kCellularWithStateSignature, cellular_fields }, | 225 { &kCellularWithStateSignature, cellular_fields }, |
| 226 { &kCellularDeviceSignature, cellular_device_fields }, |
| 191 { &kNetworkWithStateSignature, network_fields }, | 227 { &kNetworkWithStateSignature, network_fields }, |
| 192 { &kNetworkConfigurationSignature, network_fields }, | 228 { &kNetworkConfigurationSignature, network_fields }, |
| 193 { &kIPConfigSignature, ipconfig_fields }, | 229 { &kIPConfigSignature, ipconfig_fields }, |
| 194 { NULL } | 230 { NULL } |
| 195 }; | 231 }; |
| 196 | 232 |
| 197 struct NestedShillDictionaryEntry { | 233 struct NestedShillDictionaryEntry { |
| 198 const OncValueSignature* onc_signature; | 234 const OncValueSignature* onc_signature; |
| 199 // NULL terminated list of Shill property keys. | 235 // NULL terminated list of Shill property keys. |
| 200 const char* const* shill_property_path; | 236 const char* const* shill_property_path; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 { ::onc::eap::kMD5, shill::kEapPhase2AuthPEAPMD5}, | 284 { ::onc::eap::kMD5, shill::kEapPhase2AuthPEAPMD5}, |
| 249 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthPEAPMSCHAPV2}, {NULL}}; | 285 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthPEAPMSCHAPV2}, {NULL}}; |
| 250 | 286 |
| 251 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS | 287 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS |
| 252 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { | 288 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { |
| 253 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5}, | 289 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5}, |
| 254 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2}, | 290 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2}, |
| 255 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP}, | 291 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP}, |
| 256 {NULL}}; | 292 {NULL}}; |
| 257 | 293 |
| 258 // This must contain only Shill Device properties and no Service properties. | |
| 259 // For Service properties see cellular_fields. | |
| 260 const FieldTranslationEntry kCellularDeviceTable[] = { | |
| 261 { ::onc::cellular::kAllowRoaming, shill::kCellularAllowRoamingProperty}, | |
| 262 { ::onc::cellular::kCarrier, shill::kCarrierProperty}, | |
| 263 { ::onc::cellular::kESN, shill::kEsnProperty}, | |
| 264 { ::onc::cellular::kFamily, shill::kTechnologyFamilyProperty}, | |
| 265 { ::onc::cellular::kFirmwareRevision, shill::kFirmwareRevisionProperty}, | |
| 266 { ::onc::cellular::kFoundNetworks, shill::kFoundNetworksProperty}, | |
| 267 { ::onc::cellular::kHardwareRevision, shill::kHardwareRevisionProperty}, | |
| 268 { ::onc::cellular::kHomeProvider, shill::kHomeProviderProperty}, | |
| 269 { ::onc::cellular::kICCID, shill::kIccidProperty}, | |
| 270 { ::onc::cellular::kIMEI, shill::kImeiProperty}, | |
| 271 { ::onc::cellular::kIMSI, shill::kImsiProperty}, | |
| 272 { ::onc::cellular::kManufacturer, shill::kManufacturerProperty}, | |
| 273 { ::onc::cellular::kMDN, shill::kMdnProperty}, | |
| 274 { ::onc::cellular::kMEID, shill::kMeidProperty}, | |
| 275 { ::onc::cellular::kMIN, shill::kMinProperty}, | |
| 276 { ::onc::cellular::kModelID, shill::kModelIDProperty}, | |
| 277 { ::onc::cellular::kPRLVersion, shill::kPRLVersionProperty}, | |
| 278 { ::onc::cellular::kProviderRequiresRoaming, | |
| 279 shill::kProviderRequiresRoamingProperty}, | |
| 280 { ::onc::cellular::kSelectedNetwork, shill::kSelectedNetworkProperty}, | |
| 281 { ::onc::cellular::kSIMLockEnabled, shill::kSIMLockEnabledProperty}, | |
| 282 { ::onc::cellular::kSIMLockStatus, shill::kSIMLockStatusProperty}, | |
| 283 { ::onc::cellular::kSIMLockType, shill::kSIMLockTypeProperty}, | |
| 284 { ::onc::cellular::kSIMPresent, shill::kSIMPresentProperty}, | |
| 285 { ::onc::cellular::kSupportedCarriers, shill::kSupportedCarriersProperty}, | |
| 286 { ::onc::cellular::kSupportNetworkScan, shill::kSupportNetworkScanProperty}, | |
| 287 {NULL}}; | |
| 288 | |
| 289 const FieldTranslationEntry* GetFieldTranslationTable( | 294 const FieldTranslationEntry* GetFieldTranslationTable( |
| 290 const OncValueSignature& onc_signature) { | 295 const OncValueSignature& onc_signature) { |
| 291 for (const OncValueTranslationEntry* it = onc_value_translation_table; | 296 for (const OncValueTranslationEntry* it = onc_value_translation_table; |
| 292 it->onc_signature != NULL; ++it) { | 297 it->onc_signature != NULL; ++it) { |
| 293 if (it->onc_signature == &onc_signature) | 298 if (it->onc_signature == &onc_signature) |
| 294 return it->field_translation_table; | 299 return it->field_translation_table; |
| 295 } | 300 } |
| 296 return NULL; | 301 return NULL; |
| 297 } | 302 } |
| 298 | 303 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 continue; | 351 continue; |
| 347 *onc_value = table[i].onc_value; | 352 *onc_value = table[i].onc_value; |
| 348 return true; | 353 return true; |
| 349 } | 354 } |
| 350 LOG(ERROR) << "Value '" << shill_value << "' cannot be translated to ONC"; | 355 LOG(ERROR) << "Value '" << shill_value << "' cannot be translated to ONC"; |
| 351 return false; | 356 return false; |
| 352 } | 357 } |
| 353 | 358 |
| 354 } // namespace onc | 359 } // namespace onc |
| 355 } // namespace chromeos | 360 } // namespace chromeos |
| OLD | NEW |