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_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 TranslateAndAddListOfObjects(::onc::network_config::kIPConfigs, | 312 TranslateAndAddListOfObjects(::onc::network_config::kIPConfigs, |
313 *shill_ipconfigs); | 313 *shill_ipconfigs); |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void ShillToONCTranslator::TranslateIPConfig() { | 317 void ShillToONCTranslator::TranslateIPConfig() { |
318 CopyPropertiesAccordingToSignature(); | 318 CopyPropertiesAccordingToSignature(); |
319 std::string shill_ip_method; | 319 std::string shill_ip_method; |
320 shill_dictionary_->GetStringWithoutPathExpansion(shill::kMethodProperty, | 320 shill_dictionary_->GetStringWithoutPathExpansion(shill::kMethodProperty, |
321 &shill_ip_method); | 321 &shill_ip_method); |
322 if (shill_ip_method != shill::kTypeIPv4 && | 322 std::string type; |
323 shill_ip_method != shill::kTypeIPv6) { | 323 if (shill_ip_method == shill::kTypeIPv4 || |
324 LOG(ERROR) << "Unhandled IPConfig Method value " << shill_ip_method; | 324 shill_ip_method == shill::kTypeDHCP) { |
325 return; | 325 type = ::onc::ipconfig::kIPv4; |
326 } else if (shill_ip_method == shill::kTypeIPv6 || | |
327 shill_ip_method == shill::kTypeDHCP6) { | |
328 type = ::onc::ipconfig::kIPv6; | |
329 } else { | |
330 return; // Ignore unhandled IPConfig types, e.g. bootp, zeroconf, ppp | |
pneubeck (no reviews)
2014/05/05 21:09:28
optional nit: LOG(ERROR) maybe
stevenjb
2014/05/06 01:15:11
Not an ERROR. Shill may provide other IPConfigs th
| |
326 } | 331 } |
327 | 332 |
328 std::string type = ::onc::ipconfig::kIPv4; | |
329 if (shill_ip_method == shill::kTypeIPv6) | |
330 type = ::onc::ipconfig::kIPv6; | |
331 onc_object_->SetStringWithoutPathExpansion(::onc::ipconfig::kType, type); | 333 onc_object_->SetStringWithoutPathExpansion(::onc::ipconfig::kType, type); |
332 } | 334 } |
333 | 335 |
334 void ShillToONCTranslator::TranslateAndAddNestedObject( | 336 void ShillToONCTranslator::TranslateAndAddNestedObject( |
335 const std::string& onc_field_name) { | 337 const std::string& onc_field_name) { |
336 TranslateAndAddNestedObject(onc_field_name, *shill_dictionary_); | 338 TranslateAndAddNestedObject(onc_field_name, *shill_dictionary_); |
337 } | 339 } |
338 | 340 |
339 void ShillToONCTranslator::TranslateAndAddNestedObject( | 341 void ShillToONCTranslator::TranslateAndAddNestedObject( |
340 const std::string& onc_field_name, | 342 const std::string& onc_field_name, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 const base::DictionaryValue& shill_dictionary, | 453 const base::DictionaryValue& shill_dictionary, |
452 const OncValueSignature* onc_signature) { | 454 const OncValueSignature* onc_signature) { |
453 CHECK(onc_signature != NULL); | 455 CHECK(onc_signature != NULL); |
454 | 456 |
455 ShillToONCTranslator translator(shill_dictionary, *onc_signature); | 457 ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
456 return translator.CreateTranslatedONCObject(); | 458 return translator.CreateTranslatedONCObject(); |
457 } | 459 } |
458 | 460 |
459 } // namespace onc | 461 } // namespace onc |
460 } // namespace chromeos | 462 } // namespace chromeos |
OLD | NEW |