]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[567-remove-lease-t1_-and-t2_-members] Reimplemented getTeeTimes
authorFrancis Dupont <fdupont@isc.org>
Wed, 5 Jun 2019 10:52:46 +0000 (12:52 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 19 Jun 2019 06:43:03 +0000 (02:43 -0400)
src/bin/dhcp6/tests/dhcp6_client.cc
src/bin/dhcp6/tests/dhcp6_client.h

index a8b34c05d89f3d1ce7b4d4f535ef48002fee2c67..74f375bef0dd48be084722f0543fbf17c71611f9 100644 (file)
@@ -868,14 +868,32 @@ Dhcp6Client::getStatusCode(const uint32_t iaid) const {
 
 bool
 Dhcp6Client::getTeeTimes(const uint32_t iaid, uint32_t& t1, uint32_t& t2) const {
-
-    auto leases = getLeasesByIAID(iaid);
-    if (leases.empty()) {
-        // No aquired leases so punt.
+    // Sanity check.
+    if (!context_.response_) {
         return (false);
     }
 
-    return (true);
+    // Get all options in the response message and pick IA_NA, IA_PD.
+    OptionCollection opts = context_.response_->options_;
+
+    for (auto opt = opts.begin(); opt != opts.end(); ++opt) {
+        Option6IAPtr ia = boost::dynamic_pointer_cast<Option6IA>(opt->second);
+        if (!ia) {
+            // This is not IA, so let's just skip it.
+            continue;
+        }
+        if (ia->getIAID() != iaid) {
+            // This is not the right IA, so let's just skip it.
+            continue;
+        }
+        // Found the IA.
+        t1 = ia->getT1();
+        t2 = ia->getT2();
+        return (true);
+    }
+
+    // Not found the IA.
+    return (false);
 }
 
 void
index f69f3ab1ae55e7f69fbb1d3a67f5c13e65a80cd2..0fb1cc382cd1f636ffd8595583a6e71eaa36ea83 100644 (file)
@@ -505,21 +505,13 @@ public:
 
     /// @brief Returns T1 and T2 timers associated with a given iaid
     ///
-    /// Currently this method gleans the T1 an T2 times from the first
-    /// aquired lease belonging to the target iaid.  Since all leases for
-    /// an iaid should have the same values for T1 and T2, this should be 
-    /// fine.  If there are no acquired leases for the iaid, then t1 and
-    /// t2 are indeterminate.
+    /// Changed to get the T1 an T2 times from acquired leases to
+    /// IA options.
     ///
-    /// The primary impetus for this method is isolate the fact that T1
-    /// and T2 are stored on each lease.  This may change in the future. 
-    ///
-    /// @param iaid  iaid of the target IA
+    /// @param iaid iaid of the target IA
     /// @param[out] t1 set to the value of the IA's T1
     /// @param[out] t2 set to the value of the IA's T2
-    /// if there are no leases for the iaid
-    ///
-    /// @return true if there are aquired leases for the given iaid
+    /// @return true if there is an IA option for the given iaid
     bool getTeeTimes(const uint32_t iaid, uint32_t& t1, uint32_t& t2) const;
 
     /// @brief Returns number of acquired leases.