Commit 9ef628e7 authored by Francis Dupont's avatar Francis Dupont
Browse files

[295-min-max-lease-time-configuration-options] Removed default- keywords

parent ba9b894b
......@@ -726,13 +726,9 @@
// Subnet prefix.
"subnet": "192.0.0.0/8",
// Subnet level valid lifetime.
// Subnet level (default) valid lifetime.
"valid-lifetime": 6000,
// Subnet level default valid lifetime.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6000,
// Subnet level min valid lifetime.
"min-valid-lifetime": 4000,
......@@ -741,13 +737,9 @@
}
],
// Shared network level valid lifetime.
// Shared network level (default) valid lifetime.
"valid-lifetime": 6001,
// Shared network level default valid lifetime.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6001,
// Subnet level min valid lifetime.
"min-valid-lifetime": 4001,
......@@ -762,13 +754,9 @@
// List of IPv4 subnets which don't belong to any shared network.
"subnet4": [],
// Global valid lifetime value.
// Global valid (default) lifetime value.
"valid-lifetime": 6000,
// Global default valid lifetime value.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6000,
// Global min valid lifetime value.
"min-valid-lifetime": 4000,
......
......@@ -412,13 +412,9 @@
}
],
// Global value of the preferred lifetime.
// Global (default) value of the preferred lifetime.
"preferred-lifetime": 50,
// Global default value of the preferred lifetime.
// (in fact only an alias of preferred lifetime)
"default-preferred-lifetime": 50,
// Global min value of the preferred lifetime.
"min-preferred-lifetime": 40,
......@@ -491,13 +487,9 @@
// List of shared network specific DHCP options.
"option-data": [],
// Shared network specific preferred lifetime.
// Shared network specific (default) preferred lifetime.
"preferred-lifetime": 2000,
// Shared network specific default preferred lifetime.
// (in fact only an alias of preferred lifetime)
"default-preferred-lifetime": 2000,
// Shared network specific min preferred lifetime.
"min-preferred-lifetime": 1500,
......@@ -633,13 +625,9 @@
}
],
// Subnet specific preferred lifetime.
// Subnet specific (default) preferred lifetime.
"preferred-lifetime": 2000,
// Subnet specific default preferred lifetime.
// (in fact only an alias of preferred lifetime)
"default-preferred-lifetime": 2000,
// Subnet specific min preferred lifetime.
"min-preferred-lifetime": 1500,
......@@ -715,13 +703,9 @@
// Subnet prefix.
"subnet": "2001:db8::/32",
// Subnet level valid lifetime.
// Subnet level (default) valid lifetime.
"valid-lifetime": 6000,
// Subnet level default valid lifetime.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6000,
// Subnet level min valid lifetime.
"min-valid-lifetime": 4000,
......@@ -730,13 +714,9 @@
}
],
// Shared network level valid lifetime.
// Shared network level (default) valid lifetime.
"valid-lifetime": 6001,
// Shared network level default valid lifetime.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6001,
// Shared network level min valid lifetime.
"min-valid-lifetime": 4001,
......@@ -748,13 +728,9 @@
// List of IPv6 subnets which don't belong to any shared network.
"subnet6": [],
// Global valid lifetime value.
// Global (default) valid lifetime value.
"valid-lifetime": 6000,
// Global default valid lifetime value.
// (in fact only an alias of valid lifetime)
"default-valid-lifetime": 6000,
// Global min valid lifetime value.
"min-valid-lifetime": 4000,
......
......@@ -592,17 +592,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"default-valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
case isc::dhcp::Parser4Context::SUBNET4:
case isc::dhcp::Parser4Context::SHARED_NETWORK:
return isc::dhcp::Dhcp4Parser::make_DEFAULT_VALID_LIFETIME(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("default-valid-lifetime", driver.loc_);
}
}
\"min-valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
......
......@@ -102,7 +102,6 @@ using namespace std;
TCP_NODELAY "tcp-nodelay"
VALID_LIFETIME "valid-lifetime"
DEFAULT_VALID_LIFETIME "default-valid-lifetime"
MIN_VALID_LIFETIME "min-valid-lifetime"
MAX_VALID_LIFETIME "max-valid-lifetime"
RENEW_TIMER "renew-timer"
......@@ -444,7 +443,6 @@ global_params: global_param
// These are the parameters that are allowed in the top-level for
// Dhcp4.
global_param: valid_lifetime
| default_valid_lifetime
| min_valid_lifetime
| max_valid_lifetime
| renew_timer
......@@ -493,11 +491,6 @@ valid_lifetime: VALID_LIFETIME COLON INTEGER {
ctx.stack_.back()->set("valid-lifetime", prf);
};
default_valid_lifetime: DEFAULT_VALID_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("default-valid-lifetime", prf);
};
min_valid_lifetime: MIN_VALID_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("min-valid-lifetime", prf);
......
......@@ -788,17 +788,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"default-preferred-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
return isc::dhcp::Dhcp6Parser::make_DEFAULT_PREFERRED_LIFETIME(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("default-preferred-lifetime", driver.loc_);
}
}
\"min-preferred-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
......@@ -832,17 +821,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"default-valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
return isc::dhcp::Dhcp6Parser::make_DEFAULT_VALID_LIFETIME(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("default-valid-lifetime", driver.loc_);
}
}
\"min-valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::DHCP6:
......
......@@ -86,11 +86,9 @@ using namespace std;
TCP_NODELAY "tcp-nodelay"
PREFERRED_LIFETIME "preferred-lifetime"
DEFAULT_PREFERRED_LIFETIME "default-preferred-lifetime"
MIN_PREFERRED_LIFETIME "min-preferred-lifetime"
MAX_PREFERRED_LIFETIME "max-preferred-lifetime"
VALID_LIFETIME "valid-lifetime"
DEFAULT_VALID_LIFETIME "default-valid-lifetime"
MIN_VALID_LIFETIME "min-valid-lifetime"
MAX_VALID_LIFETIME "max-valid-lifetime"
RENEW_TIMER "renew-timer"
......@@ -451,11 +449,9 @@ global_params: global_param
// Dhcp6.
global_param: data_directory
| preferred_lifetime
| default_preferred_lifetime
| min_preferred_lifetime
| max_preferred_lifetime
| valid_lifetime
| default_valid_lifetime
| min_valid_lifetime
| max_valid_lifetime
| renew_timer
......@@ -509,11 +505,6 @@ preferred_lifetime: PREFERRED_LIFETIME COLON INTEGER {
ctx.stack_.back()->set("preferred-lifetime", prf);
};
default_preferred_lifetime: DEFAULT_PREFERRED_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("default-preferred-lifetime", prf);
};
min_preferred_lifetime: MIN_PREFERRED_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("min-preferred-lifetime", prf);
......@@ -529,11 +520,6 @@ valid_lifetime: VALID_LIFETIME COLON INTEGER {
ctx.stack_.back()->set("valid-lifetime", prf);
};
default_valid_lifetime: DEFAULT_VALID_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("default-valid-lifetime", prf);
};
min_valid_lifetime: MIN_VALID_LIFETIME COLON INTEGER {
ElementPtr prf(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("min-valid-lifetime", prf);
......@@ -1123,11 +1109,9 @@ subnet6_params: subnet6_param
// This defines a list of allowed parameters for each subnet.
subnet6_param: preferred_lifetime
| default_preferred_lifetime
| min_preferred_lifetime
| max_preferred_lifetime
| valid_lifetime
| default_valid_lifetime
| min_valid_lifetime
| max_valid_lifetime
| renew_timer
......@@ -1265,12 +1249,10 @@ shared_network_param: name
| client_class
| require_client_classes
| preferred_lifetime
| default_preferred_lifetime
| min_preferred_lifetime
| max_preferred_lifetime
| rapid_commit
| valid_lifetime
| default_valid_lifetime
| min_valid_lifetime
| max_valid_lifetime
| user_context
......
......@@ -373,16 +373,6 @@ AllocEngine::AllocatorPtr AllocEngine::getAllocator(Lease::Type type) {
return (alloc->second);
}
AllocEngine::Resource::Resource(const Option6IAAddrPtr& iaaddr)
: address_(iaaddr->getAddress()), prefix_len_(128),
preferred_(iaaddr->getPreferred()), valid_(iaaddr->getValid()) {
}
AllocEngine::Resource::Resource(const Option6IAPrefixPtr& iaprefix)
: address_(iaprefix->getAddress()), prefix_len_(iaprefix->getLength()),
preferred_(iaprefix->getPreferred()), valid_(iaprefix->getValid()) {
}
} // end of namespace isc::dhcp
} // end of namespace isc
......@@ -480,13 +470,21 @@ IAContext::addHint(const asiolink::IOAddress& prefix,
void
AllocEngine::ClientContext6::
IAContext::addHint(const Option6IAAddrPtr& iaaddr) {
hints_.push_back(Resource(iaaddr));
if (!iaaddr) {
isc_throw(BadValue, "IAADDR option pointer is null.");
}
addHint(iaaddr->getAddress(), 128,
iaaddr->getPreferred(), iaaddr->getValid());
}
void
AllocEngine::ClientContext6::
IAContext::addHint(const Option6IAPrefixPtr& iaprefix) {
hints_.push_back(Resource(iaprefix));
if (!iaprefix) {
isc_throw(BadValue, "IAPREFIX option pointer is null.");
}
addHint(iaprefix->getAddress(), iaprefix->getLength(),
iaprefix->getPreferred(), iaprefix->getValid());
}
void
......
......@@ -299,16 +299,6 @@ public:
preferred_(preferred), valid_(valid) {
}
/// @brief Constructor from an IAADDR DHCPv6 option.
///
/// @param iaaddr The pointer to the IAADDR option
Resource(const Option6IAAddrPtr& iaaddr);
/// @brief Constructor from an IAPREFIX DHCPv6 option.
///
/// @param iaprefix The pointer to the IAPREFIX option
Resource(const Option6IAPrefixPtr& iaprefix);
/// @brief Returns the address.
///
/// @return the address or prefix
......@@ -547,11 +537,13 @@ public:
/// @brief Convenience method adding new hint from IAADDR option.
///
/// @param iaaddr Pointer to IAADDR.
/// @throw BadValue if iaaddr is null.
void addHint(const Option6IAAddrPtr& iaaddr);
/// @brief Convenience method adding new hint from IAPREFIX option.
///
/// @param iaprefix Pointer to IAPREFIX.
/// @throw BadValue if iaprefix is null.
void addHint(const Option6IAPrefixPtr& iaprefix);
};
......
......@@ -171,21 +171,15 @@ Network::toElement() const {
// Set valid-lifetime
if (!valid_.unspecified()) {
if ((valid_.get() == valid_.getMin()) &&
(valid_.get() == valid_.getMax())) {
map->set("valid-lifetime",
Element::create(static_cast<long long>(valid_.get())));
} else {
map->set("default-valid-lifetime",
Element::create(static_cast<long long>(valid_.get())));
if (valid_.get() != valid_.getMin()) {
map->set("min-valid-lifetime",
Element::create(static_cast<long long>(valid_.getMin())));
}
if (valid_.get() != valid_.getMax()) {
map->set("max-valid-lifetime",
Element::create(static_cast<long long>(valid_.getMax())));
}
map->set("valid-lifetime",
Element::create(static_cast<long long>(valid_.get())));
if (valid_.get() != valid_.getMin()) {
map->set("min-valid-lifetime",
Element::create(static_cast<long long>(valid_.getMin())));
}
if (valid_.get() != valid_.getMax()) {
map->set("max-valid-lifetime",
Element::create(static_cast<long long>(valid_.getMax())));
}
}
......@@ -305,21 +299,15 @@ Network6::toElement() const {
// Set preferred-lifetime
if (!preferred_.unspecified()) {
if ((preferred_.get() == preferred_.getMin()) &&
(preferred_.get() == preferred_.getMax())) {
map->set("preferred-lifetime",
Element::create(static_cast<long long>(preferred_.get())));
} else {
map->set("default-preferred-lifetime",
Element::create(static_cast<long long>(preferred_.get())));
if (preferred_.get() != preferred_.getMin()) {
map->set("min-preferred-lifetime",
Element::create(static_cast<long long>(preferred_.getMin())));
}
if (preferred_.get() != preferred_.getMax()) {
map->set("max-preferred-lifetime",
Element::create(static_cast<long long>(preferred_.getMax())));
}
map->set("preferred-lifetime",
Element::create(static_cast<long long>(preferred_.get())));
if (preferred_.get() != preferred_.getMin()) {
map->set("min-preferred-lifetime",
Element::create(static_cast<long long>(preferred_.getMin())));
}
if (preferred_.get() != preferred_.getMax()) {
map->set("max-preferred-lifetime",
Element::create(static_cast<long long>(preferred_.getMax())));
}
}
......
......@@ -28,14 +28,6 @@ BaseNetworkParser::parseLifetime(const ConstElementPtr& scope,
value = getInteger(scope, name);
has_value = true;
}
if (scope->contains("default-" + name)) {
if (has_value) {
isc_throw(DhcpConfigError, "have both " << name << " and default-"
<< name << " in " << scope->getPosition());
}
value = getInteger(scope, "default-" + name);
has_value = true;
}
if (scope->contains("min-" + name)) {
min_value = getInteger(scope, "min-" + name);
has_min = true;
......@@ -67,8 +59,8 @@ BaseNetworkParser::parseLifetime(const ConstElementPtr& scope,
} else {
// min and max.
isc_throw(DhcpConfigError, "have min-" << name << " and max-"
<< name << " but no default-" << name << " nor "
<< name << " in " << scope->getPosition());
<< name << " but no " << name << " (default) in "
<< scope->getPosition());
}
} else {
// max only.
......@@ -77,7 +69,7 @@ BaseNetworkParser::parseLifetime(const ConstElementPtr& scope,
}
// Check that value is between min and max.
if ((value < min_value) || (value > max_value)) {
isc_throw(DhcpConfigError, "the value of default-" << name << " ("
isc_throw(DhcpConfigError, "the value of (default) " << name << " ("
<< value << ") is not between min-" << name << " ("
<< min_value << ") and max-" << name << " ("
<< max_value << ")");
......@@ -157,7 +149,5 @@ BaseNetworkParser::parseHostReservationMode(const data::ConstElementPtr& network
}
}
} // end of namespace isc::dhcp
} // end of namespace isc
......@@ -37,7 +37,6 @@ namespace dhcp {
/// Order follows global_param rule in bison grammar.
const SimpleKeywords SimpleParser4::GLOBAL4_PARAMETERS = {
{ "valid-lifetime", Element::integer },
{ "default-valid-lifetime", Element::integer },
{ "min-valid-lifetime", Element::integer },
{ "max-valid-lifetime", Element::integer },
{ "renew-timer", Element::integer },
......@@ -186,7 +185,6 @@ const ParamsList SimpleParser4::INHERIT_TO_SUBNET4 = {
"reservation-mode",
"server-hostname",
"valid-lifetime",
"default-valid-lifetime",
"min-valid-lifetime",
"max-valid-lifetime",
"calculate-tee-times",
......
......@@ -37,11 +37,9 @@ namespace dhcp {
const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
{ "data-directory", Element::string },
{ "preferred-lifetime", Element::integer },
{ "default-preferred-lifetime", Element::integer },
{ "min-preferred-lifetime", Element::integer },
{ "max-preferred-lifetime", Element::integer },
{ "valid-lifetime", Element::integer },
{ "default-valid-lifetime", Element::integer },
{ "min-valid-lifetime", Element::integer },
{ "max-valid-lifetime", Element::integer },
{ "renew-timer", Element::integer },
......@@ -162,7 +160,6 @@ const ParamsList SimpleParser6::INHERIT_TO_SUBNET6 = {
"interface",
"interface-id",
"preferred-lifetime",
"default-preferred-lifetime",
"min-preferred-lifetime",
"max-preferred-lifetime",
"rapid-commit",
......@@ -171,7 +168,6 @@ const ParamsList SimpleParser6::INHERIT_TO_SUBNET6 = {
"renew-timer",
"reservation-mode",
"valid-lifetime",
"default-valid-lifetime",
"min-valid-lifetime",
"max-valid-lifetime",
"calculate-tee-times",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment