Commit 6072db5f authored by Francis Dupont's avatar Francis Dupont
Browse files

[567-remove-lease-t1_-and-t2_-members] Reimplemented getTeeTimes

parent 7088f78b
......@@ -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);
}
// 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
......
......@@ -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.
///
/// 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.
/// Changed to get the T1 an T2 times from acquired leases to
/// IA options.
///
/// @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.
......
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