From: Francis Dupont Date: Wed, 5 Jun 2019 10:52:46 +0000 (+0200) Subject: [567-remove-lease-t1_-and-t2_-members] Reimplemented getTeeTimes X-Git-Tag: Kea-1.6.0-beta2~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6072db5f4ca6cfa9573152c255f97dd170acbd57;p=thirdparty%2Fkea.git [567-remove-lease-t1_-and-t2_-members] Reimplemented getTeeTimes --- diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index a8b34c05d8..74f375bef0 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -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(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 diff --git a/src/bin/dhcp6/tests/dhcp6_client.h b/src/bin/dhcp6/tests/dhcp6_client.h index f69f3ab1ae..0fb1cc382c 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.h +++ b/src/bin/dhcp6/tests/dhcp6_client.h @@ -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.