]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
fixed unit tests and fixed compilation errors regarding PDEXCLUDE after merge
authorAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 17 Jun 2016 10:24:07 +0000 (13:24 +0300)
committerAndrei Pavel <andrei.pavel@qualitance.com>
Fri, 17 Jun 2016 10:24:07 +0000 (13:24 +0300)
31 files changed:
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/tests/config_parser_unittest.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_test_utils.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/lib/dhcp/libdhcp++.cc
src/lib/dhcp/libdhcp++.h
src/lib/dhcp/option6_ia.cc
src/lib/dhcp/option6_iaaddr.cc
src/lib/dhcp/option6_iaprefix.cc
src/lib/dhcp/option_int.h
src/lib/dhcp/tests/libdhcp++_unittest.cc
src/lib/dhcp/tests/option6_ia_unittest.cc
src/lib/dhcp/tests/option_definition_unittest.cc
src/lib/dhcp/tests/option_unittest.cc
src/lib/dhcpsrv/cfg_option.cc
src/lib/dhcpsrv/cfg_option_def.cc
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/tests/cfg_option_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc
src/lib/dhcpsrv/tests/client_class_def_unittest.cc
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc
src/lib/dhcpsrv/tests/generic_host_data_source_unittest.cc
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc
src/lib/dhcpsrv/tests/host_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/tests/subnet_unittest.cc
src/lib/eval/eval_context.cc

index a2aff70634657e082f24f4dc3070d311d2bde848..2e0e7c9dc7f18b9c4db7f5b8e52d0bb373d01b60 100644 (file)
@@ -1121,7 +1121,8 @@ Dhcpv4Srv::appendBasicOptions(Dhcpv4Exchange& ex) {
             // 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;
index 4f69f25aa4789c0b049295a929a80aa6576802ce..286681486c6c17561d16acf7f2f363a3790d5122 100644 (file)
@@ -146,7 +146,7 @@ public:
         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";
@@ -158,19 +158,19 @@ public:
             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;
@@ -251,7 +251,7 @@ public:
                           << "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 "
@@ -475,7 +475,7 @@ public:
     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.
@@ -1823,7 +1823,7 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
     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.
@@ -1834,7 +1834,7 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
 
     // 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.
@@ -1885,7 +1885,7 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
     checkResult(status, 0);
 
     def = CfgMgr::instance().getStagingCfg()->
-        getCfgOptionDef()->get("dhcp4", 213);
+        getCfgOptionDef()->get(DHCP4_OPTION_SPACE, 213);
     ASSERT_TRUE(def);
 
     // Check the option data.
@@ -1927,10 +1927,10 @@ TEST_F(Dhcp4ParserTest, optionDataDefaultsGlobal) {
     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.
@@ -1994,13 +1994,13 @@ TEST_F(Dhcp4ParserTest, optionDataDefaultsSubnet) {
 
     // 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.
@@ -2078,7 +2078,7 @@ TEST_F(Dhcp4ParserTest, optionDataTwoSpaces) {
     // 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.
@@ -2207,13 +2207,13 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
 
     // 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());
 
@@ -2267,7 +2267,7 @@ TEST_F(Dhcp4ParserTest, optionDataInSingleSubnet) {
     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.
@@ -2303,7 +2303,7 @@ TEST_F(Dhcp4ParserTest, optionDataBoolean) {
     // 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";
@@ -2414,7 +2414,7 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
     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.
@@ -2439,7 +2439,7 @@ TEST_F(Dhcp4ParserTest, optionDataInMultipleSubnets) {
     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>();
@@ -2517,7 +2517,7 @@ TEST_F(Dhcp4ParserTest, optionDataLowerCase) {
     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.
@@ -2544,7 +2544,7 @@ TEST_F(Dhcp4ParserTest, stdOptionData) {
     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.
@@ -2561,7 +2561,7 @@ TEST_F(Dhcp4ParserTest, stdOptionData) {
         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());
 
@@ -2746,13 +2746,13 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) {
 
     // 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());
 
index b8e5575019fdcd904d6c00c5f68a5d9a922fac7d..787433cd9032e93c8bf4d1a91d4562965a5e8c22 100644 (file)
@@ -403,7 +403,8 @@ TEST_F(Dhcpv4SrvTest, initResponse) {
     // 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);
@@ -2166,7 +2167,8 @@ TEST_F(Dhcpv4SrvTest, relayLinkSelect) {
 
     // 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);
@@ -2193,7 +2195,8 @@ TEST_F(Dhcpv4SrvTest, relayLinkSelect) {
 
     // 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);
@@ -2276,7 +2279,8 @@ TEST_F(Dhcpv4SrvTest, subnetSelect) {
 
     // 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);
index cf6e61d36fef355e9dd2c3c8e0113604591ff516..a2e38a9160ac7461d11e14b1112b617ac4584ed5 100644 (file)
@@ -62,7 +62,7 @@ Dhcpv4SrvTest::Dhcpv4SrvTest()
     // 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_);
@@ -110,24 +110,24 @@ void Dhcpv4SrvTest::configureRequestedOptions() {
         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) {
index 34aa64863f2f398e8c20a81bb2a43d3bf5385032..c73e6f31d19db98dc5533df8d968ab12abbb7e9b 100644 (file)
@@ -1527,7 +1527,7 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
                 }
 
                 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_,
@@ -1831,7 +1831,7 @@ Dhcpv6Srv::extendIA_PD(const Pkt6Ptr& query,
             }
 
             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_,
index 6b38ea062b1bda869654a880a44d77e9745091ff..cdee579cc1b28a34d08e89f81e63505c76d1ae26 100644 (file)
@@ -146,7 +146,7 @@ public:
         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";
@@ -158,19 +158,19 @@ public:
             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;
@@ -260,7 +260,7 @@ public:
                           << " 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 "
@@ -383,7 +383,7 @@ public:
     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.
@@ -2059,7 +2059,7 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
     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.
@@ -2070,7 +2070,7 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
 
     // 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.
@@ -2121,7 +2121,7 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {
     checkResult(status, 0);
 
     def = CfgMgr::instance().getStagingCfg()->
-        getCfgOptionDef()->get("dhcp6", 63);
+        getCfgOptionDef()->get(DHCP6_OPTION_SPACE, 63);
     ASSERT_TRUE(def);
 
     // Check the option data.
@@ -2162,10 +2162,10 @@ TEST_F(Dhcp6ParserTest, optionDataDefaultsGlobal) {
     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.
@@ -2231,13 +2231,13 @@ TEST_F(Dhcp6ParserTest, optionDataDefaultsSubnet) {
 
     // 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.
@@ -2324,7 +2324,7 @@ TEST_F(Dhcp6ParserTest, optionDataTwoSpaces) {
     // 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.
@@ -2456,13 +2456,13 @@ TEST_F(Dhcp6ParserTest, optionDataEncapsulate) {
 
     // 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());
 
@@ -2514,7 +2514,7 @@ TEST_F(Dhcp6ParserTest, optionDataInMultipleSubnets) {
     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.
@@ -2540,7 +2540,7 @@ TEST_F(Dhcp6ParserTest, optionDataInMultipleSubnets) {
     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>();
@@ -2563,7 +2563,7 @@ TEST_F(Dhcp6ParserTest, optionDataBoolean) {
     // 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";
@@ -2709,7 +2709,7 @@ TEST_F(Dhcp6ParserTest, optionDataLowerCase) {
     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.
@@ -2737,7 +2737,7 @@ TEST_F(Dhcp6ParserTest, stdOptionData) {
     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";
@@ -2752,7 +2752,7 @@ TEST_F(Dhcp6ParserTest, stdOptionData) {
     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.
@@ -3007,12 +3007,12 @@ TEST_F(Dhcp6ParserTest, DISABLED_stdOptionDataEncapsulate) {
     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());
 
index cf81f9569eaccb729c396403c5a509c51f5a5fa7..269c5fc9557f0021ca3850f4020632c69ddd0da1 100644 (file)
@@ -2333,7 +2333,7 @@ TEST_F(Dhcpv6SrvTest, relayOverrideAndClientClass) {
 /// @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");
     }
index ee854b06f3df4d106c498de1ec7d7dc3dbc0151e..3c71dc348fb1a228e85d3373a81f22db1662ae9a 100644 (file)
@@ -15,7 +15,6 @@
 #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>
@@ -96,6 +95,22 @@ void initOptionSpace(OptionDefContainerPtr& defs,
                      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)) {
index decf75fbac9142410f7ae38224972dcbba581f85..d85b846e02307f19b850e91e9bacc4161dcc0fb4 100644 (file)
@@ -9,6 +9,7 @@
 
 #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>
@@ -38,8 +39,22 @@ public:
     /// @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.
index ccb4d824251279747118e7771468b4fccbf8901b..99aea52dc1054aeaa4afd49329e2762bda69e589 100644 (file)
@@ -30,7 +30,7 @@ Option6IA::Option6IA(uint16_t type, uint32_t iaid)
                   "a different layout");
     }
 
-    setEncapsulatedSpace("dhcp6");
+    setEncapsulatedSpace(DHCP6_OPTION_SPACE);
 }
 
 Option6IA::Option6IA(uint16_t type, OptionBufferConstIter begin,
@@ -43,7 +43,7 @@ Option6IA::Option6IA(uint16_t type, OptionBufferConstIter begin,
                   "a different layout");
     }
 
-    setEncapsulatedSpace("dhcp6");
+    setEncapsulatedSpace(DHCP6_OPTION_SPACE);
 
     unpack(begin, end);
 }
index c3608895350571d3e641a5c9ff57ec0bceb5216a..effc734072ff62407a753be9eb2ede5fb8c000e9 100644 (file)
@@ -29,7 +29,7 @@ Option6IAAddr::Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress& addr
                              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");
     }
@@ -38,7 +38,7 @@ Option6IAAddr::Option6IAAddr(uint16_t type, const isc::asiolink::IOAddress& addr
 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);
 }
 
index b61bd88dcba62ab72fe8c00e52dd12ac6f1b2374..2b18e34c422b9b129cfee87886d8f143f5213d75 100644 (file)
@@ -28,7 +28,7 @@ namespace dhcp {
 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)
@@ -40,7 +40,7 @@ Option6IAPrefix::Option6IAPrefix(uint16_t type, const isc::asiolink::IOAddress&
 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);
 }
 
index 180316619ee8b4ce2a18e353fb4c11b53019ebae..2733fd1e21faab47b1977dcb0037cc58d6c34ac9 100644 (file)
@@ -10,7 +10,6 @@
 #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>
index 215fba395952b2e67460a5e409f6a9a5431dd6f4..9bd5d1b8739c498b9b383a6fe588dff5ddcce30e 100644 (file)
@@ -23,7 +23,6 @@
 #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>
@@ -421,7 +420,7 @@ TEST_F(LibDhcpTest, unpackOptions6) {
 
     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
@@ -680,7 +679,8 @@ TEST_F(LibDhcpTest, packOptions4) {
     // 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));
@@ -766,7 +766,7 @@ TEST_F(LibDhcpTest, unpackOptions4) {
     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);
@@ -1629,7 +1629,7 @@ TEST_F(LibDhcpTest, getOptionDefByName6) {
     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);
     }
@@ -1645,7 +1645,7 @@ TEST_F(LibDhcpTest, getOptionDefByName4) {
     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);
     }
@@ -1698,7 +1698,7 @@ TEST_F(LibDhcpTest, vendorClass6) {
     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.
index ab1848c92014ec0b3e59e971b2e6885877be067f..f6a61653ec889933532cbaecb26a9e093d8e0ca8 100644 (file)
@@ -291,7 +291,7 @@ TEST_F(Option6IATest, suboptionsUnpack) {
     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());
index 00f4452bfb56beecf0113c938fdfb899f08e0565..ea52813c8a21313c2bc4e2a2c62f5d1fe01abd4e 100644 (file)
@@ -1241,7 +1241,7 @@ TEST_F(OptionDefinitionTest, integerInvalidType) {
     // 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
     );
index 3d8289d47fcfb3eea809da175e3db3220f128e9b..ef031fd7aa3b9cf4b98c458d0655968546b2aef2 100644 (file)
@@ -591,15 +591,14 @@ TEST_F(OptionTest, setEncapsulatedSpace) {
     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());
 }
 
 }
index d874eb80c05b8b2296af9d8d99714db41d5201e8..3c0110bd0f89385553b8f79795cc2120a66762b5 100644 (file)
@@ -5,7 +5,6 @@
 // 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>
@@ -112,7 +111,13 @@ CfgOption::encapsulateOptions(OptionPtr option) {
             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_);
+            }
         }
     }
 }
index 66afa9c6fe9caf9c1cd4eb0a0f2f39e8510c6709..2584e6a1228ed3c5765c50bd095396f841b4499f 100644 (file)
@@ -7,7 +7,6 @@
 #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 {
index 5c6dcf31b5707a01df4be9a0724b47ed11be5ac4..6ad6b25565e776e5f673b234cc8598deb090dd9e 100644 (file)
@@ -9,7 +9,6 @@
 #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>
index fcc78e9edccfada8544b38bdbfe030559dd35927..176b4394016b21d76eda52c198110f042c8a98c5 100644 (file)
@@ -525,7 +525,7 @@ OptionDataParser::extractCSVFormat() const {
 
 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");
 
@@ -834,7 +834,7 @@ OptionDefParser::createOptionDef(ConstElementPtr option_def_element) {
     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", "");
 
index adaccf4da279964fe613ae3a1795c468addefcf3..77c52748cd9da4c330f97c773cc695e7152aea8e 100644 (file)
@@ -33,7 +33,7 @@ TEST(CfgOptionTest, empty) {
 
     // 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
@@ -103,7 +103,7 @@ TEST(CfgOptionTest, add) {
     // 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
@@ -114,7 +114,7 @@ TEST(CfgOptionTest, add) {
     }
 
     // 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());
 
@@ -155,7 +155,7 @@ TEST(CfgOptionTest, merge) {
     // 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
@@ -172,7 +172,7 @@ TEST(CfgOptionTest, merge) {
     // 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
@@ -189,7 +189,7 @@ TEST(CfgOptionTest, merge) {
 
     // 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
@@ -329,7 +329,7 @@ TEST(CfgOptionTest, get) {
     // 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
@@ -341,7 +341,7 @@ TEST(CfgOptionTest, get) {
         // 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());
@@ -358,12 +358,12 @@ TEST(CfgOptionTest, addNonUniqueOptions) {
         // 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.
@@ -412,11 +412,11 @@ TEST(Subnet6Test, addPersistentOption) {
         // 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.
index c6bead00f7120cf83908477ce67682b8a045b326..55990c1ea6e83b6796661e38c49b57835defdbf0 100644 (file)
@@ -281,7 +281,7 @@ TEST_F(ClientClassDefParserTest, nameOnlyValid) {
     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.
@@ -312,7 +312,7 @@ TEST_F(ClientClassDefParserTest, nameAndExpressionClass) {
     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
@@ -355,7 +355,7 @@ TEST_F(ClientClassDefParserTest, nameAndOptionsClass) {
     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());
 
@@ -391,7 +391,7 @@ TEST_F(ClientClassDefParserTest, basicValidClass) {
     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());
 
index 643c8f967a2d24ca8fe1ffabd779a6fb7de83a14..2219666fe2372a2c2393fa39aeb1ec57c659a262 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <config.h>
 #include <dhcpsrv/client_class_def.h>
+#include <dhcp/option_space.h>
 #include <exceptions/exceptions.h>
 #include <boost/scoped_ptr.hpp>
 
@@ -67,13 +68,13 @@ TEST(ClientClassDef, cfgOptionBasics) {
     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)));
@@ -81,7 +82,7 @@ TEST(ClientClassDef, cfgOptionBasics) {
     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());
 
@@ -89,7 +90,7 @@ TEST(ClientClassDef, cfgOptionBasics) {
     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());
 }
@@ -111,7 +112,7 @@ TEST(ClientClassDef, copyAndEquality) {
     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,
@@ -174,7 +175,7 @@ TEST(ClientClassDef, copyAndEquality) {
     // 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));
index 673707968a23599316a7d03181c799a41c5b14bd..83cbdc458f89b14bd900ae735adc80e774d470f6 100644 (file)
@@ -571,7 +571,7 @@ TEST_F(ParseConfigTest, defaultSpaceOptionDefTest) {
 
     // 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.
@@ -683,7 +683,7 @@ TEST_F(ParseConfigTest, escapedOptionDataTest) {
     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);
@@ -721,7 +721,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatWithOptionDef) {
 
     // 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());
 
@@ -741,7 +741,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatWithOptionDef) {
 
     // 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());
 
@@ -761,7 +761,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatWithOptionDef) {
 
     // 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());
 }
@@ -816,7 +816,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatNoOptionDef) {
         "}";
     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]);
@@ -835,7 +835,7 @@ TEST_F(ParseConfigTest, optionDataCSVFormatNoOptionDef) {
         "}";
     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]);
@@ -857,7 +857,7 @@ TEST_F(ParseConfigTest, optionDataNoName) {
     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());
@@ -877,7 +877,7 @@ TEST_F(ParseConfigTest, optionDataNoCode) {
     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());
@@ -896,7 +896,7 @@ TEST_F(ParseConfigTest, optionDataMinimal) {
     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());
@@ -912,7 +912,7 @@ TEST_F(ParseConfigTest, optionDataMinimal) {
     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());
@@ -942,7 +942,7 @@ TEST_F(ParseConfigTest, optionDataMinimalWithOptionDef) {
     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());
@@ -967,7 +967,7 @@ TEST_F(ParseConfigTest, optionDataMinimalWithOptionDef) {
     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());
@@ -989,7 +989,7 @@ TEST_F(ParseConfigTest, emptyOptionData) {
     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());
 }
@@ -1009,7 +1009,7 @@ TEST_F(ParseConfigTest, optionDataNoSubOpion) {
     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());
 }
index a616f4f081807ddcbfaa69ad2f6d29c814373082..92ed456fe7262cc144be2b2e4b208f37b3304489 100644 (file)
@@ -8,7 +8,6 @@
 #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>
index 05a6a4381021c7c731a2e5cd90b0ab07e2426280..8c0c531ba129f0bd830482a5e17a95ae448bd7fb 100644 (file)
@@ -76,13 +76,13 @@ protected:
     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.
@@ -643,7 +643,7 @@ TEST_F(HostReservationParserTest, options4) {
 
     // 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());
@@ -652,7 +652,7 @@ TEST_F(HostReservationParserTest, options4) {
 
     // 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());
@@ -660,7 +660,7 @@ TEST_F(HostReservationParserTest, options4) {
 
     // 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());
 }
@@ -701,7 +701,7 @@ TEST_F(HostReservationParserTest, options6) {
 
     // 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());
@@ -710,7 +710,7 @@ TEST_F(HostReservationParserTest, options6) {
 
     // 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());
@@ -718,7 +718,7 @@ TEST_F(HostReservationParserTest, options6) {
 
     // 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());
 }
index 535d861ef4192f1419d672310908debc2648274b..8c9d138b565dc617c76952b86126f9b24ab932eb 100644 (file)
@@ -7,6 +7,7 @@
 #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>
@@ -742,7 +743,7 @@ TEST_F(HostTest, addOptions4) {
     // 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
@@ -753,20 +754,20 @@ TEST_F(HostTest, addOptions4) {
     }
 
     // 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());
 
@@ -806,7 +807,7 @@ TEST_F(HostTest, addOptions6) {
     // 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
@@ -817,20 +818,20 @@ TEST_F(HostTest, addOptions6) {
     }
 
     // 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());
 
index 98b8fa665f787d7357d2ee5a9e49a30c30f7436b..1890157f0ae738fb307d5b211ccbd3752a817d77 100644 (file)
@@ -284,7 +284,7 @@ TEST_F(SrvConfigTest, copy) {
 
     // 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_);
index b87c71b5c9fba2cf662fb9d9e3fafe47adfcdb80..ba7bebb0c14fb84e4d34aae182434357dbbc5789 100644 (file)
@@ -9,6 +9,7 @@
 #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>
 
@@ -282,7 +283,7 @@ TEST(Subnet4Test, addInvalidOption) {
     // 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);
 }
 
@@ -751,7 +752,7 @@ TEST(Subnet6Test, addOptions) {
     // 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
@@ -762,7 +763,7 @@ TEST(Subnet6Test, addOptions) {
     }
 
     // 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());
 
@@ -803,12 +804,12 @@ TEST(Subnet6Test, addNonUniqueOptions) {
         // 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.
@@ -855,11 +856,11 @@ TEST(Subnet6Test, addPersistentOption) {
         // 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.
@@ -886,7 +887,7 @@ TEST(Subnet6Test, getOptions) {
     // 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
@@ -898,7 +899,7 @@ TEST(Subnet6Test, getOptions) {
         // 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());
index 54ad635185c78fc9917c082811bda94b1549a5b6..f56569ad31ee518334e484674189c6b8098a89eb 100644 (file)
@@ -7,7 +7,6 @@
 #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>