mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 13:07:50 +00:00
[#3017] added testing framework for using dummy test interfaces
This commit is contained in:
parent
530e4ef280
commit
34e98d10f6
@ -1606,6 +1606,7 @@ AC_CONFIG_FILES([src/lib/database/Makefile])
|
|||||||
AC_CONFIG_FILES([src/lib/database/tests/Makefile])
|
AC_CONFIG_FILES([src/lib/database/tests/Makefile])
|
||||||
AC_CONFIG_FILES([src/lib/database/testutils/Makefile])
|
AC_CONFIG_FILES([src/lib/database/testutils/Makefile])
|
||||||
AC_CONFIG_FILES([src/lib/dhcp/Makefile])
|
AC_CONFIG_FILES([src/lib/dhcp/Makefile])
|
||||||
|
AC_CONFIG_FILES([src/lib/dhcp/testutils/Makefile])
|
||||||
AC_CONFIG_FILES([src/lib/dhcp/tests/Makefile])
|
AC_CONFIG_FILES([src/lib/dhcp/tests/Makefile])
|
||||||
AC_CONFIG_FILES([src/lib/dhcp_ddns/Makefile])
|
AC_CONFIG_FILES([src/lib/dhcp_ddns/Makefile])
|
||||||
AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile])
|
AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile])
|
||||||
|
@ -120,7 +120,7 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
|
|||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/testutils/libdhcptest.la
|
||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
||||||
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <stats/stats_mgr.h>
|
#include <stats/stats_mgr.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <database/backend_selector.h>
|
#include <database/backend_selector.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/dhcp4_srv.h>
|
#include <dhcp4/dhcp4_srv.h>
|
||||||
#include <dhcp4/ctrl_dhcp4_srv.h>
|
#include <dhcp4/ctrl_dhcp4_srv.h>
|
||||||
#include <dhcp4/json_config_parser.h>
|
#include <dhcp4/json_config_parser.h>
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/classify.h>
|
#include <dhcp/classify.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/subnet.h>
|
#include <dhcpsrv/subnet.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/cfg_expiration.h>
|
#include <dhcpsrv/cfg_expiration.h>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <config/timeouts.h>
|
#include <config/timeouts.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/libdhcp++.h>
|
#include <dhcp/libdhcp++.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
@ -103,13 +103,16 @@ public:
|
|||||||
/// @brief Path to the UNIX socket being used to communicate with the server
|
/// @brief Path to the UNIX socket being used to communicate with the server
|
||||||
std::string socket_path_;
|
std::string socket_path_;
|
||||||
|
|
||||||
|
/// @brief List of interfaces (defaults to "*").
|
||||||
|
std::string interfaces_;
|
||||||
|
|
||||||
/// @brief Pointer to the tested server object
|
/// @brief Pointer to the tested server object
|
||||||
boost::shared_ptr<NakedControlledDhcpv4Srv> server_;
|
boost::shared_ptr<NakedControlledDhcpv4Srv> server_;
|
||||||
|
|
||||||
/// @brief Default constructor
|
/// @brief Default constructor
|
||||||
///
|
///
|
||||||
/// Sets socket path to its default value.
|
/// Sets socket path to its default value.
|
||||||
CtrlChannelDhcpv4SrvTest() {
|
CtrlChannelDhcpv4SrvTest() : interfaces_("\"*\"") {
|
||||||
const char* env = getenv("KEA_SOCKET_TEST_DIR");
|
const char* env = getenv("KEA_SOCKET_TEST_DIR");
|
||||||
if (env) {
|
if (env) {
|
||||||
socket_path_ = string(env) + "/kea4.sock";
|
socket_path_ = string(env) + "/kea4.sock";
|
||||||
@ -117,6 +120,8 @@ public:
|
|||||||
socket_path_ = sandbox.join("kea4.sock");
|
socket_path_ = sandbox.join("kea4.sock");
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
|
IfaceMgr::instance().setTestMode(false);
|
||||||
|
IfaceMgr::instance().setDetectCallback(isc::dhcp::IfaceMgr::DetectCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
@ -129,6 +134,11 @@ public:
|
|||||||
CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
|
CommandMgr::instance().setConnectionTimeout(TIMEOUT_DHCP_SERVER_RECEIVE_COMMAND);
|
||||||
|
|
||||||
server_.reset();
|
server_.reset();
|
||||||
|
IfaceMgr::instance().setTestMode(false);
|
||||||
|
IfaceMgr::instance().setDetectCallback(isc::dhcp::IfaceMgr::DetectCallback());
|
||||||
|
IfaceMgr::instance().clearIfaces();
|
||||||
|
IfaceMgr::instance().closeSockets();
|
||||||
|
IfaceMgr::instance().detectIfaces();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Returns pointer to the server's IO service.
|
/// @brief Returns pointer to the server's IO service.
|
||||||
@ -147,7 +157,9 @@ public:
|
|||||||
std::string header =
|
std::string header =
|
||||||
"{"
|
"{"
|
||||||
" \"interfaces-config\": {"
|
" \"interfaces-config\": {"
|
||||||
" \"interfaces\": [ \"*\" ]"
|
" \"interfaces\": [";
|
||||||
|
|
||||||
|
std::string body = "]"
|
||||||
" },"
|
" },"
|
||||||
" \"expired-leases-processing\": {"
|
" \"expired-leases-processing\": {"
|
||||||
" \"reclaim-timer-wait-time\": 60,"
|
" \"reclaim-timer-wait-time\": 60,"
|
||||||
@ -175,8 +187,7 @@ public:
|
|||||||
|
|
||||||
// Fill in the socket-name value with socket_path_ to
|
// Fill in the socket-name value with socket_path_ to
|
||||||
// make the actual configuration text.
|
// make the actual configuration text.
|
||||||
std::string config_txt = header + socket_path_ + footer;
|
std::string config_txt = header + interfaces_ + body + socket_path_ + footer;
|
||||||
|
|
||||||
ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv4Srv()));
|
ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv4Srv()));
|
||||||
|
|
||||||
ConstElementPtr config;
|
ConstElementPtr config;
|
||||||
@ -210,7 +221,6 @@ public:
|
|||||||
ASSERT_GT(isc::config::CommandMgr::instance().getControlSocketFD(), -1);
|
ASSERT_GT(isc::config::CommandMgr::instance().getControlSocketFD(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief Reset hooks data
|
/// @brief Reset hooks data
|
||||||
///
|
///
|
||||||
/// Resets the data for the hooks-related portion of the test by ensuring
|
/// Resets the data for the hooks-related portion of the test by ensuring
|
||||||
@ -817,7 +827,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
|
|||||||
sendUnixCommand(os.str(), response);
|
sendUnixCommand(os.str(), response);
|
||||||
|
|
||||||
// Verify the configuration was successful. The config contains random
|
// Verify the configuration was successful. The config contains random
|
||||||
// socket name (/tmp/kea-<value-changing-each-time>/kea6.sock), so the
|
// socket name (/tmp/kea-<value-changing-each-time>/kea4.sock), so the
|
||||||
// hash will be different each time. As such, we can do simplified checks:
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
// - verify the "result": 0 is there
|
// - verify the "result": 0 is there
|
||||||
// - verify the "text": "Configuration successful." is there
|
// - verify the "text": "Configuration successful." is there
|
||||||
@ -885,7 +895,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configSet) {
|
|||||||
EXPECT_FALSE(fileExists(socket_path_));
|
EXPECT_FALSE(fileExists(socket_path_));
|
||||||
|
|
||||||
// With no command channel, should still receive the response. The config contains random
|
// With no command channel, should still receive the response. The config contains random
|
||||||
// socket name (/tmp/kea-<value-changing-each-time>/kea6.sock), so the
|
// socket name (/tmp/kea-<value-changing-each-time>/kea4.sock), so the
|
||||||
// hash will be different each time. As such, we can do simplified checks:
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
// - verify the "result": 0 is there
|
// - verify the "result": 0 is there
|
||||||
// - verify the "text": "Configuration successful." is there
|
// - verify the "text": "Configuration successful." is there
|
||||||
@ -1030,7 +1040,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configTest) {
|
|||||||
sendUnixCommand(os.str(), response);
|
sendUnixCommand(os.str(), response);
|
||||||
|
|
||||||
// Verify the configuration was successful. The config contains random
|
// Verify the configuration was successful. The config contains random
|
||||||
// socket name (/tmp/kea-<value-changing-each-time>/kea6.sock), so the
|
// socket name (/tmp/kea-<value-changing-each-time>/kea4.sock), so the
|
||||||
// hash will be different each time. As such, we can do simplified checks:
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
// - verify the "result": 0 is there
|
// - verify the "result": 0 is there
|
||||||
// - verify the "text": "Configuration successful." is there
|
// - verify the "text": "Configuration successful." is there
|
||||||
@ -1508,6 +1518,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configWriteFilename) {
|
|||||||
|
|
||||||
sendUnixCommand("{ \"command\": \"config-write\", "
|
sendUnixCommand("{ \"command\": \"config-write\", "
|
||||||
"\"arguments\": { \"filename\": \"test2.json\" } }", response);
|
"\"arguments\": { \"filename\": \"test2.json\" } }", response);
|
||||||
|
|
||||||
checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
|
checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
|
||||||
::remove("test2.json");
|
::remove("test2.json");
|
||||||
}
|
}
|
||||||
@ -1591,8 +1602,83 @@ TEST_F(CtrlChannelDhcpv4SrvTest, configReloadValid) {
|
|||||||
|
|
||||||
// This command should reload test8.json config.
|
// This command should reload test8.json config.
|
||||||
sendUnixCommand("{ \"command\": \"config-reload\" }", response);
|
sendUnixCommand("{ \"command\": \"config-reload\" }", response);
|
||||||
|
|
||||||
// Verify the configuration was successful. The config contains random
|
// Verify the configuration was successful. The config contains random
|
||||||
// socket name (/tmp/kea-<value-changing-each-time>/kea6.sock), so the
|
// socket name (/tmp/kea-<value-changing-each-time>/kea4.sock), so the
|
||||||
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
|
// - verify the "result": 0 is there
|
||||||
|
// - verify the "text": "Configuration successful." is there
|
||||||
|
EXPECT_NE(response.find("\"result\": 0"), std::string::npos);
|
||||||
|
EXPECT_NE(response.find("\"text\": \"Configuration successful.\""), std::string::npos);
|
||||||
|
|
||||||
|
// Check that the config was indeed applied.
|
||||||
|
const Subnet4Collection* subnets =
|
||||||
|
CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
|
||||||
|
EXPECT_EQ(2, subnets->size());
|
||||||
|
|
||||||
|
::remove("test8.json");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests if config-reload attempts to reload a file and reports that the
|
||||||
|
// file is loaded correctly.
|
||||||
|
TEST_F(CtrlChannelDhcpv4SrvTest, configReloadDetectInterfaces) {
|
||||||
|
interfaces_ = "\"eth0\"";
|
||||||
|
IfacePtr eth0 = IfaceMgrTestConfig::createIface("eth0", 0);
|
||||||
|
auto detectIfaces = [&](bool update_only) {
|
||||||
|
if (!update_only) {
|
||||||
|
eth0->addAddress(IOAddress("10.0.0.1"));
|
||||||
|
eth0->addAddress(IOAddress("fe80::3a60:77ff:fed5:cdef"));
|
||||||
|
eth0->addAddress(IOAddress("2001:db8:1::1"));
|
||||||
|
IfaceMgr::instance().addInterface(eth0);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
};
|
||||||
|
IfaceMgr::instance().setDetectCallback(detectIfaces);
|
||||||
|
IfaceMgr::instance().clearIfaces();
|
||||||
|
IfaceMgr::instance().closeSockets();
|
||||||
|
IfaceMgr::instance().detectIfaces();
|
||||||
|
createUnixChannelServer();
|
||||||
|
std::string response;
|
||||||
|
|
||||||
|
// This is normally set to whatever value is passed to -c when the server is
|
||||||
|
// started, but we're not starting it that way, so need to set it by hand.
|
||||||
|
server_->setConfigFile("test8.json");
|
||||||
|
|
||||||
|
// Ok, enough fooling around. Let's create a valid config.
|
||||||
|
const std::string cfg_txt =
|
||||||
|
"{ \"Dhcp4\": {"
|
||||||
|
" \"interfaces-config\": {"
|
||||||
|
" \"interfaces\": [ \"eth1\" ]"
|
||||||
|
" },"
|
||||||
|
" \"subnet4\": ["
|
||||||
|
" { \"id\": 1, \"subnet\": \"192.0.2.0/24\" },"
|
||||||
|
" { \"id\": 2, \"subnet\": \"192.0.3.0/24\" }"
|
||||||
|
" ],"
|
||||||
|
" \"valid-lifetime\": 4000,"
|
||||||
|
" \"lease-database\": {"
|
||||||
|
" \"type\": \"memfile\", \"persist\": false }"
|
||||||
|
"} }";
|
||||||
|
ofstream f("test8.json", ios::trunc);
|
||||||
|
f << cfg_txt;
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
IfacePtr eth1 = IfaceMgrTestConfig::createIface("eth1", 1);
|
||||||
|
auto detectUpdateIfaces = [&](bool update_only) {
|
||||||
|
if (!update_only) {
|
||||||
|
eth1->addAddress(IOAddress("192.0.2.3"));
|
||||||
|
eth1->addAddress(IOAddress("fe80::3a60:77ff:fed5:abcd"));
|
||||||
|
eth1->addAddress(IOAddress("3001:db8:100::1"));
|
||||||
|
IfaceMgr::instance().addInterface(eth1);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
};
|
||||||
|
IfaceMgr::instance().setDetectCallback(detectUpdateIfaces);
|
||||||
|
|
||||||
|
// This command should reload test8.json config.
|
||||||
|
sendUnixCommand("{ \"command\": \"config-reload\" }", response);
|
||||||
|
|
||||||
|
// Verify the configuration was successful. The config contains random
|
||||||
|
// socket name (/tmp/kea-<value-changing-each-time>/kea4.sock), so the
|
||||||
// hash will be different each time. As such, we can do simplified checks:
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
// - verify the "result": 0 is there
|
// - verify the "result": 0 is there
|
||||||
// - verify the "text": "Configuration successful." is there
|
// - verify the "text": "Configuration successful." is there
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/subnet_id.h>
|
#include <dhcpsrv/subnet_id.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <util/multi_threading_mgr.h>
|
#include <util/multi_threading_mgr.h>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <dhcp4/json_config_parser.h>
|
#include <dhcp4/json_config_parser.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/libdhcp++.h>
|
#include <dhcp/libdhcp++.h>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/pkt_filter.h>
|
#include <dhcp/pkt_filter.h>
|
||||||
#include <dhcp/pkt_filter_inet.h>
|
#include <dhcp/pkt_filter_inet.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr.h>
|
#include <dhcpsrv/lease_mgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/option_custom.h>
|
#include <dhcp/option_custom.h>
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcpsrv/cfg_db_access.h>
|
#include <dhcpsrv/cfg_db_access.h>
|
||||||
#include <dhcpsrv/cfg_multi_threading.h>
|
#include <dhcpsrv/cfg_multi_threading.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <dhcp/pkt4o6.h>
|
#include <dhcp/pkt4o6.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/ctrl_dhcp4_srv.h>
|
#include <dhcp4/ctrl_dhcp4_srv.h>
|
||||||
#include <dhcp4/dhcp4to6_ipc.h>
|
#include <dhcp4/dhcp4to6_ipc.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/pkt4.h>
|
#include <dhcp/pkt4.h>
|
||||||
#include <dhcp/classify.h>
|
#include <dhcp/classify.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/cfg_subnets4.h>
|
#include <dhcpsrv/cfg_subnets4.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/host.h>
|
#include <dhcpsrv/host.h>
|
||||||
#include <dhcpsrv/host_mgr.h>
|
#include <dhcpsrv/host_mgr.h>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <dhcp/option4_client_fqdn.h>
|
#include <dhcp/option4_client_fqdn.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
#include <dhcp_ddns/ncr_msg.h>
|
#include <dhcp_ddns/ncr_msg.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <cc/simple_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <cc/cfg_to_element.h>
|
#include <cc/cfg_to_element.h>
|
||||||
#include <testutils/user_context_utils.h>
|
#include <testutils/user_context_utils.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/parsers/simple_parser4.h>
|
#include <dhcpsrv/parsers/simple_parser4.h>
|
||||||
#include <dhcp4/dhcp4_srv.h>
|
#include <dhcp4/dhcp4_srv.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <cc/simple_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <cc/cfg_to_element.h>
|
#include <cc/cfg_to_element.h>
|
||||||
#include <testutils/user_context_utils.h>
|
#include <testutils/user_context_utils.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/parsers/simple_parser4.h>
|
#include <dhcpsrv/parsers/simple_parser4.h>
|
||||||
#include <dhcp4/dhcp4_srv.h>
|
#include <dhcp4/dhcp4_srv.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <asiolink/io_service.h>
|
#include <asiolink/io_service.h>
|
||||||
#include <cc/command_interpreter.h>
|
#include <cc/command_interpreter.h>
|
||||||
#include <config/command_mgr.h>
|
#include <config/command_mgr.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcp4/ctrl_dhcp4_srv.h>
|
#include <dhcp4/ctrl_dhcp4_srv.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <stats/stats_mgr.h>
|
#include <stats/stats_mgr.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/host.h>
|
#include <dhcpsrv/host.h>
|
||||||
#include <dhcpsrv/host_mgr.h>
|
#include <dhcpsrv/host_mgr.h>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/libdhcp++.h>
|
#include <dhcp/libdhcp++.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <stats/stats_mgr.h>
|
#include <stats/stats_mgr.h>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp_ddns/ncr_msg.h>
|
#include <dhcp_ddns/ncr_msg.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/subnet_id.h>
|
#include <dhcpsrv/subnet_id.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/subnet_id.h>
|
#include <dhcpsrv/subnet_id.h>
|
||||||
#include <dhcp4/tests/dhcp4_test_utils.h>
|
#include <dhcp4/tests/dhcp4_test_utils.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
|
@ -27,13 +27,13 @@
|
|||||||
#include <dhcp4/dhcp4_srv.h>
|
#include <dhcp4/dhcp4_srv.h>
|
||||||
#include <dhcp4/json_config_parser.h>
|
#include <dhcp4/json_config_parser.h>
|
||||||
#include <dhcp4/tests/dhcp4_client.h>
|
#include <dhcp4/tests/dhcp4_client.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/option_vendor_class.h>
|
#include <dhcp/option_vendor_class.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcpsrv/cfg_multi_threading.h>
|
#include <dhcpsrv/cfg_multi_threading.h>
|
||||||
|
@ -124,7 +124,7 @@ dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la
|
|||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/testutils/libdhcptest.la
|
||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
||||||
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
dhcp6_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@
|
|||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/opaque_data_tuple.h>
|
#include <dhcp/opaque_data_tuple.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option_vendor_class.h>
|
#include <dhcp/option_vendor_class.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <database/backend_selector.h>
|
#include <database/backend_selector.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/dhcp6_srv.h>
|
#include <dhcp6/dhcp6_srv.h>
|
||||||
#include <dhcp6/ctrl_dhcp6_srv.h>
|
#include <dhcp6/ctrl_dhcp6_srv.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <dhcp/option_custom.h>
|
#include <dhcp/option_custom.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/dhcp6_srv.h>
|
#include <dhcp6/dhcp6_srv.h>
|
||||||
#include <dhcp6/ctrl_dhcp6_srv.h>
|
#include <dhcp6/ctrl_dhcp6_srv.h>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_message_test.h>
|
#include <dhcp6/tests/dhcp6_message_test.h>
|
||||||
#include <dhcpsrv/utils.h>
|
#include <dhcpsrv/utils.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <cc/command_interpreter.h>
|
#include <cc/command_interpreter.h>
|
||||||
#include <config/command_mgr.h>
|
#include <config/command_mgr.h>
|
||||||
#include <dhcp/libdhcp++.h>
|
#include <dhcp/libdhcp++.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
@ -114,7 +114,6 @@ public:
|
|||||||
reset();
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// @brief Reset hooks data
|
/// @brief Reset hooks data
|
||||||
///
|
///
|
||||||
/// Resets the data for the hooks-related portion of the test by ensuring
|
/// Resets the data for the hooks-related portion of the test by ensuring
|
||||||
@ -139,13 +138,16 @@ public:
|
|||||||
/// @brief Path to the UNIX socket being used to communicate with the server
|
/// @brief Path to the UNIX socket being used to communicate with the server
|
||||||
std::string socket_path_;
|
std::string socket_path_;
|
||||||
|
|
||||||
|
/// @brief List of interfaces (defaults to "*").
|
||||||
|
std::string interfaces_;
|
||||||
|
|
||||||
/// @brief Pointer to the tested server object
|
/// @brief Pointer to the tested server object
|
||||||
boost::shared_ptr<NakedControlledDhcpv6Srv> server_;
|
boost::shared_ptr<NakedControlledDhcpv6Srv> server_;
|
||||||
|
|
||||||
/// @brief Default constructor
|
/// @brief Default constructor
|
||||||
///
|
///
|
||||||
/// Sets socket path to its default value.
|
/// Sets socket path to its default value.
|
||||||
CtrlChannelDhcpv6SrvTest() {
|
CtrlChannelDhcpv6SrvTest() : interfaces_("\"*\"") {
|
||||||
const char* env = getenv("KEA_SOCKET_TEST_DIR");
|
const char* env = getenv("KEA_SOCKET_TEST_DIR");
|
||||||
if (env) {
|
if (env) {
|
||||||
socket_path_ = string(env) + "/kea6.sock";
|
socket_path_ = string(env) + "/kea6.sock";
|
||||||
@ -153,12 +155,19 @@ public:
|
|||||||
socket_path_ = sandbox.join("/kea6.sock");
|
socket_path_ = sandbox.join("/kea6.sock");
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
|
IfaceMgr::instance().setTestMode(false);
|
||||||
|
IfaceMgr::instance().setDetectCallback(isc::dhcp::IfaceMgr::DetectCallback());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
~CtrlChannelDhcpv6SrvTest() {
|
~CtrlChannelDhcpv6SrvTest() {
|
||||||
server_.reset();
|
server_.reset();
|
||||||
reset();
|
reset();
|
||||||
|
IfaceMgr::instance().setTestMode(false);
|
||||||
|
IfaceMgr::instance().setDetectCallback(isc::dhcp::IfaceMgr::DetectCallback());
|
||||||
|
IfaceMgr::instance().clearIfaces();
|
||||||
|
IfaceMgr::instance().closeSockets();
|
||||||
|
IfaceMgr::instance().detectIfaces();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Returns pointer to the server's IO service.
|
/// @brief Returns pointer to the server's IO service.
|
||||||
@ -177,7 +186,9 @@ public:
|
|||||||
std::string header =
|
std::string header =
|
||||||
"{"
|
"{"
|
||||||
" \"interfaces-config\": {"
|
" \"interfaces-config\": {"
|
||||||
" \"interfaces\": [ \"*\" ]"
|
" \"interfaces\": [";
|
||||||
|
|
||||||
|
std::string body = "]"
|
||||||
" },"
|
" },"
|
||||||
" \"expired-leases-processing\": {"
|
" \"expired-leases-processing\": {"
|
||||||
" \"reclaim-timer-wait-time\": 60,"
|
" \"reclaim-timer-wait-time\": 60,"
|
||||||
@ -205,8 +216,7 @@ public:
|
|||||||
|
|
||||||
// Fill in the socket-name value with socket_path_ to
|
// Fill in the socket-name value with socket_path_ to
|
||||||
// make the actual configuration text.
|
// make the actual configuration text.
|
||||||
std::string config_txt = header + socket_path_ + footer;
|
std::string config_txt = header + interfaces_ + body + socket_path_ + footer;
|
||||||
|
|
||||||
ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv6Srv()));
|
ASSERT_NO_THROW(server_.reset(new NakedControlledDhcpv6Srv()));
|
||||||
|
|
||||||
ConstElementPtr config;
|
ConstElementPtr config;
|
||||||
@ -1541,6 +1551,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configWriteFilename) {
|
|||||||
|
|
||||||
sendUnixCommand("{ \"command\": \"config-write\", "
|
sendUnixCommand("{ \"command\": \"config-write\", "
|
||||||
"\"arguments\": { \"filename\": \"test2.json\" } }", response);
|
"\"arguments\": { \"filename\": \"test2.json\" } }", response);
|
||||||
|
|
||||||
checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
|
checkConfigWrite(response, CONTROL_RESULT_SUCCESS, "test2.json");
|
||||||
::remove("test2.json");
|
::remove("test2.json");
|
||||||
}
|
}
|
||||||
@ -1640,6 +1651,79 @@ TEST_F(CtrlChannelDhcpv6SrvTest, configReloadValid) {
|
|||||||
::remove("test8.json");
|
::remove("test8.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests if config-reload attempts to reload a file and reports that the
|
||||||
|
// file is loaded correctly.
|
||||||
|
TEST_F(CtrlChannelDhcpv6SrvTest, configReloadDetectInterfaces) {
|
||||||
|
interfaces_ = "\"eth0\"";
|
||||||
|
IfacePtr eth0 = IfaceMgrTestConfig::createIface("eth0", 0);
|
||||||
|
auto detectIfaces = [&](bool update_only) {
|
||||||
|
if (!update_only) {
|
||||||
|
eth0->addAddress(IOAddress("10.0.0.1"));
|
||||||
|
eth0->addAddress(IOAddress("fe80::3a60:77ff:fed5:cdef"));
|
||||||
|
eth0->addAddress(IOAddress("2001:db8:1::1"));
|
||||||
|
IfaceMgr::instance().addInterface(eth0);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
};
|
||||||
|
IfaceMgr::instance().setDetectCallback(detectIfaces);
|
||||||
|
IfaceMgr::instance().clearIfaces();
|
||||||
|
IfaceMgr::instance().closeSockets();
|
||||||
|
IfaceMgr::instance().detectIfaces();
|
||||||
|
createUnixChannelServer();
|
||||||
|
std::string response;
|
||||||
|
|
||||||
|
// This is normally set to whatever value is passed to -c when the server is
|
||||||
|
// started, but we're not starting it that way, so need to set it by hand.
|
||||||
|
server_->setConfigFile("test8.json");
|
||||||
|
|
||||||
|
// Ok, enough fooling around. Let's create a valid config.
|
||||||
|
const std::string cfg_txt =
|
||||||
|
"{ \"Dhcp6\": {"
|
||||||
|
" \"interfaces-config\": {"
|
||||||
|
" \"interfaces\": [ \"eth1\" ]"
|
||||||
|
" },"
|
||||||
|
" \"subnet6\": ["
|
||||||
|
" { \"subnet\": \"2001:db8:1::/64\", \"id\": 1 },"
|
||||||
|
" { \"subnet\": \"2001:db8:2::/64\", \"id\": 2 }"
|
||||||
|
" ],"
|
||||||
|
" \"lease-database\": {"
|
||||||
|
" \"type\": \"memfile\", \"persist\": false }"
|
||||||
|
"} }";
|
||||||
|
ofstream f("test8.json", ios::trunc);
|
||||||
|
f << cfg_txt;
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
IfacePtr eth1 = IfaceMgrTestConfig::createIface("eth1", ETH1_INDEX);
|
||||||
|
auto detectUpdateIfaces = [&](bool update_only) {
|
||||||
|
if (!update_only) {
|
||||||
|
eth1->addAddress(IOAddress("192.0.2.3"));
|
||||||
|
eth1->addAddress(IOAddress("fe80::3a60:77ff:fed5:abcd"));
|
||||||
|
eth1->addAddress(IOAddress("3001:db8:100::1"));
|
||||||
|
IfaceMgr::instance().addInterface(eth1);
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
};
|
||||||
|
IfaceMgr::instance().setDetectCallback(detectUpdateIfaces);
|
||||||
|
|
||||||
|
// This command should reload test8.json config.
|
||||||
|
sendUnixCommand("{ \"command\": \"config-reload\" }", response);
|
||||||
|
|
||||||
|
// Verify the configuration was successful. The config contains random
|
||||||
|
// socket name (/tmp/kea-<value-changing-each-time>/kea6.sock), so the
|
||||||
|
// hash will be different each time. As such, we can do simplified checks:
|
||||||
|
// - verify the "result": 0 is there
|
||||||
|
// - verify the "text": "Configuration successful." is there
|
||||||
|
EXPECT_NE(response.find("\"result\": 0"), std::string::npos);
|
||||||
|
EXPECT_NE(response.find("\"text\": \"Configuration successful.\""), std::string::npos);
|
||||||
|
|
||||||
|
// Check that the config was indeed applied.
|
||||||
|
const Subnet6Collection* subnets =
|
||||||
|
CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
|
||||||
|
EXPECT_EQ(2, subnets->size());
|
||||||
|
|
||||||
|
::remove("test8.json");
|
||||||
|
}
|
||||||
|
|
||||||
// This test verifies that disable DHCP service command performs sanity check on
|
// This test verifies that disable DHCP service command performs sanity check on
|
||||||
// parameters.
|
// parameters.
|
||||||
TEST_F(CtrlChannelDhcpv6SrvTest, dhcpDisableBadParam) {
|
TEST_F(CtrlChannelDhcpv6SrvTest, dhcpDisableBadParam) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_message_test.h>
|
#include <dhcp6/tests/dhcp6_message_test.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <dhcp/option6_iaaddr.h>
|
#include <dhcp/option6_iaaddr.h>
|
||||||
#include <dhcp/option6_status_code.h>
|
#include <dhcp/option6_status_code.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
#include <dhcpsrv/pool.h>
|
#include <dhcpsrv/pool.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#define DHCP6_MESSAGE_TEST_H
|
#define DHCP6_MESSAGE_TEST_H
|
||||||
|
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/dhcp6.h>
|
#include <dhcp/dhcp6.h>
|
||||||
#include <dhcp/duid.h>
|
#include <dhcp/duid.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr.h>
|
#include <dhcpsrv/lease_mgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cc/command_interpreter.h>
|
#include <cc/command_interpreter.h>
|
||||||
#include <dhcp/option6_status_code.h>
|
#include <dhcp/option6_status_code.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcpsrv/cfg_multi_threading.h>
|
#include <dhcpsrv/cfg_multi_threading.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <dhcp/option_custom.h>
|
#include <dhcp/option_custom.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr.h>
|
#include <dhcpsrv/lease_mgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_filter6_test_stub.h>
|
#include <dhcp/testutils/pkt_filter6_test_stub.h>
|
||||||
#include <dhcp6/dhcp6to4_ipc.h>
|
#include <dhcp6/dhcp6to4_ipc.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/testutils/dhcp4o6_test_ipc.h>
|
#include <dhcpsrv/testutils/dhcp4o6_test_ipc.h>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <dhcp/option6_iaaddr.h>
|
#include <dhcp/option6_iaaddr.h>
|
||||||
#include <dhcp/option6_status_code.h>
|
#include <dhcp/option6_status_code.h>
|
||||||
#include <dhcp/option_int_array.h>
|
#include <dhcp/option_int_array.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/lease.h>
|
#include <dhcpsrv/lease.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
#include <dhcpsrv/ncr_generator.h>
|
#include <dhcpsrv/ncr_generator.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <cc/simple_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <cc/cfg_to_element.h>
|
#include <cc/cfg_to_element.h>
|
||||||
#include <testutils/user_context_utils.h>
|
#include <testutils/user_context_utils.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/parsers/simple_parser6.h>
|
#include <dhcpsrv/parsers/simple_parser6.h>
|
||||||
#include <dhcp6/dhcp6_srv.h>
|
#include <dhcp6/dhcp6_srv.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <cc/simple_parser.h>
|
#include <cc/simple_parser.h>
|
||||||
#include <cc/cfg_to_element.h>
|
#include <cc/cfg_to_element.h>
|
||||||
#include <testutils/user_context_utils.h>
|
#include <testutils/user_context_utils.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/parsers/simple_parser6.h>
|
#include <dhcpsrv/parsers/simple_parser6.h>
|
||||||
#include <dhcp6/dhcp6_srv.h>
|
#include <dhcp6/dhcp6_srv.h>
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
#include <config/command_mgr.h>
|
#include <config/command_mgr.h>
|
||||||
#include <dhcp/dhcp6.h>
|
#include <dhcp/dhcp6.h>
|
||||||
#include <dhcp/duid.h>
|
#include <dhcp/duid.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr.h>
|
#include <dhcpsrv/lease_mgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
#include <boost/algorithm/string/join.hpp>
|
#include <boost/algorithm/string/join.hpp>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_message_test.h>
|
#include <dhcp6/tests/dhcp6_message_test.h>
|
||||||
#include <dhcpsrv/utils.h>
|
#include <dhcpsrv/utils.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
#include <dhcp/option6_pdexclude.h>
|
#include <dhcp/option6_pdexclude.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_message_test.h>
|
#include <dhcp6/tests/dhcp6_message_test.h>
|
||||||
#include <boost/pointer_cast.hpp>
|
#include <boost/pointer_cast.hpp>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/option6_client_fqdn.h>
|
#include <dhcp/option6_client_fqdn.h>
|
||||||
#include <dhcp/option6_pdexclude.h>
|
#include <dhcp/option6_pdexclude.h>
|
||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <dhcp/option_int.h>
|
#include <dhcp/option_int.h>
|
||||||
#include <dhcp/option6_client_fqdn.h>
|
#include <dhcp/option6_client_fqdn.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfg_subnets6.h>
|
#include <dhcpsrv/cfg_subnets6.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp6/tests/dhcp6_message_test.h>
|
#include <dhcp6/tests/dhcp6_message_test.h>
|
||||||
#include <dhcpsrv/utils.h>
|
#include <dhcpsrv/utils.h>
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
#include <dhcp6/tests/dhcp6_test_utils.h>
|
#include <dhcp6/tests/dhcp6_test_utils.h>
|
||||||
#include <dhcp6/tests/dhcp6_client.h>
|
#include <dhcp6/tests/dhcp6_client.h>
|
||||||
#include <dhcp6/json_config_parser.h>
|
#include <dhcp6/json_config_parser.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <cc/command_interpreter.h>
|
#include <cc/command_interpreter.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
SUBDIRS = . tests
|
SUBDIRS = . testutils tests
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
|
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
|
||||||
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
||||||
|
@ -477,44 +477,6 @@ IfaceMgr::hasOpenSocket(const IOAddress& addr) const {
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfaceMgr::stubDetectIfaces() {
|
|
||||||
string ifaceName;
|
|
||||||
const string v4addr("127.0.0.1"), v6addr("::1");
|
|
||||||
|
|
||||||
// This is a stub implementation for interface detection. Actual detection
|
|
||||||
// is faked by detecting loopback interface (lo or lo0). It will eventually
|
|
||||||
// be removed once we have actual implementations for all supported systems.
|
|
||||||
|
|
||||||
if (if_nametoindex("lo") > 0) {
|
|
||||||
ifaceName = "lo";
|
|
||||||
// this is Linux-like OS
|
|
||||||
} else if (if_nametoindex("lo0") > 0) {
|
|
||||||
ifaceName = "lo0";
|
|
||||||
// this is BSD-like OS
|
|
||||||
} else {
|
|
||||||
// we give up. What OS is this, anyway? Solaris? Hurd?
|
|
||||||
isc_throw(NotImplemented,
|
|
||||||
"Interface detection on this OS is not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
IfacePtr iface(new Iface(ifaceName, if_nametoindex(ifaceName.c_str())));
|
|
||||||
iface->flag_up_ = true;
|
|
||||||
iface->flag_running_ = true;
|
|
||||||
|
|
||||||
// Note that we claim that this is not a loopback. iface_mgr tries to open a
|
|
||||||
// socket on all interfaces that are up, running and not loopback. As this is
|
|
||||||
// the only interface we were able to detect, let's pretend this is a normal
|
|
||||||
// interface.
|
|
||||||
iface->flag_loopback_ = false;
|
|
||||||
iface->flag_multicast_ = true;
|
|
||||||
iface->flag_broadcast_ = true;
|
|
||||||
iface->setHWType(HWTYPE_ETHERNET);
|
|
||||||
|
|
||||||
iface->addAddress(IOAddress(v4addr));
|
|
||||||
iface->addAddress(IOAddress(v6addr));
|
|
||||||
addInterface(iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IfaceMgr::openSockets4(const uint16_t port, const bool use_bcast,
|
IfaceMgr::openSockets4(const uint16_t port, const bool use_bcast,
|
||||||
IfaceMgrErrorMsgCallback error_handler,
|
IfaceMgrErrorMsgCallback error_handler,
|
||||||
|
@ -659,6 +659,14 @@ public:
|
|||||||
/// @param fd socket descriptor of the ready socket
|
/// @param fd socket descriptor of the ready socket
|
||||||
typedef std::function<void (int fd)> SocketCallback;
|
typedef std::function<void (int fd)> SocketCallback;
|
||||||
|
|
||||||
|
/// Defines callback used when detecting interfaces.
|
||||||
|
/// @param update_only Only add interfaces that do not exist and update
|
||||||
|
/// existing interfaces.
|
||||||
|
///
|
||||||
|
/// @return true if callback exited with no issue and @ref detectIfaces
|
||||||
|
/// should continue with specific system calls, false otherwise.
|
||||||
|
typedef std::function<bool (bool)> DetectCallback;
|
||||||
|
|
||||||
/// Keeps callback information for external sockets.
|
/// Keeps callback information for external sockets.
|
||||||
struct SocketCallbackInfo {
|
struct SocketCallbackInfo {
|
||||||
/// Socket descriptor of the external socket.
|
/// Socket descriptor of the external socket.
|
||||||
@ -788,11 +796,18 @@ public:
|
|||||||
/// @c PktFilter class to mimic socket operation on these interfaces.
|
/// @c PktFilter class to mimic socket operation on these interfaces.
|
||||||
void clearIfaces();
|
void clearIfaces();
|
||||||
|
|
||||||
|
/// @brief Set a callback to perform operations before executing specific
|
||||||
|
/// system calls.
|
||||||
|
///
|
||||||
|
/// @param cb The callback used before executing specific system calls.
|
||||||
|
void setDetectCallback(const DetectCallback& cb) {
|
||||||
|
detect_callback_ = cb;
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Detects network interfaces.
|
/// @brief Detects network interfaces.
|
||||||
///
|
///
|
||||||
/// This method will eventually detect available interfaces. For now
|
/// If the @ref detect_callback_ returns true, the specific system calls are
|
||||||
/// it offers stub implementation. First interface name and link-local
|
/// executed, otherwise the @ref detectIfaces will return immediately.
|
||||||
/// IPv6 address is read from interfaces.txt file.
|
|
||||||
///
|
///
|
||||||
/// @param update_only Only add interfaces that do not exist and update
|
/// @param update_only Only add interfaces that do not exist and update
|
||||||
/// existing interfaces.
|
/// existing interfaces.
|
||||||
@ -973,7 +988,6 @@ public:
|
|||||||
int openSocketFromRemoteAddress(const isc::asiolink::IOAddress& remote_addr,
|
int openSocketFromRemoteAddress(const isc::asiolink::IOAddress& remote_addr,
|
||||||
const uint16_t port);
|
const uint16_t port);
|
||||||
|
|
||||||
|
|
||||||
/// @brief Opens IPv6 sockets on detected interfaces.
|
/// @brief Opens IPv6 sockets on detected interfaces.
|
||||||
///
|
///
|
||||||
/// This method opens sockets only on interfaces which have the
|
/// This method opens sockets only on interfaces which have the
|
||||||
@ -1444,15 +1458,6 @@ protected:
|
|||||||
/// @return Pkt6 object representing received packet (or null)
|
/// @return Pkt6 object representing received packet (or null)
|
||||||
Pkt6Ptr receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
|
Pkt6Ptr receive6Indirect(uint32_t timeout_sec, uint32_t timeout_usec = 0);
|
||||||
|
|
||||||
|
|
||||||
/// @brief Stub implementation of network interface detection.
|
|
||||||
///
|
|
||||||
/// This implementations reads a single line from interfaces.txt file
|
|
||||||
/// and pretends to detect such interface. First interface name and
|
|
||||||
/// link-local IPv6 address or IPv4 address is read from the
|
|
||||||
/// interfaces.txt file.
|
|
||||||
void stubDetectIfaces();
|
|
||||||
|
|
||||||
/// @brief List of available interfaces
|
/// @brief List of available interfaces
|
||||||
IfaceCollection ifaces_;
|
IfaceCollection ifaces_;
|
||||||
|
|
||||||
@ -1488,7 +1493,6 @@ private:
|
|||||||
getLocalAddress(const isc::asiolink::IOAddress& remote_addr,
|
getLocalAddress(const isc::asiolink::IOAddress& remote_addr,
|
||||||
const uint16_t port);
|
const uint16_t port);
|
||||||
|
|
||||||
|
|
||||||
/// @brief Open an IPv6 socket with multicast support.
|
/// @brief Open an IPv6 socket with multicast support.
|
||||||
///
|
///
|
||||||
/// This function opens a socket capable of receiving messages sent to
|
/// This function opens a socket capable of receiving messages sent to
|
||||||
@ -1586,6 +1590,13 @@ private:
|
|||||||
/// @brief Indicates if the IfaceMgr is in the test mode.
|
/// @brief Indicates if the IfaceMgr is in the test mode.
|
||||||
bool test_mode_;
|
bool test_mode_;
|
||||||
|
|
||||||
|
/// @brief Detect callback used to perform action before system dependent
|
||||||
|
/// function calls. Currently this function is used in unittests only.
|
||||||
|
///
|
||||||
|
/// If the @ref detect_callback_ returns true, the specific system calls are
|
||||||
|
/// executed, otherwise the @ref detectIfaces will return immediately.
|
||||||
|
DetectCallback detect_callback_;
|
||||||
|
|
||||||
/// @brief Allows to use loopback
|
/// @brief Allows to use loopback
|
||||||
bool allow_loopback_;
|
bool allow_loopback_;
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ namespace dhcp {
|
|||||||
/// This is a BSD specific interface detection method.
|
/// This is a BSD specific interface detection method.
|
||||||
void
|
void
|
||||||
IfaceMgr::detectIfaces(bool update_only) {
|
IfaceMgr::detectIfaces(bool update_only) {
|
||||||
|
if (detect_callback_) {
|
||||||
|
if (!detect_callback_(update_only)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isTestMode() && update_only) {
|
if (isTestMode() && update_only) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -414,6 +414,12 @@ namespace dhcp {
|
|||||||
/// Uses the socket-based netlink protocol to retrieve the list of interfaces
|
/// Uses the socket-based netlink protocol to retrieve the list of interfaces
|
||||||
/// from the Linux kernel.
|
/// from the Linux kernel.
|
||||||
void IfaceMgr::detectIfaces(bool update_only) {
|
void IfaceMgr::detectIfaces(bool update_only) {
|
||||||
|
if (detect_callback_) {
|
||||||
|
if (!detect_callback_(update_only)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isTestMode() && update_only) {
|
if (isTestMode() && update_only) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,12 @@ namespace dhcp {
|
|||||||
/// only, as earlier versions did not support getifaddrs() API.
|
/// only, as earlier versions did not support getifaddrs() API.
|
||||||
void
|
void
|
||||||
IfaceMgr::detectIfaces(bool update_only) {
|
IfaceMgr::detectIfaces(bool update_only) {
|
||||||
|
if (detect_callback_) {
|
||||||
|
if (!detect_callback_(update_only)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isTestMode() && update_only) {
|
if (isTestMode() && update_only) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,25 +18,6 @@ TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
|
|||||||
TESTS =
|
TESTS =
|
||||||
if HAVE_GTEST
|
if HAVE_GTEST
|
||||||
|
|
||||||
# Creates a library which is shared by various unit tests which require
|
|
||||||
# configuration of fake interfaces.
|
|
||||||
# The libdhcp++ does not link with this library because this would cause
|
|
||||||
# build failures being a result of concurrency between build of this
|
|
||||||
# library and the unit tests when make -j option was used, as they
|
|
||||||
# are built out of the same makefile. Instead, the libdhcp++ tests link to
|
|
||||||
# files belonging to this library, directly.
|
|
||||||
noinst_LTLIBRARIES = libdhcptest.la
|
|
||||||
|
|
||||||
libdhcptest_la_SOURCES = iface_mgr_test_config.cc iface_mgr_test_config.h
|
|
||||||
libdhcptest_la_SOURCES += pkt_filter_test_stub.cc pkt_filter_test_stub.h
|
|
||||||
libdhcptest_la_SOURCES += pkt_filter6_test_stub.cc pkt_filter6_test_stub.h
|
|
||||||
libdhcptest_la_SOURCES += pkt_captures4.cc pkt_captures6.cc pkt_captures.h
|
|
||||||
libdhcptest_la_SOURCES += packet_queue_testutils.h
|
|
||||||
libdhcptest_la_CXXFLAGS = $(AM_CXXFLAGS)
|
|
||||||
libdhcptest_la_CPPFLAGS = $(AM_CPPFLAGS)
|
|
||||||
libdhcptest_la_LDFLAGS = $(AM_LDFLAGS)
|
|
||||||
libdhcptest_la_LIBADD = $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
|
||||||
|
|
||||||
TESTS += libdhcp++_unittests
|
TESTS += libdhcp++_unittests
|
||||||
|
|
||||||
libdhcp___unittests_SOURCES = run_unittests.cc
|
libdhcp___unittests_SOURCES = run_unittests.cc
|
||||||
@ -44,7 +25,6 @@ libdhcp___unittests_SOURCES += classify_unittest.cc
|
|||||||
libdhcp___unittests_SOURCES += duid_factory_unittest.cc
|
libdhcp___unittests_SOURCES += duid_factory_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += hwaddr_unittest.cc
|
libdhcp___unittests_SOURCES += hwaddr_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += iface_mgr_unittest.cc
|
libdhcp___unittests_SOURCES += iface_mgr_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += iface_mgr_test_config.cc iface_mgr_test_config.h
|
|
||||||
libdhcp___unittests_SOURCES += libdhcp++_unittest.cc
|
libdhcp___unittests_SOURCES += libdhcp++_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += opaque_data_tuple_unittest.cc
|
libdhcp___unittests_SOURCES += opaque_data_tuple_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += option4_addrlst_unittest.cc
|
libdhcp___unittests_SOURCES += option4_addrlst_unittest.cc
|
||||||
@ -71,7 +51,6 @@ libdhcp___unittests_SOURCES += option_space_unittest.cc
|
|||||||
libdhcp___unittests_SOURCES += option_string_unittest.cc
|
libdhcp___unittests_SOURCES += option_string_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += option_vendor_unittest.cc
|
libdhcp___unittests_SOURCES += option_vendor_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += option_vendor_class_unittest.cc
|
libdhcp___unittests_SOURCES += option_vendor_class_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += pkt_captures4.cc pkt_captures6.cc pkt_captures.h
|
|
||||||
libdhcp___unittests_SOURCES += packet_queue4_unittest.cc
|
libdhcp___unittests_SOURCES += packet_queue4_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += packet_queue6_unittest.cc
|
libdhcp___unittests_SOURCES += packet_queue6_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += packet_queue_mgr4_unittest.cc
|
libdhcp___unittests_SOURCES += packet_queue_mgr4_unittest.cc
|
||||||
@ -83,8 +62,6 @@ libdhcp___unittests_SOURCES += pkt4o6_unittest.cc
|
|||||||
libdhcp___unittests_SOURCES += pkt_filter_unittest.cc
|
libdhcp___unittests_SOURCES += pkt_filter_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += pkt_filter_inet_unittest.cc
|
libdhcp___unittests_SOURCES += pkt_filter_inet_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += pkt_filter_inet6_unittest.cc
|
libdhcp___unittests_SOURCES += pkt_filter_inet6_unittest.cc
|
||||||
libdhcp___unittests_SOURCES += pkt_filter_test_stub.cc pkt_filter_test_stub.h
|
|
||||||
libdhcp___unittests_SOURCES += pkt_filter6_test_stub.cc pkt_filter_test_stub.h
|
|
||||||
libdhcp___unittests_SOURCES += pkt_filter_test_utils.h pkt_filter_test_utils.cc
|
libdhcp___unittests_SOURCES += pkt_filter_test_utils.h pkt_filter_test_utils.cc
|
||||||
libdhcp___unittests_SOURCES += pkt_filter6_test_utils.h pkt_filter6_test_utils.cc
|
libdhcp___unittests_SOURCES += pkt_filter6_test_utils.h pkt_filter6_test_utils.cc
|
||||||
|
|
||||||
@ -107,7 +84,8 @@ libdhcp___unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
|
|||||||
|
|
||||||
libdhcp___unittests_CXXFLAGS = $(AM_CXXFLAGS)
|
libdhcp___unittests_CXXFLAGS = $(AM_CXXFLAGS)
|
||||||
|
|
||||||
libdhcp___unittests_LDADD = $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
libdhcp___unittests_LDADD = $(top_builddir)/src/lib/dhcp/testutils/libdhcptest.la
|
||||||
|
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
||||||
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
||||||
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
|
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
|
||||||
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
|
libdhcp___unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/duid_factory.h>
|
#include <dhcp/duid_factory.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <testutils/io_utils.h>
|
#include <testutils/io_utils.h>
|
||||||
#include <util/encode/hex.h>
|
#include <util/encode/hex.h>
|
||||||
#include <util/range_utilities.h>
|
#include <util/range_utilities.h>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/pkt_filter.h>
|
#include <dhcp/pkt_filter.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_filter6_test_utils.h>
|
#include <dhcp/tests/pkt_filter6_test_utils.h>
|
||||||
#include <dhcp/tests/packet_queue_testutils.h>
|
#include <dhcp/tests/packet_queue_testutils.h>
|
||||||
#include <testutils/gtest_utils.h>
|
#include <testutils/gtest_utils.h>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/libdhcp++.h>
|
#include <dhcp/libdhcp++.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
@ -19,7 +20,6 @@
|
|||||||
#include <testutils/gtest_utils.h>
|
#include <testutils/gtest_utils.h>
|
||||||
#include <util/buffer.h>
|
#include <util/buffer.h>
|
||||||
#include <util/encode/hex.h>
|
#include <util/encode/hex.h>
|
||||||
#include <pkt_captures.h>
|
|
||||||
|
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <dhcp/dhcp6.h>
|
#include <dhcp/dhcp6.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option_custom.h>
|
#include <dhcp/option_custom.h>
|
||||||
@ -21,7 +22,6 @@
|
|||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/hwaddr.h>
|
#include <dhcp/hwaddr.h>
|
||||||
#include <dhcp/docsis3_option_defs.h>
|
#include <dhcp/docsis3_option_defs.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
|
||||||
#include <testutils/gtest_utils.h>
|
#include <testutils/gtest_utils.h>
|
||||||
#include <util/range_utilities.h>
|
#include <util/range_utilities.h>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
25
src/lib/dhcp/testutils/Makefile.am
Normal file
25
src/lib/dhcp/testutils/Makefile.am
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
SUBDIRS = .
|
||||||
|
|
||||||
|
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
|
||||||
|
AM_CPPFLAGS += $(BOOST_INCLUDES)
|
||||||
|
|
||||||
|
AM_CXXFLAGS = $(KEA_CXXFLAGS)
|
||||||
|
|
||||||
|
CLEANFILES = *.gcno *.gcda
|
||||||
|
|
||||||
|
if HAVE_GTEST
|
||||||
|
|
||||||
|
noinst_LTLIBRARIES = libdhcptest.la
|
||||||
|
|
||||||
|
libdhcptest_la_SOURCES = iface_mgr_test_config.cc iface_mgr_test_config.h
|
||||||
|
libdhcptest_la_SOURCES += pkt_filter_test_stub.cc pkt_filter_test_stub.h
|
||||||
|
libdhcptest_la_SOURCES += pkt_filter6_test_stub.cc pkt_filter6_test_stub.h
|
||||||
|
libdhcptest_la_SOURCES += pkt_captures4.cc pkt_captures6.cc pkt_captures.h
|
||||||
|
|
||||||
|
libdhcptest_la_CXXFLAGS = $(AM_CXXFLAGS)
|
||||||
|
libdhcptest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
|
||||||
|
|
||||||
|
libdhcptest_la_LIBADD =
|
||||||
|
libdhcptest_la_LIBADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
||||||
|
|
||||||
|
endif
|
@ -9,9 +9,9 @@
|
|||||||
#include <dhcp/pkt_filter.h>
|
#include <dhcp/pkt_filter.h>
|
||||||
#include <dhcp/pkt_filter_inet.h>
|
#include <dhcp/pkt_filter_inet.h>
|
||||||
#include <dhcp/pkt_filter_inet6.h>
|
#include <dhcp/pkt_filter_inet6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_filter_test_stub.h>
|
#include <dhcp/testutils/pkt_filter_test_stub.h>
|
||||||
#include <dhcp/tests/pkt_filter6_test_stub.h>
|
#include <dhcp/testutils/pkt_filter6_test_stub.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
@ -67,12 +67,15 @@ IfaceMgrTestConfig::addIface(const IfacePtr& iface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
IfaceMgrTestConfig::addIface(const std::string& name, const unsigned int ifindex) {
|
IfaceMgrTestConfig::addIface(const std::string& name,
|
||||||
|
const unsigned int ifindex) {
|
||||||
IfaceMgr::instance().addInterface(createIface(name, ifindex));
|
IfaceMgr::instance().addInterface(createIface(name, ifindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
IfacePtr
|
IfacePtr
|
||||||
IfaceMgrTestConfig::createIface(const std::string &name, const unsigned int ifindex) {
|
IfaceMgrTestConfig::createIface(const std::string& name,
|
||||||
|
const unsigned int ifindex,
|
||||||
|
const std::string& mac) {
|
||||||
IfacePtr iface(new Iface(name, ifindex));
|
IfacePtr iface(new Iface(name, ifindex));
|
||||||
if (name == "lo") {
|
if (name == "lo") {
|
||||||
iface->flag_loopback_ = true;
|
iface->flag_loopback_ = true;
|
||||||
@ -93,8 +96,9 @@ IfaceMgrTestConfig::createIface(const std::string &name, const unsigned int ifin
|
|||||||
iface->flag_up_ = true;
|
iface->flag_up_ = true;
|
||||||
iface->flag_running_ = true;
|
iface->flag_running_ = true;
|
||||||
|
|
||||||
// Set MAC address to 08:08:08:08:08:08.
|
// Set MAC address.
|
||||||
std::vector<uint8_t> mac_vec(6, 8);
|
HWAddr hwaddr = HWAddr::fromText(mac);
|
||||||
|
std::vector<uint8_t> mac_vec = hwaddr.hwaddr_;
|
||||||
iface->setMac(&mac_vec[0], mac_vec.size());
|
iface->setMac(&mac_vec[0], mac_vec.size());
|
||||||
iface->setHWType(HTYPE_ETHER);
|
iface->setHWType(HTYPE_ETHER);
|
||||||
|
|
||||||
@ -202,6 +206,6 @@ IfaceMgrTestConfig::unicastOpen(const std::string& iface_name) const {
|
|||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // end of namespace isc::dhcp::test
|
||||||
}
|
} // end of namespace isc::dhcp
|
||||||
}
|
} // end of namespace isc
|
@ -191,14 +191,14 @@ public:
|
|||||||
/// - multicast always to true
|
/// - multicast always to true
|
||||||
/// - broadcast always to false
|
/// - broadcast always to false
|
||||||
///
|
///
|
||||||
/// If one needs to modify the default flag settings, the setIfaceFlags
|
|
||||||
/// function should be used.
|
|
||||||
///
|
|
||||||
/// @param name A name of the interface to be created.
|
/// @param name A name of the interface to be created.
|
||||||
/// @param ifindex An index of the interface to be created.
|
/// @param ifindex An index of the interface to be created.
|
||||||
|
/// @param mac The mac of the interface.
|
||||||
///
|
///
|
||||||
/// @return An object representing interface.
|
/// @return An object representing interface.
|
||||||
static IfacePtr createIface(const std::string& name, const unsigned int ifindex);
|
static IfacePtr createIface(const std::string& name,
|
||||||
|
const unsigned int ifindex,
|
||||||
|
const std::string& mac = "08:08:08:08:08:08");
|
||||||
|
|
||||||
/// @brief Creates a default (example) set of fake interfaces.
|
/// @brief Creates a default (example) set of fake interfaces.
|
||||||
void createIfaces();
|
void createIfaces();
|
||||||
@ -258,7 +258,6 @@ public:
|
|||||||
/// @param iface_name Interface name.
|
/// @param iface_name Interface name.
|
||||||
bool unicastOpen(const std::string& iface_name) const;
|
bool unicastOpen(const std::string& iface_name) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief Currently used packet filter for DHCPv4.
|
/// @brief Currently used packet filter for DHCPv4.
|
||||||
PktFilterPtr packet_filter4_;
|
PktFilterPtr packet_filter4_;
|
||||||
@ -267,8 +266,8 @@ private:
|
|||||||
PktFilter6Ptr packet_filter6_;
|
PktFilter6Ptr packet_filter6_;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
} // end of namespace isc::dhcp::test
|
||||||
};
|
} // end of namespace isc::dhcp
|
||||||
};
|
} // end of namespace isc
|
||||||
|
|
||||||
#endif // IFACE_MGR_TEST_CONFIG_H
|
#endif // IFACE_MGR_TEST_CONFIG_H
|
@ -5,12 +5,14 @@
|
|||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
|
||||||
#include <string>
|
|
||||||
#include <asiolink/io_address.h>
|
#include <asiolink/io_address.h>
|
||||||
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <util/encode/hex.h>
|
#include <util/encode/hex.h>
|
||||||
|
|
||||||
/// @file wireshark.cc
|
#include <string>
|
||||||
|
|
||||||
|
/// @file pkt_captures.cc
|
||||||
///
|
///
|
||||||
/// @brief contains packet captures imported from Wireshark
|
/// @brief contains packet captures imported from Wireshark
|
||||||
///
|
///
|
@ -5,9 +5,11 @@
|
|||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
|
#include <dhcp/testutils/pkt_captures.h>
|
||||||
#include <util/encode/hex.h>
|
#include <util/encode/hex.h>
|
||||||
#include <dhcp/tests/pkt_captures.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/// @file pkt_captures6.cc
|
/// @file pkt_captures6.cc
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <dhcp/tests/pkt_filter6_test_stub.h>
|
#include <dhcp/testutils/pkt_filter6_test_stub.h>
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace dhcp {
|
namespace dhcp {
|
@ -9,7 +9,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <dhcp/tests/pkt_filter_test_stub.h>
|
#include <dhcp/testutils/pkt_filter_test_stub.h>
|
||||||
|
|
||||||
namespace isc {
|
namespace isc {
|
||||||
namespace dhcp {
|
namespace dhcp {
|
@ -59,7 +59,6 @@ IfacesConfigParser::parse(const CfgIfacePtr& cfg,
|
|||||||
if (element.first == "interfaces") {
|
if (element.first == "interfaces") {
|
||||||
parseInterfacesList(cfg, element.second);
|
parseInterfacesList(cfg, element.second);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.first == "dhcp-socket-type") {
|
if (element.first == "dhcp-socket-type") {
|
||||||
|
@ -166,7 +166,7 @@ libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns
|
|||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
|
||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
|
||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la
|
||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp/testutils/libdhcptest.la
|
||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
|
||||||
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
libdhcpsrv_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <dhcp/dhcp4.h>
|
#include <dhcp/dhcp4.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/tests/pkt_filter_test_stub.h>
|
#include <dhcp/testutils/pkt_filter_test_stub.h>
|
||||||
#include <dhcp/tests/pkt_filter6_test_stub.h>
|
#include <dhcp/testutils/pkt_filter6_test_stub.h>
|
||||||
#include <dhcpsrv/cfg_iface.h>
|
#include <dhcpsrv/cfg_iface.h>
|
||||||
#include <asiolink/io_service.h>
|
#include <asiolink/io_service.h>
|
||||||
#include <asiolink/asio_wrapper.h>
|
#include <asiolink/asio_wrapper.h>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <dhcp/option_definition.h>
|
#include <dhcp/option_definition.h>
|
||||||
#include <dhcp/option_space.h>
|
#include <dhcp/option_space.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
#include <dhcpsrv/parsers/dhcp_parsers.h>
|
#include <dhcpsrv/parsers/dhcp_parsers.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <dhcp/dhcp6.h>
|
#include <dhcp/dhcp6.h>
|
||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/cfg_shared_networks.h>
|
#include <dhcpsrv/cfg_shared_networks.h>
|
||||||
#include <dhcpsrv/cfg_subnets6.h>
|
#include <dhcpsrv/cfg_subnets6.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <exceptions/exceptions.h>
|
#include <exceptions/exceptions.h>
|
||||||
#include <dhcp/dhcp6.h>
|
#include <dhcp/dhcp6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/lease_mgr_factory.h>
|
#include <dhcpsrv/lease_mgr_factory.h>
|
||||||
#include <dhcpsrv/subnet_id.h>
|
#include <dhcpsrv/subnet_id.h>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <dhcp/iface_mgr.h>
|
#include <dhcp/iface_mgr.h>
|
||||||
#include <dhcp/pkt6.h>
|
#include <dhcp/pkt6.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option_vendor.h>
|
#include <dhcp/option_vendor.h>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include <dhcp/option_string.h>
|
#include <dhcp/option_string.h>
|
||||||
#include <dhcp/option4_addrlst.h>
|
#include <dhcp/option4_addrlst.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/subnet.h>
|
#include <dhcpsrv/subnet.h>
|
||||||
#include <dhcpsrv/cfg_mac_source.h>
|
#include <dhcpsrv/cfg_mac_source.h>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/parsers/ifaces_config_parser.h>
|
#include <dhcpsrv/parsers/ifaces_config_parser.h>
|
||||||
#include <testutils/test_to_element.h>
|
#include <testutils/test_to_element.h>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <dhcp/option.h>
|
#include <dhcp/option.h>
|
||||||
#include <dhcp/option4_addrlst.h>
|
#include <dhcp/option4_addrlst.h>
|
||||||
#include <dhcp/option6_addrlst.h>
|
#include <dhcp/option6_addrlst.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfg_option.h>
|
#include <dhcpsrv/cfg_option.h>
|
||||||
#include <dhcpsrv/parsers/shared_network_parser.h>
|
#include <dhcpsrv/parsers/shared_network_parser.h>
|
||||||
#include <testutils/gtest_utils.h>
|
#include <testutils/gtest_utils.h>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <cc/data.h>
|
#include <cc/data.h>
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfg_shared_networks.h>
|
#include <dhcpsrv/cfg_shared_networks.h>
|
||||||
#include <dhcpsrv/shared_network.h>
|
#include <dhcpsrv/shared_network.h>
|
||||||
#include <dhcpsrv/parsers/shared_networks_list_parser.h>
|
#include <dhcpsrv/parsers/shared_networks_list_parser.h>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <dhcp/tests/iface_mgr_test_config.h>
|
#include <dhcp/testutils/iface_mgr_test_config.h>
|
||||||
#include <dhcpsrv/cfgmgr.h>
|
#include <dhcpsrv/cfgmgr.h>
|
||||||
#include <dhcpsrv/client_class_def.h>
|
#include <dhcpsrv/client_class_def.h>
|
||||||
#include <dhcpsrv/srv_config.h>
|
#include <dhcpsrv/srv_config.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user