]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1848] Moves Triplet to isc::util
authorThomas Markwalder <tmark@isc.org>
Wed, 10 Nov 2021 16:14:00 +0000 (11:14 -0500)
committerTomek Mrugalski <tomek@isc.org>
Wed, 17 Nov 2021 14:35:19 +0000 (15:35 +0100)
    renamed:    src/lib/dhcpsrv/triplet.h -> src/lib/util/triplet.h

    modified:
    src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h
    src/hooks/dhcp/pgsql_cb/tests/pgsql_cb_impl_unittest.cc
    src/lib/cc/simple_parser.cc
    src/lib/cc/simple_parser.h
    src/lib/dhcpsrv/Makefile.am
    src/lib/dhcpsrv/client_class_def.cc
    src/lib/dhcpsrv/client_class_def.h
    src/lib/dhcpsrv/network.h
    src/lib/dhcpsrv/parsers/base_network_parser.cc
    src/lib/dhcpsrv/parsers/client_class_def_parser.cc
    src/lib/dhcpsrv/subnet.h
    src/lib/dhcpsrv/tests/Makefile.am
    src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
    src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
    src/lib/dhcpsrv/tests/alloc_engine_utils.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/client_class_def_parser_unittest.cc
    src/lib/dhcpsrv/tests/shared_network_unittest.cc
    src/lib/dhcpsrv/tests/srv_config_unittest.cc
    src/lib/dhcpsrv/tests/subnet_unittest.cc
    src/lib/dhcpsrv/tests/triplet_unittest.cc
    src/lib/util/Makefile.am

28 files changed:
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp6/json_config_parser.cc
src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.h
src/hooks/dhcp/pgsql_cb/tests/pgsql_cb_impl_unittest.cc
src/lib/cc/simple_parser.cc
src/lib/cc/simple_parser.h
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/client_class_def.cc
src/lib/dhcpsrv/client_class_def.h
src/lib/dhcpsrv/network.h
src/lib/dhcpsrv/parsers/base_network_parser.cc
src/lib/dhcpsrv/parsers/client_class_def_parser.cc
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/tests/Makefile.am
src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine_utils.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/client_class_def_parser_unittest.cc
src/lib/dhcpsrv/tests/shared_network_unittest.cc
src/lib/dhcpsrv/tests/srv_config_unittest.cc
src/lib/dhcpsrv/tests/subnet_unittest.cc
src/lib/dhcpsrv/tests/triplet_unittest.cc
src/lib/dhcpsrv/triplet.h [deleted file]
src/lib/util/Makefile.am

index f85f7fcaa35889a182eef69f0987a2227998ce13..69f638339ac2381a75d0e135c4da3ba6f6414ab4 100644 (file)
@@ -49,6 +49,7 @@ using namespace isc::data;
 using namespace isc::asiolink;
 using namespace isc::config;
 using namespace isc::dhcp::test;
+using namespace isc::util;
 
 namespace {
 
index 44005351e0d4c83cc5ca5c08aee2c529b22f4080..7a8b1c73a6926bcdab709abc58384a91f2614935 100644 (file)
@@ -23,7 +23,7 @@
 #include <dhcpsrv/pool.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/timer_mgr.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <dhcpsrv/parsers/client_class_def_parser.h>
 #include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/duid_config_parser.h>
index f0a046d2839a2abe7ca2ddc0f1649881215cfed5..ef4bd42074665d3955620422456e8aa6d5f46a74 100644 (file)
@@ -112,12 +112,12 @@ public:
     virtual ~PgSqlConfigBackendImpl();
 
     /// @todo: implement condCreateInteger(const util::Optional<T>& value)
-    static db::PsqlBindArrayPtr createBinding(const Triplet<uint32_t>& triplet);
-    static db::PsqlBindArrayPtr createMaxBinding(const Triplet<uint32_t>& triplet);
-    static db::PsqlBindArrayPtr createMinBinding(const Triplet<uint32_t>& triplet);
+    static db::PsqlBindArrayPtr createBinding(const isc::util::Triplet<uint32_t>& triplet);
+    static db::PsqlBindArrayPtr createMaxBinding(const isc::util::Triplet<uint32_t>& triplet);
+    static db::PsqlBindArrayPtr createMinBinding(const isc::util::Triplet<uint32_t>& triplet);
 #if 0
-    static Triplet<uint32_t> createTriplet(const db::PsqlBindArrayPtr& binding);
-    static Triplet<uint32_t> createTriplet(const db::PsqlBindArrayPtr& def_binding,
+    static isc::util::Triplet<uint32_t> createTriplet(const db::PsqlBindArrayPtr& binding);
+    static isc::util::Triplet<uint32_t> createTriplet(const db::PsqlBindArrayPtr& def_binding,
         const db::PsqlBindArrayPtr& min_binding, const db::PsqlBindArrayPtr& max_binding);
 #endif
 
index b4dff0abebae175d19a2c6c4d427fd0ccae1dc29..fda1e93df7de9014c7d381dc03c7e7e281b1eadf 100644 (file)
@@ -16,6 +16,7 @@
 using namespace isc::db;
 using namespace isc::dhcp;
 using namespace isc::dhcp::test;
+using namespace isc::util;
 
 namespace {
 
@@ -29,13 +30,16 @@ public:
         params["password"] = "keatest";
         params["user"] = "keatest";
 
-        createDummySchema();
+        //createDummySchema();
+        createFullSchema();
 
         cbptr_.reset(new PgSqlConfigBackendImpl(params, 0));
     }
 
     ~PgsqlConfigBackendTest() {
-        destroyDummySchema();
+        destroyFullSchema();
+
+        //destroyDummySchema();
     }
 
     /// @brief Creates the absolute minimum schema.
@@ -57,6 +61,7 @@ public:
 
         // Dummy schema queries
         const char* sql[] = {
+            "DROP TABLE IF EXISTS schema_version;",
             "CREATE TABLE schema_version (version INT PRIMARY KEY NOT NULL, minor INT);",
             "INSERT INTO schema_version VALUES (7,0);"
         };
@@ -92,7 +97,7 @@ public:
     /// Don't forget to tear it down with @ref destroyFullSchema();
     void createFullSchema() {
         // Create the actual full Kea schema.
-        isc::db::test::createPgSQLSchema(true, true);
+        isc::db::test::createPgSQLSchema();
     }
 
     /// @brief destroys the full schema (slow!)
@@ -100,7 +105,7 @@ public:
     /// Don't forget to call this method once you're done, if you used @ref createFullSchema().
     void destroyFullSchema() {
         // Clean up after ourselves.
-        isc::db::test::destroyPgSQLSchema(true, true);
+        isc::db::test::destroyPgSQLSchema();
     }
 
     /// @brief checks if specified triplet generating function stores the values properly.
index 1d77a7b7cf34449898677b7ed48c935c4658a28b..dbde486748ea80dbd0b26df4fcc7f6b2b0976fe4 100644 (file)
@@ -281,7 +281,7 @@ SimpleParser::deriveParams(ConstElementPtr parent,
     return (cnt);
 }
 
-const Triplet<uint32_t>
+const util::Triplet<uint32_t>
 SimpleParser::parseIntTriplet(const ConstElementPtr& scope,
                               const std::string& name) {
     // Initialize as some compilers complain otherwise.
@@ -304,7 +304,7 @@ SimpleParser::parseIntTriplet(const ConstElementPtr& scope,
         has_max = true;
     }
     if (!has_value && !has_min && !has_max) {
-        return (Triplet<uint32_t>());
+        return (util::Triplet<uint32_t>());
     }
     if (has_value) {
         if (!has_min && !has_max) {
@@ -359,7 +359,7 @@ SimpleParser::parseIntTriplet(const ConstElementPtr& scope,
                   << min_value << ") and max-" << name << " ("
                   << max_value << ")");
     }
-    return (Triplet<uint32_t>(min_value, value, max_value));
+    return (util::Triplet<uint32_t>(min_value, value, max_value));
 }
 
 }; // end of isc::dhcp namespace
index 34a207b5163dc5f0ea32e3b2d15d329a2b0d1063..b91ba54b3be99e00414a4d1ceb8cb9f770e74386 100644 (file)
@@ -10,7 +10,7 @@
 #include <asiolink/io_address.h>
 #include <cc/data.h>
 #include <cc/dhcp_config_error.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <map>
 #include <vector>
 #include <string>
@@ -329,8 +329,8 @@ public:
     /// to be parsed.
     /// @param name Base name of the parameter.
     /// @return A triplet with the parsed value.
-    const dhcp::Triplet<uint32_t> parseIntTriplet(const data::ConstElementPtr& scope,
-                                                  const std::string& name);
+    const isc::util::Triplet<uint32_t> parseIntTriplet(const data::ConstElementPtr& scope,
+                                                       const std::string& name);
 };
 
 };
index 7ecf8b9dfa5fcb6b9220f5070c389958c08def83..5822a2e407217f4ecab0dd3a8d82d8e7014d66fd 100644 (file)
@@ -153,7 +153,6 @@ libkea_dhcpsrv_la_SOURCES += subnet.cc subnet.h
 libkea_dhcpsrv_la_SOURCES += subnet_id.h
 libkea_dhcpsrv_la_SOURCES += subnet_selector.h
 libkea_dhcpsrv_la_SOURCES += timer_mgr.cc timer_mgr.h
-libkea_dhcpsrv_la_SOURCES += triplet.h
 libkea_dhcpsrv_la_SOURCES += utils.h
 libkea_dhcpsrv_la_SOURCES += writable_host_data_source.h
 
@@ -374,7 +373,6 @@ libkea_dhcpsrv_include_HEADERS = \
        subnet_id.h \
        subnet_selector.h \
        timer_mgr.h \
-       triplet.h \
        utils.h \
        writable_host_data_source.h
 
index cbc2fede573606adc3e770dfae6c22fb72a226dc..7930231a7fd5dddc650a89c543c357f0dc956463 100644 (file)
@@ -264,8 +264,8 @@ ClientClassDictionary::addClass(const std::string& name,
                                 asiolink::IOAddress next_server,
                                 const std::string& sname,
                                 const std::string& filename,
-                                const Triplet<uint32_t>& valid,
-                                const Triplet<uint32_t>& preferred) {
+                                const util::Triplet<uint32_t>& valid,
+                                const util::Triplet<uint32_t>& preferred) {
     ClientClassDefPtr cclass(new ClientClassDef(name, match_expr, cfg_option));
     cclass->setTest(test);
     cclass->setRequired(required);
index 012f3e9c39c4f878bb1614ad6f70782193237d49..b2c288144df48ef34bb756a1c24c5bdc9a27555d 100644 (file)
@@ -12,7 +12,7 @@
 #include <cc/user_context.h>
 #include <dhcpsrv/cfg_option.h>
 #include <dhcpsrv/cfg_option_def.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <eval/token.h>
 #include <exceptions/exceptions.h>
 
@@ -197,28 +197,28 @@ public:
     /// @brief Return valid-lifetime value
     ///
     /// @return a triplet containing the valid lifetime.
-    Triplet<uint32_t> getValid() const {
+    util::Triplet<uint32_t> getValid() const {
         return (valid_);
     }
 
     /// @brief Sets new valid lifetime
     ///
     /// @param valid New valid lifetime in seconds.
-    void setValid(const Triplet<uint32_t>& valid) {
+    void setValid(const util::Triplet<uint32_t>& valid) {
         valid_ = valid;
     }
 
     /// @brief Return preferred-lifetime value
     ///
     /// @return a triplet containing the preferred lifetime.
-    Triplet<uint32_t> getPreferred() const {
+    util::Triplet<uint32_t> getPreferred() const {
         return (preferred_);
     }
 
     /// @brief Sets new preferred lifetime
     ///
     /// @param preferred New valid lifetime in seconds.
-    void setPreferred(const Triplet<uint32_t>& preferred) {
+    void setPreferred(const util::Triplet<uint32_t>& preferred) {
         preferred_ = preferred;
     }
 
@@ -279,10 +279,10 @@ private:
     std::string filename_;
 
     /// @brief a Triplet (min/default/max) holding allowed valid lifetime values
-    Triplet<uint32_t> valid_;
+    util::Triplet<uint32_t> valid_;
 
     /// @brief a Triplet (min/default/max) holding allowed preferred lifetime values
-    Triplet<uint32_t> preferred_;
+    util::Triplet<uint32_t> preferred_;
 };
 
 /// @brief a pointer to an ClientClassDef
@@ -339,8 +339,8 @@ public:
                   asiolink::IOAddress next_server = asiolink::IOAddress("0.0.0.0"),
                   const std::string& sname = std::string(),
                   const std::string& filename = std::string(),
-                  const Triplet<uint32_t>&valid = Triplet<uint32_t>(),
-                  const Triplet<uint32_t>&preferred = Triplet<uint32_t>());
+                  const util::Triplet<uint32_t>&valid = util::Triplet<uint32_t>(),
+                  const util::Triplet<uint32_t>&preferred = util::Triplet<uint32_t>());
 
     /// @brief Adds a new class to the list
     ///
index 1ca386f7f5c94f73d50b8c018218286cc0bd3714..5521afacabbb408dbb7f0bbb9911e66024b7c4e3 100644 (file)
@@ -17,7 +17,7 @@
 #include <dhcpsrv/cfg_option.h>
 #include <dhcpsrv/cfg_4o6.h>
 #include <dhcpsrv/d2_client_cfg.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <util/optional.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
@@ -337,7 +337,7 @@ public:
     /// @brief Return valid-lifetime for addresses in that prefix
     ///
     /// @param inheritance inheritance mode to be used.
-    Triplet<uint32_t> getValid(const Inheritance& inheritance = Inheritance::ALL) const {
+    isc::util::Triplet<uint32_t> getValid(const Inheritance& inheritance = Inheritance::ALL) const {
         return (getProperty<Network>(&Network::getValid, valid_, inheritance,
                                      "valid-lifetime", "min-valid-lifetime",
                                      "max-valid-lifetime"));
@@ -346,35 +346,35 @@ public:
     /// @brief Sets new valid lifetime for a network.
     ///
     /// @param valid New valid lifetime in seconds.
-    void setValid(const Triplet<uint32_t>& valid) {
+    void setValid(const isc::util::Triplet<uint32_t>& valid) {
         valid_ = valid;
     }
 
     /// @brief Returns T1 (renew timer), expressed in seconds
     ///
     /// @param inheritance inheritance mode to be used.
-    Triplet<uint32_t> getT1(const Inheritance& inheritance = Inheritance::ALL) const {
+    isc::util::Triplet<uint32_t> getT1(const Inheritance& inheritance = Inheritance::ALL) const {
         return (getProperty<Network>(&Network::getT1, t1_, inheritance, "renew-timer"));
     }
 
     /// @brief Sets new renew timer for a network.
     ///
     /// @param t1 New renew timer value in seconds.
-    void setT1(const Triplet<uint32_t>& t1) {
+    void setT1(const isc::util::Triplet<uint32_t>& t1) {
         t1_ = t1;
     }
 
     /// @brief Returns T2 (rebind timer), expressed in seconds
     ///
     /// @param inheritance inheritance mode to be used.
-    Triplet<uint32_t> getT2(const Inheritance& inheritance = Inheritance::ALL) const {
+    isc::util::Triplet<uint32_t> getT2(const Inheritance& inheritance = Inheritance::ALL) const {
         return (getProperty<Network>(&Network::getT2, t2_, inheritance, "rebind-timer"));
     }
 
     /// @brief Sets new rebind timer for a network.
     ///
     /// @param t2 New rebind timer value in seconds.
-    void setT2(const Triplet<uint32_t>& t2) {
+    void setT2(const isc::util::Triplet<uint32_t>& t2) {
         t2_ = t2;
     }
 
@@ -798,7 +798,7 @@ protected:
         return (property);
     }
 
-    /// @brief The @c getGlobalProperty specialization for Triplet<T>.
+    /// @brief The @c getGlobalProperty specialization for isc::util::Triplet<T>.
     ///
     /// @note: use overloading vs specialization because full specialization
     /// is not allowed in this scope.
@@ -817,7 +817,7 @@ protected:
     /// @return Optional value fetched from the global level or the value
     /// of @c property.
     template<typename NumType>
-    Triplet<NumType> getGlobalProperty(Triplet<NumType> property,
+    isc::util::Triplet<NumType> getGlobalProperty(isc::util::Triplet<NumType> property,
                                        const std::string& global_name,
                                        const std::string& min_name = "",
                                        const std::string& max_name = "") const {
@@ -841,7 +841,7 @@ protected:
                         if (max_param) {
                             max_value = static_cast<NumType>(max_param->intValue());
                         }
-                        return (Triplet<NumType>(min_value, def_value, max_value));
+                        return (isc::util::Triplet<NumType>(min_value, def_value, max_value));
                     }
                 }
             }
@@ -879,7 +879,7 @@ protected:
     ///
     /// This template method provides a generic mechanism to retrieve a
     /// network parameter using inheritance. It is called from public
-    /// accessor methods which return an @c OptionalValue or @c Triplet.
+    /// accessor methods which return an @c OptionalValue or @c isc::util::Triplet.
     ///
     /// @tparam BaseType Type of this instance, e.g. @c Network, @c Network4
     /// etc, which exposes a method to be called.
@@ -1043,14 +1043,14 @@ protected:
     /// incoming packet and their evaluation will be required.
     ClientClasses required_classes_;
 
-    /// @brief a Triplet (min/default/max) holding allowed renew timer values
-    Triplet<uint32_t> t1_;
+    /// @brief a isc::util::Triplet (min/default/max) holding allowed renew timer values
+    isc::util::Triplet<uint32_t> t1_;
 
-    /// @brief a Triplet (min/default/max) holding allowed rebind timer values
-    Triplet<uint32_t> t2_;
+    /// @brief a isc::util::Triplet (min/default/max) holding allowed rebind timer values
+    isc::util::Triplet<uint32_t> t2_;
 
-    /// @brief a Triplet (min/default/max) holding allowed valid lifetime values
-    Triplet<uint32_t> valid_;
+    /// @brief a isc::util::Triplet (min/default/max) holding allowed valid lifetime values
+    isc::util::Triplet<uint32_t> valid_;
 
     /// @brief Enables global reservations.
     util::Optional<bool> reservations_global_;
@@ -1276,7 +1276,7 @@ public:
     ///
     /// @param inheritance inheritance mode to be used.
     /// @return a triplet with preferred lifetime
-    Triplet<uint32_t>
+    isc::util::Triplet<uint32_t>
     getPreferred(const Inheritance& inheritance = Inheritance::ALL) const {
         return (getProperty<Network6>(&Network6::getPreferred, preferred_,
                                       inheritance, "preferred-lifetime",
@@ -1287,7 +1287,7 @@ public:
     /// @brief Sets new preferred lifetime for a network.
     ///
     /// @param preferred New preferred lifetime in seconds.
-    void setPreferred(const Triplet<uint32_t>& preferred) {
+    void setPreferred(const isc::util::Triplet<uint32_t>& preferred) {
         preferred_ = preferred;
     }
 
@@ -1335,7 +1335,7 @@ public:
 private:
 
     /// @brief a triplet with preferred lifetime (in seconds)
-    Triplet<uint32_t> preferred_;
+    isc::util::Triplet<uint32_t> preferred_;
 
     /// @brief specifies optional interface-id
     OptionPtr interface_id_;
index 88f5886169db81f016a666790ecf0fa9b1ad09f8..21c6d7a3051eb25a98cc87fa490274a73e598cf0 100644 (file)
@@ -5,7 +5,7 @@
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 #include <config.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <dhcpsrv/parsers/base_network_parser.h>
 #include <util/optional.h>
 #include <util/strutil.h>
index 4899f0a79f5257e09af27e821f952cbc4a76b65e..07107a2bafeeb8912fb474679f74cb90e4eaa6bf 100644 (file)
@@ -22,6 +22,7 @@
 
 using namespace isc::data;
 using namespace isc::asiolink;
+using namespace isc::util;
 using namespace std;
 
 /// @file client_class_def_parser.cc
index 07458b25cf9120ec98b18425b16eef8fa7ab7713..990d95fb6fb7512504c98d07d1191846e456f441 100644 (file)
@@ -15,7 +15,7 @@
 #include <dhcpsrv/network.h>
 #include <dhcpsrv/pool.h>
 #include <dhcpsrv/subnet_id.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <boost/multi_index/mem_fun.hpp>
 #include <boost/multi_index/indexed_by.hpp>
 #include <boost/multi_index/ordered_index.hpp>
@@ -541,9 +541,9 @@ public:
     /// @param id arbitrary subnet id, default value of 0 triggers
     /// autogeneration of subnet id
     Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
-            const Triplet<uint32_t>& t1,
-            const Triplet<uint32_t>& t2,
-            const Triplet<uint32_t>& valid_lifetime,
+            const util::Triplet<uint32_t>& t1,
+            const util::Triplet<uint32_t>& t2,
+            const util::Triplet<uint32_t>& valid_lifetime,
             const SubnetID id = 0);
 
     /// @brief Factory function creating an instance of the @c Subnet4.
@@ -564,9 +564,9 @@ public:
     /// @return Pointer to the @c Subnet4 instance.
     static Subnet4Ptr
     create(const isc::asiolink::IOAddress& prefix, uint8_t length,
-           const Triplet<uint32_t>& t1,
-           const Triplet<uint32_t>& t2,
-           const Triplet<uint32_t>& valid_lifetime,
+           const util::Triplet<uint32_t>& t1,
+           const util::Triplet<uint32_t>& t2,
+           const util::Triplet<uint32_t>& valid_lifetime,
            const SubnetID id = 0);
 
     /// @brief Returns next subnet within shared network.
@@ -690,10 +690,10 @@ public:
     /// @param id arbitrary subnet id, default value of 0 triggers
     /// autogeneration of subnet id
     Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
-            const Triplet<uint32_t>& t1,
-            const Triplet<uint32_t>& t2,
-            const Triplet<uint32_t>& preferred_lifetime,
-            const Triplet<uint32_t>& valid_lifetime,
+            const util::Triplet<uint32_t>& t1,
+            const util::Triplet<uint32_t>& t2,
+            const util::Triplet<uint32_t>& preferred_lifetime,
+            const util::Triplet<uint32_t>& valid_lifetime,
             const SubnetID id = 0);
 
     /// @brief Factory function creating an instance of the @c Subnet4.
@@ -715,10 +715,10 @@ public:
     /// @return Pointer to the @c Subnet6 instance.
     static Subnet6Ptr
     create(const isc::asiolink::IOAddress& prefix, uint8_t length,
-           const Triplet<uint32_t>& t1,
-           const Triplet<uint32_t>& t2,
-           const Triplet<uint32_t>& preferred_lifetime,
-           const Triplet<uint32_t>& valid_lifetime,
+           const util::Triplet<uint32_t>& t1,
+           const util::Triplet<uint32_t>& t2,
+           const util::Triplet<uint32_t>& preferred_lifetime,
+           const util::Triplet<uint32_t>& valid_lifetime,
            const SubnetID id = 0);
 
     /// @brief Returns next subnet within shared network.
index 8aba044350d396d652fd6310bfc215253bfe4067..5a0dc629c974114110570f56b5ebed2b64f96fbe 100644 (file)
@@ -130,7 +130,6 @@ libdhcpsrv_unittests_SOURCES += shared_networks_list_parser_unittest.cc
 libdhcpsrv_unittests_SOURCES += srv_config_unittest.cc
 libdhcpsrv_unittests_SOURCES += subnet_unittest.cc
 libdhcpsrv_unittests_SOURCES += test_get_callout_handle.cc test_get_callout_handle.h
-libdhcpsrv_unittests_SOURCES += triplet_unittest.cc
 libdhcpsrv_unittests_SOURCES += timer_mgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += network_state_unittest.cc
 libdhcpsrv_unittests_SOURCES += network_unittest.cc
index 598c303b3b6be6575f0acd64ac69600d43f6ca2a..a0941f9ca5015f78841b9b55e7aec3c5f2031645 100644 (file)
@@ -22,6 +22,7 @@ using namespace isc::hooks;
 using namespace isc::asiolink;
 using namespace isc::data;
 using namespace isc::stats;
+using namespace isc::util;
 
 namespace isc {
 namespace dhcp {
index 825b74386ba22fa2185a86a035aa7e6574dabd13..f833c3a02b840c6b153c7cb512aa905ec86693e3 100644 (file)
@@ -18,6 +18,7 @@ using namespace isc::hooks;
 using namespace isc::asiolink;
 using namespace isc::stats;
 using namespace isc::data;
+using namespace isc::util;
 
 namespace isc {
 namespace dhcp {
index daa85e574bf3db31df8ab2e81ea2313ab7931021..bcda6ba57b5c73622191b07f03106e582b71c5ec 100644 (file)
@@ -34,6 +34,7 @@ using namespace std;
 using namespace isc::hooks;
 using namespace isc::asiolink;
 using namespace isc::stats;
+using namespace isc::util;
 
 namespace isc {
 namespace dhcp {
index fcc7ad8f2c6279954c83fee3c98d7a3e20ace349..fbb554565e8d60451e67df31ba08830a69ac584e 100644 (file)
@@ -14,6 +14,7 @@
 
 using namespace isc;
 using namespace isc::dhcp;
+using namespace isc::util;
 using namespace asiolink;
 
 namespace {
index c44156ad3ae4a82d13ee59ccd89d7fb06fc58e80..b884a890a15a7546b0a3ec2e08466d5e26c8cf24 100644 (file)
@@ -14,6 +14,7 @@
 
 using namespace isc;
 using namespace isc::dhcp;
+using namespace isc::util;
 using namespace asiolink;
 
 namespace {
index 365a469fc633aacf560ee3257ed2872c73ac70da..64627e1d4329b6fbf0240ab95ae539844baf9f92 100644 (file)
@@ -37,6 +37,7 @@ using namespace isc::dhcp;
 using namespace isc::dhcp::test;
 using namespace isc::stats;
 using namespace isc::test;
+using namespace isc::util;
 
 namespace {
 
index 4a461bf54c9066dd7cfada4191e6a6d31d7b8e0d..efb9111b69c416fe758376c8454fb3d83d5932eb 100644 (file)
@@ -34,6 +34,7 @@ using namespace isc::dhcp;
 using namespace isc::dhcp::test;
 using namespace isc::stats;
 using namespace isc::test;
+using namespace isc::util;
 
 namespace {
 
index 11601a82403de35d478aedac89d9730603b1e55f..a12a1ea99a0f23d75f356fd0345bacfcd1fdf35b 100644 (file)
@@ -27,6 +27,7 @@
 using namespace isc::data;
 using namespace isc::dhcp;
 using namespace isc::asiolink;
+using namespace isc::util;
 
 namespace {
 
index a2318d82c780b2c57bd411f5f3f4ed99ab5e9171..85763c5184e3b940f5690ed0ef1c6e6972d11fbd 100644 (file)
@@ -12,7 +12,7 @@
 #include <dhcpsrv/shared_network.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/subnet_id.h>
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <exceptions/exceptions.h>
 #include <testutils/test_to_element.h>
 #include <testutils/multi_threading_utils.h>
index 7c2663f79fd8fd22a823f1c835ec0695631c0818..b9390c1785a6e4864c8b8e663ab309508b9a6b35 100644 (file)
@@ -21,6 +21,7 @@ using namespace isc::asiolink;
 using namespace isc::dhcp;
 using namespace isc::data;
 using namespace isc::process;
+using namespace isc::util;
 
 // Those are the tests for SrvConfig storage. Right now they are minimal,
 // but the number is expected to grow significantly once we migrate more
index af2e1a80a3c52101e08efbfe1263513ecd6ed285..f19b06efac544c4fca51c7e45db9d6169f914672 100644 (file)
@@ -32,6 +32,7 @@ using namespace isc;
 using namespace isc::dhcp;
 using namespace isc::asiolink;
 using namespace isc::test;
+using namespace isc::util;
 
 namespace {
 
index 1618b30f5eb1df6fcc5bb599333d57f54229a204..23e3b8a22543e91ad1de5a58ca3707bf92d5d9d8 100644 (file)
@@ -6,14 +6,14 @@
 
 #include <config.h>
 
-#include <dhcpsrv/triplet.h>
+#include <util/triplet.h>
 #include <exceptions/exceptions.h>
 
 #include <gtest/gtest.h>
 
 #include <stdint.h>
 
-using namespace isc::dhcp;
+using namespace isc::util;
 using namespace isc;
 
 namespace {
diff --git a/src/lib/dhcpsrv/triplet.h b/src/lib/dhcpsrv/triplet.h
deleted file mode 100644 (file)
index 02222f8..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2012-2019 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#ifndef TRIPLET_H
-#define TRIPLET_H
-
-#include <exceptions/exceptions.h>
-#include <util/optional.h>
-
-namespace isc {
-namespace dhcp {
-
-/// @brief This template specifies a parameter value
-///
-/// This template class is used to store configuration parameters, like lifetime
-/// or T1. It defines 3 parameters: min, default, and max value. If the
-/// particular configuration parameter is not mandatory, it is possible to
-/// mark the parameter described by a @c Triplet "unspecified". For example, the
-/// T1 and T2 values in DHCPv4 server are optional and may be not specified
-/// in the configuration. The @c Triplets describing these parameters will be
-/// marked "unspecified". If the server finds that the particular parameter
-/// is unspecified it will not include it (e.g. option 58 or 59) in the message
-/// to a client.
-///
-/// There are 3 constructors:
-/// - without parameters - marks the parameter "unspecified"
-/// - simple (just one value that sets all parameters)
-/// - extended (that sets default value and two thresholds)
-///
-/// It will be used with integer types. It provides necessary operators, so
-/// it can be assigned to a plain integer or integer assigned to a Triplet.
-/// See TripletTest.operator test for details on an easy Triplet usage.
-template <class T>
-class Triplet : public util::Optional<T> {
-public:
-
-    using util::Optional<T>::get;
-
-    /// @brief Base type to Triplet conversion.
-    ///
-    /// Typically: uint32_t to Triplet assignment. It is very convenient
-    /// to be able to simply write Triplet<uint32_t> x = 7;
-    ///
-    /// @param other A number to be assigned as min, max and default value.
-    Triplet<T>& operator=(T other) {
-        min_ = other;
-        util::Optional<T>::default_ = other;
-        max_ = other;
-        // The value is now specified because we just assigned one.
-        util::Optional<T>::unspecified_ = false;
-        return (*this);
-    }
-
-    /// @brief Constructor without parameters.
-    ///
-    /// Marks value in @c Triplet unspecified.
-    Triplet()
-        : util::Optional<T>(), min_(0), max_(0) {
-    }
-
-    /// @brief Sets a fixed value.
-    ///
-    /// This constructor assigns a fixed (i.e. no range, just a single value)
-    /// value.
-    ///
-    /// @param value A number to be assigned as min, max and default value.
-    Triplet(T value)
-        : util::Optional<T>(value), min_(value), max_(value) {
-    }
-
-    /// @brief Sets the default value and thresholds
-    ///
-    /// @throw BadValue if min <= def <= max rule is violated
-    Triplet(T min, T def, T max)
-        : util::Optional<T>(def), min_(min), max_(max) {
-        if ( (min_ > def) || (def > max_) ) {
-            isc_throw(BadValue, "Invalid triplet values.");
-        }
-    }
-
-    /// @brief Returns a minimum allowed value
-    T getMin() const { return (min_);}
-
-    /// @brief Returns value with a hint
-    ///
-    /// DHCP protocol treats any values sent by a client as hints.
-    /// This is a method that implements that. We can assign any value
-    /// from configured range that client asks.
-    ///
-    /// @param hint A value being returned when if it is within the range
-    /// between min and max value of @c Triplet. If the hint value is lower
-    /// than min value, the min value is returned. if the hint is greater
-    /// than max value, the max value is returned.
-    ///
-    /// @return A value adjusted to the hint.
-    T get(T hint) const {
-        if (hint <= min_) {
-            return (min_);
-        }
-
-        if (hint >= max_) {
-            return (max_);
-        }
-
-        return (hint);
-    }
-
-    /// @brief Returns a maximum allowed value
-    T getMax() const { return (max_); }
-
-private:
-
-    /// @brief the minimum value
-    T min_;
-
-    /// @brief the maximum value
-    T max_;
-};
-
-
-} // namespace isc::dhcp
-} // namespace isc
-
-#endif // TRIPLET_H
index e596b0249c50825d30e5f04d9a4355f2cd1b1cc7..a86cf0e82e83c4a160f2af17628c1ea06cb58880 100644 (file)
@@ -30,6 +30,7 @@ libkea_util_la_SOURCES += stopwatch_impl.cc stopwatch_impl.h
 libkea_util_la_SOURCES += strutil.h strutil.cc
 libkea_util_la_SOURCES += thread_pool.h
 libkea_util_la_SOURCES += time_utilities.h time_utilities.cc
+libkea_util_la_SOURCES += triplet.h
 libkea_util_la_SOURCES += unlock_guard.h
 libkea_util_la_SOURCES += versioned_csv_file.h versioned_csv_file.cc
 libkea_util_la_SOURCES += watch_socket.cc watch_socket.h
@@ -76,6 +77,7 @@ libkea_util_include_HEADERS = \
        strutil.h \
        thread_pool.h \
        time_utilities.h \
+       triplet.h \
        unlock_guard.h \
        versioned_csv_file.h \
        watch_socket.h \