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

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

Issue 749013003: ONC: Add IPAddressConfigType and NameServersConfigType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alywas use empty dictionary to clear StaticIPConfig properties Created 5 years, 11 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_translator_unittest.cc ('k') | chromeos/test/data/network/augmented_merge.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/onc/onc_validator.cc
diff --git a/chromeos/network/onc/onc_validator.cc b/chromeos/network/onc/onc_validator.cc
index 60a863c7f8064863270ed368771ab83518ed7255..a3374eec03ecf6c222c288740f28ec927477bb81 100644
--- a/chromeos/network/onc/onc_validator.cc
+++ b/chromeos/network/onc/onc_validator.cc
@@ -522,7 +522,15 @@ bool Validator::ValidateNetworkConfiguration(base::DictionaryValue* result) {
::onc::network_type::kEthernet, ::onc::network_type::kVPN,
::onc::network_type::kWiFi, ::onc::network_type::kCellular};
const std::vector<const char*> valid_types(toVector(kValidTypes));
+ const char* const kValidIPConfigTypes[] = {kIPConfigTypeDHCP,
+ kIPConfigTypeStatic};
+ const std::vector<const char*> valid_ipconfig_types(
+ toVector(kValidIPConfigTypes));
if (FieldExistsAndHasNoValidValue(*result, kType, valid_types) ||
+ FieldExistsAndHasNoValidValue(*result, kIPAddressConfigType,
+ valid_ipconfig_types) ||
+ FieldExistsAndHasNoValidValue(*result, kNameServersConfigType,
+ valid_ipconfig_types) ||
FieldExistsAndIsEmpty(*result, kGUID)) {
return false;
}
@@ -538,6 +546,18 @@ bool Validator::ValidateNetworkConfiguration(base::DictionaryValue* result) {
all_required_exist &=
RequireField(*result, kName) && RequireField(*result, kType);
+ std::string ip_address_config_type, name_servers_config_type;
+ result->GetStringWithoutPathExpansion(kIPAddressConfigType,
+ &ip_address_config_type);
+ result->GetStringWithoutPathExpansion(kNameServersConfigType,
+ &name_servers_config_type);
+ if (ip_address_config_type == kIPConfigTypeStatic ||
+ name_servers_config_type == kIPConfigTypeStatic) {
+ // TODO(pneubeck): Add ValidateStaticIPConfig and confirm that the
+ // correct properties are provided based on the config type.
+ all_required_exist &= RequireField(*result, kStaticIPConfig);
+ }
+
std::string type;
result->GetStringWithoutPathExpansion(kType, &type);
« no previous file with comments | « chromeos/network/onc/onc_translator_unittest.cc ('k') | chromeos/test/data/network/augmented_merge.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698