mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 13:07:50 +00:00
[#1007] Replaced some option spaces
This commit is contained in:
parent
dec8595d2f
commit
01e10ceba1
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -368,18 +368,19 @@ TEST_F(Dhcp4CBTest, mergeOptions) {
|
||||
CfgOptionPtr options = staging_cfg->getCfgOption();
|
||||
|
||||
// dhcp-message should come from the original config.
|
||||
OptionDescriptor found_opt = options->get("dhcp4", DHO_DHCP_MESSAGE);
|
||||
OptionDescriptor found_opt =
|
||||
options->get(DHCP4_OPTION_SPACE, DHO_DHCP_MESSAGE);
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
EXPECT_EQ("0x0A0B0C0D", found_opt.option_->toHexString());
|
||||
|
||||
// host-name should come from the first back end,
|
||||
// (overwriting the original).
|
||||
found_opt = options->get("dhcp4", DHO_HOST_NAME);
|
||||
found_opt = options->get(DHCP4_OPTION_SPACE, DHO_HOST_NAME);
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
EXPECT_EQ("new.example.com", found_opt.option_->toString());
|
||||
|
||||
// booth-file-name should come from the first back end.
|
||||
found_opt = options->get("dhcp4", DHO_BOOT_FILE_NAME);
|
||||
found_opt = options->get(DHCP4_OPTION_SPACE, DHO_BOOT_FILE_NAME);
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
EXPECT_EQ("my-boot-file", found_opt.option_->toString());
|
||||
}
|
||||
|
@ -3392,7 +3392,8 @@ TEST_F(Dhcp4ParserTest, optionDataSinglePool) {
|
||||
Pool4Ptr pool4 = boost::dynamic_pointer_cast<Pool4>(pool);
|
||||
ASSERT_TRUE(pool4);
|
||||
|
||||
OptionContainerPtr options = pool4->getCfgOption()->getAll("dhcp4");
|
||||
OptionContainerPtr options =
|
||||
pool4->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
|
||||
ASSERT_EQ(2, options->size());
|
||||
|
||||
// Get the search index. Index #1 is to search using option code.
|
||||
@ -3465,7 +3466,8 @@ TEST_F(Dhcp4ParserTest, optionDataMultiplePools) {
|
||||
Pool4Ptr pool41 = boost::dynamic_pointer_cast<Pool4>(pool1);
|
||||
ASSERT_TRUE(pool41);
|
||||
|
||||
OptionContainerPtr options1 = pool41->getCfgOption()->getAll("dhcp4");
|
||||
OptionContainerPtr options1 =
|
||||
pool41->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options1->size());
|
||||
|
||||
// Get the search index. Index #1 is to search using option code.
|
||||
@ -3491,7 +3493,8 @@ TEST_F(Dhcp4ParserTest, optionDataMultiplePools) {
|
||||
Pool4Ptr pool42 = boost::dynamic_pointer_cast<Pool4>(pool2);
|
||||
ASSERT_TRUE(pool42);
|
||||
|
||||
OptionContainerPtr options2 = pool42->getCfgOption()->getAll("dhcp4");
|
||||
OptionContainerPtr options2 =
|
||||
pool42->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options2->size());
|
||||
|
||||
const OptionContainerTypeIndex& idx2 = options2->get<1>();
|
||||
|
@ -806,7 +806,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
|
||||
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
|
||||
EXPECT_EQ(1, subnets->size());
|
||||
|
||||
OptionDefinitionPtr def = LibDHCP::getRuntimeOptionDef("dhcp4", 163);
|
||||
OptionDefinitionPtr def =
|
||||
LibDHCP::getRuntimeOptionDef(DHCP4_OPTION_SPACE, 163);
|
||||
ASSERT_TRUE(def);
|
||||
|
||||
// Create a config with malformed subnet that should fail to parse.
|
||||
@ -835,7 +836,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
|
||||
subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
|
||||
EXPECT_EQ(1, subnets->size());
|
||||
|
||||
def = LibDHCP::getRuntimeOptionDef("dhcp4", 163);
|
||||
def = LibDHCP::getRuntimeOptionDef(DHCP4_OPTION_SPACE, 163);
|
||||
ASSERT_TRUE(def);
|
||||
|
||||
// Create a valid config with two subnets and no command channel.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -348,14 +348,15 @@ TEST_F(Dhcp6CBTest, mergeOptions) {
|
||||
|
||||
// bootfile-url should come from the first config back end.
|
||||
// (overwriting the original).
|
||||
OptionDescriptor found_opt = options->get("dhcp6", D6O_BOOTFILE_URL);
|
||||
OptionDescriptor found_opt =
|
||||
options->get(DHCP6_OPTION_SPACE, D6O_BOOTFILE_URL);
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
OptionStringPtr opstr = boost::dynamic_pointer_cast<OptionString>(found_opt.option_);
|
||||
ASSERT_TRUE(opstr);
|
||||
EXPECT_EQ("updated-boot-file", opstr->getValue());
|
||||
|
||||
// sol-maxt-rt should come from the original config
|
||||
found_opt = options->get("dhcp6", D6O_SOL_MAX_RT);
|
||||
found_opt = options->get(DHCP6_OPTION_SPACE, D6O_SOL_MAX_RT);
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
OptionUint32Ptr opint = boost::dynamic_pointer_cast<OptionUint32>(found_opt.option_);
|
||||
ASSERT_TRUE(opint);
|
||||
|
@ -3584,7 +3584,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
|
||||
Pool6Ptr pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
|
||||
ASSERT_TRUE(pool6);
|
||||
|
||||
OptionContainerPtr options1 = pool6->getCfgOption()->getAll("dhcp6");
|
||||
OptionContainerPtr options1 =
|
||||
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options1->size());
|
||||
|
||||
// Get the search index. Index #1 is to search using option code.
|
||||
@ -3611,7 +3612,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
|
||||
pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
|
||||
ASSERT_TRUE(pool6);
|
||||
|
||||
OptionContainerPtr options2 = pool6->getCfgOption()->getAll("dhcp6");
|
||||
OptionContainerPtr options2 =
|
||||
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options2->size());
|
||||
|
||||
const OptionContainerTypeIndex& idx2 = options2->get<1>();
|
||||
@ -3632,7 +3634,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
|
||||
pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
|
||||
ASSERT_TRUE(pool6);
|
||||
|
||||
OptionContainerPtr options3 = pool6->getCfgOption()->getAll("dhcp6");
|
||||
OptionContainerPtr options3 =
|
||||
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options3->size());
|
||||
|
||||
const OptionContainerTypeIndex& idx3 = options3->get<1>();
|
||||
@ -3652,7 +3655,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
|
||||
pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
|
||||
ASSERT_TRUE(pool6);
|
||||
|
||||
OptionContainerPtr options4 = pool6->getCfgOption()->getAll("dhcp6");
|
||||
OptionContainerPtr options4 =
|
||||
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
|
||||
ASSERT_EQ(1, options4->size());
|
||||
|
||||
const OptionContainerTypeIndex& idx4 = options4->get<1>();
|
||||
|
@ -715,7 +715,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configSet) {
|
||||
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
|
||||
EXPECT_EQ(1, subnets->size());
|
||||
|
||||
OptionDefinitionPtr def = LibDHCP::getRuntimeOptionDef("dhcp6", 163);
|
||||
OptionDefinitionPtr def =
|
||||
LibDHCP::getRuntimeOptionDef(DHCP6_OPTION_SPACE, 163);
|
||||
ASSERT_TRUE(def);
|
||||
|
||||
// Create a config with malformed subnet that should fail to parse.
|
||||
@ -744,7 +745,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configSet) {
|
||||
subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
|
||||
EXPECT_EQ(1, subnets->size());
|
||||
|
||||
def = LibDHCP::getRuntimeOptionDef("dhcp6", 163);
|
||||
def = LibDHCP::getRuntimeOptionDef(DHCP6_OPTION_SPACE, 163);
|
||||
ASSERT_TRUE(def);
|
||||
|
||||
// Create a valid config with two subnets and no command channel.
|
||||
|
@ -1962,7 +1962,7 @@ public:
|
||||
void createUpdateOptionDef4(const ServerSelector& server_selector,
|
||||
const OptionDefinitionPtr& option_def) {
|
||||
|
||||
createUpdateOptionDef(server_selector, option_def, "dhcp4",
|
||||
createUpdateOptionDef(server_selector, option_def, DHCP4_OPTION_SPACE,
|
||||
MySqlConfigBackendDHCPv4Impl::GET_OPTION_DEF4_CODE_SPACE,
|
||||
MySqlConfigBackendDHCPv4Impl::INSERT_OPTION_DEF4,
|
||||
MySqlConfigBackendDHCPv4Impl::UPDATE_OPTION_DEF4,
|
||||
|
@ -2377,7 +2377,7 @@ public:
|
||||
void createUpdateOptionDef6(const ServerSelector& server_selector,
|
||||
const OptionDefinitionPtr& option_def) {
|
||||
|
||||
createUpdateOptionDef(server_selector, option_def, "dhcp6",
|
||||
createUpdateOptionDef(server_selector, option_def, DHCP6_OPTION_SPACE,
|
||||
MySqlConfigBackendDHCPv6Impl::GET_OPTION_DEF6_CODE_SPACE,
|
||||
MySqlConfigBackendDHCPv6Impl::INSERT_OPTION_DEF6,
|
||||
MySqlConfigBackendDHCPv6Impl::UPDATE_OPTION_DEF6,
|
||||
|
@ -322,15 +322,15 @@ public:
|
||||
|
||||
OptionDefinitionPtr option_def(new OptionDefinition("foo", 234, "string",
|
||||
"espace"));
|
||||
option_def->setOptionSpaceName("dhcp4");
|
||||
option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("bar", 234, "uint32", true));
|
||||
option_def->setOptionSpaceName("dhcp4");
|
||||
option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("fish", 235, "record", true));
|
||||
option_def->setOptionSpaceName("dhcp4");
|
||||
option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
|
||||
option_def->addRecordField("uint32");
|
||||
option_def->addRecordField("string");
|
||||
test_option_defs_.push_back(option_def);
|
||||
@ -340,7 +340,7 @@ public:
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("foobar", 234, "uint64", true));
|
||||
option_def->setOptionSpaceName("dhcp4");
|
||||
option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
}
|
||||
|
||||
|
@ -368,15 +368,15 @@ public:
|
||||
|
||||
OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234, "string",
|
||||
"espace"));
|
||||
option_def->setOptionSpaceName("dhcp6");
|
||||
option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("bar", 1234, "uint32", true));
|
||||
option_def->setOptionSpaceName("dhcp6");
|
||||
option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("fish", 5235, "record", true));
|
||||
option_def->setOptionSpaceName("dhcp6");
|
||||
option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
|
||||
option_def->addRecordField("uint32");
|
||||
option_def->addRecordField("string");
|
||||
test_option_defs_.push_back(option_def);
|
||||
@ -386,7 +386,7 @@ public:
|
||||
test_option_defs_.push_back(option_def);
|
||||
|
||||
option_def.reset(new OptionDefinition("bar", 1234, "uint64", true));
|
||||
option_def->setOptionSpaceName("dhcp6");
|
||||
option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
|
||||
test_option_defs_.push_back(option_def);
|
||||
}
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ TEST_F(LibDhcpTest, emptyHostName) {
|
||||
list<uint16_t> deferred;
|
||||
|
||||
ASSERT_NO_THROW(
|
||||
LibDHCP::unpackOptions4(packed, "dhcp4", options, deferred, false);
|
||||
LibDHCP::unpackOptions4(packed, DHCP4_OPTION_SPACE, options, deferred, false);
|
||||
);
|
||||
|
||||
// Host Name should not exist, we quietly drop it when empty.
|
||||
@ -2370,7 +2370,7 @@ TEST_F(LibDhcpTest, sw46options) {
|
||||
|
||||
size_t parsed = 0;
|
||||
|
||||
EXPECT_NO_THROW (parsed = LibDHCP::unpackOptions6(buf, "dhcp6", options));
|
||||
EXPECT_NO_THROW (parsed = LibDHCP::unpackOptions6(buf, DHCP6_OPTION_SPACE, options));
|
||||
EXPECT_EQ(mape_bin.size(), parsed);
|
||||
|
||||
// We expect to have exactly one option (with tons of suboptions, but we'll
|
||||
|
@ -913,7 +913,8 @@ private:
|
||||
|
||||
// If empty or null space provided, use a default top level space.
|
||||
if (space.empty()) {
|
||||
space = (universe_ == Option::V4 ? "dhcp4" : "dhcp6");
|
||||
space = (universe_ == Option::V4 ?
|
||||
DHCP4_OPTION_SPACE : DHCP6_OPTION_SPACE);
|
||||
}
|
||||
|
||||
// Convert formatted_value to string as well.
|
||||
|
@ -588,7 +588,8 @@ private:
|
||||
|
||||
// If empty or null space provided, use a default top level space.
|
||||
if (space.empty()) {
|
||||
space = (universe_ == Option::V4 ? "dhcp4" : "dhcp6");
|
||||
space = (universe_ == Option::V4 ?
|
||||
DHCP4_OPTION_SPACE : DHCP6_OPTION_SPACE);
|
||||
}
|
||||
|
||||
// persistent: BOOL default false
|
||||
|
@ -489,7 +489,7 @@ public:
|
||||
// modification time is later than last audit revision time it should
|
||||
// be merged.
|
||||
auto options = srv_cfg->getCfgOption();
|
||||
auto found_opt = options->get("dhcp4", DHO_HOST_NAME);
|
||||
auto found_opt = options->get(DHCP4_OPTION_SPACE, DHO_HOST_NAME);
|
||||
if (hasConfigElement("dhcp4_options") &&
|
||||
(getTimestamp("dhcp4_options") > lb_modification_time)) {
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
@ -603,8 +603,10 @@ public:
|
||||
{
|
||||
SCOPED_TRACE("global options");
|
||||
// One of the options should still be there.
|
||||
EXPECT_TRUE(srv_cfg->getCfgOption()->get("dhcp4", DHO_TFTP_SERVER_NAME).option_);
|
||||
auto found_opt = srv_cfg->getCfgOption()->get("dhcp4", DHO_HOST_NAME);
|
||||
EXPECT_TRUE(srv_cfg->getCfgOption()->get(DHCP4_OPTION_SPACE,
|
||||
DHO_TFTP_SERVER_NAME).option_);
|
||||
auto found_opt = srv_cfg->getCfgOption()->get(DHCP4_OPTION_SPACE,
|
||||
DHO_HOST_NAME);
|
||||
if (deleteConfigElement("dhcp4_options", 1)) {
|
||||
EXPECT_FALSE(found_opt.option_);
|
||||
|
||||
@ -1135,7 +1137,7 @@ public:
|
||||
// modification time is later than last audit revision time it should
|
||||
// be merged.
|
||||
auto options = srv_cfg->getCfgOption();
|
||||
auto found_opt = options->get("dhcp6", D6O_BOOTFILE_URL);
|
||||
auto found_opt = options->get(DHCP6_OPTION_SPACE, D6O_BOOTFILE_URL);
|
||||
if (hasConfigElement("dhcp6_options") &&
|
||||
(getTimestamp("dhcp6_options") > lb_modification_time)) {
|
||||
ASSERT_TRUE(found_opt.option_);
|
||||
@ -1249,8 +1251,10 @@ public:
|
||||
{
|
||||
SCOPED_TRACE("global options");
|
||||
// One of the options should still be there.
|
||||
EXPECT_TRUE(srv_cfg->getCfgOption()->get("dhcp6", D6O_AFTR_NAME).option_);
|
||||
auto found_opt = srv_cfg->getCfgOption()->get("dhcp6", D6O_AFTR_NAME);
|
||||
EXPECT_TRUE(srv_cfg->getCfgOption()->get(DHCP6_OPTION_SPACE,
|
||||
D6O_AFTR_NAME).option_);
|
||||
auto found_opt = srv_cfg->getCfgOption()->get(DHCP6_OPTION_SPACE,
|
||||
D6O_AFTR_NAME);
|
||||
if (deleteConfigElement("dhcp6_options", 1)) {
|
||||
EXPECT_FALSE(found_opt.option_);
|
||||
|
||||
|
@ -608,7 +608,7 @@ TEST_F(CfgOptionTest, createDescriptorOptionValid) {
|
||||
defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint8", true))), "isc");
|
||||
|
||||
// We'll try a standard V4 option first.
|
||||
std::string space = "dhcp4";
|
||||
std::string space = DHCP4_OPTION_SPACE;
|
||||
std::string value = "v4.example.com";
|
||||
OptionPtr option(new Option(Option::V6, DHO_HOST_NAME));
|
||||
option->setData(value.begin(), value.end());
|
||||
@ -622,7 +622,7 @@ TEST_F(CfgOptionTest, createDescriptorOptionValid) {
|
||||
EXPECT_EQ("v4.example.com", opstr->getValue());
|
||||
|
||||
// Next we'll try a standard V6 option.
|
||||
space = "dhcp6";
|
||||
space = DHCP6_OPTION_SPACE;
|
||||
std::vector<uint8_t> fqdn =
|
||||
{ 2, 'v', '6', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0 };
|
||||
option.reset(new Option(Option::V6, D6O_AFTR_NAME));
|
||||
|
@ -77,7 +77,7 @@ AdaptorOption::setCode(ElementPtr option, const OptionCodes& codes) {
|
||||
|
||||
void
|
||||
AdaptorOption::initCodes(OptionCodes& codes, const string& space) {
|
||||
if (space == "dhcp4") {
|
||||
if (space == DHCP4_OPTION_SPACE) {
|
||||
initCodesInternal(codes, space, STANDARD_V4_OPTION_DEFINITIONS,
|
||||
STANDARD_V4_OPTION_DEFINITIONS_SIZE);
|
||||
initCodesInternal(codes, space, LAST_RESORT_V4_OPTION_DEFINITIONS,
|
||||
@ -85,7 +85,7 @@ AdaptorOption::initCodes(OptionCodes& codes, const string& space) {
|
||||
initCodesInternal(codes, "vendor-4491",
|
||||
DOCSIS3_V4_OPTION_DEFINITIONS,
|
||||
DOCSIS3_V4_OPTION_DEFINITIONS_SIZE);
|
||||
} else if (space == "dhcp6") {
|
||||
} else if (space == DHCP6_OPTION_SPACE) {
|
||||
initCodesInternal(codes, space, STANDARD_V6_OPTION_DEFINITIONS,
|
||||
STANDARD_V6_OPTION_DEFINITIONS_SIZE);
|
||||
initCodesInternal(codes, "vendor-4491",
|
||||
|
@ -193,7 +193,7 @@ TEST(AdaptorOptionTest, initCodesInternal) {
|
||||
const size_t DEFS_SIZE = sizeof(DEFS) / sizeof(DEFS[0]);
|
||||
OptionCodes codes;
|
||||
ASSERT_NO_THROW(TestAdaptorOption::initCodesInternal(codes,
|
||||
"dhcp4",
|
||||
DHCP4_OPTION_SPACE,
|
||||
DEFS,
|
||||
DEFS_SIZE));
|
||||
ASSERT_EQ(2, codes.size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user