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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 { ::onc::wifi::kHiddenSSID, shill::kWifiHiddenSsid}, | 112 { ::onc::wifi::kHiddenSSID, shill::kWifiHiddenSsid}, |
113 { ::onc::wifi::kPassphrase, shill::kPassphraseProperty}, | 113 { ::onc::wifi::kPassphrase, shill::kPassphraseProperty}, |
114 // This field is converted during translation, see onc_translator_*. | 114 // This field is converted during translation, see onc_translator_*. |
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::kApn, shill::kApnProperty}, |
122 { ::onc::cellular_apn::kName, shill::kApnProperty}, | 123 { ::onc::cellular_apn::kName, shill::kApnProperty}, |
123 { ::onc::cellular_apn::kUsername, shill::kApnUsernameProperty}, | 124 { ::onc::cellular_apn::kUsername, shill::kApnUsernameProperty}, |
124 { ::onc::cellular_apn::kPassword, shill::kApnPasswordProperty}, | 125 { ::onc::cellular_apn::kPassword, shill::kApnPasswordProperty}, |
| 126 { ::onc::cellular_apn::kLocalizedName, shill::kApnLocalizedNameProperty}, |
| 127 { ::onc::cellular_apn::kLanguage, shill::kApnLanguageProperty}, |
| 128 {NULL}}; |
| 129 |
| 130 const FieldTranslationEntry cellular_found_network_fields[] = { |
| 131 { ::onc::cellular_found_network::kNetworkId, shill::kNetworkIdProperty}, |
| 132 { ::onc::cellular_found_network::kStatus, shill::kStatusProperty}, |
| 133 { ::onc::cellular_found_network::kTechnology, shill::kTechnologyProperty}, |
| 134 { ::onc::cellular_found_network::kShortName, shill::kShortNameProperty}, |
| 135 { ::onc::cellular_found_network::kLongName, shill::kLongNameProperty}, |
125 {NULL}}; | 136 {NULL}}; |
126 | 137 |
127 const FieldTranslationEntry cellular_provider_fields[] = { | 138 const FieldTranslationEntry cellular_provider_fields[] = { |
128 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey}, | 139 { ::onc::cellular_provider::kCode, shill::kOperatorCodeKey}, |
129 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey}, | 140 { ::onc::cellular_provider::kCountry, shill::kOperatorCountryKey}, |
130 { ::onc::cellular_provider::kName, shill::kOperatorNameKey}, | 141 { ::onc::cellular_provider::kName, shill::kOperatorNameKey}, |
131 {NULL}}; | 142 {NULL}}; |
132 | 143 |
| 144 const FieldTranslationEntry sim_lock_status_fields[] = { |
| 145 { ::onc::sim_lock_status::kLockEnabled, shill::kSIMLockEnabledProperty}, |
| 146 { ::onc::sim_lock_status::kLockType, shill::kSIMLockTypeProperty}, |
| 147 { ::onc::sim_lock_status::kRetriesLeft, shill::kSIMLockRetriesLeftProperty}, |
| 148 {NULL}}; |
| 149 |
133 // This must only contain Service properties and not Device properties. | 150 // This must only contain Service properties and not Device properties. |
134 // 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 |
| 159 // This must contain only Shill Device properties and no Service properties. |
| 160 const FieldTranslationEntry cellular_device_fields[] = { |
| 161 // This field is converted during translation, see onc_translator_*. |
| 162 // { ::onc::cellular::kAPNList, shill::kCellularApnListProperty}, |
| 163 { ::onc::cellular::kAllowRoaming, shill::kCellularAllowRoamingProperty}, |
| 164 { ::onc::cellular::kCarrier, shill::kCarrierProperty}, |
| 165 { ::onc::cellular::kESN, shill::kEsnProperty}, |
| 166 { ::onc::cellular::kFamily, shill::kTechnologyFamilyProperty}, |
| 167 { ::onc::cellular::kFirmwareRevision, shill::kFirmwareRevisionProperty}, |
| 168 // This field is converted during translation, see onc_translator_*. |
| 169 // { ::onc::cellular::kFoundNetworks, shill::kFoundNetworksProperty}, |
| 170 { ::onc::cellular::kHardwareRevision, shill::kHardwareRevisionProperty}, |
| 171 { ::onc::cellular::kHomeProvider, shill::kHomeProviderProperty}, |
| 172 { ::onc::cellular::kICCID, shill::kIccidProperty}, |
| 173 { ::onc::cellular::kIMEI, shill::kImeiProperty}, |
| 174 { ::onc::cellular::kIMSI, shill::kImsiProperty}, |
| 175 { ::onc::cellular::kManufacturer, shill::kManufacturerProperty}, |
| 176 { ::onc::cellular::kMDN, shill::kMdnProperty}, |
| 177 { ::onc::cellular::kMEID, shill::kMeidProperty}, |
| 178 { ::onc::cellular::kMIN, shill::kMinProperty}, |
| 179 { ::onc::cellular::kModelID, shill::kModelIDProperty}, |
| 180 { ::onc::cellular::kPRLVersion, shill::kPRLVersionProperty}, |
| 181 { ::onc::cellular::kProviderRequiresRoaming, |
| 182 shill::kProviderRequiresRoamingProperty}, |
| 183 { ::onc::cellular::kSelectedNetwork, shill::kSelectedNetworkProperty}, |
| 184 // This field is converted during translation, see onc_translator_*. |
| 185 // { ::onc::cellular::kSIMLockStatus, shill::kSIMLockStatusProperty}, |
| 186 { ::onc::cellular::kSIMPresent, shill::kSIMPresentProperty}, |
| 187 { ::onc::cellular::kSupportedCarriers, shill::kSupportedCarriersProperty}, |
| 188 { ::onc::cellular::kSupportNetworkScan, shill::kSupportNetworkScanProperty}, |
| 189 {NULL}}; |
| 190 |
143 const FieldTranslationEntry network_fields[] = { | 191 const FieldTranslationEntry network_fields[] = { |
144 { ::onc::network_config::kGUID, shill::kGuidProperty}, | 192 { ::onc::network_config::kGUID, shill::kGuidProperty}, |
145 { ::onc::network_config::kConnectable, shill::kConnectableProperty }, | 193 { ::onc::network_config::kConnectable, shill::kConnectableProperty }, |
146 { ::onc::network_config::kErrorState, shill::kErrorProperty }, | 194 { ::onc::network_config::kErrorState, shill::kErrorProperty }, |
147 | 195 |
148 // Shill doesn't allow setting the name for non-VPN networks. | 196 // Shill doesn't allow setting the name for non-VPN networks. |
149 // Name is conditionally translated, see onc_translator_*. | 197 // Name is conditionally translated, see onc_translator_*. |
150 // { ::onc::network_config::kName, shill::kNameProperty }, | 198 // { ::onc::network_config::kName, shill::kNameProperty }, |
151 | 199 |
152 // Type is converted during translation, see onc_translator_*. | 200 // Type is converted during translation, see onc_translator_*. |
(...skipping 25 matching lines...) Expand all Loading... |
178 { &kEAPSignature, eap_fields }, | 226 { &kEAPSignature, eap_fields }, |
179 { &kIPsecSignature, ipsec_fields }, | 227 { &kIPsecSignature, ipsec_fields }, |
180 { &kL2TPSignature, l2tp_fields }, | 228 { &kL2TPSignature, l2tp_fields }, |
181 { &kXAUTHSignature, xauth_fields }, | 229 { &kXAUTHSignature, xauth_fields }, |
182 { &kOpenVPNSignature, openvpn_fields }, | 230 { &kOpenVPNSignature, openvpn_fields }, |
183 { &kVerifyX509Signature, verify_x509_fields }, | 231 { &kVerifyX509Signature, verify_x509_fields }, |
184 { &kVPNSignature, vpn_fields }, | 232 { &kVPNSignature, vpn_fields }, |
185 { &kWiFiSignature, wifi_fields }, | 233 { &kWiFiSignature, wifi_fields }, |
186 { &kWiFiWithStateSignature, wifi_fields }, | 234 { &kWiFiWithStateSignature, wifi_fields }, |
187 { &kCellularApnSignature, cellular_apn_fields }, | 235 { &kCellularApnSignature, cellular_apn_fields }, |
| 236 { &kCellularFoundNetworkSignature, cellular_found_network_fields }, |
188 { &kCellularProviderSignature, cellular_provider_fields }, | 237 { &kCellularProviderSignature, cellular_provider_fields }, |
| 238 { &kSIMLockStatusSignature, sim_lock_status_fields }, |
189 { &kCellularSignature, cellular_fields }, | 239 { &kCellularSignature, cellular_fields }, |
190 { &kCellularWithStateSignature, cellular_fields }, | 240 { &kCellularWithStateSignature, cellular_fields }, |
| 241 { &kCellularDeviceSignature, cellular_device_fields }, |
191 { &kNetworkWithStateSignature, network_fields }, | 242 { &kNetworkWithStateSignature, network_fields }, |
192 { &kNetworkConfigurationSignature, network_fields }, | 243 { &kNetworkConfigurationSignature, network_fields }, |
193 { &kIPConfigSignature, ipconfig_fields }, | 244 { &kIPConfigSignature, ipconfig_fields }, |
194 { NULL } | 245 { NULL } |
195 }; | 246 }; |
196 | 247 |
197 struct NestedShillDictionaryEntry { | 248 struct NestedShillDictionaryEntry { |
198 const OncValueSignature* onc_signature; | 249 const OncValueSignature* onc_signature; |
199 // NULL terminated list of Shill property keys. | 250 // NULL terminated list of Shill property keys. |
200 const char* const* shill_property_path; | 251 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}, | 299 { ::onc::eap::kMD5, shill::kEapPhase2AuthPEAPMD5}, |
249 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthPEAPMSCHAPV2}, {NULL}}; | 300 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthPEAPMSCHAPV2}, {NULL}}; |
250 | 301 |
251 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS | 302 // Translation of the EAP.Inner field in case of EAP.Outer == TTLS |
252 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { | 303 const StringTranslationEntry kEAP_TTLS_InnerTable[] = { |
253 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5}, | 304 { ::onc::eap::kMD5, shill::kEapPhase2AuthTTLSMD5}, |
254 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2}, | 305 { ::onc::eap::kMSCHAPv2, shill::kEapPhase2AuthTTLSMSCHAPV2}, |
255 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP}, | 306 { ::onc::eap::kPAP, shill::kEapPhase2AuthTTLSPAP}, |
256 {NULL}}; | 307 {NULL}}; |
257 | 308 |
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( | 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) |
294 return it->field_translation_table; | 314 return it->field_translation_table; |
295 } | 315 } |
296 return NULL; | 316 return NULL; |
297 } | 317 } |
298 | 318 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |