]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[94-cb-implement-mysqlconfigbackenddhcpv6-prepare] Address last comment
authorFrancis Dupont <fdupont@isc.org>
Fri, 22 Feb 2019 13:25:01 +0000 (14:25 +0100)
committerFrancis Dupont <fdupont@isc.org>
Fri, 22 Feb 2019 22:59:26 +0000 (17:59 -0500)
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc
src/hooks/dhcp/mysql_cb/mysql_cb_impl.h

index 2278f98a2b1895cef6ac79530ba037607ea42867..7d9db8891a4a27514f324507b80d9289a7c2950e 100644 (file)
@@ -1426,10 +1426,9 @@ public:
         MySqlTransaction transaction(conn_);
 
         OptionDescriptorPtr existing_option =
-            getOption(GET_OPTION4_POOL_ID_CODE_SPACE, Option::V4,
-                      server_selector, pool_id,
-                      option->option_->getType(),
-                      option->space_name_);
+            getOption(GET_OPTION4_POOL_ID_CODE_SPACE,
+                      server_selector, Lease::TYPE_V4, pool_id,
+                      option->option_->getType(), option->space_name_);
 
         // Create scoped audit revision. As long as this instance exists
         // no new audit revisions are created in any subsequent calls.
index a66ae53ceaf01fa8e91fa91aaa4296d789f099a6..d06611f90c758216e92c3d23e0ec5c439f99e741 100644 (file)
@@ -462,8 +462,8 @@ MySqlConfigBackendImpl::getOption(const int index,
 
 OptionDescriptorPtr
 MySqlConfigBackendImpl::getOption(const int index,
-                                  const Option::Universe& universe,
                                   const ServerSelector& server_selector,
+                                  const Lease::Type pool_type,
                                   const uint64_t pool_id,
                                   const uint16_t code,
                                   const std::string& space) {
@@ -473,16 +473,25 @@ MySqlConfigBackendImpl::getOption(const int index,
                   " (unassigned) is unsupported at the moment");
     }
 
-    auto tag = getServerTag(server_selector, "fetching [pd] pool level option");
+    std::string msg = "fetching ";
+    if (pool_type == Lease::TYPE_PD) {
+        msg += "prefix delegation";
+    } else {
+        msg += "address";
+    }
+    msg += " pool level option";
+    auto tag = getServerTag(server_selector, msg);
 
+    Option::Universe universe = Option::V4;
     OptionContainer options;
     MySqlBindingCollection in_bindings;
     in_bindings.push_back(MySqlBinding::createString(tag));
     in_bindings.push_back(MySqlBinding::createInteger<uint64_t>(pool_id));
-    if (universe == Option::V4) {
+    if (pool_type == Lease::TYPE_V4) {
         in_bindings.push_back(MySqlBinding::createInteger<uint8_t>(static_cast<uint8_t>(code)));
     } else {
         in_bindings.push_back(MySqlBinding::createInteger<uint16_t>(code));
+        universe =Option::V6;
     }
     in_bindings.push_back(MySqlBinding::createString(space));
     getOptions(index, in_bindings, universe, options);
index af76295017da419682322b9d55924f943920ad66..a3ca2f75dac9a5f2900612f15731c460c481a404 100644 (file)
@@ -14,6 +14,7 @@
 #include <dhcp/option.h>
 #include <dhcp/option_definition.h>
 #include <dhcpsrv/cfg_option.h>
+#include <dhcpsrv/lease.h>
 #include <dhcpsrv/network.h>
 #include <dhcpsrv/subnet_id.h>
 #include <exceptions/exceptions.h>
@@ -426,8 +427,8 @@ public:
     /// for a given address or prefix delegation (v6) pool id.
     ///
     /// @param index Index of the query to be used.
-    /// @param universe Option universe, i.e. V4 or V6.
     /// @param server_selector Server selector.
+    /// @param pool_type Pool type (Lease::TYPE_V4, TYPE_NA or TYPE_PD).
     /// @param pool_id Pool identifier in the database.
     /// @param code Option code.
     /// @param space Option space name.
@@ -435,8 +436,8 @@ public:
     /// @return Pointer to the returned option descriptor or NULL if such
     /// option doesn't exist.
     OptionDescriptorPtr getOption(const int index,
-                                  const Option::Universe& universe,
                                   const db::ServerSelector& server_selector,
+                                  const dhcp::Lease::Type pool_type,
                                   const uint64_t pool_id,
                                   const uint16_t code,
                                   const std::string& space);