Commit 6011b532 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[4204] OptionDef config parser updates runtime definitions in libdhcp.

parent 1e7bdebf
......@@ -120,14 +120,18 @@ public:
OptionDefinitionPtr get(const std::string& option_space,
const std::string& option_name) const;
/// @brief Returns reference to container holding option definitions.
const OptionDefSpaceContainer& getContainer() const {
return (option_definitions_);
}
private:
/// @brief A collection of option definitions.
///
/// The option definitions stored in this container can be accessed
/// using the option space name they belong to.
OptionSpaceContainer<OptionDefContainer, OptionDefinitionPtr,
std::string> option_definitions_;
OptionDefSpaceContainer option_definitions_;
};
......
......@@ -780,6 +780,12 @@ OptionDefParser::build(ConstElementPtr option_def) {
isc_throw(DhcpConfigError, ex.what() << " ("
<< option_def->getPosition() << ")");
}
// All definitions have been prepared. Put them as runtime options into
// the libdhcp++.
const OptionDefSpaceContainer& container =
CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->getContainer();
LibDHCP::setRuntimeOptionDefs(container);
}
void
......
......@@ -495,6 +495,15 @@ TEST_F(ParseConfigTest, basicOptionDefTest) {
EXPECT_FALSE(def->getArrayType());
EXPECT_EQ(OPT_IPV4_ADDRESS_TYPE, def->getType());
EXPECT_TRUE(def->getEncapsulatedSpace().empty());
// Check if libdhcp++ runtime options have been updated.
OptionDefinitionPtr def_libdhcp = LibDHCP::getRuntimeOptionDef("isc", 100);
ASSERT_TRUE(def_libdhcp);
// The LibDHCP should return a separate instance of the option definition
// but the values should be equal.
EXPECT_TRUE(def_libdhcp != def);
EXPECT_TRUE(*def_libdhcp == *def);
}
/// @brief Check minimal parsing of option definitions.
......
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