From f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:15:43 +0200 Subject: Adding upstream version 2.4.1. Signed-off-by: Daniel Baumann --- .../dhcpsrv/parsers/expiration_config_parser.cc | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/lib/dhcpsrv/parsers/expiration_config_parser.cc (limited to 'src/lib/dhcpsrv/parsers/expiration_config_parser.cc') diff --git a/src/lib/dhcpsrv/parsers/expiration_config_parser.cc b/src/lib/dhcpsrv/parsers/expiration_config_parser.cc new file mode 100644 index 0000000..3bbe333 --- /dev/null +++ b/src/lib/dhcpsrv/parsers/expiration_config_parser.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2015-2019 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include +#include +#include +#include + +using namespace isc::data; + +namespace isc { +namespace dhcp { + +void +ExpirationConfigParser::parse(ConstElementPtr expiration_config) { + CfgExpirationPtr cfg = CfgMgr::instance().getStagingCfg()->getCfgExpiration(); + + std::string param; + + try { + param = "reclaim-timer-wait-time"; + if (expiration_config->contains(param)) { + cfg->setReclaimTimerWaitTime(getInteger(expiration_config, param)); + } + + param = "flush-reclaimed-timer-wait-time"; + if (expiration_config->contains(param)) { + cfg->setFlushReclaimedTimerWaitTime(getInteger(expiration_config, + param)); + } + + param = "hold-reclaimed-time"; + if (expiration_config->contains(param)) { + cfg->setHoldReclaimedTime(getInteger(expiration_config, param)); + } + + param = "max-reclaim-leases"; + if (expiration_config->contains(param)) { + cfg->setMaxReclaimLeases(getInteger(expiration_config, param)); + } + + param = "max-reclaim-time"; + if (expiration_config->contains(param)) { + cfg->setMaxReclaimTime(getInteger(expiration_config, param)); + } + + param = "unwarned-reclaim-cycles"; + if (expiration_config->contains(param)) { + cfg->setUnwarnedReclaimCycles( + getInteger(expiration_config, param)); + } + } catch (const DhcpConfigError&) { + throw; + } catch (const std::exception& ex) { + // Append position of the configuration parameter to the error message. + isc_throw(DhcpConfigError, ex.what() << " (" + << getPosition(param, expiration_config) << ")"); + } +} + +} // end of namespace isc::dhcp +} // end of namespace isc -- cgit v1.2.3