2
0
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:
Francis Dupont 2020-08-03 17:37:32 +02:00
parent dec8595d2f
commit 01e10ceba1
17 changed files with 60 additions and 43 deletions

View File

@ -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 // 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 // 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(); CfgOptionPtr options = staging_cfg->getCfgOption();
// dhcp-message should come from the original config. // 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_); ASSERT_TRUE(found_opt.option_);
EXPECT_EQ("0x0A0B0C0D", found_opt.option_->toHexString()); EXPECT_EQ("0x0A0B0C0D", found_opt.option_->toHexString());
// host-name should come from the first back end, // host-name should come from the first back end,
// (overwriting the original). // (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_); ASSERT_TRUE(found_opt.option_);
EXPECT_EQ("new.example.com", found_opt.option_->toString()); EXPECT_EQ("new.example.com", found_opt.option_->toString());
// booth-file-name should come from the first back end. // 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_); ASSERT_TRUE(found_opt.option_);
EXPECT_EQ("my-boot-file", found_opt.option_->toString()); EXPECT_EQ("my-boot-file", found_opt.option_->toString());
} }

View File

@ -3392,7 +3392,8 @@ TEST_F(Dhcp4ParserTest, optionDataSinglePool) {
Pool4Ptr pool4 = boost::dynamic_pointer_cast<Pool4>(pool); Pool4Ptr pool4 = boost::dynamic_pointer_cast<Pool4>(pool);
ASSERT_TRUE(pool4); ASSERT_TRUE(pool4);
OptionContainerPtr options = pool4->getCfgOption()->getAll("dhcp4"); OptionContainerPtr options =
pool4->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
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.
@ -3465,7 +3466,8 @@ TEST_F(Dhcp4ParserTest, optionDataMultiplePools) {
Pool4Ptr pool41 = boost::dynamic_pointer_cast<Pool4>(pool1); Pool4Ptr pool41 = boost::dynamic_pointer_cast<Pool4>(pool1);
ASSERT_TRUE(pool41); ASSERT_TRUE(pool41);
OptionContainerPtr options1 = pool41->getCfgOption()->getAll("dhcp4"); OptionContainerPtr options1 =
pool41->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
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.
@ -3491,7 +3493,8 @@ TEST_F(Dhcp4ParserTest, optionDataMultiplePools) {
Pool4Ptr pool42 = boost::dynamic_pointer_cast<Pool4>(pool2); Pool4Ptr pool42 = boost::dynamic_pointer_cast<Pool4>(pool2);
ASSERT_TRUE(pool42); ASSERT_TRUE(pool42);
OptionContainerPtr options2 = pool42->getCfgOption()->getAll("dhcp4"); OptionContainerPtr options2 =
pool42->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(1, options2->size()); ASSERT_EQ(1, options2->size());
const OptionContainerTypeIndex& idx2 = options2->get<1>(); const OptionContainerTypeIndex& idx2 = options2->get<1>();

View File

@ -806,7 +806,8 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll(); CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
EXPECT_EQ(1, subnets->size()); EXPECT_EQ(1, subnets->size());
OptionDefinitionPtr def = LibDHCP::getRuntimeOptionDef("dhcp4", 163); OptionDefinitionPtr def =
LibDHCP::getRuntimeOptionDef(DHCP4_OPTION_SPACE, 163);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Create a config with malformed subnet that should fail to parse. // 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(); subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
EXPECT_EQ(1, subnets->size()); EXPECT_EQ(1, subnets->size());
def = LibDHCP::getRuntimeOptionDef("dhcp4", 163); def = LibDHCP::getRuntimeOptionDef(DHCP4_OPTION_SPACE, 163);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Create a valid config with two subnets and no command channel. // Create a valid config with two subnets and no command channel.

View File

@ -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 // 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 // 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. // bootfile-url should come from the first config back end.
// (overwriting the original). // (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_); ASSERT_TRUE(found_opt.option_);
OptionStringPtr opstr = boost::dynamic_pointer_cast<OptionString>(found_opt.option_); OptionStringPtr opstr = boost::dynamic_pointer_cast<OptionString>(found_opt.option_);
ASSERT_TRUE(opstr); ASSERT_TRUE(opstr);
EXPECT_EQ("updated-boot-file", opstr->getValue()); EXPECT_EQ("updated-boot-file", opstr->getValue());
// sol-maxt-rt should come from the original config // 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_); ASSERT_TRUE(found_opt.option_);
OptionUint32Ptr opint = boost::dynamic_pointer_cast<OptionUint32>(found_opt.option_); OptionUint32Ptr opint = boost::dynamic_pointer_cast<OptionUint32>(found_opt.option_);
ASSERT_TRUE(opint); ASSERT_TRUE(opint);

View File

@ -3584,7 +3584,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
Pool6Ptr pool6 = boost::dynamic_pointer_cast<Pool6>(pool); Pool6Ptr pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
ASSERT_TRUE(pool6); ASSERT_TRUE(pool6);
OptionContainerPtr options1 = pool6->getCfgOption()->getAll("dhcp6"); OptionContainerPtr options1 =
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
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.
@ -3611,7 +3612,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
pool6 = boost::dynamic_pointer_cast<Pool6>(pool); pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
ASSERT_TRUE(pool6); ASSERT_TRUE(pool6);
OptionContainerPtr options2 = pool6->getCfgOption()->getAll("dhcp6"); OptionContainerPtr options2 =
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options2->size()); ASSERT_EQ(1, options2->size());
const OptionContainerTypeIndex& idx2 = options2->get<1>(); const OptionContainerTypeIndex& idx2 = options2->get<1>();
@ -3632,7 +3634,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
pool6 = boost::dynamic_pointer_cast<Pool6>(pool); pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
ASSERT_TRUE(pool6); ASSERT_TRUE(pool6);
OptionContainerPtr options3 = pool6->getCfgOption()->getAll("dhcp6"); OptionContainerPtr options3 =
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options3->size()); ASSERT_EQ(1, options3->size());
const OptionContainerTypeIndex& idx3 = options3->get<1>(); const OptionContainerTypeIndex& idx3 = options3->get<1>();
@ -3652,7 +3655,8 @@ TEST_F(Dhcp6ParserTest, optionDataMultiplePools) {
pool6 = boost::dynamic_pointer_cast<Pool6>(pool); pool6 = boost::dynamic_pointer_cast<Pool6>(pool);
ASSERT_TRUE(pool6); ASSERT_TRUE(pool6);
OptionContainerPtr options4 = pool6->getCfgOption()->getAll("dhcp6"); OptionContainerPtr options4 =
pool6->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options4->size()); ASSERT_EQ(1, options4->size());
const OptionContainerTypeIndex& idx4 = options4->get<1>(); const OptionContainerTypeIndex& idx4 = options4->get<1>();

View File

@ -715,7 +715,8 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configSet) {
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll(); CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
EXPECT_EQ(1, subnets->size()); EXPECT_EQ(1, subnets->size());
OptionDefinitionPtr def = LibDHCP::getRuntimeOptionDef("dhcp6", 163); OptionDefinitionPtr def =
LibDHCP::getRuntimeOptionDef(DHCP6_OPTION_SPACE, 163);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Create a config with malformed subnet that should fail to parse. // 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(); subnets = CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
EXPECT_EQ(1, subnets->size()); EXPECT_EQ(1, subnets->size());
def = LibDHCP::getRuntimeOptionDef("dhcp6", 163); def = LibDHCP::getRuntimeOptionDef(DHCP6_OPTION_SPACE, 163);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Create a valid config with two subnets and no command channel. // Create a valid config with two subnets and no command channel.

View File

@ -1962,7 +1962,7 @@ public:
void createUpdateOptionDef4(const ServerSelector& server_selector, void createUpdateOptionDef4(const ServerSelector& server_selector,
const OptionDefinitionPtr& option_def) { 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::GET_OPTION_DEF4_CODE_SPACE,
MySqlConfigBackendDHCPv4Impl::INSERT_OPTION_DEF4, MySqlConfigBackendDHCPv4Impl::INSERT_OPTION_DEF4,
MySqlConfigBackendDHCPv4Impl::UPDATE_OPTION_DEF4, MySqlConfigBackendDHCPv4Impl::UPDATE_OPTION_DEF4,

View File

@ -2377,7 +2377,7 @@ public:
void createUpdateOptionDef6(const ServerSelector& server_selector, void createUpdateOptionDef6(const ServerSelector& server_selector,
const OptionDefinitionPtr& option_def) { 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::GET_OPTION_DEF6_CODE_SPACE,
MySqlConfigBackendDHCPv6Impl::INSERT_OPTION_DEF6, MySqlConfigBackendDHCPv6Impl::INSERT_OPTION_DEF6,
MySqlConfigBackendDHCPv6Impl::UPDATE_OPTION_DEF6, MySqlConfigBackendDHCPv6Impl::UPDATE_OPTION_DEF6,

View File

@ -322,15 +322,15 @@ public:
OptionDefinitionPtr option_def(new OptionDefinition("foo", 234, "string", OptionDefinitionPtr option_def(new OptionDefinition("foo", 234, "string",
"espace")); "espace"));
option_def->setOptionSpaceName("dhcp4"); option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("bar", 234, "uint32", true)); 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); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("fish", 235, "record", true)); 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("uint32");
option_def->addRecordField("string"); option_def->addRecordField("string");
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
@ -340,7 +340,7 @@ public:
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("foobar", 234, "uint64", true)); 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); test_option_defs_.push_back(option_def);
} }

View File

@ -368,15 +368,15 @@ public:
OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234, "string", OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234, "string",
"espace")); "espace"));
option_def->setOptionSpaceName("dhcp6"); option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("bar", 1234, "uint32", true)); 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); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("fish", 5235, "record", true)); 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("uint32");
option_def->addRecordField("string"); option_def->addRecordField("string");
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
@ -386,7 +386,7 @@ public:
test_option_defs_.push_back(option_def); test_option_defs_.push_back(option_def);
option_def.reset(new OptionDefinition("bar", 1234, "uint64", true)); 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); test_option_defs_.push_back(option_def);
} }

View File

@ -1282,7 +1282,7 @@ TEST_F(LibDhcpTest, emptyHostName) {
list<uint16_t> deferred; list<uint16_t> deferred;
ASSERT_NO_THROW( 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. // Host Name should not exist, we quietly drop it when empty.
@ -2370,7 +2370,7 @@ TEST_F(LibDhcpTest, sw46options) {
size_t parsed = 0; 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); EXPECT_EQ(mape_bin.size(), parsed);
// We expect to have exactly one option (with tons of suboptions, but we'll // We expect to have exactly one option (with tons of suboptions, but we'll

View File

@ -913,7 +913,8 @@ private:
// If empty or null space provided, use a default top level space. // If empty or null space provided, use a default top level space.
if (space.empty()) { 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. // Convert formatted_value to string as well.

View File

@ -588,7 +588,8 @@ private:
// If empty or null space provided, use a default top level space. // If empty or null space provided, use a default top level space.
if (space.empty()) { if (space.empty()) {
space = (universe_ == Option::V4 ? "dhcp4" : "dhcp6"); space = (universe_ == Option::V4 ?
DHCP4_OPTION_SPACE : DHCP6_OPTION_SPACE);
} }
// persistent: BOOL default false // persistent: BOOL default false

View File

@ -489,7 +489,7 @@ public:
// modification time is later than last audit revision time it should // modification time is later than last audit revision time it should
// be merged. // be merged.
auto options = srv_cfg->getCfgOption(); 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") && if (hasConfigElement("dhcp4_options") &&
(getTimestamp("dhcp4_options") > lb_modification_time)) { (getTimestamp("dhcp4_options") > lb_modification_time)) {
ASSERT_TRUE(found_opt.option_); ASSERT_TRUE(found_opt.option_);
@ -603,8 +603,10 @@ public:
{ {
SCOPED_TRACE("global options"); SCOPED_TRACE("global options");
// One of the options should still be there. // One of the options should still be there.
EXPECT_TRUE(srv_cfg->getCfgOption()->get("dhcp4", DHO_TFTP_SERVER_NAME).option_); EXPECT_TRUE(srv_cfg->getCfgOption()->get(DHCP4_OPTION_SPACE,
auto found_opt = srv_cfg->getCfgOption()->get("dhcp4", DHO_HOST_NAME); DHO_TFTP_SERVER_NAME).option_);
auto found_opt = srv_cfg->getCfgOption()->get(DHCP4_OPTION_SPACE,
DHO_HOST_NAME);
if (deleteConfigElement("dhcp4_options", 1)) { if (deleteConfigElement("dhcp4_options", 1)) {
EXPECT_FALSE(found_opt.option_); EXPECT_FALSE(found_opt.option_);
@ -1135,7 +1137,7 @@ public:
// modification time is later than last audit revision time it should // modification time is later than last audit revision time it should
// be merged. // be merged.
auto options = srv_cfg->getCfgOption(); 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") && if (hasConfigElement("dhcp6_options") &&
(getTimestamp("dhcp6_options") > lb_modification_time)) { (getTimestamp("dhcp6_options") > lb_modification_time)) {
ASSERT_TRUE(found_opt.option_); ASSERT_TRUE(found_opt.option_);
@ -1249,8 +1251,10 @@ public:
{ {
SCOPED_TRACE("global options"); SCOPED_TRACE("global options");
// One of the options should still be there. // One of the options should still be there.
EXPECT_TRUE(srv_cfg->getCfgOption()->get("dhcp6", D6O_AFTR_NAME).option_); EXPECT_TRUE(srv_cfg->getCfgOption()->get(DHCP6_OPTION_SPACE,
auto found_opt = srv_cfg->getCfgOption()->get("dhcp6", D6O_AFTR_NAME); D6O_AFTR_NAME).option_);
auto found_opt = srv_cfg->getCfgOption()->get(DHCP6_OPTION_SPACE,
D6O_AFTR_NAME);
if (deleteConfigElement("dhcp6_options", 1)) { if (deleteConfigElement("dhcp6_options", 1)) {
EXPECT_FALSE(found_opt.option_); EXPECT_FALSE(found_opt.option_);

View File

@ -608,7 +608,7 @@ TEST_F(CfgOptionTest, createDescriptorOptionValid) {
defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint8", true))), "isc"); defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint8", true))), "isc");
// We'll try a standard V4 option first. // We'll try a standard V4 option first.
std::string space = "dhcp4"; std::string space = DHCP4_OPTION_SPACE;
std::string value = "v4.example.com"; std::string value = "v4.example.com";
OptionPtr option(new Option(Option::V6, DHO_HOST_NAME)); OptionPtr option(new Option(Option::V6, DHO_HOST_NAME));
option->setData(value.begin(), value.end()); option->setData(value.begin(), value.end());
@ -622,7 +622,7 @@ TEST_F(CfgOptionTest, createDescriptorOptionValid) {
EXPECT_EQ("v4.example.com", opstr->getValue()); EXPECT_EQ("v4.example.com", opstr->getValue());
// Next we'll try a standard V6 option. // Next we'll try a standard V6 option.
space = "dhcp6"; space = DHCP6_OPTION_SPACE;
std::vector<uint8_t> fqdn = std::vector<uint8_t> fqdn =
{ 2, 'v', '6', 7, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 3, 'c', 'o', 'm', 0 }; { 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)); option.reset(new Option(Option::V6, D6O_AFTR_NAME));

View File

@ -77,7 +77,7 @@ AdaptorOption::setCode(ElementPtr option, const OptionCodes& codes) {
void void
AdaptorOption::initCodes(OptionCodes& codes, const string& space) { AdaptorOption::initCodes(OptionCodes& codes, const string& space) {
if (space == "dhcp4") { if (space == DHCP4_OPTION_SPACE) {
initCodesInternal(codes, space, STANDARD_V4_OPTION_DEFINITIONS, initCodesInternal(codes, space, STANDARD_V4_OPTION_DEFINITIONS,
STANDARD_V4_OPTION_DEFINITIONS_SIZE); STANDARD_V4_OPTION_DEFINITIONS_SIZE);
initCodesInternal(codes, space, LAST_RESORT_V4_OPTION_DEFINITIONS, initCodesInternal(codes, space, LAST_RESORT_V4_OPTION_DEFINITIONS,
@ -85,7 +85,7 @@ AdaptorOption::initCodes(OptionCodes& codes, const string& space) {
initCodesInternal(codes, "vendor-4491", initCodesInternal(codes, "vendor-4491",
DOCSIS3_V4_OPTION_DEFINITIONS, DOCSIS3_V4_OPTION_DEFINITIONS,
DOCSIS3_V4_OPTION_DEFINITIONS_SIZE); DOCSIS3_V4_OPTION_DEFINITIONS_SIZE);
} else if (space == "dhcp6") { } else if (space == DHCP6_OPTION_SPACE) {
initCodesInternal(codes, space, STANDARD_V6_OPTION_DEFINITIONS, initCodesInternal(codes, space, STANDARD_V6_OPTION_DEFINITIONS,
STANDARD_V6_OPTION_DEFINITIONS_SIZE); STANDARD_V6_OPTION_DEFINITIONS_SIZE);
initCodesInternal(codes, "vendor-4491", initCodesInternal(codes, "vendor-4491",

View File

@ -193,7 +193,7 @@ TEST(AdaptorOptionTest, initCodesInternal) {
const size_t DEFS_SIZE = sizeof(DEFS) / sizeof(DEFS[0]); const size_t DEFS_SIZE = sizeof(DEFS) / sizeof(DEFS[0]);
OptionCodes codes; OptionCodes codes;
ASSERT_NO_THROW(TestAdaptorOption::initCodesInternal(codes, ASSERT_NO_THROW(TestAdaptorOption::initCodesInternal(codes,
"dhcp4", DHCP4_OPTION_SPACE,
DEFS, DEFS,
DEFS_SIZE)); DEFS_SIZE));
ASSERT_EQ(2, codes.size()); ASSERT_EQ(2, codes.size());