From a2b33c0072307ced2777037069e018e3d9e69aba Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Sun, 20 Oct 2024 13:42:01 +0200 Subject: [PATCH] [#2974] Addressed some comments --- doc/sphinx/arm/ctrl-channel.rst | 15 ++++++++----- src/bin/dhcp4/ctrl_dhcp4_srv.cc | 2 +- .../dhcp4/tests/ctrl_dhcp4_srv_unittest.cc | 22 +++++++++---------- src/bin/dhcp6/ctrl_dhcp6_srv.cc | 2 +- .../dhcp6/tests/ctrl_dhcp6_srv_unittest.cc | 10 ++++----- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doc/sphinx/arm/ctrl-channel.rst b/doc/sphinx/arm/ctrl-channel.rst index 11a621d70a..239e92e70d 100644 --- a/doc/sphinx/arm/ctrl-channel.rst +++ b/doc/sphinx/arm/ctrl-channel.rst @@ -873,8 +873,9 @@ Commands Supported by the DHCPv4 Server The ``localize4`` Command ------------------------- -The :isccmd:`localize4` command returns the result of DHCPv4 subnet selection. -Recognized entries take strings and are: +The :isccmd:`localize4` provides a way to test DHCPv4 subnet selection based +on a set of input parameters typically supplied in a client packet. +Recognized parameters take strings and are: - ``interface`` - the incoming interface name - ``address`` - the client address @@ -901,8 +902,9 @@ Outside of errors possible results are: The ``localize4o6`` Command --------------------------- -The :isccmd:`localize4o6` command returns the result of DHCPv4-over-DHCPv6 -subnet selection. Recognized entries take strings and are: +The :isccmd:`localize4to5` provides a way to test DHCPv4-over-DHCPv6 subnet +selection based on a set of input parameters typically supplied in a client +packet. Recognized parameters take strings and are: - ``interface`` - the incoming interface name of the DHCPv6 server - ``interface-id`` - the binary content of the interface-id relay option @@ -935,8 +937,9 @@ Commands Supported by the DHCPv6 Server The ``localize6`` Command ------------------------- -The :isccmd:`localize6` command returns the result of DHCPv6 subnet selection. -Recognized entries take strings and are: +The :isccmd:`localize6` provides a way to test DHCPv6 subnet selection based +on a set of input parameters typically supplied in a client packet. +Recognized parameters take strings and are: - ``interface`` - the incoming interface name - ``interface-id`` - the binary content of the interface-id relay option diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 8285d7a2d7..89e1b261f6 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -848,7 +848,7 @@ ControlledDhcpv4Srv::commandLocalize4Handler(const string&, ConstSubnet4Ptr subnet = CfgMgr::instance().getCurrentCfg()-> getCfgSubnets4()->selectSubnet(selector); if (!subnet) { - return (createAnswer(CONTROL_RESULT_EMPTY, "no selected subnet")); + return (createAnswer(CONTROL_RESULT_EMPTY, "no subnet selected")); } SharedNetwork4Ptr network; subnet->getSharedNetwork(network); diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 847cbf832f..0972166fa1 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -2349,7 +2349,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4RAILinkSelect) { " \"link\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2400,7 +2400,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4SubnetSelect) { " \"subnet\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2452,7 +2452,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4RelayAddress) { " \"relay\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2503,7 +2503,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4Gateway) { " \"relay\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2554,7 +2554,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4Client) { " \"address\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2605,7 +2605,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4Remote) { " \"remote\": \"10.0.1.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2659,7 +2659,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4Iface) { " \"interface\": \"eth0\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Same interface: the subnet is selected. @@ -2710,7 +2710,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4Class) { " \"address\": \"192.0.2.1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range and in guard: the subnet is selected. @@ -3036,7 +3036,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4o6Remote) { " \"remote\": \"2001:db8:2::2\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -3092,7 +3092,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4o6RelayInterfaceId) { " \"interface-id\": \"'foobar'\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Same interface: the subnet is selected. @@ -3145,7 +3145,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, localize4o6Iface) { " \"interface\": \"foobar\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Same interface: the subnet is selected. diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index f6d5b32751..d7b0acff94 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -798,7 +798,7 @@ ControlledDhcpv6Srv::commandLocalize6Handler(const string&, ConstSubnet6Ptr subnet = CfgMgr::instance().getCurrentCfg()-> getCfgSubnets6()->selectSubnet(selector); if (!subnet) { - return (createAnswer(CONTROL_RESULT_EMPTY, "no selected subnet")); + return (createAnswer(CONTROL_RESULT_EMPTY, "no subnet selected")); } SharedNetwork6Ptr network; subnet->getSharedNetwork(network); diff --git a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc index 1fd21ab3f0..fec8263d48 100644 --- a/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc @@ -2280,7 +2280,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, localize6Addr) { " \"remote\": \"fe80::abcd\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2332,7 +2332,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, localize6Iface) { " \"interface\": \"bar\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Same interface: the subnet is selected. @@ -2383,7 +2383,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, localize6RelayLinkaddr) { " \"link\": \"2001:db8:2::2\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range: the subnet is selected. @@ -2441,7 +2441,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, localize6RelayInterfaceId) { " \"interface-id\": \"'foobar'\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Same interface id: the subnet is selected. @@ -2494,7 +2494,7 @@ TEST_F(CtrlChannelDhcpv6SrvTest, localize6Class) { " \"remote\": \"2001:db8:1::1\"" " }" "}", response); - EXPECT_EQ("{ \"result\": 3, \"text\": \"no selected subnet\" }", + EXPECT_EQ("{ \"result\": 3, \"text\": \"no subnet selected\" }", response); // Address in range and in guard: the subnet is selected.