Changes were cosmetic, no fucntional changes required.
Modified:
doc/sphinx/arm/dhcp4-srv.rst
src/bin/dhcp4/tests/config_parser_unittest.cc
src/lib/cc/simple_parser.h
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/client_class_def.h
src/lib/dhcpsrv/parsers/shared_network_parser.cc
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc
.. note::
- Beginning with Kea 1.6.0 the lease valid lifetime is extended from a
- single value to a triplet with minimum, default and maximum values using
- ``min-valid-lifetime``, ``valid-lifetime`` and ``max-valid-lifetime``.
- As of Kea 1.9.5, these values may be specified in client classes. The recipe
- the server uses to select which lifetime value to use is as follows:
-
- If the client query is a BOOTP query, the server will always use the
- infinite lease time (e.g.0xffffffff). Otherwise the server must next
- determine which configured triplet to use by first searching all
- classes assigned to the query, and then the subnet selected for
- the query.
-
- Classes are searched in the order they were assigned to the query. The
- server will use the triplet from the first class that specifies it.
- If no classes specify the triplet then the server will use the triplet
- specified by the subnet selected for the client. If the subnet does not
- explicitly specify it the server will look next at the subnet's
- shared-network (if one), then for a global specification, and
- finally the global default.
-
- If the client requested a lifetime value via DHCP option 51, then the
- lifetime value used will be the requested value bounded by the configured
- triplet. In other words, If the requested lifetime is less than the
- configured minimum the configured minimum will be used; if it is more
- than the configured maximum the configured maximum will be used. If
- the client did not provide a requested value, the lifetime value used
- is the simple be the triplet default value.
+ Beginning with Kea 1.6.0 the lease valid lifetime is extended from a
+ single value to a triplet with minimum, default and maximum values using
+ ``min-valid-lifetime``, ``valid-lifetime`` and ``max-valid-lifetime``.
+ As of Kea 1.9.5, these values may be specified in client classes. The recipe
+ the server uses to select which lifetime value to use is as follows:
+
+ If the client query is a BOOTP query, the server will always use the
+ infinite lease time (e.g. 0xffffffff). Otherwise the server must next
+ determine which configured triplet to use by first searching all
+ classes assigned to the query, and then the subnet selected for
+ the query.
+
+ Classes are searched in the order they were assigned to the query. The
+ server will use the triplet from the first class that specifies it.
+ If no classes specify the triplet then the server will use the triplet
+ specified by the subnet selected for the client. If the subnet does not
+ explicitly specify it the server will look next at the subnet's
+ shared-network (if one), then for a global specification, and
+ finally the global default.
+
+ If the client requested a lifetime value via DHCP option 51, then the
+ lifetime value used will be the requested value bounded by the configured
+ triplet. In other words, if the requested lifetime is less than the
+ configured minimum the configured minimum will be used; if it is more
+ than the configured maximum the configured maximum will be used. If
+ the client did not provide a requested value, the lifetime value used
+ will be the triplet default value.
.. note::
class_def = dictionary->findClass("two");
ASSERT_TRUE(class_def);
EXPECT_TRUE(class_def->getValid().unspecified());
-
}
/// @brief Parses a integer triplet
///
- /// Parse an integer triplet parameter of the form:
+ /// Parses an integer triplet parameter of the form:
///
/// min-<name>, <name>, max-<name>
///
- /// @param scope Data element holding e.g. shared network configuration
+ /// @param scope Data element holding e.g. shared network configuration
/// to be parsed.
/// @param name Base name of the parameter.
/// @return A triplet with the parsed value.
const dhcp::Triplet<uint32_t> parseIntTriplet(const data::ConstElementPtr& scope,
- const std::string& name);
+ const std::string& name);
};
};
// If it's BOOTP, use infinite valid lifetime.
if (ctx.query_->inClass("BOOTP")) {
- return(Lease::INFINITY_LFT);
+ return (Lease::INFINITY_LFT);
}
// Use the dhcp-lease-time content from the client if it's there.
}
}
-
// If the triplet is specified in one of our classes use it.
// We use the first one we find.
- Triplet<uint32_t>candidate_lft;
+ Triplet<uint32_t> candidate_lft;
const ClientClasses classes = ctx.query_->getClasses();
if (!classes.empty()) {
// Let's get class definitions
// If client requested a value, use the value bounded by
// the candidate triplet.
if (requested_lft > 0) {
- return(candidate_lft.get(requested_lft));
+ return (candidate_lft.get(requested_lft));
}
// Use the candidate's default value.
/// it simply returns the candidate triplet's default value.
///
/// @param ctx Client context holding various information about the client.
- /// @return unsigned integer value of the valid lifetime to use
+ /// @return unsigned integer value of the valid lifetime to use.
static uint32_t getValidLft(const ClientContext4& ctx);
private:
// Set valid-lifetime
if (!valid_.unspecified()) {
result->set("valid-lifetime",
- Element::create(static_cast<long long>(valid_.get())));
+ Element::create(static_cast<long long>(valid_.get())));
+
if (valid_.getMin() < valid_.get()) {
result->set("min-valid-lifetime",
- Element::create(static_cast<long long>(valid_.getMin())));
+ Element::create(static_cast<long long>(valid_.getMin())));
}
+
if (valid_.getMax() > valid_.get()) {
result->set("max-valid-lifetime",
- Element::create(static_cast<long long>(valid_.getMax())));
+ Element::create(static_cast<long long>(valid_.getMax())));
}
}
return (*it).second;
}
- return(ClientClassDefPtr());
+ return (ClientClassDefPtr());
}
void
}
/// @brief Return valid-lifetime value
+ /// @return a triplet containing the valid lifetime.
Triplet<uint32_t> getValid() const {
return(valid_);
}
// preferred-lifetime
shared_network->setPreferred(parseIntTriplet(shared_network_data,
- "preferred-lifetime"));
+ "preferred-lifetime"));
// Get interface-id option content. For now we support string
// representation only
ClientClassDictionaryPtr dictionary = CfgMgr::instance().getStagingCfg()->getClientClassDictionary();
ClientClassDefPtr class_def(new ClientClassDef("valid_one", ExpressionPtr()));
- Triplet<uint32_t>valid_one(50,100,150);
+ Triplet<uint32_t> valid_one(50, 100, 150);
class_def->setValid(valid_one);
dictionary->addClass(class_def);
CfgMgr::instance().commit();
// Update the subnet's triplet to something more useful.
- subnet_->setValid(Triplet<uint32_t>(500,1000,1500));
+ subnet_->setValid(Triplet<uint32_t>(500, 1000, 1500));
// Describes a test scenario.
struct Scenario {
std::vector<Scenario> scenarios = {
{
"BOOTP",
- {"BOOTP"},
+ { "BOOTP" },
0,
Lease::INFINITY_LFT
},
},
{
"class plus option",
- {"valid_one"},
+ { "valid_one" },
valid_one.getMin() + 25,
valid_one.getMin() + 25
},
{
"class plus option too small",
- {"valid_one"},
+ { "valid_one" },
valid_one.getMin() - 25,
valid_one.getMin()
},
{
"class plus option too big",
- {"valid_one"},
+ { "valid_one" },
valid_one.getMax() + 25,
valid_one.getMax()
}
std::vector<Scenario> scenarios = {
{
- "unspecified",
- "",
- Triplet<uint32_t>()
+ "unspecified",
+ "",
+ Triplet<uint32_t>()
},
{
- "valid only",
- "\"valid-lifetime\": 100",
- Triplet<uint32_t>(100)
+ "valid only",
+ "\"valid-lifetime\": 100",
+ Triplet<uint32_t>(100)
},
{
- "min only",
- "\"min-valid-lifetime\": 50",
- Triplet<uint32_t>(50, 50, 50)
+ "min only",
+ "\"min-valid-lifetime\": 50",
+ Triplet<uint32_t>(50, 50, 50)
},
{
- "max only",
- "\"max-valid-lifetime\": 75",
- Triplet<uint32_t>(75, 75, 75)
+ "max only",
+ "\"max-valid-lifetime\": 75",
+ Triplet<uint32_t>(75, 75, 75)
},
{
- "all three",
- "\"min-valid-lifetime\": 25, \"valid-lifetime\": 50, \"max-valid-lifetime\": 75",
- Triplet<uint32_t>(25, 50, 75)
+ "all three",
+ "\"min-valid-lifetime\": 25, \"valid-lifetime\": 50, \"max-valid-lifetime\": 75",
+ Triplet<uint32_t>(25, 50, 75)
}
};
if (!scenario.cfg_txt_.empty()) {
oss << ",\n" << scenario.cfg_txt_;
}
- oss << "\n}\n";
+ oss << "\n}\n";
ClientClassDefPtr class_def;
ASSERT_NO_THROW_LOG(class_def = parseClientClassDef(oss.str(), AF_INET));