From: Marcin Siodelski Date: Mon, 8 Jun 2015 12:50:59 +0000 (+0200) Subject: [3070] Added Rapid Commit flag to Subnet6. X-Git-Tag: trac3732a_base~15^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e683b702be81cbc763a05d23e997f6c11e719e6;p=thirdparty%2Fkea.git [3070] Added Rapid Commit flag to Subnet6. --- diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc index c5b775b302..36f1ae19ec 100644 --- a/src/lib/dhcpsrv/subnet.cc +++ b/src/lib/dhcpsrv/subnet.cc @@ -329,8 +329,8 @@ Subnet6::Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length, const Triplet& preferred_lifetime, const Triplet& 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"); diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h index 4d630cc50e..5a025dacf0 100644 --- a/src/lib/dhcpsrv/subnet.h +++ b/src/lib/dhcpsrv/subnet.h @@ -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 preferred_; + + /// @brief A flag indicating if Rapid Commit option is supported + /// for this subnet. + bool rapid_commit_; }; /// @brief A pointer to a Subnet6 object diff --git a/src/lib/dhcpsrv/tests/subnet_unittest.cc b/src/lib/dhcpsrv/tests/subnet_unittest.cc index 58377ac396..b5b3021cb0 100644 --- a/src/lib/dhcpsrv/tests/subnet_unittest.cc +++ b/src/lib/dhcpsrv/tests/subnet_unittest.cc @@ -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");