From: Marcin Siodelski Date: Fri, 22 Nov 2013 08:30:36 +0000 (+0100) Subject: [master] Merge branch 'trac2940' X-Git-Tag: bind10-1.2.0beta1-release~102^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a232f3d7d92ebcfb7793dc6b67914299c45c715b;p=thirdparty%2Fkea.git [master] Merge branch 'trac2940' Conflicts: src/lib/dhcpsrv/lease.cc src/lib/dhcpsrv/lease.h --- a232f3d7d92ebcfb7793dc6b67914299c45c715b diff --cc src/lib/dhcpsrv/lease.cc index 2e4bf2e4eb,a9e3d4bfc4..4ca6a3ce0b --- a/src/lib/dhcpsrv/lease.cc +++ b/src/lib/dhcpsrv/lease.cc @@@ -74,26 -74,16 +74,36 @@@ Lease4::Lease4(const Lease4& other } } + const std::vector& + Lease4::getClientIdVector() const { + if(!client_id_) { + static std::vector empty_vec; + return (empty_vec); + } + + return (client_id_->getClientId()); + } + +bool +Lease4::matches(const Lease4& other) const { + if ((client_id_ && !other.client_id_) || + (!client_id_ && other.client_id_)) { + // One lease has client-id, but the other doesn't + return false; + } + + if (client_id_ && other.client_id_ && + *client_id_ != *other.client_id_) { + // Different client-ids + return false; + } + + return (addr_ == other.addr_ && + ext_ == other.ext_ && + hwaddr_ == other.hwaddr_); + +} + Lease4& Lease4::operator=(const Lease4& other) { if (this != &other) { diff --cc src/lib/dhcpsrv/lease.h index 0f0cb3cec6,1bf6796fb2..86266205c9 --- a/src/lib/dhcpsrv/lease.h +++ b/src/lib/dhcpsrv/lease.h @@@ -209,20 -209,17 +209,31 @@@ struct Lease4 : public Lease /// @param other the @c Lease4 object to be copied. Lease4(const Lease4& other); + /// @brief Returns a client identifier. + /// + /// @warning Since the function returns the reference to a vector (not a + /// copy), the returned object should be used with caution because it will + /// remain valid only for the period of time when an object which returned + /// it exists. + /// + /// @return A reference to a vector holding client identifier, + /// or an empty vector if client identifier is NULL. + const std::vector& getClientIdVector() const; + + /// @brief Check if two objects encapsulate the lease for the same + /// client. + /// + /// Checks if two @c Lease4 objects have the same address, client id, + /// HW address and ext_ value. If these parameters match it is an + /// indication that both objects describe the lease for the same + /// client but apparently one is a result of renewal of the other. The + /// special case of the matching lease is the one that is equal to another. + /// + /// @param other A lease to compare with. + /// + /// @return true if the selected parameters of the two leases match. + bool matches(const Lease4& other) const; + /// @brief Assignment operator. /// /// @param other the @c Lease4 object to be assigned. @@@ -334,20 -331,16 +345,30 @@@ struct Lease6 : public Lease type_(TYPE_NA) { } + /// @brief Returns a reference to a vector representing a DUID. + /// + /// @warning Since the function returns the reference to a vector (not a + /// copy), the returned object should be used with caution because it will + /// remain valid only for the period of time when an object which returned + /// it exists. + /// + /// @return A reference to a vector holding a DUID. + const std::vector& getDuidVector() const; + + /// @brief Checks if two lease objects encapsulate the lease for the same + /// client. + /// + /// This function compares address, type, prefix length, IAID and DUID + /// parameters between two @c Lease6 objects. If these parameters match + /// it is an indication that both objects describe the lease for the same + /// client but apparently one is a result of renewal of the other. The + /// special case of the matching lease is the one that is equal to another. + /// + /// @param other A lease to compare to. + /// + /// @return true if selected parameters of the two leases match. + bool matches(const Lease6& other) const; + /// @brief Compare two leases for equality /// /// @param other lease6 object with which to compare