Commit 7d46d891 authored by Marcin Siodelski's avatar Marcin Siodelski

[5442] Addressed review comments.

parent 075aedce
......@@ -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);
}
......
......@@ -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";
}
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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
......
......@@ -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) {
......
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