]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5458] CtrlDhcpv6Srv now passes network_state to dhcp6_srv_configured co.
authorMarcin Siodelski <marcin@isc.org>
Mon, 30 Apr 2018 15:17:10 +0000 (17:17 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 30 Apr 2018 15:17:10 +0000 (17:17 +0200)
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/hooks_unittest.cc

index 1e9362886874f7e45b8d8fb3a1adb320c228c782..e50ed9fef9c8dbd9b90f389e8f12077ed9998d73 100644 (file)
@@ -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
index 0680daa28d4f16ea945ff7c4157587fe89d1a6c1..764a6173bad673d1dc8510b9292dc97345fa19c7 100644 (file)
@@ -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());
index 9668275ad7ab9db3e28a4b5dd15f7d70e846693b..242246a85a1f226dc19d341d46dd8782d06962ec 100644 (file)
@@ -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_;
 
 };
 
index b105e5557d0a29633985acde6f2dbb31f8edc482..dfd5467efa7b3d0197f2bdb8b54a8bbfb2b884bf 100644 (file)
@@ -1,4 +1,4 @@
-// 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
index d4b345c5df6dc80a5b648bf5e9b9597d72dcdd84..3c547b38eebd7155437ab007eeb3cfc8eb419920 100644 (file)
@@ -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