Commit ad44a39d authored by Marcin Siodelski's avatar Marcin Siodelski

[master] Merge branch 'trac3589'

parents 1ae54ff5 902bfdf4
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
* - @subpage libdhcpsrv * - @subpage libdhcpsrv
* - @subpage leasemgr * - @subpage leasemgr
* - @subpage cfgmgr * - @subpage cfgmgr
* - @subpage optionsConfig
* - @subpage allocengine * - @subpage allocengine
* - @subpage libdhcp_ddns * - @subpage libdhcp_ddns
* - @subpage dhcpDatabaseBackends * - @subpage dhcpDatabaseBackends
......
...@@ -601,10 +601,9 @@ Dhcpv4Srv::appendRequestedOptions(const Pkt4Ptr& question, Pkt4Ptr& msg) { ...@@ -601,10 +601,9 @@ Dhcpv4Srv::appendRequestedOptions(const Pkt4Ptr& question, Pkt4Ptr& msg) {
for (std::vector<uint8_t>::const_iterator opt = requested_opts.begin(); for (std::vector<uint8_t>::const_iterator opt = requested_opts.begin();
opt != requested_opts.end(); ++opt) { opt != requested_opts.end(); ++opt) {
if (!msg->getOption(*opt)) { if (!msg->getOption(*opt)) {
Subnet::OptionDescriptor desc = OptionDescriptor desc = subnet->getCfgOption()->get("dhcp4", *opt);
subnet->getOptionDescriptor("dhcp4", *opt); if (desc.option_ && !msg->getOption(*opt)) {
if (desc.option && !msg->getOption(*opt)) { msg->addOption(desc.option_);
msg->addOption(desc.option);
} }
} }
} }
...@@ -652,10 +651,10 @@ Dhcpv4Srv::appendRequestedVendorOptions(const Pkt4Ptr& question, Pkt4Ptr& answer ...@@ -652,10 +651,10 @@ Dhcpv4Srv::appendRequestedVendorOptions(const Pkt4Ptr& question, Pkt4Ptr& answer
for (std::vector<uint8_t>::const_iterator code = requested_opts.begin(); for (std::vector<uint8_t>::const_iterator code = requested_opts.begin();
code != requested_opts.end(); ++code) { code != requested_opts.end(); ++code) {
if (!vendor_rsp->getOption(*code)) { if (!vendor_rsp->getOption(*code)) {
Subnet::OptionDescriptor desc = subnet->getVendorOptionDescriptor(vendor_id, OptionDescriptor desc = subnet->getCfgOption()->get(vendor_id,
*code); *code);
if (desc.option) { if (desc.option_) {
vendor_rsp->addOption(desc.option); vendor_rsp->addOption(desc.option_);
added = true; added = true;
} }
} }
...@@ -691,10 +690,10 @@ Dhcpv4Srv::appendBasicOptions(const Pkt4Ptr& question, Pkt4Ptr& msg) { ...@@ -691,10 +690,10 @@ Dhcpv4Srv::appendBasicOptions(const Pkt4Ptr& question, Pkt4Ptr& msg) {
OptionPtr opt = msg->getOption(required_options[i]); OptionPtr opt = msg->getOption(required_options[i]);
if (!opt) { if (!opt) {
// Check whether option has been configured. // Check whether option has been configured.
Subnet::OptionDescriptor desc = OptionDescriptor desc = subnet->getCfgOption()->
subnet->getOptionDescriptor("dhcp4", required_options[i]); get("dhcp4", required_options[i]);
if (desc.option) { if (desc.option_) {
msg->addOption(desc.option); msg->addOption(desc.option_);
} }
} }
} }
...@@ -1981,12 +1980,12 @@ bool Dhcpv4Srv::classSpecificProcessing(const Pkt4Ptr& query, const Pkt4Ptr& rsp ...@@ -1981,12 +1980,12 @@ bool Dhcpv4Srv::classSpecificProcessing(const Pkt4Ptr& query, const Pkt4Ptr& rsp
// Now try to set up file field in DHCPv4 packet. We will just copy // Now try to set up file field in DHCPv4 packet. We will just copy
// content of the boot-file option, which contains the same information. // content of the boot-file option, which contains the same information.
Subnet::OptionDescriptor desc = OptionDescriptor desc = subnet->getCfgOption()->
subnet->getOptionDescriptor("dhcp4", DHO_BOOT_FILE_NAME); get("dhcp4", DHO_BOOT_FILE_NAME);
if (desc.option) { if (desc.option_) {
boost::shared_ptr<OptionString> boot = boost::shared_ptr<OptionString> boot =
boost::dynamic_pointer_cast<OptionString>(desc.option); boost::dynamic_pointer_cast<OptionString>(desc.option_);
if (boot) { if (boot) {
std::string filename = boot->getValue(); std::string filename = boot->getValue();
rsp->setFile((const uint8_t*)filename.c_str(), filename.size()); rsp->setFile((const uint8_t*)filename.c_str(), filename.size());
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <dhcp4/dhcp4_log.h> #include <dhcp4/dhcp4_log.h>
#include <dhcp/libdhcp++.h> #include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h> #include <dhcp/option_definition.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfgmgr.h> #include <dhcpsrv/cfgmgr.h>
#include <dhcp4/json_config_parser.h> #include <dhcp4/json_config_parser.h>
#include <dhcpsrv/dbaccess_parser.h> #include <dhcpsrv/dbaccess_parser.h>
...@@ -41,72 +42,6 @@ using namespace isc::asiolink; ...@@ -41,72 +42,6 @@ using namespace isc::asiolink;
namespace { namespace {
/// @brief Parser for DHCP4 option data value.
///
/// This parser parses configuration entries that specify value of
/// a single option specific to DHCP4. It provides the DHCP4-specific
/// implementation of the abstract class OptionDataParser.
class Dhcp4OptionDataParser : public OptionDataParser {
public:
/// @brief Constructor.
///
/// @param dummy first param, option names are always "Dhcp4/option-data[n]"
/// @param options is the option storage in which to store the parsed option
/// upon "commit".
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
Dhcp4OptionDataParser(const std::string&,
OptionStoragePtr options, ParserContextPtr global_context)
:OptionDataParser("", options, global_context) {
}
/// @brief static factory method for instantiating Dhcp4OptionDataParsers
///
/// @param param_name name of the parameter to be parsed.
/// @param options storage where the parameter value is to be stored.
/// @param global_context is a pointer to the global context which
/// stores global scope parameters, options, option defintions.
/// @return returns a pointer to a new OptionDataParser. Caller is
/// is responsible for deleting it when it is no longer needed.
static OptionDataParser* factory(const std::string& param_name,
OptionStoragePtr options, ParserContextPtr global_context) {
return (new Dhcp4OptionDataParser(param_name, options, global_context));
}
protected:
/// @brief Finds an option definition within the server's option space
///
/// Given an option space and an option code, find the correpsonding
/// option defintion within the server's option defintion storage.
///
/// @param option_space name of the parameter option space
/// @param option_code numeric value of the parameter to find
/// @return OptionDefintionPtr of the option defintion or an
/// empty OptionDefinitionPtr if not found.
/// @throw DhcpConfigError if the option space requested is not valid
/// for this server.
virtual OptionDefinitionPtr findServerSpaceOptionDefinition (
std::string& option_space, uint32_t option_code) {
OptionDefinitionPtr def;
if (option_space == "dhcp4" &&
LibDHCP::isStandardOption(Option::V4, option_code)) {
def = LibDHCP::getOptionDef(Option::V4, option_code);
} else if (option_space == "dhcp6") {
isc_throw(DhcpConfigError, "'dhcp6' option space name is reserved"
<< " for DHCPv6 server");
} else {
// Check if this is a vendor-option. If it is, get vendor-specific
// definition.
uint32_t vendor_id = SubnetConfigParser::optionSpaceToVendorId(option_space);
if (vendor_id) {
def = LibDHCP::getVendorOptionDef(Option::V4, vendor_id, option_code);
}
}
return (def);
}
};
/// @brief Parser for IPv4 pool definitions. /// @brief Parser for IPv4 pool definitions.
/// ///
/// This is the IPv4 derivation of the PoolParser class and handles pool /// This is the IPv4 derivation of the PoolParser class and handles pool
...@@ -244,9 +179,7 @@ protected: ...@@ -244,9 +179,7 @@ protected:
} else if (config_id.compare("relay") == 0) { } else if (config_id.compare("relay") == 0) {
parser = new RelayInfoParser(config_id, relay_info_, Option::V4); parser = new RelayInfoParser(config_id, relay_info_, Option::V4);
} else if (config_id.compare("option-data") == 0) { } else if (config_id.compare("option-data") == 0) {
parser = new OptionDataListParser(config_id, options_, parser = new OptionDataListParser(config_id, options_, AF_INET);
global_context_,
Dhcp4OptionDataParser::factory);
} else { } else {
isc_throw(NotImplemented, "unsupported parameter: " << config_id); isc_throw(NotImplemented, "unsupported parameter: " << config_id);
} }
...@@ -447,10 +380,7 @@ namespace dhcp { ...@@ -447,10 +380,7 @@ namespace dhcp {
} else if (config_id.compare("subnet4") == 0) { } else if (config_id.compare("subnet4") == 0) {
parser = new Subnets4ListConfigParser(config_id); parser = new Subnets4ListConfigParser(config_id);
} else if (config_id.compare("option-data") == 0) { } else if (config_id.compare("option-data") == 0) {
parser = new OptionDataListParser(config_id, parser = new OptionDataListParser(config_id, CfgOptionPtr(), AF_INET);
globalContext()->options_,
globalContext(),
Dhcp4OptionDataParser::factory);
} else if (config_id.compare("option-def") == 0) { } else if (config_id.compare("option-def") == 0) {
parser = new OptionDefListParser(config_id, globalContext()); parser = new OptionDefListParser(config_id, globalContext());
} else if ((config_id.compare("version") == 0) || } else if ((config_id.compare("version") == 0) ||
......
...@@ -231,7 +231,7 @@ public: ...@@ -231,7 +231,7 @@ public:
/// @return Descriptor of the option. If the descriptor holds a /// @return Descriptor of the option. If the descriptor holds a
/// NULL option pointer, it means that there was no such option /// NULL option pointer, it means that there was no such option
/// in the subnet. /// in the subnet.
Subnet::OptionDescriptor OptionDescriptor
getOptionFromSubnet(const IOAddress& subnet_address, getOptionFromSubnet(const IOAddress& subnet_address,
const uint16_t option_code, const uint16_t option_code,
const uint16_t expected_options_count = 1) { const uint16_t expected_options_count = 1) {
...@@ -243,8 +243,8 @@ public: ...@@ -243,8 +243,8 @@ public:
<< subnet_address.toText() << subnet_address.toText()
<< "does not exist in Config Manager"; << "does not exist in Config Manager";
} }
Subnet::OptionContainerPtr options = OptionContainerPtr options =
subnet->getOptionDescriptors("dhcp4"); subnet->getCfgOption()->getAll("dhcp4");
if (expected_options_count != options->size()) { if (expected_options_count != options->size()) {
ADD_FAILURE() << "The number of options in the subnet '" ADD_FAILURE() << "The number of options in the subnet '"
<< subnet_address.toText() << "' is different " << subnet_address.toText() << "' is different "
...@@ -253,13 +253,13 @@ public: ...@@ -253,13 +253,13 @@ public:
} }
// Get the search index. Index #1 is to search using option code. // Get the search index. Index #1 is to search using option code.
const Subnet::OptionContainerTypeIndex& idx = options->get<1>(); const OptionContainerTypeIndex& idx = options->get<1>();
// Get the options for specified index. Expecting one option to be // Get the options for specified index. Expecting one option to be
// returned but in theory we may have multiple options with the same // returned but in theory we may have multiple options with the same
// code so we get the range. // code so we get the range.
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range = OptionContainerTypeIndex::const_iterator> range =
idx.equal_range(option_code); idx.equal_range(option_code);
if (std::distance(range.first, range.second) > 1) { if (std::distance(range.first, range.second) > 1) {
ADD_FAILURE() << "There is more than one option having the" ADD_FAILURE() << "There is more than one option having the"
...@@ -267,7 +267,7 @@ public: ...@@ -267,7 +267,7 @@ public:
<< subnet_address.toText() << "'. Expected " << subnet_address.toText() << "'. Expected "
" at most one option"; " at most one option";
} else if (std::distance(range.first, range.second) == 0) { } else if (std::distance(range.first, range.second) == 0) {
return (Subnet::OptionDescriptor(OptionPtr(), false)); return (OptionDescriptor(OptionPtr(), false));
} }
return (*range.first); return (*range.first);
...@@ -319,35 +319,35 @@ public: ...@@ -319,35 +319,35 @@ public:
/// @param expected_data_len length of the reference data. /// @param expected_data_len length of the reference data.
/// @param extra_data if true extra data is allowed in an option /// @param extra_data if true extra data is allowed in an option
/// after tested data. /// after tested data.
void testOption(const Subnet::OptionDescriptor& option_desc, void testOption(const OptionDescriptor& option_desc,
uint16_t expected_code, const uint8_t* expected_data, uint16_t expected_code, const uint8_t* expected_data,
size_t expected_data_len, size_t expected_data_len,
bool extra_data = false) { bool extra_data = false) {
// Check if option descriptor contains valid option pointer. // Check if option descriptor contains valid option pointer.
ASSERT_TRUE(option_desc.option); ASSERT_TRUE(option_desc.option_);
// Verify option type. // Verify option type.
EXPECT_EQ(expected_code, option_desc.option->getType()); EXPECT_EQ(expected_code, option_desc.option_->getType());
// We may have many different option types being created. Some of them // We may have many different option types being created. Some of them
// have dedicated classes derived from Option class. In such case if // have dedicated classes derived from Option class. In such case if
// we want to verify the option contents against expected_data we have // we want to verify the option contents against expected_data we have
// to prepare raw buffer with the contents of the option. The easiest // to prepare raw buffer with the contents of the option. The easiest
// way is to call pack() which will prepare on-wire data. // way is to call pack() which will prepare on-wire data.
util::OutputBuffer buf(option_desc.option->getData().size()); util::OutputBuffer buf(option_desc.option_->getData().size());
option_desc.option->pack(buf); option_desc.option_->pack(buf);
if (extra_data) { if (extra_data) {
// The length of the buffer must be at least equal to size of the // The length of the buffer must be at least equal to size of the
// reference data but it can sometimes be greater than that. This is // reference data but it can sometimes be greater than that. This is
// because some options carry suboptions that increase the overall // because some options carry suboptions that increase the overall
// length. // length.
ASSERT_GE(buf.getLength() - option_desc.option->getHeaderLen(), ASSERT_GE(buf.getLength() - option_desc.option_->getHeaderLen(),
expected_data_len); expected_data_len);
} else { } else {
ASSERT_EQ(buf.getLength() - option_desc.option->getHeaderLen(), ASSERT_EQ(buf.getLength() - option_desc.option_->getHeaderLen(),
expected_data_len); expected_data_len);
} }
// Verify that the data is correct. Do not verify suboptions and a header. // Verify that the data is correct. Do not verify suboptions and a header.
const uint8_t* data = static_cast<const uint8_t*>(buf.getData()); const uint8_t* data = static_cast<const uint8_t*>(buf.getData());
EXPECT_EQ(0, memcmp(expected_data, data + option_desc.option->getHeaderLen(), EXPECT_EQ(0, memcmp(expected_data, data + option_desc.option_->getHeaderLen(),
expected_data_len)); expected_data_len));
} }
...@@ -378,9 +378,9 @@ public: ...@@ -378,9 +378,9 @@ public:
std::string config = createConfigWithOption(params); std::string config = createConfigWithOption(params);
ASSERT_TRUE(executeConfiguration(config, "parse option configuration")); ASSERT_TRUE(executeConfiguration(config, "parse option configuration"));
// The subnet should now hold one option with the specified option code. // The subnet should now hold one option with the specified option code.
Subnet::OptionDescriptor desc = OptionDescriptor desc =
getOptionFromSubnet(IOAddress("192.0.2.24"), option_code); getOptionFromSubnet(IOAddress("192.0.2.24"), option_code);
ASSERT_TRUE(desc.option); ASSERT_TRUE(desc.option_);
testOption(desc, option_code, expected_data, expected_data_len); testOption(desc, option_code, expected_data, expected_data_len);
} }
...@@ -1797,17 +1797,17 @@ TEST_F(Dhcp4ParserTest, optionDataDefaults) { ...@@ -1797,17 +1797,17 @@ TEST_F(Dhcp4ParserTest, optionDataDefaults) {
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.200"), Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.200"),
classify_); classify_);
ASSERT_TRUE(subnet); ASSERT_TRUE(subnet);
Subnet::OptionContainerPtr options = subnet->getOptionDescriptors("dhcp4"); OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
ASSERT_EQ(2, options->size()); ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code. // Get the search index. Index #1 is to search using option code.
const Subnet::OptionContainerTypeIndex& idx = options->get<1>(); const OptionContainerTypeIndex& idx = options->get<1>();
// Get the options for specified index. Expecting one option to be // Get the options for specified index. Expecting one option to be
// returned but in theory we may have multiple options with the same // returned but in theory we may have multiple options with the same
// code so we get the range. // code so we get the range.
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range = OptionContainerTypeIndex::const_iterator> range =
idx.equal_range(56); idx.equal_range(56);
// Expect single option with the code equal to 56. // Expect single option with the code equal to 56.
ASSERT_EQ(1, std::distance(range.first, range.second)); ASSERT_EQ(1, std::distance(range.first, range.second));
...@@ -1884,17 +1884,17 @@ TEST_F(Dhcp4ParserTest, optionDataTwoSpaces) { ...@@ -1884,17 +1884,17 @@ TEST_F(Dhcp4ParserTest, optionDataTwoSpaces) {
classify_); classify_);
ASSERT_TRUE(subnet); ASSERT_TRUE(subnet);
// Try to get the option from the space dhcp4. // Try to get the option from the space dhcp4.
Subnet::OptionDescriptor desc1 = subnet->getOptionDescriptor("dhcp4", 56); OptionDescriptor desc1 = subnet->getCfgOption()->get("dhcp4", 56);
ASSERT_TRUE(desc1.option); ASSERT_TRUE(desc1.option_);
EXPECT_EQ(56, desc1.option->getType()); EXPECT_EQ(56, desc1.option_->getType());
// Try to get the option from the space isc. // Try to get the option from the space isc.
Subnet::OptionDescriptor desc2 = subnet->getOptionDescriptor("isc", 56); OptionDescriptor desc2 = subnet->getCfgOption()->get("isc", 56);
ASSERT_TRUE(desc2.option); ASSERT_TRUE(desc2.option_);
EXPECT_EQ(56, desc1.option->getType()); EXPECT_EQ(56, desc1.option_->getType());
// Try to get the non-existing option from the non-existing // Try to get the non-existing option from the non-existing
// option space and expect that option is not returned. // option space and expect that option is not returned.
Subnet::OptionDescriptor desc3 = subnet->getOptionDescriptor("non-existing", 56); OptionDescriptor desc3 = subnet->getCfgOption()->get("non-existing", 56);
ASSERT_FALSE(desc3.option); ASSERT_FALSE(desc3.option_);
} }
// The goal of this test is to verify that it is possible to // The goal of this test is to verify that it is possible to
...@@ -2039,23 +2039,23 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) { ...@@ -2039,23 +2039,23 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
ASSERT_TRUE(subnet); ASSERT_TRUE(subnet);
// We should have one option available. // We should have one option available.
Subnet::OptionContainerPtr options = subnet->getOptionDescriptors("dhcp4"); OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
ASSERT_TRUE(options); ASSERT_TRUE(options);
ASSERT_EQ(1, options->size()); ASSERT_EQ(1, options->size());
// Get the option. // Get the option.
Subnet::OptionDescriptor desc = subnet->getOptionDescriptor("dhcp4", 222); OptionDescriptor desc = subnet->getCfgOption()->get("dhcp4", 222);
EXPECT_TRUE(desc.option); EXPECT_TRUE(desc.option_);
EXPECT_EQ(222, desc.option->getType()); EXPECT_EQ(222, desc.option_->getType());
// This opton should comprise two sub-options. // This opton should comprise two sub-options.
// One of them is 'foo' with code 1. // One of them is 'foo' with code 1.
OptionPtr option_foo = desc.option->getOption(1); OptionPtr option_foo = desc.option_->getOption(1);
ASSERT_TRUE(option_foo); ASSERT_TRUE(option_foo);
EXPECT_EQ(1, option_foo->getType()); EXPECT_EQ(1, option_foo->getType());
// ...another one 'foo2' with code 2. // ...another one 'foo2' with code 2.
OptionPtr option_foo2 = desc.option->getOption(2); OptionPtr option_foo2 = desc.option_->getOption(2);
ASSERT_TRUE(option_foo2); ASSERT_TRUE(option_foo2);
EXPECT_EQ(2, option_foo2->getType()); EXPECT_EQ(2, option_foo2->getType());
} }
...@@ -2104,17 +2104,17 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) { ...@@ -2104,17 +2104,17 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) {
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.24"), Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.24"),
classify_); classify_);
ASSERT_TRUE(subnet); ASSERT_TRUE(subnet);
Subnet::OptionContainerPtr options = subnet->getOptionDescriptors("dhcp4"); OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
ASSERT_EQ(2, options->size()); ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code. // Get the search index. Index #1 is to search using option code.
const Subnet::OptionContainerTypeIndex& idx = options->get<1>(); const OptionContainerTypeIndex& idx = options->get<1>();
// Get the options for specified index. Expecting one option to be // Get the options for specified index. Expecting one option to be
// returned but in theory we may have multiple options with the same // returned but in theory we may have multiple options with the same
// code so we get the range. // code so we get the range.
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range = OptionContainerTypeIndex::const_iterator> range =
idx.equal_range(56); idx.equal_range(56);
// Expect single option with the code equal to 100. // Expect single option with the code equal to 100.
ASSERT_EQ(1, std::distance(range.first, range.second)); ASSERT_EQ(1, std::distance(range.first, range.second));
...@@ -2150,9 +2150,9 @@ TEST_F(Dhcp4ParserTest, optionDataBoolean) { ...@@ -2150,9 +2150,9 @@ TEST_F(Dhcp4ParserTest, optionDataBoolean) {
" boolean value")); " boolean value"));
// The subnet should now hold one option with the code 19. // The subnet should now hold one option with the code 19.
Subnet::OptionDescriptor desc = getOptionFromSubnet(IOAddress("192.0.2.24"), OptionDescriptor desc = getOptionFromSubnet(IOAddress("192.0.2.24"),
19); 19);
ASSERT_TRUE(desc.option); ASSERT_TRUE(desc.option_);
// This option should be set to "true", represented as 0x1 in the option // This option should be set to "true", represented as 0x1 in the option
// buffer. // buffer.
...@@ -2255,17 +2255,17 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) { ...@@ -2255,17 +2255,17 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
Subnet4Ptr subnet1 = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.100"), Subnet4Ptr subnet1 = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.100"),
classify_); classify_);
ASSERT_TRUE(subnet1); ASSERT_TRUE(subnet1);
Subnet::OptionContainerPtr options1 = subnet1->getOptionDescriptors("dhcp4"); OptionContainerPtr options1 = subnet1->getCfgOption()->getAll("dhcp4");
ASSERT_EQ(1, options1->size()); ASSERT_EQ(1, options1->size());
// Get the search index. Index #1 is to search using option code. // Get the search index. Index #1 is to search using option code.
const Subnet::OptionContainerTypeIndex& idx1 = options1->get<1>(); const OptionContainerTypeIndex& idx1 = options1->get<1>();
// Get the options for specified index. Expecting one option to be // Get the options for specified index. Expecting one option to be
// returned but in theory we may have multiple options with the same // returned but in theory we may have multiple options with the same
// code so we get the range. // code so we get the range.
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range1 = OptionContainerTypeIndex::const_iterator> range1 =
idx1.equal_range(56); idx1.equal_range(56);
// Expect single option with the code equal to 56. // Expect single option with the code equal to 56.
ASSERT_EQ(1, std::distance(range1.first, range1.second)); ASSERT_EQ(1, std::distance(range1.first, range1.second));
...@@ -2280,12 +2280,12 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) { ...@@ -2280,12 +2280,12 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
Subnet4Ptr subnet2 = CfgMgr::instance().getSubnet4(IOAddress("192.0.3.102"), Subnet4Ptr subnet2 = CfgMgr::instance().getSubnet4(IOAddress("192.0.3.102"),
classify_); classify_);
ASSERT_TRUE(subnet2); ASSERT_TRUE(subnet2);
Subnet::OptionContainerPtr options2 = subnet2->getOptionDescriptors("dhcp4"); OptionContainerPtr options2 = subnet2->getCfgOption()->getAll("dhcp4");
ASSERT_EQ(1, options2->size()); ASSERT_EQ(1, options2->size());
const Subnet::OptionContainerTypeIndex& idx2 = options2->get<1>(); const OptionContainerTypeIndex& idx2 = options2->get<1>();
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range2 = OptionContainerTypeIndex::const_iterator> range2 =
idx2.equal_range(23); idx2.equal_range(23);
ASSERT_EQ(1, std::distance(range2.first, range2.second)); ASSERT_EQ(1, std::distance(range2.first, range2.second));
...@@ -2358,17 +2358,17 @@ TEST_F(Dhcp4ParserTest, optionDataLowerCase) { ...@@ -2358,17 +2358,17 @@ TEST_F(Dhcp4ParserTest, optionDataLowerCase) {
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"), Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"),
classify_); classify_);
ASSERT_TRUE(subnet); ASSERT_TRUE(subnet);
Subnet::OptionContainerPtr options = subnet->getOptionDescriptors("dhcp4"); OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
ASSERT_EQ(1, options->size()); ASSERT_EQ(1, options->size());
// Get the search index. Index #1 is to search using option code. // Get the search index. Index #1 is to search using option code.
const Subnet::OptionContainerTypeIndex& idx = options->get<1>(); const OptionContainerTypeIndex& idx = options->get<1>();
// Get the options for specified index. Expecting one option to be // Get the options for specified index. Expecting one option to be
// returned but in theory we may have multiple options with the same // returned but in theory we may have multiple options with the same
// code so we get the range. // code so we get the range.
std::pair<Subnet::OptionContainerTypeIndex::const_iterator, std::pair<OptionContainerTypeIndex::const_iterator,
Subnet::OptionContainerTypeIndex::const_iterator> range = OptionContainerTypeIndex::const_iterator> range =
idx.equal_range(56); idx.equal_range(56);
// Expect single option with the code equal to 100. // Expect single option with the code equal to 100.
ASSERT_EQ(1, std::distance(range.first, range.second)); ASSERT_EQ(1, std::distance(range.first, range.second));
...@@ -2401,25 +2401,25 @@ TEST_F(Dhcp4ParserTest, stdOptionData) { ...@@ -2401,25 +2401,25 @@ TEST_F(Dhcp4ParserTest, stdOptionData) {
Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"), Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(IOAddress("192.0.2.5"),
classify_);