Commit 0e683b70 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3070] Added Rapid Commit flag to Subnet6.

parent c5430032
......@@ -329,8 +329,8 @@ Subnet6::Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
const Triplet<uint32_t>& preferred_lifetime,
const Triplet<uint32_t>& valid_lifetime,
const SubnetID id)
:Subnet(prefix, length, t1, t2, valid_lifetime, RelayInfo(IOAddress("::")), id),
preferred_(preferred_lifetime) {
:Subnet(prefix, length, t1, t2, valid_lifetime, RelayInfo(IOAddress("::")), id),
preferred_(preferred_lifetime), rapid_commit_(false) {
if (!prefix.isV6()) {
isc_throw(BadValue, "Non IPv6 prefix " << prefix
<< " specified in subnet6");
......
......@@ -639,7 +639,23 @@ public:
return interface_id_;
}
protected:
/// @brief Enables or disables Rapid Commit option support for the subnet.
///
/// @param rapid_commit A boolean value indicating that the Rapid Commit
/// option support is enabled (if true), or disabled (if false).
void setRapidCommit(const bool rapid_commit) {
rapid_commit_ = rapid_commit;
};
/// @brief Returns boolean value indicating that the Rapid Commit option
/// is supported or unsupported for the subnet.
///
/// @return true if the Rapid Commit option is supported, false otherwise.
bool getRapidCommit() const {
return (rapid_commit_);
}
private:
/// @brief Returns default address for pool selection
/// @return ANY IPv6 address
......@@ -660,6 +676,10 @@ protected:
/// @brief a triplet with preferred lifetime (in seconds)
Triplet<uint32_t> preferred_;
/// @brief A flag indicating if Rapid Commit option is supported
/// for this subnet.
bool rapid_commit_;
};
/// @brief A pointer to a Subnet6 object
......
......@@ -1041,6 +1041,24 @@ TEST(Subnet6Test, interfaceId) {
}
// This test checks that the Rapid Commit support can be enabled or
// disabled for a subnet. It also checks that the Rapid Commit is
// support is disabled by default.
TEST(Subnet6Test, rapidCommit) {
Subnet6 subnet(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4);
// By default, the RC should be disabled.
EXPECT_FALSE(subnet.getRapidCommit());
// Enable Rapid Commit.
subnet.setRapidCommit(true);
EXPECT_TRUE(subnet.getRapidCommit());
// Disable again.
subnet.setRapidCommit(false);
EXPECT_FALSE(subnet.getRapidCommit());
}
// Checks if last allocated address/prefix is stored/retrieved properly
TEST(Subnet6Test, lastAllocated) {
IOAddress ia("2001:db8:1::1");
......
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