Commit 5a1f60fc authored by Marcin Siodelski's avatar Marcin Siodelski

[5458] CtrlDhcpv6Srv now passes network_state to dhcp6_srv_configured co.

parent db448f80
......@@ -435,7 +435,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
// The user specified that the DHCP service should resume not
// later than in max-period seconds. If the 'dhcp-enable' command
// is not sent, the DHCP service will resume automatically.
network_state_.delayedEnableAll(static_cast<unsigned>(max_period));
network_state_->delayedEnableAll(static_cast<unsigned>(max_period));
}
}
}
......@@ -443,7 +443,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
// No error occurred, so let's disable the service.
if (message.tellp() == 0) {
network_state_.disableService();
network_state_->disableService();
message << "DHCPv6 service disabled";
if (max_period > 0) {
......@@ -459,7 +459,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
ConstElementPtr
ControlledDhcpv6Srv::commandDhcpEnableHandler(const std::string&, ConstElementPtr) {
network_state_.enableService();
network_state_->enableService();
return (config::createAnswer(CONTROL_RESULT_SUCCESS, "DHCP service successfully enabled"));
}
......@@ -689,7 +689,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
callout_handle->setArgument("io_context", srv->getIOService());
// callout_handle->setArgument("network_state", srv->getNetworkState());
callout_handle->setArgument("network_state", srv->getNetworkState());
callout_handle->setArgument("json_config", config);
callout_handle->setArgument("server_config", CfgMgr::instance().getStagingCfg());
......@@ -886,7 +886,7 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
TimerMgr::instance()->cancel("Dhcp6DbReconnectTimer"); }
// Set network state to service enabled
network_state_.enableService();
network_state_->enableService();
// Toss the reconnct control, we're done with it
db_reconnect_ctl.reset();
......@@ -918,7 +918,7 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
bool
ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
// Disable service until we recover
network_state_.disableService();
network_state_->disableService();
if (!db_reconnect_ctl) {
// This shouldn't never happen
......
......@@ -180,7 +180,8 @@ const std::string Dhcpv6Srv::VENDOR_CLASS_PREFIX("VENDOR_CLASS_");
Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
: io_service_(new IOService()), port_(port), serverid_(), shutdown_(true),
alloc_engine_(), name_change_reqs_(), network_state_(NetworkState::DHCPv6)
alloc_engine_(), name_change_reqs_(),
network_state_(new NetworkState(NetworkState::DHCPv6))
{
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
......@@ -476,7 +477,7 @@ void Dhcpv6Srv::run_one() {
}
// If the DHCP service has been globally disabled, drop the packet.
if (!network_state_.isServiceEnabled()) {
if (!network_state_->isServiceEnabled()) {
LOG_DEBUG(bad_packet6_logger, DBG_DHCP6_DETAIL_DATA,
DHCP6_PACKET_DROP_DHCP_DISABLED)
.arg(query->getLabel());
......
......@@ -91,6 +91,11 @@ public:
return (io_service_);
}
/// @brief Returns pointer to the network state used by the server.
NetworkStatePtr& getNetworkState() {
return (network_state_);
}
/// @brief returns Kea version on stdout and exit.
/// redeclaration/redefinition. @ref Daemon::getVersion()
static std::string getVersion(bool extended);
......@@ -938,7 +943,7 @@ protected:
/// @brief Holds information about disabled DHCP service and/or
/// disabled subnet/network scopes.
NetworkState network_state_;
NetworkStatePtr network_state_;
};
......
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
......@@ -1192,7 +1192,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, dhcpDisable) {
ConstElementPtr cfg = parseAnswer(status, rsp);
EXPECT_EQ(CONTROL_RESULT_SUCCESS, status);
EXPECT_FALSE(server_->network_state_.isServiceEnabled());
EXPECT_FALSE(server_->network_state_->isServiceEnabled());
}
// This test verifies that it is possible to disable DHCP service for a short
......@@ -1219,10 +1219,10 @@ TEST_F(CtrlChannelDhcpv6SrvTest, dhcpDisableTemporarily) {
EXPECT_EQ(CONTROL_RESULT_SUCCESS, status);
// The service should be disabled.
EXPECT_FALSE(server_->network_state_.isServiceEnabled());
EXPECT_FALSE(server_->network_state_->isServiceEnabled());
// And the timer should be scheduled which counts the time to automatic
// enabling of the service.
EXPECT_TRUE(server_->network_state_.isDelayedEnableAll());
EXPECT_TRUE(server_->network_state_->isDelayedEnableAll());
}
// This test verifies if it is possible to enable DHCP service via command.
......@@ -1241,7 +1241,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, dhcpEnable) {
ConstElementPtr cfg = parseAnswer(status, rsp);
EXPECT_EQ(CONTROL_RESULT_SUCCESS, status);
EXPECT_TRUE(server_->network_state_.isServiceEnabled());
EXPECT_TRUE(server_->network_state_->isServiceEnabled());
}
/// Verify that concurrent connections over the control channel can be
......
......@@ -3750,7 +3750,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
// parameters should be recorded.
//// not yet network_state
EXPECT_TRUE(checkMarkerFile(SRV_CONFIG_MARKER_FILE,
"3io_contextjson_configserver_config"));
"3io_contextjson_confignetwork_stateserver_config"));
// Destroy the server, instance which should unload the libraries.
srv.reset();
......@@ -3761,7 +3761,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
EXPECT_TRUE(checkMarkerFile(LOAD_MARKER_FILE, "3"));
EXPECT_TRUE(checkMarkerFile(UNLOAD_MARKER_FILE, "3"));
EXPECT_TRUE(checkMarkerFile(SRV_CONFIG_MARKER_FILE,
"3io_contextjson_configserver_config"));
"3io_contextjson_confignetwork_stateserver_config"));
}
} // end of anonymous namespace
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment