mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[4105] Changes after review:
- getters/setters implemented in Cfg4o6. - extra space removed.
This commit is contained in:
@@ -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&) {
|
||||
|
||||
}
|
||||
|
@@ -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<uint8_t> data = ifaceid->getData();
|
||||
|
@@ -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<asiolink::IOAddress, uint8_t> 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_;
|
||||
};
|
||||
|
Reference in New Issue
Block a user