#ifdef HAVE_CQL
tmp << CqlLeaseMgr::getDBVersion() << endl;
#endif
- tmp << Memfile_LeaseMgr::getDBVersion();
+ tmp << Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V4);
// @todo: more details about database runtime
}
#ifdef HAVE_CQL
tmp << CqlLeaseMgr::getDBVersion() << endl;
#endif
- tmp << Memfile_LeaseMgr::getDBVersion();
+ tmp << Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V6);
// @todo: more details about database runtime
}
version_stream << VERSION;
if (extended) {
- version_stream << std::endl << EXTENDED_VERSION << std::endl
- << "database: " << isc::dhcp::Memfile_LeaseMgr::getDBVersion();
+ std::string db_version;
+ if (protocol_version_ == 4) {
+ db_version = Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V4);
+ } else if (protocol_version_ == 6) {
+ db_version = Memfile_LeaseMgr::getDBVersion(Memfile_LeaseMgr::V6);
+ }
+ if (!db_version.empty()) {
+ db_version = "database: " + db_version;
+ }
+ version_stream << std::endl
+ << EXTENDED_VERSION << std::endl
+ << db_version;
}
return (version_stream.str());
// Explicit definition of class static constants. Values are given in the
// declaration so they're not needed here.
-const int Memfile_LeaseMgr::MAJOR_VERSION;
-const int Memfile_LeaseMgr::MINOR_VERSION;
+const int Memfile_LeaseMgr::MAJOR_VERSION_V4;
+const int Memfile_LeaseMgr::MINOR_VERSION_V4;
+const int Memfile_LeaseMgr::MAJOR_VERSION_V6;
+const int Memfile_LeaseMgr::MINOR_VERSION_V6;
Memfile_LeaseMgr::Memfile_LeaseMgr(const DatabaseConnection::ParameterMap& parameters)
: LeaseMgr(), lfc_setup_(), conn_(parameters), mutex_(new std::mutex) {
LOG_WARN(dhcpsrv_logger, DHCPSRV_MEMFILE_NO_STORAGE);
} else {
if (conversion_needed) {
+ auto const& version(getVersion());
LOG_WARN(dhcpsrv_logger, DHCPSRV_MEMFILE_CONVERTING_LEASE_FILES)
- .arg(MAJOR_VERSION).arg(MINOR_VERSION);
+ .arg(version.first).arg(version.second);
}
lfcSetup(conversion_needed);
}
}
std::string
-Memfile_LeaseMgr::getDBVersion() {
+Memfile_LeaseMgr::getDBVersion(Universe const& u) {
std::stringstream tmp;
- tmp << "Memfile backend " << MAJOR_VERSION;
- tmp << "." << MINOR_VERSION;
- return (tmp.str());
+ tmp << "Memfile backend ";
+ if (u == V4) {
+ tmp << MAJOR_VERSION_V4 << "." << MINOR_VERSION_V4;
+ } else if (u == V6) {
+ tmp << MAJOR_VERSION_V6 << "." << MINOR_VERSION_V6;
+ }
+ return tmp.str();
}
bool
return (std::string("In memory database with leases stored in a CSV file."));
}
+std::pair<uint32_t, uint32_t>
+Memfile_LeaseMgr::getVersion() const {
+ std::string const& universe(conn_.getParameter("universe"));
+ if (universe == "4") {
+ return std::make_pair(MAJOR_VERSION_V4, MINOR_VERSION_V4);
+ } else if (universe == "6") {
+ return std::make_pair(MAJOR_VERSION_V6, MINOR_VERSION_V6);
+ }
+ isc_throw(BadValue, "cannot determine version for universe " << universe);
+}
+
void
Memfile_LeaseMgr::commit() {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_COMMIT);
class Memfile_LeaseMgr : public LeaseMgr {
public:
- /// @defgroup versions Specified memfile backend version.
- ///
- /// @brief Defines major version of the memfile backend.
+ /// @defgroup v4 memfile backend versions
///
/// Version history:
/// 1.0 - initial version (released in Kea 0.9)
- /// 2.0 - hwaddr column added (to be released in Kea 0.9.1)
- /// 2.1 - user context column add (to be released in Kea 1.5)
+ /// 2.0 - hwaddr column added (released in Kea 0.9.1)
+ /// 2.1 - user context column added (released in Kea 1.4.0)
///
/// @{
- static const int MAJOR_VERSION = 2;
+ /// @brief the major version of the v4 memfile backend
+ static const int MAJOR_VERSION_V4 = 2;
- /// Defines minor version of the memfile backend.
- static const int MINOR_VERSION = 1;
+ /// @brief the minor version of the v4 memfile backend
+ static const int MINOR_VERSION_V4 = 1;
+ /// @}
+ /// @defgroup v6 memfile backend versions
+ ///
+ /// Version history:
+ /// 1.0 - initial version (released in Kea 0.9)
+ /// 2.0 - hwaddr column added (released in Kea 0.9.1)
+ /// 3.0 - state column added (released in Kea 0.9.2)
+ /// 3.1 - user context column added (released in Kea 1.4.0)
+ /// 4.0 - hwtype,hwaddr_source columns added (released in Kea 2.1.2)
+ ///
+ /// @{
+ /// @brief the major version of the v6 memfile backend
+ static const int MAJOR_VERSION_V6 = 4;
+
+ /// @brief the minor version of the v6 memfile backend
+ static const int MINOR_VERSION_V6 = 0;
/// @}
virtual ~Memfile_LeaseMgr();
/// @brief Local version of getDBVersion() class method
- static std::string getDBVersion();
+ static std::string getDBVersion(Universe const& u);
/// @brief Adds an IPv4 lease.
///
///
/// @return Version number as a pair of unsigned integers. "first" is the
/// major version number, "second" the minor number.
- virtual std::pair<uint32_t, uint32_t> getVersion() const {
- return (std::make_pair(MAJOR_VERSION, MINOR_VERSION));
- }
+ virtual std::pair<uint32_t, uint32_t> getVersion() const;
/// @brief Commit Transactions
///