]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1585] Checkpoint: did first pass
authorFrancis Dupont <fdupont@isc.org>
Thu, 17 Dec 2020 21:24:00 +0000 (22:24 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 11 Jan 2021 14:28:01 +0000 (15:28 +0100)
21 files changed:
src/bin/dhcp4/tests/config_backend_unittest.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/tests/config_backend_unittest.cc
src/bin/dhcp6/tests/config_parser_unittest.cc
src/hooks/dhcp/flex_option/tests/flex_option_unittests.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp6_unittest.cc
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/dhcpsrv/tests/cb_ctl_dhcp_unittest.cc
src/lib/dhcpsrv/tests/cfg_option_def_unittest.cc
src/lib/dhcpsrv/tests/cfg_option_unittest.cc
src/lib/dhcpsrv/tests/cfg_shared_networks4_unittest.cc
src/lib/dhcpsrv/tests/cfg_shared_networks6_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/testutils/generic_host_data_source_unittest.cc
src/lib/yang/tests/adaptor_option_unittests.cc

index 2aae7a56e7cb645a0399478e5228a919fadaf596..af0ed0db294cd2b0ef523ec7c5e654bb3f60ddb5 100644 (file)
@@ -264,18 +264,15 @@ TEST_F(Dhcp4CBTest, mergeOptionDefs) {
 
     // Create option one replacement and add it to first backend.
     OptionDefinitionPtr def;
-    def.reset(new OptionDefinition("one", 101, "uint16"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("one", 101, "isc", "uint16"));
     db1_->createUpdateOptionDef4(ServerSelector::ALL(), def);
 
     // Create option three and add it to first backend.
-    def.reset(new OptionDefinition("three", 3, "string"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("three", 3, "isc", "string"));
     db1_->createUpdateOptionDef4(ServerSelector::ALL(), def);
 
     // Create option four and add it to second backend.
-    def.reset(new OptionDefinition("four", 4, "string"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("four", 4, "isc", "string"));
     db2_->createUpdateOptionDef4(ServerSelector::ALL(), def);
 
     // Should parse and merge without error.
index 145903e3a60249e63f149b20811c3be037ecf42e..187d4063a389a66fe93438f6b557d1e468717601 100644 (file)
@@ -2439,7 +2439,7 @@ TEST_F(Dhcp4ParserTest, optionDefDuplicate) {
     // should override it, but when the new configuration fails, it should
     // revert to this original configuration.
     OptionDefSpaceContainer defs;
-    OptionDefinitionPtr def(new OptionDefinition("bar", 233, "string"));
+    OptionDefinitionPtr def(new OptionDefinition("bar", 233, "isc", "string"));
     defs.addItem(def, "isc");
     LibDHCP::setRuntimeOptionDefs(defs);
     LibDHCP::commitRuntimeOptionDefs();
index 4f4fc080380713620b65905d79eaa28da6af743b..07b55de6bf06a1e800538cccf16de24362e004d7 100644 (file)
@@ -2178,7 +2178,7 @@ TEST_F(Dhcpv4SrvTest, acceptServerId) {
 
     // Create definition of the server identifier option.
     OptionDefinition def("server-identifier", DHO_DHCP_SERVER_IDENTIFIER,
-                         "ipv4-address", false);
+                         DHCP4_OPTION_SPACE, "ipv4-address", false);
 
     // Add a server identifier option which doesn't match server ids being
     // used by the server. The accepted server ids are the IPv4 addresses
index f4de640ca1eb6e244c53fcdd3d716e36f4a19b8e..10d8a3bcd73ca1bafeea276829c4dada4f54e4c1 100644 (file)
@@ -127,7 +127,8 @@ void Dhcpv4SrvTest::configureRequestedOptions() {
     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);
+    OptionDefinition def("domain-name", DHO_DOMAIN_NAME, DHCP4_OPTION_SPACE,
+                         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_OPTION_SPACE);
index 4a7b09c34a3c315dc39a32a4a2fcc370a3d6159d..687a9f4e7403ee3628fb41ea0c6442d0fd00360a 100644 (file)
@@ -256,18 +256,15 @@ TEST_F(Dhcp6CBTest, mergeOptionDefs) {
 
     // Create option one replacement and add it to first backend.
     OptionDefinitionPtr def;
-    def.reset(new OptionDefinition("one", 101, "uint16"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("one", 101, "isc", "uint16"));
     db1_->createUpdateOptionDef6(ServerSelector::ALL(), def);
 
     // Create option three and add it to first backend.
-    def.reset(new OptionDefinition("three", 3, "string"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("three", 3, "isc", "string"));
     db1_->createUpdateOptionDef6(ServerSelector::ALL(), def);
 
     // Create option four and add it to second backend.
-    def.reset(new OptionDefinition("four", 4, "string"));
-    def->setOptionSpaceName("isc");
+    def.reset(new OptionDefinition("four", 4, "isc", "string"));
     db2_->createUpdateOptionDef6(ServerSelector::ALL(), def);
 
     // Should parse and merge without error.
index 8c7b25c70b4e6afdd40502865634f504d72e0528..53ec0e9c9952fd9b87a6885292d0a9187da075ee 100644 (file)
@@ -2808,7 +2808,7 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
     // should override it, but when the new configuration fails, it should
     // revert to this original configuration.
     OptionDefSpaceContainer defs;
-    OptionDefinitionPtr def(new OptionDefinition("bar", 233, "string"));
+    OptionDefinitionPtr def(new OptionDefinition("bar", 233, "isc", "string"));
     defs.addItem(def, "isc");
     LibDHCP::setRuntimeOptionDefs(defs);
     LibDHCP::commitRuntimeOptionDefs();
index 42aea9c5c2260ae1a1bdaf553b0668824f55ccd3..a328e405341783a5a20df0413a9938f6e4b51cd0 100644 (file)
@@ -323,7 +323,8 @@ TEST_F(FlexOptionTest, optionConfigStandardName) {
 // Verify that the name can be an user defined option.
 TEST_F(FlexOptionTest, optionConfigDefinedName) {
     OptionDefSpaceContainer defs;
-    OptionDefinitionPtr def(new OptionDefinition("my-option", 222, "string"));
+    OptionDefinitionPtr def(new OptionDefinition("my-option", 222,
+                                                 DHCP4_OPTION_SPACE, "string"));
     defs.addItem(def, DHCP4_OPTION_SPACE);
     EXPECT_NO_THROW(LibDHCP::setRuntimeOptionDefs(defs));
 
@@ -1086,7 +1087,8 @@ TEST_F(FlexOptionTest, processSupersedeExisting) {
     Pkt6Ptr response(new Pkt6(DHCPV6_ADVERTISE, 12345));
     OptionStringPtr str(new OptionString(Option::V6, D6O_BOOTFILE_URL, "http"));
     response->addOption(str);
-    OptionDefinition def("domain-name", D6O_DOMAIN_SEARCH, OPT_FQDN_TYPE);
+    OptionDefinition def("domain-name", D6O_DOMAIN_SEARCH, DHCP6_OPTION_SPACE,
+                         OPT_FQDN_TYPE);
     OptionCustomPtr option_domain_name(new OptionCustom(def, Option::V6));
     option_domain_name->writeFqdn("old.example.com");
     response->addOption(option_domain_name);
index 64b9bb1caa25ccf05f3d72561bc90aafe68788c4..819e80f4e897b3b7652e5f56b7459159599b97bb 100644 (file)
@@ -427,6 +427,7 @@ MySqlConfigBackendImpl::getOptionDefs(const int index,
                 // Create array option.
                 last_def = OptionDefinition::create(out_bindings[2]->getString(),
                                                     out_bindings[1]->getInteger<uint16_t>(),
+                                                    out_bindings[3]->getString(),
                                                     static_cast<OptionDataType>
                                                     (out_bindings[4]->getInteger<uint8_t>()),
                                                     array_type);
@@ -434,14 +435,12 @@ MySqlConfigBackendImpl::getOptionDefs(const int index,
                 // Create non-array option.
                 last_def = OptionDefinition::create(out_bindings[2]->getString(),
                                                     out_bindings[1]->getInteger<uint16_t>(),
+                                                    out_bindings[3]->getString(),
                                                     static_cast<OptionDataType>
                                                     (out_bindings[4]->getInteger<uint8_t>()),
                                                     out_bindings[7]->getStringOrDefault("").c_str());
             }
 
-            // space
-            last_def->setOptionSpaceName(out_bindings[3]->getStringOrDefault(""));
-
             // id
             last_def->setId(last_def_id);
 
@@ -538,8 +537,7 @@ MySqlConfigBackendImpl::createUpdateOptionDef(const db::ServerSelector& server_s
     MySqlBindingCollection in_bindings = {
         MySqlBinding::createInteger<uint16_t>(option_def->getCode()),
         MySqlBinding::createString(option_def->getName()),
-        MySqlBinding::createString(option_def->getOptionSpaceName().empty() ?
-                                   space : option_def->getOptionSpaceName()),
+        MySqlBinding::createString(option_def->getOptionSpaceName()),
         MySqlBinding::createInteger<uint8_t>(static_cast<uint8_t>(option_def->getType())),
         MySqlBinding::createTimestamp(option_def->getModificationTime()),
         MySqlBinding::createBool(option_def->getArrayType()),
index 129cd258da22de750813aea6b116b90e95b0b6b8..7fbb0950f248110230fd057bebef1e1060496946 100644 (file)
@@ -332,27 +332,27 @@ public:
         ElementPtr user_context = Element::createMap();
         user_context->set("foo", Element::create("bar"));
 
-        OptionDefinitionPtr option_def(new OptionDefinition("foo", 234, "string",
+        OptionDefinitionPtr option_def(new OptionDefinition("foo", 234,
+                                                            DHCP4_OPTION_SPACE,
+                                                            "string",
                                                             "espace"));
-        option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("bar", 234, "uint32", true));
-        option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("bar", 234, DHCP4_OPTION_SPACE,
+                                              "uint32", true));
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("fish", 235, "record", true));
-        option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("fish", 235, DHCP4_OPTION_SPACE,
+                                              "record", true));
         option_def->addRecordField("uint32");
         option_def->addRecordField("string");
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("whale", 236, "string"));
-        option_def->setOptionSpaceName("xyz");
+        option_def.reset(new OptionDefinition("whale", 236, "xyz", "string"));
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("foobar", 234, "uint64", true));
-        option_def->setOptionSpaceName(DHCP4_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("foobar", 234, DHCP4_OPTION_SPACE,
+                                              "uint64", true));
         test_option_defs_.push_back(option_def);
     }
 
@@ -410,13 +410,18 @@ public:
         // the @c toElement functions require option definitions to generate the
         // proper output.
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "vendor-encapsulated-1", 1, "uint32")),
+                         "vendor-encapsulated-1", 1,
+                         "vendor-encapsulated-options", "uint32")),
                      "vendor-encapsulated-options");
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "option-254", 254, "ipv4-address", true)),
+                         "option-254", 254, DHCP4_OPTION_SPACE,
+                         "ipv4-address", true)),
                      DHCP4_OPTION_SPACE);
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "empty")), "isc");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "ipv4-address", true)),
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-1", 1, "isc", "empty")),
+                     "isc");
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-2", 2, "isc", "ipv4-address", true)),
                      "isc");
 
         // Register option definitions.
index 224624d5f5db82f0070d5abae2563805ee3ad904..d2520594c4f7872862fe8f21e35c5a6483d92168 100644 (file)
@@ -378,27 +378,27 @@ public:
         ElementPtr user_context = Element::createMap();
         user_context->set("foo", Element::create("bar"));
 
-        OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234, "string",
+        OptionDefinitionPtr option_def(new OptionDefinition("foo", 1234,
+                                                            DHCP6_OPTION_SPACE,
+                                                            "string",
                                                             "espace"));
-        option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("bar", 1234, "uint32", true));
-        option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("bar", 1234, DHCP6_OPTION_SPACE,
+                                              "uint32", true));
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("fish", 5235, "record", true));
-        option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("fish", 5235, DHCP6_OPTION_SPACE,
+                                              "record", true));
         option_def->addRecordField("uint32");
         option_def->addRecordField("string");
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("whale", 20236, "string"));
-        option_def->setOptionSpaceName("xyz");
+        option_def.reset(new OptionDefinition("whale", 20236, "xyz", "string"));
         test_option_defs_.push_back(option_def);
 
-        option_def.reset(new OptionDefinition("bar", 1234, "uint64", true));
-        option_def->setOptionSpaceName(DHCP6_OPTION_SPACE);
+        option_def.reset(new OptionDefinition("bar", 1234, DHCP6_OPTION_SPACE,
+                                              "uint64", true));
         test_option_defs_.push_back(option_def);
     }
 
@@ -458,13 +458,18 @@ public:
         // the @c toElement functions require option definitions to generate the
         // proper output.
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "vendor-encapsulated-1", 1, "uint32")),
+                         "vendor-encapsulated-1", 1,
+                         "vendor-encapsulated-options", "uint32")),
                      "vendor-encapsulated-options");
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "option-1254", 1254, "ipv6-address", true)),
+                         "option-1254", 1254, DHCP6_OPTION_SPACE,
+                         "ipv6-address", true)),
                      DHCP6_OPTION_SPACE);
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "empty")), "isc");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "ipv6-address", true)),
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-1", 1, "isc", "empty")),
+                     "isc");
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-2", 2, "isc", "ipv6-address", true)),
                      "isc");
 
         // Register option definitions.
index dee67c832b3b099fed869b8cb4159f12c18b15d1..6fad44511bab1bf9fa867c4bc7f78769ae6e3728 100644 (file)
@@ -211,12 +211,12 @@ OptionDefParser::parse(ConstElementPtr option_def) {
                       << option_def->getPosition() << ")");
 
         } else {
-            def.reset(new OptionDefinition(name, code, type,
+            def.reset(new OptionDefinition(name, code, space, type,
                         encapsulates.c_str()));
         }
 
     } else {
-        def.reset(new OptionDefinition(name, code, type, array_type));
+        def.reset(new OptionDefinition(name, code, space, type, array_type));
 
     }
 
index d643733956beb266dea1d2e8a1b62719b54149ae..4420d2db1d0d34d14fcc568e4e48cff6b91619f1 100644 (file)
@@ -317,16 +317,14 @@ public:
                                                                     global_parameter));
 
         // Insert option definitions into the database.
-        OptionDefinitionPtr def(new OptionDefinition("one", 101, "uint16"));
+        OptionDefinitionPtr def(new OptionDefinition("one", 101, "isc", "uint16"));
         def->setId(1);
-        def->setOptionSpaceName("isc");
         def->setModificationTime(getTimestamp("dhcp4_option_def"));
         ASSERT_NO_THROW(mgr.getPool()->createUpdateOptionDef4(BackendSelector::UNSPEC(),
                                                               ServerSelector::ALL(),
                                                               def));
-        def.reset(new OptionDefinition("two", 102, "uint16"));
+        def.reset(new OptionDefinition("two", 102, "isc", "uint16"));
         def->setId(2);
-        def->setOptionSpaceName("isc");
         def->setModificationTime(getTimestamp("dhcp4_option_def"));
         ASSERT_NO_THROW(mgr.getPool()->createUpdateOptionDef4(BackendSelector::UNSPEC(),
                                                               ServerSelector::ALL(),
@@ -1035,16 +1033,14 @@ public:
                                                                     global_parameter));
 
         // Insert option definitions into the database.
-        OptionDefinitionPtr def(new OptionDefinition("one", 101, "uint16"));
+        OptionDefinitionPtr def(new OptionDefinition("one", 101, "isc", "uint16"));
         def->setId(1);
-        def->setOptionSpaceName("isc");
         def->setModificationTime(getTimestamp("dhcp6_option_def"));
         ASSERT_NO_THROW(mgr.getPool()->createUpdateOptionDef6(BackendSelector::UNSPEC(),
                                                               ServerSelector::ALL(),
                                                               def));
-        def.reset(new OptionDefinition("two", 102, "uint16"));
+        def.reset(new OptionDefinition("two", 102, "isc", "uint16"));
         def->setId(2);
-        def->setOptionSpaceName("isc");
         def->setModificationTime(getTimestamp("dhcp6_option_def"));
         ASSERT_NO_THROW(mgr.getPool()->createUpdateOptionDef6(BackendSelector::UNSPEC(),
                                                               ServerSelector::ALL(),
index 1aa9d96d52b7303e29def694defe95e8a46e85ee..6ef6fde4ad2d646e9b5e958e79cf38ed19583b29 100644 (file)
@@ -28,10 +28,10 @@ TEST(CfgOptionDefTest, equal) {
     ASSERT_FALSE(cfg1 != cfg2);
 
     // Let's add the same option but to two different option spaces.
-    cfg1.add(OptionDefinitionPtr(new OptionDefinition("option-foo",
-                                                      5, "uint16")), "isc");
-    cfg2.add(OptionDefinitionPtr(new OptionDefinition("option-foo",
-                                                      5, "uint16")), "dns");
+    cfg1.add(OptionDefinitionPtr(new OptionDefinition("option-foo", 5, "isc",
+                                                      "uint16")), "isc");
+    cfg2.add(OptionDefinitionPtr(new OptionDefinition("option-foo", 5, "dns",
+                                                      "uint16")), "dns");
     // Configurations must be unequal.
     ASSERT_FALSE(cfg1 == cfg2);
     ASSERT_TRUE(cfg1 != cfg2);
@@ -39,10 +39,10 @@ TEST(CfgOptionDefTest, equal) {
     // Now, let's add them again but to original option spaces. Both objects
     // should now contain the same options under two option spaces. The
     // order should not matter so configurations should be equal.
-    cfg1.add(OptionDefinitionPtr(new OptionDefinition("option-foo",
-                                                      5, "uint16")), "dns");
-    cfg2.add(OptionDefinitionPtr(new OptionDefinition("option-foo",
-                                                      5, "uint16")), "isc");
+    cfg1.add(OptionDefinitionPtr(new OptionDefinition("option-foo", 5, "dns",
+                                                      "uint16")), "dns");
+    cfg2.add(OptionDefinitionPtr(new OptionDefinition("option-foo", 5, "isc",
+                                                      "uint16")), "isc");
 
     EXPECT_TRUE(cfg1 == cfg2);
     EXPECT_FALSE(cfg1 != cfg2);
@@ -60,7 +60,7 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
         // Option name is unique, e.g. option-100, option-101 etc.
         option_name << "option-" << code;
         OptionDefinitionPtr def(new OptionDefinition(option_name.str(), code,
-                                                     "uint16"));
+                                                     "isc", "uint16"));
         // We're setting id of 123 for all option definitions in this
         // code range.
         def->setId(123);
@@ -77,7 +77,7 @@ TEST(CfgOptionDefTest, getAllThenDelete) {
         std::ostringstream option_name;
         option_name << "option-" << code;
         OptionDefinitionPtr def(new OptionDefinition(option_name.str(), code,
-                                                     "uint16"));
+                                                     "abcde", "uint16"));
         // We're setting id of 234 for all option definitions in this
         // code range.
         def->setId(234);
@@ -158,7 +158,7 @@ TEST(CfgOptionDefTest, get) {
         // Option name is unique, e.g. option-100, option-101 etc.
         option_name << "option-" << code;
         OptionDefinitionPtr def(new OptionDefinition(option_name.str(), code,
-                                                     "uint16"));
+                                                     "isc", "uint16"));
         // Add option definition to "isc" option space.
         // Option codes are not duplicated so expect no error
         // when adding them.
@@ -171,7 +171,7 @@ TEST(CfgOptionDefTest, get) {
         std::ostringstream option_name;
         option_name << "option-other-" << code;
         OptionDefinitionPtr def(new OptionDefinition(option_name.str(), code,
-                                                     "uint16"));
+                                                     "abcde", "uint16"));
         ASSERT_NO_THROW(cfg.add(def, "abcde"));
     }
 
@@ -217,10 +217,14 @@ TEST(CfgOptionDefTest, get) {
     // Check that an option definition can be added to the standard
     // (dhcp4 and dhcp6) option spaces when the option code is not
     // reserved by the standard option.
-    OptionDefinitionPtr def6(new OptionDefinition("option-foo", 1000, "uint16"));
+    OptionDefinitionPtr def6(new OptionDefinition("option-foo", 1000,
+                                                  DHCP6_OPTION_SPACE,
+                                                  "uint16"));
     EXPECT_NO_THROW(cfg.add(def6, DHCP6_OPTION_SPACE));
 
-    OptionDefinitionPtr def4(new OptionDefinition("option-foo", 222, "uint16"));
+    OptionDefinitionPtr def4(new OptionDefinition("option-foo", 222,
+                                                  DHCP4_OPTION_SPACE,
+                                                  "uint16"));
     EXPECT_NO_THROW(cfg.add(def4, DHCP4_OPTION_SPACE));
 
     // Try to query the option definition from an non-existing
@@ -242,29 +246,34 @@ TEST(CfgOptionDefTest, overrideStdOptionDef) {
     OptionDefinitionPtr def;
     // There is a definition for routers option in libdhcp++, so an attempt
     // to add (override) another definition for this option should fail.
-    def.reset(new OptionDefinition("routers", DHO_ROUTERS, "uint32"));
+    def.reset(new OptionDefinition("routers", DHO_ROUTERS,
+                                   DHCP4_OPTION_SPACE, "uint32"));
     EXPECT_THROW(cfg.add(def, DHCP4_OPTION_SPACE), isc::BadValue);
 
     // Check code duplicate (same code, different name).
-    def.reset(new OptionDefinition("routers-bis", DHO_ROUTERS, "uint32"));
+    def.reset(new OptionDefinition("routers-bis", DHO_ROUTERS,
+                                   DHCP4_OPTION_SPACE, "uint32"));
     EXPECT_THROW(cfg.add(def, DHCP4_OPTION_SPACE), isc::BadValue);
 
     // Check name duplicate (different code, same name).
-    def.reset(new OptionDefinition("routers", 170, "uint32"));
+    def.reset(new OptionDefinition("routers", 170, DHCP4_OPTION_SPACE,
+                                   "uint32"));
     EXPECT_THROW(cfg.add(def, DHCP4_OPTION_SPACE), isc::BadValue);
 
     /// There is no definition for unassigned option 170.
-    def.reset(new OptionDefinition("unassigned-option-170", 170, "string"));
+    def.reset(new OptionDefinition("unassigned-option-170", 170,
+                                   DHCP4_OPTION_SPACE, "string"));
     EXPECT_NO_THROW(cfg.add(def, DHCP4_OPTION_SPACE));
 
     // It is not allowed to override the definition of the option which
     // has its definition in the libdhcp++.
     def.reset(new OptionDefinition("sntp-servers", D6O_SNTP_SERVERS,
-                                   "ipv4-address"));
+                                   DHCP6_OPTION_SPACE, "ipv4-address"));
     EXPECT_THROW(cfg.add(def, DHCP6_OPTION_SPACE), isc::BadValue);
     // There is no definition for option 163 in libdhcp++ yet, so it should
     // be possible provide a custom definition.
-    def.reset(new OptionDefinition("geolocation", 163, "uint32"));
+    def.reset(new OptionDefinition("geolocation", 163, DHCP6_OPTION_SPACE,
+                                   "uint32"));
     EXPECT_NO_THROW(cfg.add(def, DHCP6_OPTION_SPACE));
 }
 
@@ -273,7 +282,8 @@ TEST(CfgOptionDefTest, overrideStdOptionDef) {
 TEST(CfgOptionDefTest, addNegative) {
     CfgOptionDef cfg;
 
-    OptionDefinitionPtr def(new OptionDefinition("option-foo", 1000, "uint16"));
+    OptionDefinitionPtr def(new OptionDefinition("option-foo", 1000, "isc",
+                                                 "uint16"));
 
     // Try empty option space name.
     ASSERT_THROW(cfg.add(def, ""), isc::BadValue);
@@ -293,12 +303,12 @@ TEST(CfgOptionDefTest, unparse) {
 
     // Add some options.
     cfg.add(OptionDefinitionPtr(new
-        OptionDefinition("option-foo", 5, "uint16")), "isc");
+        OptionDefinition("option-foo", 5, "isc", "uint16")), "isc");
     cfg.add(OptionDefinitionPtr(new
-        OptionDefinition("option-bar", 5, "uint16", true)), "dns");
+        OptionDefinition("option-bar", 5, "dns", "uint16", true)), "dns");
     cfg.add(OptionDefinitionPtr(new
-        OptionDefinition("option-baz", 6, "uint16", "dns")), "isc");
-    OptionDefinitionPtr rec(new OptionDefinition("option-rec", 6, "record"));
+        OptionDefinition("option-baz", 6, "isc", "uint16", "dns")), "isc");
+    OptionDefinitionPtr rec(new OptionDefinition("option-rec", 6, "dns", "record"));
     std::string json = "{ \"comment\": \"foo\", \"bar\": 1 }";
     rec->setContext(data::Element::fromJSON(json));
     rec->addRecordField("uint16");
@@ -350,10 +360,10 @@ TEST(CfgOptionDefTest, merge) {
     CfgOptionDef to;         // Configuration we are merging to.
 
     // Add some options to the "to" config.
-    to.add((OptionDefinitionPtr(new OptionDefinition("one", 1, "uint16"))), "isc");
-    to.add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint16"))), "isc");
-    to.add((OptionDefinitionPtr(new OptionDefinition("three", 3, "uint16"))), "fluff");
-    to.add((OptionDefinitionPtr(new OptionDefinition("four", 4, "uint16"))), "fluff");
+    to.add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "uint16"))), "isc");
+    to.add((OptionDefinitionPtr(new OptionDefinition("two", 2, "isc", "uint16"))), "isc");
+    to.add((OptionDefinitionPtr(new OptionDefinition("three", 3, "fluff", "uint16"))), "fluff");
+    to.add((OptionDefinitionPtr(new OptionDefinition("four", 4, "fluff", "uint16"))), "fluff");
 
     // Clone the "to" config and use that for merging.
     CfgOptionDef to_clone;
@@ -372,15 +382,15 @@ TEST(CfgOptionDefTest, merge) {
     // Construct a non-empty "from" config.
     // Options "two" and "three" will be updated definitions and "five" will be new.
     CfgOptionDef from;
-    from.add((OptionDefinitionPtr(new OptionDefinition("two", 22, "uint16"))), "isc");
-    from.add((OptionDefinitionPtr(new OptionDefinition("three", 3, "string"))), "fluff");
-    from.add((OptionDefinitionPtr(new OptionDefinition("five", 5, "uint16"))), "fluff");
+    from.add((OptionDefinitionPtr(new OptionDefinition("two", 22, "isc", "uint16"))), "isc");
+    from.add((OptionDefinitionPtr(new OptionDefinition("three", 3, "fluff", "string"))), "fluff");
+    from.add((OptionDefinitionPtr(new OptionDefinition("five", 5, "fluff", "uint16"))), "fluff");
 
     // Now let's clone "from" config and use that manually construct the expected config.
     CfgOptionDef expected;
     from.copyTo(expected);
-    expected.add((OptionDefinitionPtr(new OptionDefinition("one", 1, "uint16"))), "isc");
-    expected.add((OptionDefinitionPtr(new OptionDefinition("four", 4, "uint16"))), "fluff");
+    expected.add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "uint16"))), "isc");
+    expected.add((OptionDefinitionPtr(new OptionDefinition("four", 4, "fluff", "uint16"))), "fluff");
 
     // Do the merge.
     ASSERT_NO_THROW(to_clone.merge(from));
@@ -389,5 +399,4 @@ TEST(CfgOptionDefTest, merge) {
     ASSERT_TRUE(expected.equals(to_clone));
 }
 
-
 }
index 5cca3f35e5e6c7ecc3978e562c926ae3c4b5f2de..1005602a99e4163adb4803d4ed5f99155ef77b82 100644 (file)
@@ -482,13 +482,13 @@ TEST_F(CfgOptionTest, validMerge) {
     CfgOption this_cfg;
     CfgOption other_cfg;
 
-    // We need to create a dictionary of defintions pass into option merge.
+    // We need to create a dictionary of definitions pass into option merge.
     CfgOptionDefPtr defs(new CfgOptionDef());
-    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "uint8"))), "isc");
-    defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint8"))), "isc");
-    defs->add((OptionDefinitionPtr(new OptionDefinition("four", 4, "uint8"))), "isc");
-    defs->add((OptionDefinitionPtr(new OptionDefinition("three", 3, "uint8"))), "fluff");
-    defs->add((OptionDefinitionPtr(new OptionDefinition("four", 4, "uint8"))), "fluff");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "uint8"))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "isc", "uint8"))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("four", 4, "isc", "uint8"))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("three", 3, "fluff", "uint8"))), "fluff");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("four", 4, "fluff", "uint8"))), "fluff");
 
     // Create our existing config, that gets merged into.
     OptionPtr option(new Option(Option::V4, 1, OptionBuffer(1, 0x01)));
@@ -584,7 +584,7 @@ TEST_F(CfgOptionTest, mergeInvalid) {
 
     // Now let's add an option definition that will force data truncated
     // error for option 1.
-    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "uint16"))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "uint16"))), "isc");
 
     // When we attempt to merge, it should fail because option 1's data
     // is not valid per its definition.
@@ -604,8 +604,8 @@ TEST_F(CfgOptionTest, mergeInvalid) {
 TEST_F(CfgOptionTest, createDescriptorOptionValid) {
     // First we'll create our "known" user definitions
     CfgOptionDefPtr defs(new CfgOptionDef());
-    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "uint8"))), "isc");
-    defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "uint8", true))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "uint8"))), "isc");
+    defs->add((OptionDefinitionPtr(new OptionDefinition("two", 2, "isc", "uint8", true))), "isc");
 
     // We'll try a standard V4 option first.
     std::string space = DHCP4_OPTION_SPACE;
index 4bf17662ec36ea6db56598f11e8384f7adda61fa..ab26a97da730a069dcd02f5f4edc92b6cc6f1c61 100644 (file)
@@ -279,7 +279,7 @@ TEST(CfgSharedNetworks4Test, mergeNetworks) {
     // Create custom options dictionary for testing merge. We're keeping it
     // simple because they are more rigorous tests elsewhere.
     CfgOptionDefPtr cfg_def(new CfgOptionDef());
-    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "string"))), "isc");
+    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "string"))), "isc");
 
     Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.1.0"),
                                    26, 1, 2, 100, SubnetID(1)));
index 18878dffee3b9218f097a9254b39310ac641c041..df6d1b4ee4fd26d816ba8dcb51d57245d4a7bf1c 100644 (file)
@@ -286,7 +286,7 @@ TEST(CfgSharedNetworks6Test, mergeNetworks) {
     // Create custom options dictionary for testing merge. We're keeping it
     // simple because they are more rigorous tests elsewhere.
     CfgOptionDefPtr cfg_def(new CfgOptionDef());
-    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "string"))), "isc");
+    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "string"))), "isc");
 
     Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:1::"),
                                    64, 60, 80, 100, 200, SubnetID(1)));
index accf43a9891917849ae67a9fae5e0731ebde1733..fa03af4a327756f8cef28f701cbdfdbf110aa3b4 100644 (file)
@@ -223,7 +223,7 @@ TEST(CfgSubnets4Test, mergeSubnets) {
     // Create custom options dictionary for testing merge. We're keeping it
     // simple because they are more rigorous tests elsewhere.
     CfgOptionDefPtr cfg_def(new CfgOptionDef());
-    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "string"))), "isc");
+    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "string"))), "isc");
 
     Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.1.0"),
                                    26, 1, 2, 100, SubnetID(1)));
index 9d928c5ab0e22d0746897a5e3e2468725051d2d9..5ccc612b99b1866e65fc86a31ad401c291ecafca 100644 (file)
@@ -869,7 +869,7 @@ TEST(CfgSubnets6Test, mergeSubnets) {
     // Create custom options dictionary for testing merge. We're keeping it
     // simple because they are more rigorous tests elsewhere.
     CfgOptionDefPtr cfg_def(new CfgOptionDef());
-    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "string"))), "isc");
+    cfg_def->add((OptionDefinitionPtr(new OptionDefinition("one", 1, "isc", "string"))), "isc");
 
     Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:1::"),
                                    64, 1, 2, 100, 100, SubnetID(1)));
index 5900d7b6c4b8e0515d753fb0fedd3020b7874c23..1af2932297d8001b6a990e0b0d2420037461864e 100644 (file)
@@ -326,7 +326,7 @@ TEST_F(SrvConfigTest, copy) {
     conf1.addLoggingInfo(info);
 
     // Add option definition.
-    OptionDefinitionPtr def(new OptionDefinition("option-foo", 5, "string"));
+    OptionDefinitionPtr def(new OptionDefinition("option-foo", 5, "isc", "string"));
     conf1.getCfgOptionDef()->add(def, "isc");
 
     // Add an option.
@@ -390,14 +390,14 @@ TEST_F(SrvConfigTest, equality) {
 
     // Differ by option definitions.
     conf1.getCfgOptionDef()->
-        add(OptionDefinitionPtr(new OptionDefinition("option-foo", 123,
+        add(OptionDefinitionPtr(new OptionDefinition("option-foo", 123, "isc",
                                                      "uint16_t")), "isc");
 
     EXPECT_FALSE(conf1 == conf2);
     EXPECT_TRUE(conf1 != conf2);
 
     conf2.getCfgOptionDef()->
-        add(OptionDefinitionPtr(new OptionDefinition("option-foo", 123,
+        add(OptionDefinitionPtr(new OptionDefinition("option-foo", 123, "isc",
                                                      "uint16_t")), "isc");
     EXPECT_TRUE(conf1 == conf2);
     EXPECT_FALSE(conf1 != conf2);
index 5a40da374b440a6a1f472385ea4b9939fa632c44..ee470a351889dc0098fdc1669505c33525393596 100644 (file)
@@ -135,13 +135,18 @@ GenericHostDataSourceTest::addTestOptions(const HostPtr& host,
 
         // Add definitions for DHCPv4 non-standard options.
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "vendor-encapsulated-1", 1, "uint32")),
+                         "vendor-encapsulated-1", 1,
+                         "vendor-encapsulated-options", "uint32")),
                      "vendor-encapsulated-options");
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "option-254", 254, "ipv4-address", true)),
+                         "option-254", 254, DHCP4_OPTION_SPACE,
+                         "ipv4-address", true)),
                      DHCP4_OPTION_SPACE);
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-1", 1, "empty")), "isc");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("isc-2", 2, "ipv4-address", true)),
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-1", 1, "isc", "empty")),
+                     "isc");
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "isc-2", 2, "isc", "ipv4-address", true)),
                      "isc");
     }
 
@@ -167,10 +172,14 @@ GenericHostDataSourceTest::addTestOptions(const HostPtr& host,
 
         // Add definitions for DHCPv6 non-standard options.
         defs.addItem(OptionDefinitionPtr(new OptionDefinition(
-                         "option-1024", 1024, "ipv6-address", true)),
+                         "option-1024", 1024, DHCP6_OPTION_SPACE,
+                         "ipv6-address", true)),
                      DHCP6_OPTION_SPACE);
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-1", 1, "empty")), "isc2");
-        defs.addItem(OptionDefinitionPtr(new OptionDefinition("option-2", 2, "ipv6-address", true)),
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "option-1", 1, "isc2", "empty")),
+                     "isc2");
+        defs.addItem(OptionDefinitionPtr(new OptionDefinition(
+                         "option-2", 2, "isc2", "ipv6-address", true)),
                      "isc2");
     }
 
index 5134c6a122530cb11d9589720f77d793a02014dc..abc47e7cc61ef08e000716f2a23a8d54879497d7 100644 (file)
@@ -185,9 +185,9 @@ public:
 // Verifies that initCodesInternal works as expected.
 TEST(AdaptorOptionTest, initCodesInternal) {
     const OptionDefParams DEFS[] = {
-        { "subnet-mask", DHO_SUBNET_MASK, OPT_IPV4_ADDRESS_TYPE,
-          false, 0, 0, "" },
-        { "time-offset", DHO_TIME_OFFSET, OPT_INT32_TYPE,
+        { "subnet-mask", DHO_SUBNET_MASK, DHCP4_OPTION_SPACE,
+          OPT_IPV4_ADDRESS_TYPE, false, 0, 0, "" },
+        { "time-offset", DHO_TIME_OFFSET, DHCP4_OPTION_SPACE, OPT_INT32_TYPE,
           false, 0, 0, "" }
     };
     const size_t DEFS_SIZE = sizeof(DEFS) / sizeof(DEFS[0]);
@@ -237,4 +237,4 @@ TEST(AdaptorOptionTest, initCodes6) {
     EXPECT_EQ(ISC_V6_4O6_INTERFACE, codes["vendor-2495@4o6-interface"]);
 }
 
-}; // end of anonymous namespace
+} // end of anonymous namespace