23 bool has_renew = network_data->contains(
"renew-timer");
24 bool has_rebind = network_data->contains(
"rebind-timer");
29 renew =
getInteger(network_data,
"renew-timer");
32 << renew <<
") must be a positive number");
34 network->setT1(renew);
38 rebind =
getInteger(network_data,
"rebind-timer");
41 << rebind <<
") must be a positive number");
43 network->setT2(rebind);
46 if (has_renew && has_rebind && (renew > rebind)) {
51 .arg(network->getLabel())
58 if (network_data->contains(
"store-extended-info")) {
59 network->setStoreExtendedInfo(
getBoolean(network_data,
60 "store-extended-info"));
63 if (network_data->contains(
"reservations-global")) {
64 network->setReservationsGlobal(
getBoolean(network_data,
65 "reservations-global"));
68 if (network_data->contains(
"reservations-in-subnet")) {
69 network->setReservationsInSubnet(
getBoolean(network_data,
70 "reservations-in-subnet"));
73 if (network_data->contains(
"reservations-out-of-pool")) {
74 network->setReservationsOutOfPool(
getBoolean(network_data,
75 "reservations-out-of-pool"));
82 bool calculate_tee_times = network->getCalculateTeeTimes();
83 if (network_data->contains(
"calculate-tee-times")) {
84 calculate_tee_times =
getBoolean(network_data,
"calculate-tee-times");
85 network->setCalculateTeeTimes(calculate_tee_times);
88 Optional<double> t2_percent;
89 if (network_data->contains(
"t2-percent")) {
90 t2_percent =
getDouble(network_data,
"t2-percent");
93 Optional<double> t1_percent;
94 if (network_data->contains(
"t1-percent")) {
95 t1_percent =
getDouble(network_data,
"t1-percent");
97 if (calculate_tee_times) {
98 if (!t2_percent.unspecified() && ((t2_percent.get() <= 0.0) ||
99 (t2_percent.get() >= 1.0))) {
101 <<
" is invalid, it must be greater than 0.0 and less than 1.0");
104 if (!t1_percent.unspecified() && ((t1_percent.get() <= 0.0) ||
105 (t1_percent.get() >= 1.0))) {
107 <<
" is invalid it must be greater than 0.0 and less than 1.0");
110 if (!t1_percent.unspecified() && !t2_percent.unspecified() &&
111 (t1_percent.get() >= t2_percent.get())) {
113 <<
" is invalid, it must be less than t2-percent: "
114 << t2_percent.get());
118 network->setT2Percent(t2_percent);
119 network->setT1Percent(t1_percent);
125 if (network_data->contains(
"cache-threshold")) {
126 double cache_threshold =
getDouble(network_data,
"cache-threshold");
127 if ((cache_threshold <= 0.0) || (cache_threshold >= 1.0)) {
129 <<
" is invalid, it must be greater than 0.0 and less than 1.0");
131 network->setCacheThreshold(cache_threshold);
134 if (network_data->contains(
"cache-max-age")) {
135 network->setCacheMaxAge(
getInteger(network_data,
"cache-max-age"));
143 if (network_data->contains(
"ddns-send-updates")) {
144 network->setDdnsSendUpdates(
getBoolean(network_data,
"ddns-send-updates"));
147 if (network_data->contains(
"ddns-override-no-update")) {
148 network->setDdnsOverrideNoUpdate(
getBoolean(network_data,
"ddns-override-no-update"));
151 if (network_data->contains(
"ddns-override-client-update")) {
152 network->setDdnsOverrideClientUpdate(
getBoolean(network_data,
"ddns-override-client-update"));
155 if (network_data->contains(
"ddns-replace-client-name")) {
158 (network_data,
"ddns-replace-client-name",
159 "ReplaceClientName mode"));
162 if (network_data->contains(
"ddns-generated-prefix")) {
163 network->setDdnsGeneratedPrefix(
getString(network_data,
"ddns-generated-prefix"));
166 if (network_data->contains(
"ddns-qualifying-suffix")) {
167 network->setDdnsQualifyingSuffix(
getString(network_data,
"ddns-qualifying-suffix"));
170 std::string hostname_char_set;
171 if (network_data->contains(
"hostname-char-set")) {
172 hostname_char_set =
getString(network_data,
"hostname-char-set");
173 network->setHostnameCharSet(hostname_char_set);
176 std::string hostname_char_replacement;
177 if (network_data->contains(
"hostname-char-replacement")) {
178 hostname_char_replacement =
getString(network_data,
"hostname-char-replacement");
179 network->setHostnameCharReplacement(hostname_char_replacement);
185 if (!hostname_char_set.empty()) {
188 hostname_char_replacement));
189 }
catch (
const std::exception& ex) {
191 <<
"' is not a valid regular expression");
195 if (network_data->contains(
"ddns-update-on-renew")) {
196 network->setDdnsUpdateOnRenew(
getBoolean(network_data,
"ddns-update-on-renew"));
199 if (network_data->contains(
"ddns-ttl-percent")) {
200 network->setDdnsTtlPercent(
getDouble(network_data,
"ddns-ttl-percent"));
204 if (network_data->contains(
"ddns-conflict-resolution-mode")) {
205 network->setDdnsConflictResolutionMode(
getString(network_data,
206 "ddns-conflict-resolution-mode"));
213 if (network_data->contains(
"allocator")) {
214 auto allocator_type =
getString(network_data,
"allocator");
215 if ((allocator_type !=
"iterative") && (allocator_type !=
"random") &&
216 (allocator_type !=
"flq")) {
220 network->setAllocatorType(allocator_type);
227 if (network_data->contains(
"pd-allocator")) {
228 auto allocator_type =
getString(network_data,
"pd-allocator");
229 if ((allocator_type !=
"iterative") && (allocator_type !=
"random") &&
230 (allocator_type !=
"flq")) {
234 network->setPdAllocatorType(allocator_type);
241 if (network_data->contains(
"offer-lifetime")) {
242 auto value =
getInteger(network_data,
"offer-lifetime");
245 << value <<
"' must be a positive number ("
246 <<
getPosition(
"offer-lifetime", network_data) <<
")");
249 network->setOfferLft(value);
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
target_type getAndConvert(isc::data::ConstElementPtr scope, const std::string &name, const std::string &type_name)
Returns a converted value from a scope.
static const data::Element::Position & getPosition(const std::string &name, const data::ConstElementPtr parent)
Utility method that returns position of an element.
static double getDouble(const ConstElementPtr &scope, const std::string &name)
Returns a floating point parameter from a scope.
static std::string getString(isc::data::ConstElementPtr scope, const std::string &name)
Returns a string parameter from a scope.
const isc::util::Triplet< uint32_t > parseIntTriplet(const data::ConstElementPtr &scope, const std::string &name)
Parses an integer triplet.
static bool getBoolean(isc::data::ConstElementPtr scope, const std::string &name)
Returns a boolean parameter from a scope.
static int64_t getInteger(isc::data::ConstElementPtr scope, const std::string &name)
Returns an integer parameter from a scope.
void parseCacheParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to lease cache settings.
void parseAllocatorParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to allocator selection.
void parseDdnsParams(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters pertaining to DDNS behavior.
void parseCommon(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses common parameters.
void parseTeePercents(const data::ConstElementPtr &network_data, NetworkPtr &network)
Parses parameters related to "percent" timers settings.
void parsePdAllocatorParams(const data::ConstElementPtr &network_data, Network6Ptr &network)
Parses parameters pertaining to prefix delegation allocator selection.
void parseOfferLft(const data::ConstElementPtr &network_data, Network4Ptr &network)
Parses offer-lifetime parameter (v4 only)
static ReplaceClientNameMode stringToReplaceClientNameMode(const std::string &mode_str)
Converts labels to ReplaceClientNameMode enum values.
ReplaceClientNameMode
Defines the client name replacement modes.
To be removed. Please use ConfigError instead.
Implements a regular expression based string scrubber.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define LOG_WARN(LOGGER, MESSAGE)
Macro to conveniently test warn output and log it.
boost::shared_ptr< const Element > ConstElementPtr
isc::log::Logger dhcpsrv_logger("dhcpsrv")
DHCP server library Logger.
boost::shared_ptr< Network4 > Network4Ptr
Pointer to the Network4 object.
const isc::log::MessageID DHCPSRV_CFGMGR_RENEW_GTR_REBIND
boost::shared_ptr< Network6 > Network6Ptr
Pointer to the Network6 object.
boost::shared_ptr< Network > NetworkPtr
Pointer to the Network object.
std::unique_ptr< StringSanitizer > StringSanitizerPtr
Type representing the pointer to the StringSanitizer.
Defines the logger used by the top-level component of kea-lfc.