Kea 2.7.6
expiration_config_parser.cc
Go to the documentation of this file.
1// Copyright (C) 2015-2024 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>
8
9#include <cc/data.h>
11#include <dhcpsrv/cfgmgr.h>
14
15using namespace isc::data;
16
17namespace isc {
18namespace dhcp {
19
20void
22 std::string param;
23 try {
24 param = "reclaim-timer-wait-time";
25 if (expiration_config->contains(param)) {
26 cfg->setReclaimTimerWaitTime(getInteger(expiration_config, param));
27 }
28
29 param = "flush-reclaimed-timer-wait-time";
30 if (expiration_config->contains(param)) {
31 cfg->setFlushReclaimedTimerWaitTime(getInteger(expiration_config,
32 param));
33 }
34
35 param = "hold-reclaimed-time";
36 if (expiration_config->contains(param)) {
37 cfg->setHoldReclaimedTime(getInteger(expiration_config, param));
38 }
39
40 param = "max-reclaim-leases";
41 if (expiration_config->contains(param)) {
42 cfg->setMaxReclaimLeases(getInteger(expiration_config, param));
43 }
44
45 param = "max-reclaim-time";
46 if (expiration_config->contains(param)) {
47 cfg->setMaxReclaimTime(getInteger(expiration_config, param));
48 }
49
50 param = "unwarned-reclaim-cycles";
51 if (expiration_config->contains(param)) {
52 cfg->setUnwarnedReclaimCycles(
53 getInteger(expiration_config, param));
54 }
55 } catch (const DhcpConfigError&) {
56 throw;
57 } catch (const std::exception& ex) {
58 // Append position of the configuration parameter to the error message.
59 isc_throw(DhcpConfigError, ex.what() << " ("
60 << getPosition(param, expiration_config) << ")");
61 }
62}
63
64} // end of namespace isc::dhcp
65} // end of namespace isc
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
To be removed. Please use ConfigError instead.
void parse(isc::data::ConstElementPtr expiration_config, isc::dhcp::CfgExpirationPtr expiration)
Parses parameters in the JSON map, pertaining to the processing of the expired leases.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Pointer to the Non-const object.
Defines the logger used by the top-level component of kea-lfc.