From: Marcin Siodelski Date: Fri, 1 Mar 2019 14:28:39 +0000 (+0100) Subject: [#489,!250] Extended MySQL backend to store floating values in shared nets. X-Git-Tag: 430-configure-location-of-datadir_base~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bf8628eb0e50a4db77533f720e4b94f88f1aa50;p=thirdparty%2Fkea.git [#489,!250] Extended MySQL backend to store floating values in shared nets. --- diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index 5a2b4d0070..372ab9f30c 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -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(), // option: pool_id - MySqlBinding::createTimestamp() //option: modification_ts + MySqlBinding::createTimestamp(), //option: modification_ts + MySqlBinding::createInteger(), // calculate_tee_times + MySqlBinding::createInteger(), // t1_percent + MySqlBinding::createInteger() // 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. diff --git a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h index f3c0a3a496..e7a0c4dd33 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h +++ b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h @@ -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 " \ diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index 01703835cc..c997cbe07e 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -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_,