// Check whether option has been configured.
for (CfgOptionList::const_iterator copts = co_list.begin();
copts != co_list.end(); ++copts) {
- OptionDescriptor desc = (*copts)->get("dhcp4", required_options[i]);
+ OptionDescriptor desc = (*copts)->get(DHCP4_OPTION_SPACE,
+ required_options[i]);
if (desc.option_) {
resp->addOption(desc.option_);
break;
std::map<std::string, std::string> params;
if (parameter == "name") {
params["name"] = param_value;
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
params["code"] = "56";
params["data"] = "ABCDEF0105";
params["csv-format"] = "False";
params["csv-format"] = "False";
} else if (parameter == "code") {
params["name"] = "dhcp-message";
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
params["code"] = param_value;
params["data"] = "ABCDEF0105";
params["csv-format"] = "False";
} else if (parameter == "data") {
params["name"] = "dhcp-message";
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
params["code"] = "56";
params["data"] = param_value;
params["csv-format"] = "False";
} else if (parameter == "csv-format") {
params["name"] = "dhcp-message";
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
params["code"] = "56";
params["data"] = "ABCDEF0105";
params["csv-format"] = param_value;
<< "does not exist in Config Manager";
}
OptionContainerPtr options =
- subnet->getCfgOption()->getAll("dhcp4");
+ subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
if (expected_options_count != options->size()) {
ADD_FAILURE() << "The number of options in the subnet '"
<< subnet_address.toText() << "' is different "
template<typename ReturnType>
ReturnType
retrieveOption(const Host& host, const uint16_t option_code) const {
- return (retrieveOption<ReturnType>(host, "dhcp4", option_code));
+ return (retrieveOption<ReturnType>(host, DHCP4_OPTION_SPACE, option_code));
}
/// @brief Retrieve an option associated with a host.
ElementPtr json = Element::fromJSON(config);
OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp4", 109);
+ getCfgOptionDef()->get(DHCP4_OPTION_SPACE, 109);
ASSERT_FALSE(def);
// Use the configuration string to create new option definition.
// The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp4", 109);
+ getCfgOptionDef()->get(DHCP4_OPTION_SPACE, 109);
ASSERT_TRUE(def);
// Check the option data.
checkResult(status, 0);
def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp4", 213);
+ getCfgOptionDef()->get(DHCP4_OPTION_SPACE, 213);
ASSERT_TRUE(def);
// Check the option data.
Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.200"));
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(0, options->size());
- options = CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp4");
+ options = CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code.
// These options are subnet options
OptionContainerPtr options =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp4");
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(0, options->size());
Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.200"));
ASSERT_TRUE(subnet);
- options = subnet->getCfgOption()->getAll("dhcp4");
+ options = subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code.
// Options should be now available
// Try to get the option from the space dhcp4.
OptionDescriptor desc1 =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->get("dhcp4", 56);
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->get(DHCP4_OPTION_SPACE, 56);
ASSERT_TRUE(desc1.option_);
EXPECT_EQ(56, desc1.option_->getType());
// Try to get the option from the space isc.
// We should have one option available.
OptionContainerPtr options =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp4");
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(1, options->size());
// Get the option.
OptionDescriptor desc =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->get("dhcp4", 222);
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->get(DHCP4_OPTION_SPACE, 222);
EXPECT_TRUE(desc.option_);
EXPECT_EQ(222, desc.option_->getType());
Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.24"));
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code.
// Create configuration. Use standard option 19 (ip-forwarding).
std::map<std::string, std::string> params;
params["name"] = "ip-forwarding";
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
params["code"] = "19";
params["data"] = "true";
params["csv-format"] = "true";
Subnet4Ptr subnet1 = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.100"));
ASSERT_TRUE(subnet1);
- OptionContainerPtr options1 = subnet1->getCfgOption()->getAll("dhcp4");
+ OptionContainerPtr options1 = subnet1->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(1, options1->size());
// Get the search index. Index #1 is to search using option code.
Subnet4Ptr subnet2 = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.3.102"));
ASSERT_TRUE(subnet2);
- OptionContainerPtr options2 = subnet2->getCfgOption()->getAll("dhcp4");
+ OptionContainerPtr options2 = subnet2->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(1, options2->size());
const OptionContainerTypeIndex& idx2 = options2->get<1>();
Subnet4Ptr subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.5"));
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp4");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_EQ(1, options->size());
// Get the search index. Index #1 is to search using option code.
ConstElementPtr x;
std::map<std::string, std::string> params;
params["name"] = "nis-servers";
- params["space"] = "dhcp4";
+ params["space"] = DHCP4_OPTION_SPACE;
// Option code 41 means nis-servers.
params["code"] = "41";
// Specify option values in a CSV (user friendly) format.
getCfgSubnets4()->selectSubnet(IOAddress("192.0.2.5"));
ASSERT_TRUE(subnet);
OptionContainerPtr options =
- subnet->getCfgOption()->getAll("dhcp4");
+ subnet->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(1, options->size());
// We should have one option available.
OptionContainerPtr options =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp4");
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(1, options->size());
// Get the option.
OptionDescriptor desc = CfgMgr::instance().getStagingCfg()->
- getCfgOption()->get("dhcp4", DHO_VENDOR_ENCAPSULATED_OPTIONS);
+ getCfgOption()->get(DHCP4_OPTION_SPACE, DHO_VENDOR_ENCAPSULATED_OPTIONS);
EXPECT_TRUE(desc.option_);
EXPECT_EQ(DHO_VENDOR_ENCAPSULATED_OPTIONS, desc.option_->getType());
// rai echo is done in relayAgentInfoEcho
// Do subnet selection option
OptionDefinitionPtr sbnsel_def = LibDHCP::getOptionDef(Option::V4,
- DHO_SUBNET_SELECTION);
+ DHO_SUBNET_SELECTION,
+ DHCP4_OPTION_SPACE);
ASSERT_TRUE(sbnsel_def);
OptionCustomPtr sbnsel(new OptionCustom(*sbnsel_def, Option::V4));
ASSERT_TRUE(sbnsel);
// Let's create a Relay Agent Information option
OptionDefinitionPtr rai_def = LibDHCP::getOptionDef(Option::V4,
- DHO_DHCP_AGENT_OPTIONS);
+ DHO_DHCP_AGENT_OPTIONS,
+ DHCP4_OPTION_SPACE);
ASSERT_TRUE(rai_def);
OptionCustomPtr rai(new OptionCustom(*rai_def, Option::V4));
ASSERT_TRUE(rai);
// Subnet select option has a lower precedence
OptionDefinitionPtr sbnsel_def = LibDHCP::getOptionDef(Option::V4,
- DHO_SUBNET_SELECTION);
+ DHO_SUBNET_SELECTION,
+ DHCP4_OPTION_SPACE);
ASSERT_TRUE(sbnsel_def);
OptionCustomPtr sbnsel(new OptionCustom(*sbnsel_def, Option::V4));
ASSERT_TRUE(sbnsel);
// Let's create a Subnet Selection option
OptionDefinitionPtr sbnsel_def = LibDHCP::getOptionDef(Option::V4,
- DHO_SUBNET_SELECTION);
+ DHO_SUBNET_SELECTION,
+ DHCP4_OPTION_SPACE);
ASSERT_TRUE(sbnsel_def);
OptionCustomPtr sbnsel(new OptionCustom(*sbnsel_def, Option::V4));
ASSERT_TRUE(sbnsel);
// Add Router option.
Option4AddrLstPtr opt_routers(new Option4AddrLst(DHO_ROUTERS));
opt_routers->setAddress(IOAddress("192.0.2.2"));
- subnet_->getCfgOption()->add(opt_routers, false, "dhcp4");
+ subnet_->getCfgOption()->add(opt_routers, false, DHCP4_OPTION_SPACE);
CfgMgr::instance().clear();
CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->add(subnet_);
option_dns_servers(new Option4AddrLst(DHO_DOMAIN_NAME_SERVERS));
option_dns_servers->addAddress(IOAddress("192.0.2.1"));
option_dns_servers->addAddress(IOAddress("192.0.2.100"));
- ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_dns_servers, false, "dhcp4"));
+ ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_dns_servers, false, DHCP4_OPTION_SPACE));
// domain-name
OptionDefinition def("domain-name", DHO_DOMAIN_NAME, OPT_FQDN_TYPE);
OptionCustomPtr option_domain_name(new OptionCustom(def, Option::V4));
option_domain_name->writeFqdn("example.com");
- subnet_->getCfgOption()->add(option_domain_name, false, "dhcp4");
+ subnet_->getCfgOption()->add(option_domain_name, false, DHCP4_OPTION_SPACE);
// log-servers
Option4AddrLstPtr option_log_servers(new Option4AddrLst(DHO_LOG_SERVERS));
option_log_servers->addAddress(IOAddress("192.0.2.2"));
option_log_servers->addAddress(IOAddress("192.0.2.10"));
- ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_log_servers, false, "dhcp4"));
+ ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_log_servers, false, DHCP4_OPTION_SPACE));
// cookie-servers
Option4AddrLstPtr option_cookie_servers(new Option4AddrLst(DHO_COOKIE_SERVERS));
option_cookie_servers->addAddress(IOAddress("192.0.2.1"));
- ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_cookie_servers, false, "dhcp4"));
+ ASSERT_NO_THROW(subnet_->getCfgOption()->add(option_cookie_servers, false, DHCP4_OPTION_SPACE));
}
void Dhcpv4SrvTest::messageCheck(const Pkt4Ptr& q, const Pkt4Ptr& a) {
}
Pool6Ptr pool = boost::dynamic_pointer_cast<Pool6>
- (ctx.subnet_->getPool(ctx.type_, (*l)->addr_, false));
+ (ctx.subnet_->getPool(ctx.currentIA().type_, (*l)->addr_, false));
if (pdExcludeFound && pool && pool->getPrefixExcludedLength() > 0) {
OptionPtr opt(new Option6PDExclude((*l)->addr_, (*l)->prefixlen_,
}
Pool6Ptr pool = boost::dynamic_pointer_cast<Pool6>
- (ctx.subnet_->getPool(ctx.type_, (*l)->addr_, false));
+ (ctx.subnet_->getPool(ctx.currentIA().type_, (*l)->addr_, false));
if (pdExcludeFound && pool && pool->getPrefixExcludedLength() > 0) {
OptionPtr opt(new Option6PDExclude((*l)->addr_, (*l)->prefixlen_,
std::map<std::string, std::string> params;
if (parameter == "name") {
params["name"] = param_value;
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
params["code"] = "38";
params["data"] = "ABCDEF0105";
params["csv-format"] = "False";
params["csv-format"] = "False";
} else if (parameter == "code") {
params["name"] = "subscriber-id";
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
params["code"] = param_value;
params["data"] = "ABCDEF0105";
params["csv-format"] = "False";
} else if (parameter == "data") {
params["name"] = "subscriber-id";
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
params["code"] = "38";
params["data"] = param_value;
params["csv-format"] = "False";
} else if (parameter == "csv-format") {
params["name"] = "subscriber-id";
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
params["code"] = "38";
params["data"] = "ABCDEF0105";
params["csv-format"] = param_value;
<< " does not exist in Config Manager";
}
OptionContainerPtr options =
- subnet->getCfgOption()->getAll("dhcp6");
+ subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
if (expected_options_count != options->size()) {
ADD_FAILURE() << "The number of options in the subnet '"
<< subnet_address.toText() << "' is different "
template<typename ReturnType>
ReturnType
retrieveOption(const Host& host, const uint16_t option_code) const {
- return (retrieveOption<ReturnType>(host, "dhcp6", option_code));
+ return (retrieveOption<ReturnType>(host, DHCP6_OPTION_SPACE, option_code));
}
/// @brief Retrieve an option associated with a host.
ElementPtr json = Element::fromJSON(config);
OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp6", 100);
+ getCfgOptionDef()->get(DHCP6_OPTION_SPACE, 100);
ASSERT_FALSE(def);
// Use the configuration string to create new option definition.
// The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp6", 100);
+ getCfgOptionDef()->get(DHCP6_OPTION_SPACE, 100);
ASSERT_TRUE(def);
// Check the option data.
checkResult(status, 0);
def = CfgMgr::instance().getStagingCfg()->
- getCfgOptionDef()->get("dhcp6", 63);
+ getCfgOptionDef()->get(DHCP6_OPTION_SPACE, 63);
ASSERT_TRUE(def);
// Check the option data.
Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::5"), classify_);
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(0, options->size());
- options = CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp6");
+ options = CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code.
// These options are subnet options
OptionContainerPtr options =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp6");
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(0, options->size());
Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::5"), classify_);
ASSERT_TRUE(subnet);
- options = subnet->getCfgOption()->getAll("dhcp6");
+ options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(2, options->size());
// Get the search index. Index #1 is to search using option code.
// Options should be now available
// Try to get the option from the space dhcp6.
OptionDescriptor desc1 =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->get("dhcp6", 38);
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->get(DHCP6_OPTION_SPACE, 38);
ASSERT_TRUE(desc1.option_);
EXPECT_EQ(38, desc1.option_->getType());
// Try to get the option from the space isc.
// We should have one option available.
OptionContainerPtr options =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll("dhcp6");
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(1, options->size());
// Get the option.
OptionDescriptor desc =
- CfgMgr::instance().getStagingCfg()->getCfgOption()->get("dhcp6", 100);
+ CfgMgr::instance().getStagingCfg()->getCfgOption()->get(DHCP6_OPTION_SPACE, 100);
EXPECT_TRUE(desc.option_);
EXPECT_EQ(100, desc.option_->getType());
Subnet6Ptr subnet1 = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::5"), classify_);
ASSERT_TRUE(subnet1);
- OptionContainerPtr options1 = subnet1->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options1 = subnet1->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options1->size());
// Get the search index. Index #1 is to search using option code.
Subnet6Ptr subnet2 = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:2::4"), classify_);
ASSERT_TRUE(subnet2);
- OptionContainerPtr options2 = subnet2->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options2 = subnet2->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options2->size());
const OptionContainerTypeIndex& idx2 = options2->get<1>();
// Create configuration. Use standard option 1000.
std::map<std::string, std::string> params;
params["name"] = "bool-option";
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
params["code"] = "1000";
params["data"] = "true";
params["csv-format"] = "true";
Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::5"), classify_);
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options->size());
// Get the search index. Index #1 is to search using option code.
ConstElementPtr x;
std::map<std::string, std::string> params;
params["name"] = "ia-na";
- params["space"] = "dhcp6";
+ params["space"] = DHCP6_OPTION_SPACE;
// Option code 3 means OPTION_IA_NA.
params["code"] = "3";
params["data"] = "12345, 6789, 1516";
Subnet6Ptr subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->
selectSubnet(IOAddress("2001:db8:1::5"), classify_);
ASSERT_TRUE(subnet);
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(1, options->size());
// Get the search index. Index #1 is to search using option code.
ASSERT_TRUE(subnet);
// We should have one option available.
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(1, options->size());
// Get the option.
- OptionDescriptor desc = subnet->getCfgOption()->get("dhcp6", D6O_VENDOR_OPTS);
+ OptionDescriptor desc = subnet->getCfgOption()->get(DHCP6_OPTION_SPACE, D6O_VENDOR_OPTS);
EXPECT_TRUE(desc.option_);
EXPECT_EQ(D6O_VENDOR_OPTS, desc.option_->getType());
/// @param payload specified payload (0 = fill payload with repeating option code)
/// @return RSOO with nested options
OptionPtr createRSOO(const std::vector<uint16_t>& codes, uint8_t payload = 0) {
- OptionDefinitionPtr def = LibDHCP::getOptionDef(Option::V6, D6O_RSOO);
+ OptionDefinitionPtr def = LibDHCP::getOptionDef(Option::V6, D6O_RSOO, DHCP6_OPTION_SPACE);
if (!def) {
isc_throw(BadValue, "Can't find RSOO definition");
}
#include <dhcp/option6_iaaddr.h>
#include <dhcp/option_definition.h>
#include <dhcp/option_int_array.h>
-#include <dhcp/option_space.h>
#include <dhcp/std_option_defs.h>
#include <dhcp/docsis3_option_defs.h>
#include <exceptions/exceptions.h>
const OptionDefParams* params,
size_t params_size);
+const OptionDefContainerPtr
+LibDHCP::getOptionDefs(const Option::Universe u) {
+ std::string space = "";
+ if (Option::V4 == u) {
+ space = DHCP4_OPTION_SPACE;
+ } else if (Option::V6 == u) {
+ space = DHCP6_OPTION_SPACE;
+ } else {
+ return OptionDefContainerPtr();
+ }
+ if (option_defs_.end() == option_defs_.find(space)) {
+ initStdOptionDefs(space);
+ }
+ return option_defs_[space];
+}
+
const OptionDefContainerPtr
LibDHCP::getOptionDefs(const Option::Universe, const std::string& space) {
if (option_defs_.end() == option_defs_.find(space)) {
#include <dhcp/option_definition.h>
#include <dhcp/option_space_container.h>
+#include <dhcp/option_space.h>
#include <dhcp/pkt6.h>
#include <util/buffer.h>
#include <util/staged_value.h>
/// @param u universe of the options (V4 or V6).
///
/// @return Pointer to a collection of option definitions.
+ static const OptionDefContainerPtr getOptionDefs(const Option::Universe u);
+
+ /// @brief Return collection of option definitions.
+ ///
+ /// Method returns the collection of DHCP standard DHCP
+ /// option definitions.
+ /// @todo DHCPv4 option definitions are not implemented. For now
+ /// this function will throw isc::NotImplemented in case of attempt
+ /// to get option definitions for V4 universe.
+ ///
+ /// @param u universe of the options (V4 or V6).
+ /// @param space space of the options.
+ ///
+ /// @return Pointer to a collection of option definitions.
static const OptionDefContainerPtr getOptionDefs(const Option::Universe u,
- const std::string& space);
+ const std::string& space);
/// @brief Return the first option definition matching a
/// particular option code.
"a different layout");
}
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
}
Option6IA::Option6IA(uint16_t type, OptionBufferConstIter begin,
"a different layout");
}
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
unpack(begin, end);
}
uint32_t pref, uint32_t valid)
:Option(V6, type), addr_(addr), preferred_(pref),
valid_(valid) {
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
if (!addr.isV6()) {
isc_throw(isc::BadValue, addr_ << " is not an IPv6 address");
}
Option6IAAddr::Option6IAAddr(uint32_t type, OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end)
:Option(V6, type), addr_("::") {
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
unpack(begin, end);
}
Option6IAPrefix::Option6IAPrefix(uint16_t type, const isc::asiolink::IOAddress& prefix,
uint8_t prefix_len, uint32_t pref, uint32_t valid)
:Option6IAAddr(type, prefix, pref, valid), prefix_len_(prefix_len) {
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
// Option6IAAddr will check if prefix is IPv6 and will throw if it is not
if (prefix_len > 128) {
isc_throw(BadValue, static_cast<unsigned>(prefix_len)
Option6IAPrefix::Option6IAPrefix(uint32_t type, OptionBuffer::const_iterator begin,
OptionBuffer::const_iterator end)
:Option6IAAddr(type, begin, end) {
- setEncapsulatedSpace("dhcp6");
+ setEncapsulatedSpace(DHCP6_OPTION_SPACE);
unpack(begin, end);
}
#include <dhcp/libdhcp++.h>
#include <dhcp/option.h>
#include <dhcp/option_data_types.h>
-#include <dhcp/option_space.h>
#include <util/io_utilities.h>
#include <stdint.h>
#include <dhcp/option_int.h>
#include <dhcp/option_int_array.h>
#include <dhcp/option_opaque_data_tuples.h>
-#include <dhcp/option_space.h>
#include <dhcp/option_string.h>
#include <dhcp/option_vendor.h>
#include <dhcp/option_vendor_class.h>
EXPECT_NO_THROW ({
LibDHCP::unpackOptions6(OptionBuffer(buf.begin(), buf.begin() + sizeof(v6packed)),
- "dhcp6", options);
+ DHCP6_OPTION_SPACE, options);
});
EXPECT_EQ(options.size(), 6); // there should be 5 options
// by OptionCustom which requires a definition to be passed to
// the constructor.
OptionDefinitionPtr rai_def = LibDHCP::getOptionDef(Option::V4,
- DHO_DHCP_AGENT_OPTIONS);
+ DHO_DHCP_AGENT_OPTIONS,
+ DHCP4_OPTION_SPACE);
ASSERT_TRUE(rai_def);
// Create RAI option.
OptionCustomPtr rai(new OptionCustom(*rai_def, Option::V4));
isc::dhcp::OptionCollection options; // list of options
ASSERT_NO_THROW(
- LibDHCP::unpackOptions4(v4packed, "dhcp4", options);
+ LibDHCP::unpackOptions4(v4packed, DHCP4_OPTION_SPACE, options);
);
isc::dhcp::OptionCollection::const_iterator x = options.find(12);
for (OptionDefContainer::const_iterator def = defs->begin();
def != defs->end(); ++def) {
OptionDefinitionPtr def_by_name =
- LibDHCP::getOptionDef(Option::V6, (*def)->getName());
+ LibDHCP::getOptionDef(Option::V6, (*def)->getName(), DHCP6_OPTION_SPACE);
ASSERT_TRUE(def_by_name);
ASSERT_TRUE(**def == *def_by_name);
}
for (OptionDefContainer::const_iterator def = defs->begin();
def != defs->end(); ++def) {
OptionDefinitionPtr def_by_name =
- LibDHCP::getOptionDef(Option::V4, (*def)->getName());
+ LibDHCP::getOptionDef(Option::V4, (*def)->getName(), DHCP4_OPTION_SPACE);
ASSERT_TRUE(def_by_name);
ASSERT_TRUE(**def == *def_by_name);
}
isc::util::encode::decodeHex(vendor_class_hex, bin);
ASSERT_NO_THROW ({
- LibDHCP::unpackOptions6(bin, "dhcp6", options);
+ LibDHCP::unpackOptions6(bin, DHCP6_OPTION_SPACE, options);
});
EXPECT_EQ(options.size(), 1); // There should be 1 option.
ASSERT_NE(OptionPtr(), subopt); // non-NULL
// Checks for address option
- Option6IAAddr * addr = dynamic_cast<Option6IAAddr*>(subopt.get());
+ Option6IAAddr* addr = dynamic_cast<Option6IAAddr*>(subopt.get());
ASSERT_TRUE(NULL != addr);
EXPECT_EQ(D6O_IAADDR, addr->getType());
// see if it rejects it.
OptionBuffer buf(1);
EXPECT_THROW(
- OptionDefinition::factoryInteger<bool>(Option::V6, D6O_PREFERENCE, "dhcp6",
+ OptionDefinition::factoryInteger<bool>(Option::V6, D6O_PREFERENCE, DHCP6_OPTION_SPACE,
buf.begin(), buf.end()),
isc::dhcp::InvalidDataType
);
Option optv6(Option::V6, 258);
EXPECT_TRUE(optv6.getEncapsulatedSpace().empty());
- optv6.setEncapsulatedSpace("dhcp6");
- EXPECT_EQ("dhcp6", optv6.getEncapsulatedSpace());
+ optv6.setEncapsulatedSpace(DHCP6_OPTION_SPACE);
+ EXPECT_EQ(DHCP6_OPTION_SPACE, optv6.getEncapsulatedSpace());
Option optv4(Option::V4, 125);
EXPECT_TRUE(optv4.getEncapsulatedSpace().empty());
- optv4.setEncapsulatedSpace("dhcp4");
- EXPECT_EQ("dhcp4", optv4.getEncapsulatedSpace());
-
+ optv4.setEncapsulatedSpace(DHCP4_OPTION_SPACE);
+ EXPECT_EQ(DHCP4_OPTION_SPACE, optv4.getEncapsulatedSpace());
}
}
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <dhcp/libdhcp++.h>
-#include <dhcp/option_space.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcp/dhcp6.h>
#include <string>
if (!option->getOption(encap_opt->option_->getType())) {
option->addOption(encap_opt->option_);
}
- encapsulateOptions(encap_opt->option_);
+ // This is a workaround for preventing infinite recursion when
+ // trying to encapsulate options created with default global option
+ // spaces.
+ if (encap_space != DHCP4_OPTION_SPACE &&
+ encap_space != DHCP6_OPTION_SPACE) {
+ encapsulateOptions(encap_opt->option_);
+ }
}
}
}
#include <config.h>
#include <dhcp/libdhcp++.h>
#include <dhcp/option_definition.h>
-#include <dhcp/option_space.h>
#include <dhcpsrv/cfg_option_def.h>
namespace isc {
#include <dhcp/libdhcp++.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
-#include <dhcp/option_space.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/dhcpsrv_log.h>
#include <dhcpsrv/mysql_host_data_source.h>
std::string
OptionDataParser::extractSpace() const {
- std::string space = address_family_ == AF_INET ? "dhcp4" : "dhcp6";
+ std::string space = address_family_ == AF_INET ? DHCP4_OPTION_SPACE : DHCP6_OPTION_SPACE;
try {
space = string_values_->getParam("space");
std::string record_types =
string_values_->getOptionalParam("record-types", "");
std::string space = string_values_->getOptionalParam("space",
- global_context_->universe_ == Option::V4 ? "dhcp4" : "dhcp6");
+ global_context_->universe_ == Option::V4 ? DHCP4_OPTION_SPACE : DHCP6_OPTION_SPACE);
std::string encapsulates =
string_values_->getOptionalParam("encapsulate", "");
// Add an option to each configuration
OptionPtr option(new Option(Option::V6, 1));
- ASSERT_NO_THROW(cfg1.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg1.add(option, false, DHCP6_OPTION_SPACE));
ASSERT_NO_THROW(cfg2.add(option, true, "isc"));
// The first option configuration has an option
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(cfg.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg.add(option, false, DHCP6_OPTION_SPACE));
}
// Add 7 options to another option space. The option codes partially overlap
}
// Get options from the Subnet and check if all 10 are there.
- OptionContainerPtr options = cfg.getAll("dhcp6");
+ OptionContainerPtr options = cfg.getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(10, options->size());
// from the range of 100 to 109 and holding one byte of data equal to 0xFF.
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(1, 0xFF)));
- ASSERT_NO_THROW(cfg_src.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg_src.add(option, false, DHCP6_OPTION_SPACE));
}
// Create collection of options in vendor space 123, with option codes
// 100 to 108.
for (uint16_t code = 100; code < 110; code += 2) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(1, 0x01)));
- ASSERT_NO_THROW(cfg_dst.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg_dst.add(option, false, DHCP6_OPTION_SPACE));
}
// Create collection of options having odd option codes in the range of
// Validate the options in the dhcp6 option space in the destination.
for (uint16_t code = 100; code < 110; ++code) {
- OptionDescriptor desc = cfg_dst.get("dhcp6", code);
+ OptionDescriptor desc = cfg_dst.get(DHCP6_OPTION_SPACE, code);
ASSERT_TRUE(desc.option_);
ASSERT_EQ(1, desc.option_->getData().size());
// The options with even option codes should hold one byte of data
// Add 10 options to a "dhcp6" option space in the subnet.
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(cfg.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg.add(option, false, DHCP6_OPTION_SPACE));
}
// Check that we can get each added option descriptor using
// Returned descriptor should contain NULL option ptr.
EXPECT_FALSE(desc.option_);
// Now, try the valid option space.
- desc = cfg.get("dhcp6", code);
+ desc = cfg.get(DHCP6_OPTION_SPACE, code);
// Test that the option code matches the expected code.
ASSERT_TRUE(desc.option_);
EXPECT_EQ(code, desc.option_->getType());
// In the inner loop we create options with unique codes (100-109).
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(cfg.add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(cfg.add(option, false, DHCP6_OPTION_SPACE));
}
}
// Sanity check that all options are there.
- OptionContainerPtr options = cfg.getAll("dhcp6");
+ OptionContainerPtr options = cfg.getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(20, options->size());
// Use container index #1 to get the options by their codes.
// and options with these codes will be flagged non-persistent.
// Options with other codes will be flagged persistent.
bool persistent = (code % 3) ? true : false;
- ASSERT_NO_THROW(cfg.add(option, persistent, "dhcp6"));
+ ASSERT_NO_THROW(cfg.add(option, persistent, DHCP6_OPTION_SPACE));
}
// Get added options from the subnet.
- OptionContainerPtr options = cfg.getAll("dhcp6");
+ OptionContainerPtr options = cfg.getAll(DHCP6_OPTION_SPACE);
// options->get<2> returns reference to container index #2. This
// index is used to access options by the 'persistent' flag.
cfg_option = cclass->getCfgOption();
ASSERT_TRUE(cfg_option);
OptionContainerPtr oc;
- ASSERT_TRUE(oc = cclass->getCfgOption()->getAll("dhcp4"));
+ ASSERT_TRUE(oc = cclass->getCfgOption()->getAll(DHCP4_OPTION_SPACE));
EXPECT_EQ(0, oc->size());
// Verify we have no expression.
cfg_option = cclass->getCfgOption();
ASSERT_TRUE(cfg_option);
OptionContainerPtr oc;
- ASSERT_TRUE(oc = cclass->getCfgOption()->getAll("dhcp4"));
+ ASSERT_TRUE(oc = cclass->getCfgOption()->getAll(DHCP4_OPTION_SPACE));
EXPECT_EQ(0, oc->size());
// Verify we can retrieve the expression
EXPECT_EQ("MICROSOFT", cclass->getName());
// Our one option should exist.
- OptionDescriptor od = cclass->getCfgOption()->get("dhcp4", 6);
+ OptionDescriptor od = cclass->getCfgOption()->get(DHCP4_OPTION_SPACE, 6);
ASSERT_TRUE(od.option_);
EXPECT_EQ(6, od.option_->getType());
EXPECT_EQ("MICROSOFT", cclass->getName());
// Our one option should exist.
- OptionDescriptor od = cclass->getCfgOption()->get("dhcp4", 6);
+ OptionDescriptor od = cclass->getCfgOption()->get(DHCP4_OPTION_SPACE, 6);
ASSERT_TRUE(od.option_);
EXPECT_EQ(6, od.option_->getType());
#include <config.h>
#include <dhcpsrv/client_class_def.h>
+#include <dhcp/option_space.h>
#include <exceptions/exceptions.h>
#include <boost/scoped_ptr.hpp>
OptionPtr option;
test_options.reset(new CfgOption());
option.reset(new Option(Option::V4, 17, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(test_options->add(option, false, "dhcp4"));
+ ASSERT_NO_THROW(test_options->add(option, false, DHCP4_OPTION_SPACE));
option.reset(new Option(Option::V6, 101, OptionBuffer(10, 0xFF)));
ASSERT_NO_THROW(test_options->add(option, false, "isc"));
option.reset(new Option(Option::V6, 100, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(test_options->add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(test_options->add(option, false, DHCP6_OPTION_SPACE));
// Now remake the client class with cfg_option
ASSERT_NO_THROW(cclass.reset(new ClientClassDef(name, expr, test_options)));
ASSERT_TRUE(class_options);
// Now make sure we can find all the options
- OptionDescriptor opt_desc = class_options->get("dhcp4",17);
+ OptionDescriptor opt_desc = class_options->get(DHCP4_OPTION_SPACE,17);
ASSERT_TRUE(opt_desc.option_);
EXPECT_EQ(17, opt_desc.option_->getType());
ASSERT_TRUE(opt_desc.option_);
EXPECT_EQ(101, opt_desc.option_->getType());
- opt_desc = class_options->get("dhcp6",100);
+ opt_desc = class_options->get(DHCP6_OPTION_SPACE,100);
ASSERT_TRUE(opt_desc.option_);
EXPECT_EQ(100, opt_desc.option_->getType());
}
OptionPtr option;
test_options.reset(new CfgOption());
option.reset(new Option(Option::V4, 17, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(test_options->add(option, false, "dhcp4"));
+ ASSERT_NO_THROW(test_options->add(option, false, DHCP4_OPTION_SPACE));
// Now remake the client class with cfg_option
ASSERT_NO_THROW(cclass.reset(new ClientClassDef("class_one", expr,
// Make a class that with same name and expression, but different options
// verify that the equality tools reflect that the classes are not equal.
option.reset(new Option(Option::V4, 20, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(test_options->add(option, false, "dhcp4"));
+ ASSERT_NO_THROW(test_options->add(option, false, DHCP4_OPTION_SPACE));
ASSERT_NO_THROW(cclass2.reset(new ClientClassDef("class_one", expr,
test_options)));
EXPECT_FALSE(cclass->equals(*cclass2));
// Verify that the option definition can be retrieved.
OptionDefinitionPtr def =
- CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("dhcp6", 10000);
+ CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get(DHCP6_OPTION_SPACE, 10000);
ASSERT_TRUE(def);
// Verify that the option definition is correct.
ASSERT_EQ(0, rcode);
// Verify that the option can be retrieved.
- OptionPtr opt = getOptionPtr("dhcp4", DHO_BOOT_FILE_NAME);
+ OptionPtr opt = getOptionPtr(DHCP4_OPTION_SPACE, DHO_BOOT_FILE_NAME);
ASSERT_TRUE(opt);
util::OutputBuffer buf(100);
// Verify that the option data is correct.
OptionCustomPtr addr_opt = boost::dynamic_pointer_cast<
- OptionCustom>(getOptionPtr("dhcp4", 16));
+ OptionCustom>(getOptionPtr(DHCP4_OPTION_SPACE, 16));
ASSERT_TRUE(addr_opt);
EXPECT_EQ("192.0.2.0", addr_opt->readAddress().toText());
// Verify that the option data is correct.
addr_opt = boost::dynamic_pointer_cast<
- OptionCustom>(getOptionPtr("dhcp4", 16));
+ OptionCustom>(getOptionPtr(DHCP4_OPTION_SPACE, 16));
ASSERT_TRUE(addr_opt);
EXPECT_EQ("192.0.2.0", addr_opt->readAddress().toText());
// Verify that the option data is correct.
addr_opt = boost::dynamic_pointer_cast<
- OptionCustom>(getOptionPtr("dhcp4", 16));
+ OptionCustom>(getOptionPtr(DHCP4_OPTION_SPACE, 16));
ASSERT_TRUE(addr_opt);
EXPECT_EQ("192.0.2.0", addr_opt->readAddress().toText());
}
"}";
ASSERT_NO_THROW(rcode = parseConfiguration(config));
ASSERT_EQ(0, rcode);
- OptionPtr opt = getOptionPtr("dhcp6", 25000);
+ OptionPtr opt = getOptionPtr(DHCP6_OPTION_SPACE, 25000);
ASSERT_TRUE(opt);
ASSERT_EQ(1, opt->getData().size());
EXPECT_EQ(0, opt->getData()[0]);
"}";
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
- opt = getOptionPtr("dhcp6", 25000);
+ opt = getOptionPtr(DHCP6_OPTION_SPACE, 25000);
ASSERT_TRUE(opt);
ASSERT_EQ(3, opt->getData().size());
EXPECT_EQ(0x12, opt->getData()[0]);
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
Option6AddrLstPtr opt = boost::dynamic_pointer_cast<
- Option6AddrLst>(getOptionPtr("dhcp6", 23));
+ Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE, 23));
ASSERT_TRUE(opt);
ASSERT_EQ(1, opt->getAddresses().size());
EXPECT_EQ( "2001:db8:1::1", opt->getAddresses()[0].toText());
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
Option6AddrLstPtr opt = boost::dynamic_pointer_cast<
- Option6AddrLst>(getOptionPtr("dhcp6", 23));
+ Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE, 23));
ASSERT_TRUE(opt);
ASSERT_EQ(1, opt->getAddresses().size());
EXPECT_EQ( "2001:db8:1::1", opt->getAddresses()[0].toText());
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
Option6AddrLstPtr opt = boost::dynamic_pointer_cast<
- Option6AddrLst>(getOptionPtr("dhcp6", 23));
+ Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE, 23));
ASSERT_TRUE(opt);
ASSERT_EQ(1, opt->getAddresses().size());
EXPECT_EQ( "2001:db8:1::10", opt->getAddresses()[0].toText());
rcode = 0;
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
- opt = boost::dynamic_pointer_cast<Option6AddrLst>(getOptionPtr("dhcp6",
+ opt = boost::dynamic_pointer_cast<Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE,
23));
ASSERT_TRUE(opt);
ASSERT_EQ(1, opt->getAddresses().size());
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
Option6AddrLstPtr opt = boost::dynamic_pointer_cast<
- Option6AddrLst>(getOptionPtr("dhcp6", 2345));
+ Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE, 2345));
ASSERT_TRUE(opt);
ASSERT_EQ(2, opt->getAddresses().size());
EXPECT_EQ("2001:db8:1::10", opt->getAddresses()[0].toText());
rcode = 0;
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
- opt = boost::dynamic_pointer_cast<Option6AddrLst>(getOptionPtr("dhcp6",
+ opt = boost::dynamic_pointer_cast<Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE,
2345));
ASSERT_TRUE(opt);
ASSERT_EQ(2, opt->getAddresses().size());
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
const Option6AddrLstPtr opt = boost::dynamic_pointer_cast<
- Option6AddrLst>(getOptionPtr("dhcp6", D6O_DHCPV4_O_DHCPV6_SERVER));
+ Option6AddrLst>(getOptionPtr(DHCP6_OPTION_SPACE, D6O_DHCPV4_O_DHCPV6_SERVER));
ASSERT_TRUE(opt);
ASSERT_EQ(0, opt->getAddresses().size());
}
int rcode = 0;
ASSERT_NO_THROW(rcode = parseConfiguration(config));
EXPECT_EQ(0, rcode);
- const OptionPtr opt = getOptionPtr("dhcp4", DHO_VENDOR_ENCAPSULATED_OPTIONS);
+ const OptionPtr opt = getOptionPtr(DHCP4_OPTION_SPACE, DHO_VENDOR_ENCAPSULATED_OPTIONS);
ASSERT_TRUE(opt);
ASSERT_EQ(0, opt->getOptions().size());
}
#include <dhcp/libdhcp++.h>
#include <dhcp/option4_addrlst.h>
#include <dhcp/option6_addrlst.h>
-#include <dhcp/option_space.h>
#include <dhcp/option_string.h>
#include <dhcp/option_int.h>
#include <dhcp/option_vendor.h>
OptionPtr
retrieveOption(const Host& host, const std::string& option_space,
const uint16_t option_code) const {
- if ((option_space != "dhcp6") && (option_space != "dhcp4")) {
+ if ((option_space != DHCP6_OPTION_SPACE) && (option_space != DHCP4_OPTION_SPACE)) {
return (OptionPtr());
}
// Retrieve a pointer to the appropriate container depending if we're
// interested in DHCPv4 or DHCPv6 options.
- ConstCfgOptionPtr cfg_option = (option_space == "dhcp4" ?
+ ConstCfgOptionPtr cfg_option = (option_space == DHCP4_OPTION_SPACE ?
host.getCfgOption4() : host.getCfgOption6());
// Retrieve options.
// Retrieve and sanity check name servers.
Option4AddrLstPtr opt_dns = boost::dynamic_pointer_cast<
- Option4AddrLst>(retrieveOption(*hosts[0], "dhcp4", DHO_NAME_SERVERS));
+ Option4AddrLst>(retrieveOption(*hosts[0], DHCP4_OPTION_SPACE, DHO_NAME_SERVERS));
ASSERT_TRUE(opt_dns);
Option4AddrLst::AddressContainer dns_addrs = opt_dns->getAddresses();
ASSERT_EQ(2, dns_addrs.size());
// Retrieve and sanity check log servers.
Option4AddrLstPtr opt_log = boost::dynamic_pointer_cast<
- Option4AddrLst>(retrieveOption(*hosts[0], "dhcp4", DHO_LOG_SERVERS));
+ Option4AddrLst>(retrieveOption(*hosts[0], DHCP4_OPTION_SPACE, DHO_LOG_SERVERS));
ASSERT_TRUE(opt_log);
Option4AddrLst::AddressContainer log_addrs = opt_log->getAddresses();
ASSERT_EQ(1, log_addrs.size());
// Retrieve and sanity check default IP TTL.
OptionUint8Ptr opt_ttl = boost::dynamic_pointer_cast<
- OptionUint8>(retrieveOption(*hosts[0], "dhcp4", DHO_DEFAULT_IP_TTL));
+ OptionUint8>(retrieveOption(*hosts[0], DHCP4_OPTION_SPACE, DHO_DEFAULT_IP_TTL));
ASSERT_TRUE(opt_ttl);
EXPECT_EQ(64, opt_ttl->getValue());
}
// Retrieve and sanity check DNS servers option.
Option6AddrLstPtr opt_dns = boost::dynamic_pointer_cast<
- Option6AddrLst>(retrieveOption(*hosts[0], "dhcp6", D6O_NAME_SERVERS));
+ Option6AddrLst>(retrieveOption(*hosts[0], DHCP6_OPTION_SPACE, D6O_NAME_SERVERS));
ASSERT_TRUE(opt_dns);
Option6AddrLst::AddressContainer dns_addrs = opt_dns->getAddresses();
ASSERT_EQ(2, dns_addrs.size());
// Retrieve and sanity check NIS servers option.
Option6AddrLstPtr opt_nis = boost::dynamic_pointer_cast<
- Option6AddrLst>(retrieveOption(*hosts[0], "dhcp6", D6O_NIS_SERVERS));
+ Option6AddrLst>(retrieveOption(*hosts[0], DHCP6_OPTION_SPACE, D6O_NIS_SERVERS));
ASSERT_TRUE(opt_nis);
Option6AddrLst::AddressContainer nis_addrs = opt_nis->getAddresses();
ASSERT_EQ(1, nis_addrs.size());
// Retrieve and sanity check preference option.
OptionUint8Ptr opt_prf = boost::dynamic_pointer_cast<
- OptionUint8>(retrieveOption(*hosts[0], "dhcp6", D6O_PREFERENCE));
+ OptionUint8>(retrieveOption(*hosts[0], DHCP6_OPTION_SPACE, D6O_PREFERENCE));
ASSERT_TRUE(opt_prf);
EXPECT_EQ(11, opt_prf->getValue());
}
#include <config.h>
#include <dhcpsrv/host.h>
+#include <dhcp/option_space.h>
#include <util/encode/hex.h>
#include <util/range_utilities.h>
#include <boost/scoped_ptr.hpp>
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V4, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(host.getCfgOption4()->add(option, false, "dhcp4"));
+ ASSERT_NO_THROW(host.getCfgOption4()->add(option, false, DHCP4_OPTION_SPACE));
}
// Add 7 options to another option space. The option codes partially overlap
}
// Get options from the Subnet and check if all 10 are there.
- OptionContainerPtr options = host.getCfgOption4()->getAll("dhcp4");
+ OptionContainerPtr options = host.getCfgOption4()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(10, options->size());
// It should be possible to retrieve DHCPv6 options but the container
// should be empty.
- OptionContainerPtr options6 = host.getCfgOption6()->getAll("dhcp6");
+ OptionContainerPtr options6 = host.getCfgOption6()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options6);
EXPECT_TRUE(options6->empty());
// Also make sure that for dhcp4 option space no DHCPv6 options are
// returned. This is to check that containers for DHCPv4 and DHCPv6
// options do not share information.
- options6 = host.getCfgOption6()->getAll("dhcp4");
+ options6 = host.getCfgOption6()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options6);
EXPECT_TRUE(options6->empty());
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(host.getCfgOption6()->add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(host.getCfgOption6()->add(option, false, DHCP6_OPTION_SPACE));
}
// Add 7 options to another option space. The option codes partially overlap
}
// Get options from the Subnet and check if all 10 are there.
- OptionContainerPtr options = host.getCfgOption6()->getAll("dhcp6");
+ OptionContainerPtr options = host.getCfgOption6()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(10, options->size());
// It should be possible to retrieve DHCPv4 options but the container
// should be empty.
- OptionContainerPtr options4 = host.getCfgOption4()->getAll("dhcp4");
+ OptionContainerPtr options4 = host.getCfgOption4()->getAll(DHCP4_OPTION_SPACE);
ASSERT_TRUE(options4);
EXPECT_TRUE(options4->empty());
// Also make sure that for dhcp6 option space no DHCPv4 options are
// returned. This is to check that containers for DHCPv4 and DHCPv6
// options do not share information.
- options4 = host.getCfgOption4()->getAll("dhcp6");
+ options4 = host.getCfgOption4()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options4);
EXPECT_TRUE(options4->empty());
// Add an option.
OptionPtr option(new Option(Option::V6, 1000, OptionBuffer(10, 0xFF)));
- conf1.getCfgOption()->add(option, true, "dhcp6");
+ conf1.getCfgOption()->add(option, true, DHCP6_OPTION_SPACE);
// Add a class dictionary
conf1.setClientClassDictionary(ref_dictionary_);
#include <asiolink/io_address.h>
#include <dhcp/option.h>
#include <dhcp/dhcp6.h>
+#include <dhcp/option_space.h>
#include <dhcpsrv/subnet.h>
#include <exceptions/exceptions.h>
// should result in exception.
OptionPtr option2;
ASSERT_FALSE(option2);
- EXPECT_THROW(subnet->getCfgOption()->add(option2, false, "dhcp4"),
+ EXPECT_THROW(subnet->getCfgOption()->add(option2, false, DHCP4_OPTION_SPACE),
isc::BadValue);
}
// Differentiate options by their codes (100-109)
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, DHCP6_OPTION_SPACE));
}
// Add 7 options to another option space. The option codes partially overlap
}
// Get options from the Subnet and check if all 10 are there.
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_TRUE(options);
ASSERT_EQ(10, options->size());
// In the inner loop we create options with unique codes (100-109).
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, DHCP6_OPTION_SPACE));
}
}
// Sanity check that all options are there.
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
ASSERT_EQ(20, options->size());
// Use container index #1 to get the options by their codes.
// and options with these codes will be flagged non-persistent.
// Options with other codes will be flagged persistent.
bool persistent = (code % 3) ? true : false;
- ASSERT_NO_THROW(subnet->getCfgOption()->add(option, persistent, "dhcp6"));
+ ASSERT_NO_THROW(subnet->getCfgOption()->add(option, persistent, DHCP6_OPTION_SPACE));
}
// Get added options from the subnet.
- OptionContainerPtr options = subnet->getCfgOption()->getAll("dhcp6");
+ OptionContainerPtr options = subnet->getCfgOption()->getAll(DHCP6_OPTION_SPACE);
// options->get<2> returns reference to container index #2. This
// index is used to access options by the 'persistent' flag.
// Add 10 options to a "dhcp6" option space in the subnet.
for (uint16_t code = 100; code < 110; ++code) {
OptionPtr option(new Option(Option::V6, code, OptionBuffer(10, 0xFF)));
- ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, "dhcp6"));
+ ASSERT_NO_THROW(subnet->getCfgOption()->add(option, false, DHCP6_OPTION_SPACE));
}
// Check that we can get each added option descriptor using
// Returned descriptor should contain NULL option ptr.
EXPECT_FALSE(desc.option_);
// Now, try the valid option space.
- desc = subnet->getCfgOption()->get("dhcp6", code);
+ desc = subnet->getCfgOption()->get(DHCP6_OPTION_SPACE, code);
// Test that the option code matches the expected code.
ASSERT_TRUE(desc.option_);
EXPECT_EQ(code, desc.option_->getType());
#include <dhcp/dhcp6.h>
#include <dhcp/option.h>
#include <dhcp/option_definition.h>
-#include <dhcp/option_space.h>
#include <dhcp/libdhcp++.h>
#include <eval/eval_context.h>
#include <eval/parser.h>