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

Side by Side Diff: chromeos/network/onc/onc_validator.cc

Issue 830133003: ONC: Remove the top level fields NameServers and SearchDomains. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix IPConfig documentation and adapt validation. 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 unified diff | Download patch
« no previous file with comments | « chromeos/network/onc/onc_signature.cc ('k') | components/onc/docs/onc_spec.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_validator.h" 5 #include "chromeos/network/onc/onc_validator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 result->GetStringWithoutPathExpansion(::onc::ipconfig::kType, &type); 601 result->GetStringWithoutPathExpansion(::onc::ipconfig::kType, &type);
602 int lower_bound = 1; 602 int lower_bound = 1;
603 // In case of missing type, choose higher upper_bound. 603 // In case of missing type, choose higher upper_bound.
604 int upper_bound = (type == kIPv4) ? 32 : 128; 604 int upper_bound = (type == kIPv4) ? 32 : 128;
605 if (FieldExistsAndIsNotInRange( 605 if (FieldExistsAndIsNotInRange(
606 *result, kRoutingPrefix, lower_bound, upper_bound)) { 606 *result, kRoutingPrefix, lower_bound, upper_bound)) {
607 return false; 607 return false;
608 } 608 }
609 609
610 bool all_required_exist = RequireField(*result, kIPAddress) && 610 bool all_required_exist = RequireField(*result, kIPAddress) &&
611 RequireField(*result, kRoutingPrefix) &&
612 RequireField(*result, ::onc::ipconfig::kType); 611 RequireField(*result, ::onc::ipconfig::kType);
612 if (result->HasKey(kIPAddress))
613 all_required_exist &= RequireField(*result, kRoutingPrefix);
614
613 615
614 return !error_on_missing_field_ || all_required_exist; 616 return !error_on_missing_field_ || all_required_exist;
615 } 617 }
616 618
617 bool Validator::ValidateWiFi(base::DictionaryValue* result) { 619 bool Validator::ValidateWiFi(base::DictionaryValue* result) {
618 using namespace ::onc::wifi; 620 using namespace ::onc::wifi;
619 621
620 const char* const kValidSecurities[] = {kSecurityNone, kWEP_PSK, kWEP_8021X, 622 const char* const kValidSecurities[] = {kSecurityNone, kWEP_PSK, kWEP_8021X,
621 kWPA_PSK, kWPA_EAP}; 623 kWPA_PSK, kWPA_EAP};
622 const std::vector<const char*> valid_securities(toVector(kValidSecurities)); 624 const std::vector<const char*> valid_securities(toVector(kValidSecurities));
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 906 }
905 907
906 std::string Validator::MessageHeader() { 908 std::string Validator::MessageHeader() {
907 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); 909 std::string path = path_.empty() ? "toplevel" : JoinString(path_, ".");
908 std::string message = "At " + path + ": "; 910 std::string message = "At " + path + ": ";
909 return message; 911 return message;
910 } 912 }
911 913
912 } // namespace onc 914 } // namespace onc
913 } // namespace chromeos 915 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_signature.cc ('k') | components/onc/docs/onc_spec.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698