static constexpr StatementTag DELETE_LEASE6 = "DELETE_LEASE6";
static constexpr StatementTag GET_LEASE6_EXPIRE = "GET_LEASE6_EXPIRE";
static constexpr StatementTag GET_LEASE6_ADDR = "GET_LEASE6_ADDR";
+ static constexpr StatementTag GET_LEASE6_DUID = "GET_LEASE6_DUID";
static constexpr StatementTag GET_LEASE6_DUID_IAID = "GET_LEASE6_DUID_IAID";
static constexpr StatementTag GET_LEASE6_DUID_IAID_SUBID = "GET_LEASE6_DUID_IAID_SUBID";
static constexpr StatementTag GET_LEASE6_LIMIT = "GET_LEASE6_LIMIT";
constexpr StatementTag CqlLease6Exchange::DELETE_LEASE6;
constexpr StatementTag CqlLease6Exchange::GET_LEASE6_EXPIRE;
constexpr StatementTag CqlLease6Exchange::GET_LEASE6_ADDR;
+constexpr StatementTag CqlLease6Exchange::GET_LEASE6_DUID;
constexpr StatementTag CqlLease6Exchange::GET_LEASE6_DUID_IAID;
constexpr StatementTag CqlLease6Exchange::GET_LEASE6_DUID_IAID_SUBID;
constexpr StatementTag CqlLease6Exchange::GET_LEASE6_LIMIT;
"AND lease_type = ? "
"ALLOW FILTERING "}},
+ // Gets an IPv6 lease with specified duid
+ {GET_LEASE6_DUID,
+ {GET_LEASE6_DUID,
+ "SELECT "
+ "address, valid_lifetime, expire, subnet_id, pref_lifetime, duid, iaid, "
+ "lease_type, prefix_len, fqdn_fwd, fqdn_rev, hostname, hwaddr, hwtype, "
+ "hwaddr_source, state "
+ "FROM lease6 "
+ "WHERE duid = ? "
+ "ALLOW FILTERING "}},
+
// Gets an IPv6 lease(s) with specified duid and iaid
{GET_LEASE6_DUID_IAID,
{GET_LEASE6_DUID_IAID,
return (result);
}
+Lease6Collection
+CqlLeaseMgr::getLeases6(const DUID& duid) const {
+
+ // Set up the WHERE clause value
+ AnyArray data;
+
+ CassBlob duid_data(duid.getDuid());
+
+ data.add(&duid_data);
+
+ // Get the data.
+ Lease6Collection result;
+ std::unique_ptr<CqlLease6Exchange> exchange6(new CqlLease6Exchange(dbconn_));
+ exchange6->getLeaseCollection(CqlLease6Exchange::GET_LEASE6_DUID, data, result);
+
+ return (result);
+
+}
+
Lease6Collection
CqlLeaseMgr::getLeases6(Lease::Type lease_type, const DUID &duid, uint32_t iaid) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_IAID_DUID)
/// this backend.
virtual Lease6Collection getLeases6() const override;
+ /// @brief Returns all IPv6 leases.
+ ///
+ /// @return Lease collection (may be empty if no IPv6 lease found).
+ virtual Lease6Collection getLeases6(const DUID& duid) const;
+
/// @brief Returns range of IPv6 leases using paging.
///
/// This method implements paged browsing of the lease database. The first
/// @return Lease collection (may be empty if no IPv6 lease found).
virtual Lease6Collection getLeases6() const = 0;
+ /// @brief Returns collection of lease for matching DUID
+ ///
+ /// @return Lease collection (may be empty if no IPv6 lease found for the DUID).
+ virtual Lease6Collection getLeases6(const DUID& duid) const = 0;
+
/// @brief Returns range of IPv6 leases using paging.
///
/// This method implements paged browsing of the lease database. The first
return (collection);
}
+Lease6Collection
+Memfile_LeaseMgr::getLeases6(const DUID& duid) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MEMFILE_GET6);
+
+ Lease6Collection collection;
+ for (auto lease = storage6_.begin(); lease != storage6_.end(); ++lease ) {
+ if ( (**lease).duid_->getDuid() == duid.getDuid() )
+ collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ }
+
+ return (collection);
+}
+
Lease6Collection
Memfile_LeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const {
///
/// @return Lease collection (may be empty if no IPv6 lease found).
virtual Lease6Collection getLeases6() const;
+
+ /// @brief Returns IPv6 leases for the DUID.
+ ///
+ /// @todo: implement an optimised of the query using index.
+ /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID.
+ virtual Lease6Collection getLeases6(const DUID& duid) const;
/// @brief Returns range of IPv6 leases using paging.
///
"state, user_context "
"FROM lease6 "
"WHERE address = ? AND lease_type = ?"},
- {MySqlLeaseMgr::GET_LEASE6_DUID_IAID,
+ {MySqlLeaseMgr::GET_LEASE6_DUID_IAID,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len, "
return (result);
}
+Lease6Collection
+MySqlLeaseMgr::getLeases6(const DUID& duid) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_DUID);
+
+ Lease6Collection result = getLeases6();
+
+ //erase the ones not containing the matching DUID
+ for (auto iter = result.begin(); iter != result.end();
+ iter++) {
+ if ((*iter)->duid_->getDuid() != duid.getDuid()) {
+ result.erase(iter);
+ }
+ }
+
+ return result;
+}
+
Lease6Collection
MySqlLeaseMgr::getLeases6(const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) const {
///
/// @return Lease collection (may be empty if no IPv6 lease found).
virtual Lease6Collection getLeases6() const;
+
+ /// @brief Returns all IPv6 leases for the DUID.
+ ///
+ /// @todo: implement an optimised of the query using index.
+ /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID.
+ virtual Lease6Collection getLeases6(const DUID& duid) const;
/// @brief Returns range of IPv6 leases using paging.
///
return (result);
}
+Lease6Collection
+PgSqlLeaseMgr::getLeases6( const DUID& duid ) const {
+ LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
+ DHCPSRV_PGSQL_GET_DUID)
+ .arg(duid.toText());
+
+ Lease6Collection result = getLeases6();
+
+ //erase the ones not containing the matching DUID
+ for (auto iter = result.begin(); iter != result.end();
+ iter++) {
+ if ((*iter)->duid_->getDuid() != duid.getDuid()) {
+ result.erase(iter);
+ }
+ }
+
+ return (result);
+}
+
Lease6Collection
PgSqlLeaseMgr::getLeases6() const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET6);
///
/// @return Lease collection (may be empty if no IPv6 lease found).
virtual Lease6Collection getLeases6() const;
+
+ /// @brief Returns IPv6 leases for the DUID.
+ ///
+ /// @todo: implement an optimised of the query using index.
+ /// @return Lease collection (may be empty if no IPv6 lease found) for the DUID
+ virtual Lease6Collection getLeases6(const DUID& duid) const;
/// @brief Returns range of IPv6 leases using paging.
///
return (leases6_);
}
+ /// @brief Returns collection of lease for matching DUID
+ ///
+ /// @param duid ignored
+ /// @return whatever is set in leases6_ field
+ virtual Lease6Collection getLeases6(const DUID& duid) const {
+ return (leases6_);
+ }
+
/// @brief Returns all IPv6 leases for the particular subnet identifier.
///
/// @param subnet_id subnet identifier.
}
HostPtr
-HostDataSourceUtils::initializeHost6(std::string address,
+HostDataSourceUtils::initializeHost6(const std::string address,
Host::IdentifierType identifier,
bool prefix,
bool new_identifier,
++subnet4;
++subnet6;
+ std::string default_string;
HostPtr host(new Host(&ident[0], ident.size(), identifier, subnet4, subnet6,
IOAddress("0.0.0.0")));