Kea  1.9.9-git
sanity_checks_parser.cc
Go to the documentation of this file.
1 // Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC")
2 //
3 // This Source Code Form is subject to the terms of the Mozilla Public
4 // License, v. 2.0. If a copy of the MPL was not distributed with this
5 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 
7 #include <config.h>
10 #include <cc/data.h>
11 
12 using namespace isc::data;
13 
14 namespace isc {
15 namespace dhcp {
16 
17 void
18 SanityChecksParser::parse(SrvConfig& cfg, const ConstElementPtr& sanity_checks) {
19 
20  if (!sanity_checks) {
21  return;
22  }
23  if (sanity_checks->getType() != Element::map) {
24  isc_throw(DhcpConfigError, "sanity-checks is supposed to be a map");
25  }
26 
27  ConstElementPtr lease_checks = sanity_checks->get("lease-checks");
28  if (lease_checks) {
29  if (lease_checks->getType() != Element::string) {
30  isc_throw(DhcpConfigError, "lease-checks must be a string");
31  }
32  std::string lc = lease_checks->stringValue();
34  if (lc == "none") {
35  check = CfgConsistency::LEASE_CHECK_NONE;
36  } else if (lc == "warn") {
37  check = CfgConsistency::LEASE_CHECK_WARN;
38  } else if (lc == "fix") {
39  check = CfgConsistency::LEASE_CHECK_FIX;
40  } else if (lc == "fix-del") {
41  check = CfgConsistency::LEASE_CHECK_FIX_DEL;
42  } else if (lc == "del") {
43  check = CfgConsistency::LEASE_CHECK_DEL;
44  } else {
45  isc_throw(DhcpConfigError, "Unsupported lease-checks value: " << lc
46  << ", supported values are: none, warn, fix, fix-del, del");
47  }
48  cfg.getConsistency()->setLeaseSanityCheck(check);
49  }
50 
51  // Additional sanity check fields will come in later here.
52 }
53 
54 };
55 };
CfgConsistencyPtr getConsistency()
Returns const pointer to object holding sanity checks flags.
Definition: srv_config.h:452
LeaseSanity
Values for subnet-id sanity checks done for leases.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
To be removed. Please use ConfigError instead.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
Specifies current DHCP configuration.
Definition: srv_config.h:167
Defines the logger used by the top-level component of kea-dhcp-ddns.