| Kea 3.0.2-git

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>
10#include <dhcpsrv/cfg_expiration.h>
11#include <dhcpsrv/cfgmgr.h>
12#include <dhcpsrv/parsers/expiration_config_parser.h>
13#include <dhcpsrv/parsers/dhcp_parsers.h>
14
15 using namespace isc::data;
16
17 namespace isc {
18 namespace dhcp {
19
20 void
21 ExpirationConfigParser::parse(ConstElementPtr expiration_config, CfgExpirationPtr cfg) {
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
cfg_expiration.h
cfgmgr.h
isc::data::SimpleParser::getPosition
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
Definition lib/cc/simple_parser.cc:158
isc::data::SimpleParser::getInteger
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
Definition lib/cc/simple_parser.cc:77
isc::dhcp::DhcpConfigError
To be removed. Please use ConfigError instead.
Definition dhcp_config_error.h:58
isc::dhcp::ExpirationConfigParser::parse
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.
Definition expiration_config_parser.cc:21
data.h
dhcp_parsers.h
isc_throw
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Definition exceptions/exceptions.h:210
expiration_config_parser.h
isc::data
Definition base_stamped_element.cc:12
isc::data::ConstElementPtr
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
isc::dhcp
Definition dhcp4/client_handler.cc:20
isc::dhcp::CfgExpirationPtr
boost::shared_ptr< CfgExpiration > CfgExpirationPtr
Pointer to the Non-const object.
Definition cfg_expiration.h:275
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148