summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dhcpsrv')
-rw-r--r--src/lib/dhcpsrv/Makefile.am7
-rw-r--r--src/lib/dhcpsrv/host_data_source_factory.cc6
-rw-r--r--src/lib/dhcpsrv/host_data_source_factory.h6
-rw-r--r--src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc15
4 files changed, 33 insertions, 1 deletions
diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am
index 444bebffc3..d14933e4f0 100644
--- a/src/lib/dhcpsrv/Makefile.am
+++ b/src/lib/dhcpsrv/Makefile.am
@@ -221,7 +221,7 @@ libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la
libkea_dhcpsrv_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
libkea_dhcpsrv_la_LIBADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) $(BOOST_LIBS)
-libkea_dhcpsrv_la_LDFLAGS = -no-undefined -version-info 8:0:0
+libkea_dhcpsrv_la_LDFLAGS = -no-undefined -version-info 9:0:0
libkea_dhcpsrv_la_LDFLAGS += $(CRYPTO_LDFLAGS)
if HAVE_MYSQL
libkea_dhcpsrv_la_LDFLAGS += $(MYSQL_LIBS)
@@ -276,8 +276,10 @@ libkea_dhcpsrv_include_HEADERS = \
daemon.h \
database_connection.h \
db_exceptions.h \
+ db_log.h \
db_type.h \
dhcp4o6_ipc.h \
+ dhcpsrv_db_log.h \
dhcpsrv_log.h \
host.h \
host_container.h \
@@ -296,6 +298,7 @@ libkea_dhcpsrv_include_HEADERS = \
memfile_lease_storage.h \
ncr_generator.h \
network.h \
+ network_state.h \
pool.h \
shared_network.h \
sql_common.h \
@@ -311,6 +314,8 @@ libkea_dhcpsrv_include_HEADERS = \
if HAVE_CQL
libkea_dhcpsrv_include_HEADERS += \
cql_connection.h \
+ cql_exchange.h \
+ cql_host_data_source.h \
cql_lease_mgr.h
endif
diff --git a/src/lib/dhcpsrv/host_data_source_factory.cc b/src/lib/dhcpsrv/host_data_source_factory.cc
index ec5cac31fd..76b8cd595e 100644
--- a/src/lib/dhcpsrv/host_data_source_factory.cc
+++ b/src/lib/dhcpsrv/host_data_source_factory.cc
@@ -126,6 +126,12 @@ HostDataSourceFactory::deregisterFactory(const string& db_type, bool no_log) {
}
}
+bool
+HostDataSourceFactory::registeredFactory(const std::string& db_type) {
+ auto index = map_.find(db_type);
+ return (index != map_.end());
+}
+
void
HostDataSourceFactory::printRegistered() {
std::stringstream txt;
diff --git a/src/lib/dhcpsrv/host_data_source_factory.h b/src/lib/dhcpsrv/host_data_source_factory.h
index b28f291d0b..20f5fe7a57 100644
--- a/src/lib/dhcpsrv/host_data_source_factory.h
+++ b/src/lib/dhcpsrv/host_data_source_factory.h
@@ -107,6 +107,12 @@ public:
static bool deregisterFactory(const std::string& db_type,
bool no_log = false);
+ /// @brief Check if a host data source factory was registered
+ ///
+ /// @param db_type database type
+ /// @return true if a factory was registered for db_type, false if not.
+ static bool registeredFactory(const std::string& db_type);
+
/// @brief Prints out all registered backends.
///
/// We need a dedicated method for this, because we sometimes can't log
diff --git a/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc b/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc
index 3d8f7a2711..596b908a8e 100644
--- a/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc
+++ b/src/lib/dhcpsrv/tests/host_data_source_factory_unittest.cc
@@ -96,6 +96,20 @@ TEST_F(HostDataSourceFactoryTest, registerFactory) {
EXPECT_FALSE(registerFactory());
}
+// Verify a factory registration can be checked.
+TEST_F(HostDataSourceFactoryTest, registeredFactory) {
+ // Not yet registered
+ EXPECT_FALSE(HostDataSourceFactory::registeredFactory("mem"));
+ EXPECT_FALSE(HostDataSourceFactory::registeredFactory("mem1"));
+
+ // Register mem
+ EXPECT_TRUE(registerFactory());
+
+ // Now mem is registered but not mem1
+ EXPECT_TRUE(HostDataSourceFactory::registeredFactory("mem"));
+ EXPECT_FALSE(HostDataSourceFactory::registeredFactory("mem1"));
+}
+
// Verify a factory can be registered and deregistered
TEST_F(HostDataSourceFactoryTest, deregisterFactory) {
// Does not exist at the beginning
@@ -104,6 +118,7 @@ TEST_F(HostDataSourceFactoryTest, deregisterFactory) {
// Register and deregister
EXPECT_TRUE(registerFactory());
EXPECT_TRUE(HostDataSourceFactory::deregisterFactory("mem"));
+ EXPECT_FALSE(HostDataSourceFactory::registeredFactory("mem"));
// No longer exists
EXPECT_FALSE(HostDataSourceFactory::deregisterFactory("mem"));