From: Tomek Mrugalski Date: Sat, 31 Oct 2015 11:24:04 +0000 (+0900) Subject: [4105] Changes after review: X-Git-Tag: trac4113_base~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51d5c00f676c71e534659f106c9350d9a1285b83;p=thirdparty%2Fkea.git [4105] Changes after review: - getters/setters implemented in Cfg4o6. - extra space removed. --- diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 43d5bb5251..df4550841b 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -314,8 +314,8 @@ protected: // Try 4o6 specific parameter: 4o6-interface try { string iface4o6 = string_values_->getParam("4o6-interface"); - subnet4->get4o6().iface4o6_ = iface4o6; - subnet4->get4o6().enabled_ = true; + subnet4->get4o6().setIface4o6(iface4o6); + subnet4->get4o6().enabled(true); } catch (const DhcpConfigError&) { // Don't care. 4o6-subnet is optional. } @@ -338,8 +338,8 @@ protected: isc_throw(DhcpConfigError, "Invalid prefix length specified in " "4o6-subnet parameter: " + subnet4o6 + ", expected 0..128 value"); } - subnet4->get4o6().subnet4o6_ = make_pair(IOAddress(prefix), len); - subnet4->get4o6().enabled_ = true; + subnet4->get4o6().setSubnet4o6(IOAddress(prefix), len); + subnet4->get4o6().enabled(true); } catch (const DhcpConfigError&) { // Don't care. 4o6-subnet is optional. } @@ -349,8 +349,8 @@ protected: std::string ifaceid = string_values_->getParam("4o6-interface-id"); OptionBuffer tmp(ifaceid.begin(), ifaceid.end()); OptionPtr opt(new Option(Option::V6, D6O_INTERFACE_ID, tmp)); - subnet4->get4o6().interface_id_ = opt; - subnet4->get4o6().enabled_ = true; + subnet4->get4o6().setInterfaceId(opt); + subnet4->get4o6().enabled(true); } catch (const DhcpConfigError&) { } diff --git a/src/bin/dhcp4/tests/config_parser_unittest.cc b/src/bin/dhcp4/tests/config_parser_unittest.cc index 413c98ec7d..1cfdc7ddcf 100644 --- a/src/bin/dhcp4/tests/config_parser_unittest.cc +++ b/src/bin/dhcp4/tests/config_parser_unittest.cc @@ -3812,7 +3812,7 @@ TEST_F(Dhcp4ParserTest, 4o6default) { ASSERT_TRUE(subnet); Cfg4o6& dhcp4o6 = subnet->get4o6(); - EXPECT_FALSE(dhcp4o6.enabled_); + EXPECT_FALSE(dhcp4o6.enabled()); } // Checks if the DHCPv4 is able to parse the configuration with 4o6 subnet @@ -3845,9 +3845,9 @@ TEST_F(Dhcp4ParserTest, 4o6subnet) { ASSERT_TRUE(subnet); Cfg4o6& dhcp4o6 = subnet->get4o6(); - EXPECT_TRUE(dhcp4o6.enabled_); - EXPECT_EQ(IOAddress("2001:db8::123"), dhcp4o6.subnet4o6_.first); - EXPECT_EQ(45, dhcp4o6.subnet4o6_.second); + EXPECT_TRUE(dhcp4o6.enabled()); + EXPECT_EQ(IOAddress("2001:db8::123"), dhcp4o6.getSubnet4o6().first); + EXPECT_EQ(45, dhcp4o6.getSubnet4o6().second); } // Checks if the DHCPv4 is able to parse the configuration with 4o6 network @@ -3880,8 +3880,8 @@ TEST_F(Dhcp4ParserTest, 4o6iface) { ASSERT_TRUE(subnet); Cfg4o6& dhcp4o6 = subnet->get4o6(); - EXPECT_TRUE(dhcp4o6.enabled_); - EXPECT_EQ("ethX", dhcp4o6.iface4o6_); + EXPECT_TRUE(dhcp4o6.enabled()); + EXPECT_EQ("ethX", dhcp4o6.getIface4o6()); } // Checks if the DHCPv4 is able to parse the configuration with both 4o6 network @@ -3916,10 +3916,10 @@ TEST_F(Dhcp4ParserTest, 4o6subnetIface) { // ... and that subnet has 4o6 network interface specified. Cfg4o6& dhcp4o6 = subnet->get4o6(); - EXPECT_TRUE(dhcp4o6.enabled_); - EXPECT_EQ(IOAddress("2001:db8::543"), dhcp4o6.subnet4o6_.first); - EXPECT_EQ(21, dhcp4o6.subnet4o6_.second); - EXPECT_EQ("ethX", dhcp4o6.iface4o6_); + EXPECT_TRUE(dhcp4o6.enabled()); + EXPECT_EQ(IOAddress("2001:db8::543"), dhcp4o6.getSubnet4o6().first); + EXPECT_EQ(21, dhcp4o6.getSubnet4o6().second); + EXPECT_EQ("ethX", dhcp4o6.getIface4o6()); } // Checks if the DHCPv4 is able to parse the configuration with 4o6 network @@ -3952,8 +3952,8 @@ TEST_F(Dhcp4ParserTest, 4o6subnetInterfaceId) { ASSERT_TRUE(subnet); Cfg4o6& dhcp4o6 = subnet->get4o6(); - EXPECT_TRUE(dhcp4o6.enabled_); - OptionPtr ifaceid = dhcp4o6.interface_id_; + EXPECT_TRUE(dhcp4o6.enabled()); + OptionPtr ifaceid = dhcp4o6.getInterfaceId(); ASSERT_TRUE(ifaceid); vector data = ifaceid->getData(); diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h index f0c72ece5c..54ce6a6ee0 100644 --- a/src/lib/dhcpsrv/subnet.h +++ b/src/lib/dhcpsrv/subnet.h @@ -520,6 +520,57 @@ struct Cfg4o6 { :enabled_(false), subnet4o6_(std::make_pair(asiolink::IOAddress("::"), 128u)) { } + /// @brief Returns whether the DHCP4o6 is enabled or not. + /// @return true if enabled + bool enabled() const { + return (enabled_); + } + + /// @brief Sets the DHCP4o6 enabled status. + /// @param enabled specifies if the DHCP4o6 should be enabled or not + void enabled(bool enabled) { + enabled_ = enabled; + } + + /// @brief Returns the DHCP4o6 interface. + /// @return value of the 4o6-interface parameter. + std::string getIface4o6() const { + return (iface4o6_); + } + + /// @brief Sets the 4o6-interface. + /// @param iface name of the network interface the 4o6 traffic is received on + void setIface4o6(const std::string& iface) { + iface4o6_ = iface; + } + + /// @brief Returns prefix/len for the IPv6 subnet. + /// @return prefix/length pair + std::pair getSubnet4o6() const { + return (subnet4o6_); + } + + /// @brief Sets the prefix/length information (content of the 4o6-subnet). + /// @param subnet IOAddress that represents a prefix + /// @param prefix specifies prefix length + void setSubnet4o6(const asiolink::IOAddress& subnet, uint8_t prefix) { + subnet4o6_ = std::make_pair(subnet, prefix); + } + + /// @brief Returns the interface-id. + /// @return the option representing interface-id (or NULL) + OptionPtr getInterfaceId() const { + return (interface_id_); + } + + /// @brief Sets the interface-id + /// @param opt option to be used as interface-id match + void setInterfaceId(const OptionPtr& opt) { + interface_id_ = opt; + } + +private: + /// Specifies if 4o6 is enabled on this subnet. bool enabled_; @@ -616,7 +667,6 @@ private: /// lookup. bool match_client_id_; - /// @brief All the information related to DHCP4o6 Cfg4o6 dhcp4o6_; };