]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3070] Added Rapid Commit flag to Subnet6.
authorMarcin Siodelski <marcin@isc.org>
Mon, 8 Jun 2015 12:50:59 +0000 (14:50 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 9 Jun 2015 10:31:31 +0000 (12:31 +0200)
src/lib/dhcpsrv/subnet.cc
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/tests/subnet_unittest.cc

index c5b775b302517cf26d9f598393b8f0e75c13363d..36f1ae19ec000e6d986b1960bc39a21057c1c112 100644 (file)
@@ -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");
index 4d630cc50e84fedbe03343f4738eeb6b761b62da..5a025dacf02133b99a8ecf29c0b58b3a97551e1b 100644 (file)
@@ -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
index 58377ac39611365097790ee7c8a34423c9c69677..b5b3021cb011f56f48868d205be093dfd9c65a51 100644 (file)
@@ -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");