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_translator_shill_to_onc.cc

Issue 23506040: Add ethernet to ONC validation and Shill translation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed networkingPrivate api test on non-chromeos. Created 7 years, 3 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
Index: chromeos/network/onc/onc_translator_shill_to_onc.cc
diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc
index 0bd82ea341762d57e36c2240135732297aaaf317..80e00bab58c969ccfeb3b9c3e7d5cc386a5e04b0 100644
--- a/chromeos/network/onc/onc_translator_shill_to_onc.cc
+++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc
@@ -58,6 +58,7 @@ class ShillToONCTranslator {
scoped_ptr<base::DictionaryValue> CreateTranslatedONCObject();
private:
+ void TranslateEthernet();
void TranslateOpenVPN();
void TranslateVPN();
void TranslateWiFiWithState();
@@ -109,6 +110,8 @@ ShillToONCTranslator::CreateTranslatedONCObject() {
onc_object_.reset(new base::DictionaryValue);
if (onc_signature_ == &kNetworkWithStateSignature) {
TranslateNetworkWithState();
+ } else if (onc_signature_ == &kEthernetSignature) {
+ TranslateEthernet();
} else if (onc_signature_ == &kVPNSignature) {
TranslateVPN();
} else if (onc_signature_ == &kOpenVPNSignature) {
@@ -123,6 +126,17 @@ ShillToONCTranslator::CreateTranslatedONCObject() {
return onc_object_.Pass();
}
+void ShillToONCTranslator::TranslateEthernet() {
+ std::string shill_network_type;
+ shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty,
+ &shill_network_type);
+ const char* onc_auth = ethernet::kNone;
+ if (shill_network_type == shill::kTypeEthernetEap)
+ onc_auth = ethernet::k8021X;
+ onc_object_->SetStringWithoutPathExpansion(ethernet::kAuthentication,
+ onc_auth);
+}
+
void ShillToONCTranslator::TranslateOpenVPN() {
// Shill supports only one RemoteCertKU but ONC requires a list. If existing,
// wraps the value into a list.
@@ -219,14 +233,21 @@ void ShillToONCTranslator::TranslateCellularWithState() {
}
void ShillToONCTranslator::TranslateNetworkWithState() {
- TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable,
- network_config::kType);
CopyPropertiesAccordingToSignature();
- std::string network_type;
- if (onc_object_->GetStringWithoutPathExpansion(network_config::kType,
- &network_type)) {
- TranslateAndAddNestedObject(network_type);
+ std::string shill_network_type;
+ shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty,
+ &shill_network_type);
+ std::string onc_network_type = network_type::kEthernet;
+ if (shill_network_type != flimflam::kTypeEthernet &&
+ shill_network_type != shill::kTypeEthernetEap) {
+ TranslateStringToONC(
+ kNetworkTypeTable, shill_network_type, &onc_network_type);
+ }
+ if (!onc_network_type.empty()) {
+ onc_object_->SetStringWithoutPathExpansion(network_config::kType,
+ onc_network_type);
+ TranslateAndAddNestedObject(onc_network_type);
}
// Since Name is a read only field in Shill unless it's a VPN, it is copied
« no previous file with comments | « chromeos/network/onc/onc_translator_onc_to_shill.cc ('k') | chromeos/network/onc/onc_translator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698