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

Unified Diff: chromeos/network/onc/onc_translation_tables.cc

Issue 12390017: Separating ONC<->Shill translation from the ONC signature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed browser tests. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.h ('k') | chromeos/network/onc/onc_translator_onc_to_shill.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/onc/onc_translation_tables.cc
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc
index 0fa8f312750d3831f776c53d034d608ee318c70f..74a2f94cd0577e4940adbce9869597823262da60 100644
--- a/chromeos/network/onc/onc_translation_tables.cc
+++ b/chromeos/network/onc/onc_translation_tables.cc
@@ -13,6 +13,169 @@
namespace chromeos {
namespace onc {
+// CertificatePattern is converted with function CreateUIData(...) to UIData
+// stored in Shill.
+//
+// Proxy settings are converted to Shill by function
+// ConvertOncProxySettingsToProxyConfig(...).
+//
+// Translation of IPConfig objects is not supported, yet.
+
+namespace {
+
+const FieldTranslationEntry eap_fields[] = {
+ { eap::kAnonymousIdentity, flimflam::kEapAnonymousIdentityProperty },
+ { eap::kIdentity, flimflam::kEapIdentityProperty },
+ // This field is converted during translation, see onc_translator_*.
+ // { eap::kInner, flimflam::kEapPhase2AuthProperty },
+
+ // This field is converted during translation, see onc_translator_*.
+ // { eap::kOuter, flimflam::kEapMethodProperty },
+ { eap::kPassword, flimflam::kEapPasswordProperty },
+ { eap::kSaveCredentials, flimflam::kSaveCredentialsProperty },
+ { eap::kServerCARef, flimflam::kEapCaCertNssProperty },
+ { eap::kUseSystemCAs, flimflam::kEapUseSystemCasProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry ipsec_fields[] = {
+ // Ignored by Shill, not necessary to synchronize.
+ // { vpn::kAuthenticationType, flimflam::kL2tpIpsecAuthenticationType },
+ { vpn::kGroup, flimflam::kL2tpIpsecGroupNameProperty },
+ // Ignored by Shill, not necessary to synchronize.
+ // { vpn::kIKEVersion, flimflam::kL2tpIpsecIkeVersion },
+ { vpn::kPSK, flimflam::kL2tpIpsecPskProperty },
+ { vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty },
+ { vpn::kServerCARef, flimflam::kL2tpIpsecCaCertNssProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry l2tp_fields[] = {
+ { vpn::kPassword, flimflam::kL2tpIpsecPasswordProperty },
+ // We don't synchronize l2tp's SaveCredentials field for now, as Shill doesn't
+ // support separate settings for ipsec and l2tp.
+ // { vpn::kSaveCredentials, &kBoolSignature },
+ { vpn::kUsername, flimflam::kL2tpIpsecUserProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry openvpn_fields[] = {
+ { vpn::kAuth, flimflam::kOpenVPNAuthProperty },
+ { vpn::kAuthNoCache, flimflam::kOpenVPNAuthNoCacheProperty },
+ { vpn::kAuthRetry, flimflam::kOpenVPNAuthRetryProperty },
+ { vpn::kCipher, flimflam::kOpenVPNCipherProperty },
+ { vpn::kCompLZO, flimflam::kOpenVPNCompLZOProperty },
+ { vpn::kCompNoAdapt, flimflam::kOpenVPNCompNoAdaptProperty },
+ { vpn::kKeyDirection, flimflam::kOpenVPNKeyDirectionProperty },
+ { vpn::kNsCertType, flimflam::kOpenVPNNsCertTypeProperty },
+ { vpn::kPassword, flimflam::kOpenVPNPasswordProperty },
+ { vpn::kPort, flimflam::kOpenVPNPortProperty },
+ { vpn::kProto, flimflam::kOpenVPNProtoProperty },
+ { vpn::kPushPeerInfo, flimflam::kOpenVPNPushPeerInfoProperty },
+ { vpn::kRemoteCertEKU, flimflam::kOpenVPNRemoteCertEKUProperty },
+ // This field is converted during translation, see onc_translator_*.
+ // { vpn::kRemoteCertKU, flimflam::kOpenVPNRemoteCertKUProperty },
+ { vpn::kRemoteCertTLS, flimflam::kOpenVPNRemoteCertTLSProperty },
+ { vpn::kRenegSec, flimflam::kOpenVPNRenegSecProperty },
+ { vpn::kSaveCredentials, flimflam::kSaveCredentialsProperty },
+ { vpn::kServerCARef, flimflam::kOpenVPNCaCertNSSProperty },
+ { vpn::kServerPollTimeout, flimflam::kOpenVPNServerPollTimeoutProperty },
+ { vpn::kShaper, flimflam::kOpenVPNShaperProperty },
+ { vpn::kStaticChallenge, flimflam::kOpenVPNStaticChallengeProperty },
+ { vpn::kTLSAuthContents, flimflam::kOpenVPNTLSAuthContentsProperty },
+ { vpn::kTLSRemote, flimflam::kOpenVPNTLSRemoteProperty },
+ { vpn::kUsername, flimflam::kOpenVPNUserProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry vpn_fields[] = {
+ { vpn::kAutoConnect, flimflam::kAutoConnectProperty },
+ { vpn::kHost, flimflam::kProviderHostProperty },
+ // This field is converted during translation, see onc_translator_*.
+ // { vpn::kType, flimflam::kProviderTypeProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry wifi_fields[] = {
+ { wifi::kAutoConnect, flimflam::kAutoConnectProperty },
+ { wifi::kBSSID, flimflam::kWifiBSsid },
+ { wifi::kHiddenSSID, flimflam::kWifiHiddenSsid },
+ { wifi::kPassphrase, flimflam::kPassphraseProperty },
+ { wifi::kSSID, flimflam::kSSIDProperty },
+ // This field is converted during translation, see onc_translator_*.
+ // { wifi::kSecurity, flimflam::kSecurityProperty },
+ { wifi::kSignalStrength, flimflam::kSignalStrengthProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry cellular_with_state_fields[] = {
+ { cellular::kActivateOverNonCellularNetwork,
+ shill::kActivateOverNonCellularNetworkProperty },
+ { cellular::kActivationState, flimflam::kActivationStateProperty },
+ { cellular::kAllowRoaming, flimflam::kCellularAllowRoamingProperty },
+ { cellular::kAPN, flimflam::kApnProperty },
+ { cellular::kCarrier, flimflam::kCarrierProperty },
+ { cellular::kESN, flimflam::kEsnProperty },
+ { cellular::kFamily, flimflam::kTechnologyFamilyProperty },
+ { cellular::kFirmwareRevision, flimflam::kFirmwareRevisionProperty },
+ { cellular::kFoundNetworks, flimflam::kFoundNetworksProperty },
+ { cellular::kHardwareRevision, flimflam::kHardwareRevisionProperty },
+ { cellular::kHomeProvider, flimflam::kHomeProviderProperty },
+ { cellular::kICCID, flimflam::kIccidProperty },
+ { cellular::kIMEI, flimflam::kImeiProperty },
+ { cellular::kIMSI, flimflam::kImsiProperty },
+ { cellular::kManufacturer, flimflam::kManufacturerProperty },
+ { cellular::kMDN, flimflam::kMdnProperty },
+ { cellular::kMEID, flimflam::kMeidProperty },
+ { cellular::kMIN, flimflam::kMinProperty },
+ { cellular::kModelID, flimflam::kModelIDProperty },
+ { cellular::kNetworkTechnology, flimflam::kNetworkTechnologyProperty },
+ { cellular::kOperatorCode, flimflam::kOperatorCodeProperty },
+ { cellular::kOperatorName, flimflam::kOperatorNameProperty },
+ { cellular::kPRLVersion, flimflam::kPRLVersionProperty },
+ { cellular::kProviderRequiresRoaming,
+ shill::kProviderRequiresRoamingProperty },
+ { cellular::kRoamingState, flimflam::kRoamingStateProperty },
+ { cellular::kSelectedNetwork, flimflam::kSelectedNetworkProperty },
+ { cellular::kServingOperator, flimflam::kServingOperatorProperty },
+ { cellular::kSIMLockStatus, flimflam::kSIMLockStatusProperty },
+ { cellular::kSIMPresent, shill::kSIMPresentProperty },
+ { cellular::kSupportedCarriers, shill::kSupportedCarriersProperty },
+ { cellular::kSupportNetworkScan, flimflam::kSupportNetworkScanProperty },
+ { NULL }
+};
+
+const FieldTranslationEntry network_fields[] = {
+ // Shill doesn't allow setting the name for non-VPN networks.
+ // This field is conditionally translated, see onc_translator_*.
+ // { network_config::kName, flimflam::kNameProperty },
+ { network_config::kGUID, flimflam::kGuidProperty },
+ // This field is converted during translation, see onc_translator_*.
+ // { network_config::kType, flimflam::kTypeProperty },
+
+ // This field is converted during translation, see
+ // onc_translator_shill_to_onc.cc. It is only converted when going from
+ // Shill->ONC, and ignored otherwise.
+ // { network_config::kConnectionState, flimflam::kStateProperty },
+ { NULL }
+};
+
+const OncValueTranslationEntry onc_value_translation_table[] = {
+ { &kEAPSignature, eap_fields },
+ { &kIPsecSignature, ipsec_fields },
+ { &kL2TPSignature, l2tp_fields },
+ { &kOpenVPNSignature, openvpn_fields },
+ { &kVPNSignature, vpn_fields },
+ { &kWiFiSignature, wifi_fields },
+ { &kWiFiWithStateSignature, wifi_fields },
+ { &kCellularWithStateSignature, cellular_with_state_fields },
+ { &kNetworkWithStateSignature, network_fields },
+ { &kNetworkConfigurationSignature, network_fields },
+ { NULL }
+};
+
+} // namespace
+
const StringTranslationEntry kNetworkTypeTable[] = {
{ network_type::kEthernet, flimflam::kTypeEthernet },
{ network_type::kWiFi, flimflam::kTypeWifi },
@@ -58,6 +221,30 @@ const StringTranslationEntry kEAP_TTLS_InnerTable[] = {
{ NULL }
};
+const FieldTranslationEntry* GetFieldTranslationTable(
+ const OncValueSignature& onc_signature) {
+ for (const OncValueTranslationEntry* it = onc_value_translation_table;
+ it->onc_signature != NULL; ++it) {
+ if (it->onc_signature != &onc_signature)
+ continue;
+ return it->field_translation_table;
+ }
+ return NULL;
+}
+
+bool GetShillPropertyName(const std::string& onc_field_name,
+ const FieldTranslationEntry table[],
+ std::string* shill_property_name) {
+ for (const FieldTranslationEntry* it = table;
+ it->onc_field_name != NULL; ++it) {
+ if (it->onc_field_name != onc_field_name)
+ continue;
+ *shill_property_name = it->shill_property_name;
+ return true;
+ }
+ return false;
+}
+
bool TranslateStringToShill(const StringTranslationEntry table[],
const std::string& onc_value,
std::string* shill_value) {
@@ -67,7 +254,7 @@ bool TranslateStringToShill(const StringTranslationEntry table[],
*shill_value = table[i].shill_value;
return true;
}
- LOG(ERROR) << "Value '" << onc_value << "cannot be translated to Shill";
+ LOG(ERROR) << "Value '" << onc_value << "' cannot be translated to Shill";
return false;
}
@@ -80,7 +267,7 @@ bool TranslateStringToONC(const StringTranslationEntry table[],
*onc_value = table[i].onc_value;
return true;
}
- LOG(ERROR) << "Value '" << shill_value << "cannot be translated to ONC";
+ LOG(ERROR) << "Value '" << shill_value << "' cannot be translated to ONC";
return false;
}
« no previous file with comments | « chromeos/network/onc/onc_translation_tables.h ('k') | chromeos/network/onc/onc_translator_onc_to_shill.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698