]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5442] Addressed review comments.
authorMarcin Siodelski <marcin@isc.org>
Mon, 11 Dec 2017 10:29:27 +0000 (11:29 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 11 Dec 2017 10:29:27 +0000 (11:29 +0100)
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/network_state.cc
src/lib/dhcpsrv/network_state.h
src/lib/dhcpsrv/tests/network_state_unittest.cc

index ca2e58abdc51e218e0f9443ad5eadd0504ef011b..97ecfa5cf3520bf49d43f27aefd32b7ffadae23a 100644 (file)
@@ -805,10 +805,11 @@ Dhcpv4Srv::run_one() {
     }
 
     // If the DHCP service has been globally disabled, drop the packet.
-    if (network_state_.isServiceEnabled()) {
+    if (!network_state_.isServiceEnabled()) {
         LOG_DEBUG(bad_packet4_logger, DBG_DHCP4_BASIC,
                   DHCP4_PACKET_DROP_0008)
             .arg(query->getLabel());
+    } else {
         processPacket(query, rsp);
     }
 
index eeadd5e70d99d94218d4b0810e35d4177f7eb19b..dceb6367fbd5474bcc1627afccd23ee1d17a0ea6 100644 (file)
@@ -418,7 +418,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
     if (message.tellp() == 0) {
         network_state_.disableService();
 
-        message << "DHCPv4 service disabled";
+        message << "DHCPv6 service disabled";
         if (max_period > 0) {
             message << " for " << max_period << " seconds";
         }
index d895a45493cfb74bbdbb48f7df2c25156cd32714..0d6c9caebe892e93ddd4261d678ec869610e3672 100644 (file)
@@ -416,7 +416,7 @@ service may be enabled by the "dhcp-enable" control command or automatically
 after a specified amount of time since receiving "dhcp-disable" command.
 
 % DHCP6_PACKET_DROP_PARSE_FAIL failed to parse packet from %1 to %2, received over interface %3, reason: %4
-The DHCPv4 server has received a packet that it is unable to
+The DHCPv6 server has received a packet that it is unable to
 interpret. The reason why the packet is invalid is included in the message.
 
 % DHCP6_PACKET_DROP_SERVERID_MISMATCH %1: dropping packet with server identifier: %2, server is using: %3
index c39073519e4ffe6498e8dac3461255832b1ebdd3..08c2dc13d23eb838ed9fc3b80cbb34bd08cbe5f5 100644 (file)
@@ -469,10 +469,11 @@ 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());
+    } else {
         processPacket(query, rsp);
     }
 
index 8e757607d34a106ba745afcbd03b65fb9acefbf8..552f7c76d8d6c79f375369d73449b886f8edd429 100644 (file)
@@ -52,7 +52,7 @@ public:
         destroyTimer();
     }
 
-    /// @brief Creates a timer couting the time when @c enableAll should be
+    /// @brief Creates a timer counting the time when @c enableAll should be
     /// automatically called.
     ///
     /// If the timer has been already scheduled, it is destroyed and replaced
@@ -67,7 +67,7 @@ public:
                                               shared_from_this()),
                                   seconds * 1000,
                                   asiolink::IntervalTimer::ONE_SHOT);
-        timer_mgr_->setup("network-state-timer");
+        timer_mgr_->setup(NETWORK_STATE_TIMER_NAME);
     }
 
     /// @brief Destroys a timer if present.
index cfd48a3615df74c8d5eb0c7c5dd88a263d14119f..137c29bbed81585c92b8bd848702d86fb6fa7c88 100644 (file)
@@ -23,7 +23,7 @@ class NetworkStateImpl;
 /// When the DHCP server receives a command to disable DHCP service entirely
 /// or for specific networks, this has to be recorded to allow for re-enabling
 /// DHCP service for these networks as a result of receiving a command from
-/// the administrator or when the tiemout for re-enabling the service occurs.
+/// the administrator or when the timeout for re-enabling the service occurs.
 ///
 /// In the future, it will be possible to specify "disabled" parameter for
 /// a subnet (or network) in the configuration file to indicate that this subnet
index ab2837b350012a61e98ff70a28016374ad9b7315..b21be026e7d47227c57dbca1734620abb5327fde 100644 (file)
@@ -49,7 +49,7 @@ public:
 
     /// @brief Runs IO service with a timeout.
     ///
-    /// @param timeout_ms Timeout for runninr IO service in milliseconds.
+    /// @param timeout_ms Timeout for running IO service in milliseconds.
     void runIOService(const long timeout_ms) {
         test_timer_.setup(boost::bind(&NetworkStateTest::testTimerCallback, this), timeout_ms,
                           IntervalTimer::ONE_SHOT);
@@ -63,8 +63,8 @@ public:
     IntervalTimer test_timer_;
 };
 
-// This test verifies that it is possible to disable and then enable service.
-TEST_F(NetworkStateTest, disableEnableService) {
+// This test verifies that it is possible to disable and then enable DHCPv4 service.
+TEST_F(NetworkStateTest, disableEnableService4) {
     NetworkState state(NetworkState::DHCPv4);
     state.disableService();
     EXPECT_FALSE(state.isServiceEnabled());
@@ -72,6 +72,15 @@ TEST_F(NetworkStateTest, disableEnableService) {
     EXPECT_TRUE(state.isServiceEnabled());
 }
 
+// This test verifies that it is possible to disable and then enable DHCPv6 service.
+TEST_F(NetworkStateTest, disableEnableService6) {
+    NetworkState state(NetworkState::DHCPv6);
+    state.disableService();
+    EXPECT_FALSE(state.isServiceEnabled());
+    state.enableService();
+    EXPECT_TRUE(state.isServiceEnabled());
+}
+
 // This test verifies that enableAll() enables the service. This test will be extended
 // in the future to verify that it also enables disabled scopes.
 TEST_F(NetworkStateTest, enableAll) {