]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#489,!250] Extended MySQL backend to store floating values in shared nets.
authorMarcin Siodelski <marcin@isc.org>
Fri, 1 Mar 2019 14:28:39 +0000 (15:28 +0100)
committerMarcin Siodelski <marcin@isc.org>
Fri, 1 Mar 2019 14:28:39 +0000 (15:28 +0100)
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc

index 5a2b4d0070408458caff75d3912b7a00f1ca2cdb..372ab9f30c3a5963e40a07bb30a041c61d7ab009 100644 (file)
@@ -1001,7 +1001,10 @@ public:
             MySqlBinding::createString(USER_CONTEXT_BUF_LENGTH), // option: user_context
             MySqlBinding::createString(SHARED_NETWORK_NAME_BUF_LENGTH), // option: shared_network_name
             MySqlBinding::createInteger<uint64_t>(), // option: pool_id
-            MySqlBinding::createTimestamp() //option: modification_ts
+            MySqlBinding::createTimestamp(), //option: modification_ts
+            MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
+            MySqlBinding::createInteger<float>(), // t1_percent
+            MySqlBinding::createInteger<float>() // t2_percent
         };
 
         uint64_t last_network_id = 0;
@@ -1100,6 +1103,21 @@ public:
                     last_network->setValid(createTriplet(out_bindings[12]));
                 }
 
+                // calculate_tee_times
+                if (!out_bindings[25]->amNull()) {
+                    last_network->setCalculateTeeTimes(out_bindings[25]->getBool());
+                }
+
+                // t1_percent
+                if (!out_bindings[26]->amNull()) {
+                    last_network->setT1Percent(out_bindings[26]->getFloat());
+                }
+
+                // t2_percent
+                if (!out_bindings[27]->amNull()) {
+                    last_network->setT2Percent(out_bindings[27]->getFloat());
+                }
+
                 shared_networks.push_back(last_network);
             }
 
@@ -1220,7 +1238,10 @@ public:
             createInputRequiredClassesBinding(shared_network),
             hr_mode_binding,
             createInputContextBinding(shared_network),
-            createBinding(shared_network->getValid())
+            createBinding(shared_network->getValid()),
+            MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes()),
+            MySqlBinding::condCreateFloat(shared_network->getT1Percent()),
+            MySqlBinding::condCreateFloat(shared_network->getT2Percent())
         };
 
         MySqlTransaction transaction(conn_);
@@ -2068,8 +2089,11 @@ TaggedStatementArray tagged_statements = { {
       "  require_client_classes,"
       "  reservation_mode,"
       "  user_context,"
-      "  valid_lifetime"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
+      "  valid_lifetime,"
+      "  calculate_tee_times,"
+      "  t1_percent,"
+      "  t2_percent"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the shared network with a server.
     { MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4_SERVER,
@@ -2143,7 +2167,10 @@ TaggedStatementArray tagged_statements = { {
       "  require_client_classes = ?,"
       "  reservation_mode = ?,"
       "  user_context = ?,"
-      "  valid_lifetime = ? "
+      "  valid_lifetime = ?,"
+      "  calculate_tee_times = ?,"
+      "  t1_percent = ?,"
+      "  t2_percent = ? "
       "WHERE name = ?" },
 
     // Update existing option definition.
index f3c0a3a4962704df11aaa67bebe6fbeada2943c9..e7a0c4dd3339799176586dd1731fc885215fc68a 100644 (file)
@@ -223,7 +223,10 @@ namespace {
     "  o.user_context," \
     "  o.shared_network_name," \
     "  o.pool_id," \
-    "  o.modification_ts " \
+    "  o.modification_ts," \
+    "  n.calculate_tee_times," \
+    "  n.t1_percent," \
+    "  n.t2_percent " \
     "FROM dhcp4_shared_network AS n " \
     "INNER JOIN dhcp4_shared_network_server AS a " \
     "  ON n.id = a.shared_network_id " \
index 01703835ccab7b73754d6d6d426f92f3d0b6db0a..c997cbe07edf896cf14cf4157715103cf6169ca9 100644 (file)
@@ -185,6 +185,9 @@ public:
         shared_network->setHostReservationMode(Subnet4::HR_DISABLED);
         shared_network->setContext(user_context);
         shared_network->setValid(5555);
+        shared_network->setCalculateTeeTimes(true);
+        shared_network->setT1Percent(0.345);
+        shared_network->setT2Percent(0.444);
 
         // Add several options to the shared network.
         shared_network->getCfgOption()->add(test_options_[2]->option_,