}
}
+ const std::vector<uint8_t>&
+ Lease4::getClientIdVector() const {
+ if(!client_id_) {
+ static std::vector<uint8_t> 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) {
/// @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<uint8_t>& 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.
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<uint8_t>& 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