24 bool has_renew = network_data->contains(
"renew-timer");
25 bool has_rebind = network_data->contains(
"rebind-timer");
30 renew =
getInteger(network_data,
"renew-timer");
33 << renew <<
") must be a positive number");
35 network->setT1(renew);
39 rebind =
getInteger(network_data,
"rebind-timer");
42 << rebind <<
") must be a positive number");
44 network->setT2(rebind);
47 if (has_renew && has_rebind && (renew > rebind)) {
52 .arg(network->getLabel())
59 if (network_data->contains(
"store-extended-info")) {
60 network->setStoreExtendedInfo(
getBoolean(network_data,
61 "store-extended-info"));
64 if (network_data->contains(
"reservations-global")) {
65 network->setReservationsGlobal(
getBoolean(network_data,
66 "reservations-global"));
69 if (network_data->contains(
"reservations-in-subnet")) {
70 network->setReservationsInSubnet(
getBoolean(network_data,
71 "reservations-in-subnet"));
74 if (network_data->contains(
"reservations-out-of-pool")) {
75 network->setReservationsOutOfPool(
getBoolean(network_data,
76 "reservations-out-of-pool"));
83 bool calculate_tee_times = network->getCalculateTeeTimes();
84 if (network_data->contains(
"calculate-tee-times")) {
85 calculate_tee_times =
getBoolean(network_data,
"calculate-tee-times");
86 network->setCalculateTeeTimes(calculate_tee_times);
90 if (network_data->contains(
"t2-percent")) {
91 t2_percent =
getDouble(network_data,
"t2-percent");
95 if (network_data->contains(
"t1-percent")) {
96 t1_percent =
getDouble(network_data,
"t1-percent");
98 if (calculate_tee_times) {
100 (t2_percent.
get() >= 1.0))) {
102 <<
" is invalid, it must be greater than 0.0 and less than 1.0");
106 (t1_percent.
get() >= 1.0))) {
108 <<
" is invalid it must be greater than 0.0 and less than 1.0");
112 (t1_percent.
get() >= t2_percent.
get())) {
114 <<
" is invalid, it must be less than t2-percent: "
115 << t2_percent.
get());
119 network->setT2Percent(t2_percent);
120 network->setT1Percent(t1_percent);
126 if (network_data->contains(
"cache-threshold")) {
127 double cache_threshold =
getDouble(network_data,
"cache-threshold");
128 if ((cache_threshold <= 0.0) || (cache_threshold >= 1.0)) {
130 <<
" is invalid, it must be greater than 0.0 and less than 1.0");
132 network->setCacheThreshold(cache_threshold);
135 if (network_data->contains(
"cache-max-age")) {
136 network->setCacheMaxAge(
getInteger(network_data,
"cache-max-age"));
144 if (network_data->contains(
"ddns-send-updates")) {
145 network->setDdnsSendUpdates(
getBoolean(network_data,
"ddns-send-updates"));
148 if (network_data->contains(
"ddns-override-no-update")) {
149 network->setDdnsOverrideNoUpdate(
getBoolean(network_data,
"ddns-override-no-update"));
152 if (network_data->contains(
"ddns-override-client-update")) {
153 network->setDdnsOverrideClientUpdate(
getBoolean(network_data,
"ddns-override-client-update"));
156 if (network_data->contains(
"ddns-replace-client-name")) {
159 (network_data,
"ddns-replace-client-name",
160 "ReplaceClientName mode"));
163 if (network_data->contains(
"ddns-generated-prefix")) {
164 network->setDdnsGeneratedPrefix(
getString(network_data,
"ddns-generated-prefix"));
167 if (network_data->contains(
"ddns-qualifying-suffix")) {
168 network->setDdnsQualifyingSuffix(
getString(network_data,
"ddns-qualifying-suffix"));
171 std::string hostname_char_set;
172 if (network_data->contains(
"hostname-char-set")) {
173 hostname_char_set =
getString(network_data,
"hostname-char-set");
174 network->setHostnameCharSet(hostname_char_set);
177 std::string hostname_char_replacement;
178 if (network_data->contains(
"hostname-char-replacement")) {
179 hostname_char_replacement =
getString(network_data,
"hostname-char-replacement");
180 network->setHostnameCharReplacement(hostname_char_replacement);
186 if (!hostname_char_set.empty()) {
189 hostname_char_replacement));
190 }
catch (
const std::exception& ex) {
192 <<
"' is not a valid regular expression");
196 if (network_data->contains(
"ddns-update-on-renew")) {
197 network->setDdnsUpdateOnRenew(
getBoolean(network_data,
"ddns-update-on-renew"));
200 bool has_ddns_ttl =
false;
201 uint32_t ddns_ttl = 0;
202 if (network_data->contains(
"ddns-ttl")) {
203 ddns_ttl =
getInteger(network_data,
"ddns-ttl");
204 network->setDdnsTtl(ddns_ttl);
208 if (network_data->contains(
"ddns-ttl-percent")) {
213 network->setDdnsTtlPercent(
getDouble(network_data,
"ddns-ttl-percent"));
216 uint32_t ddns_ttl_min = 0;
217 if (network_data->contains(
"ddns-ttl-min")) {
222 ddns_ttl_min =
getInteger(network_data,
"ddns-ttl-min");
223 network->setDdnsTtlMin(ddns_ttl_min);
226 if (network_data->contains(
"ddns-ttl-max")) {
231 uint32_t ddns_ttl_max =
getInteger(network_data,
"ddns-ttl-max");
232 if (ddns_ttl_max < ddns_ttl_min) {
234 <<
" must be greater than ddns-ttl-min: " << ddns_ttl_min);
237 network->setDdnsTtlMax(ddns_ttl_max);
241 if (network_data->contains(
"ddns-conflict-resolution-mode")) {
242 network->setDdnsConflictResolutionMode(
getString(network_data,
243 "ddns-conflict-resolution-mode"));
250 if (network_data->contains(
"allocator")) {
251 auto allocator_type =
getString(network_data,
"allocator");
252 if ((allocator_type !=
"iterative") && (allocator_type !=
"random") &&
253 (allocator_type !=
"flq")) {
257 network->setAllocatorType(allocator_type);
264 if (network_data->contains(
"pd-allocator")) {
265 auto allocator_type =
getString(network_data,
"pd-allocator");
266 if ((allocator_type !=
"iterative") && (allocator_type !=
"random") &&
267 (allocator_type !=
"flq")) {
271 network->setPdAllocatorType(allocator_type);
278 if (network_data->contains(
"offer-lifetime")) {
279 auto value =
getInteger(network_data,
"offer-lifetime");
282 << value <<
"' must be a positive number ("
283 <<
getPosition(
"offer-lifetime", network_data) <<
")");
286 network->setOfferLft(value);
295 ConstElementPtr class_list = params->get(
"evaluate-additional-classes");
296 if (req_class_list) {
299 class_list = req_class_list;
302 "cannot specify both 'require-client-classes' and "
303 "'evaluate-additional-classes'. Use only the latter.");
308 const std::vector<data::ElementPtr>& classes = class_list->listValue();
309 for (
auto const& cclass : classes) {
311 cclass->stringValue().empty()) {
315 (adder_func)(cclass->stringValue());
333 if (!class_elem->stringValue().empty()) {
334 (adder_func)(class_elem->stringValue());
338 "cannot specify both 'client-class' and "
339 "'client-classes'. Use only the latter.");
344 for (
auto const& cclass : class_list->listValue()) {
346 cclass->stringValue().empty()) {
350 (adder_func)(cclass->stringValue());
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.
static void getClientClassesElem(data::ConstElementPtr params, ClassAdderFunc adder_func)
Fetches the element for either 'client-classes' or deprecated 'client-class'.
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.
std::function< void(const isc::dhcp::ClientClass &)> ClassAdderFunc
static void getAdditionalClassesElem(data::ConstElementPtr params, ClassAdderFunc adder_func)
Fetches the element for either 'evaluate-additional-classes' or deprecated 'require-client-classes'.
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.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
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.
const isc::log::MessageID DHCPSRV_CLIENT_CLASS_DEPRECATED
const isc::log::MessageID DHCPSRV_REQUIRE_CLIENT_CLASSES_DEPRECATED
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.