A debug message issued when the server is attempting to obtain an IPv4
lease from the memory file database for the specified address.
-% DHCPSRV_MEMFILE_GET_ADDR6 obtaining IPv6 lease for address %1
+% DHCPSRV_MEMFILE_GET_ADDR6 obtaining IPv6 lease for address %1 and lease type %2
A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for the specified address.
IPv4 leases from the memory file database for a client with the specified
hardware address.
-% DHCPSRV_MEMFILE_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2
+% DHCPSRV_MEMFILE_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2 and lease type %3
A debug message issued when the server is attempting to obtain a set of
IPv6 lease from the memory file database for a client with the specified
IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
-% DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2 and DUID %3
+% DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2, DUID %3 and lease type %4
A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
}
Lease6Ptr
-Memfile_LeaseMgr::getLease6(Lease::Type /* not used yet */,
+Memfile_LeaseMgr::getLease6(Lease::Type type,
const isc::asiolink::IOAddress& addr) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_MEMFILE_GET_ADDR6).arg(addr.toText());
-
+ DHCPSRV_MEMFILE_GET_ADDR6)
+ .arg(addr.toText())
+ .arg(Lease::typeToText(type));
Lease6Storage::iterator l = storage6_.find(addr);
- if (l == storage6_.end()) {
+ if (l == storage6_.end() || !(*l) || ((*l)->type_ != type)) {
return (Lease6Ptr());
} else {
return (Lease6Ptr(new Lease6(**l)));
}
Lease6Collection
-Memfile_LeaseMgr::getLeases6(Lease::Type /* not used yet */,
+Memfile_LeaseMgr::getLeases6(Lease::Type type,
const DUID& duid, uint32_t iaid) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
- DHCPSRV_MEMFILE_GET_IAID_DUID).arg(iaid).arg(duid.toText());
+ DHCPSRV_MEMFILE_GET_IAID_DUID)
+ .arg(iaid)
+ .arg(duid.toText())
+ .arg(Lease::typeToText(type));
- /// @todo Not implemented.
+ // We are going to use index #1 of the multi index container.
+ typedef Lease6Storage::nth_index<1>::type SearchIndex;
+ // Get the index.
+ const SearchIndex& idx = storage6_.get<1>();
+ // Try to get the lease using the DUID, IAID and lease type.
+ std::pair<SearchIndex::iterator, SearchIndex::iterator> l =
+ idx.equal_range(boost::make_tuple(duid.getDuid(), iaid, type));
+ Lease6Collection collection;
+ for(SearchIndex::iterator lease = l.first; lease != l.second; ++lease) {
+ collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ }
- return (Lease6Collection());
+ return (collection);
}
Lease6Collection
-Memfile_LeaseMgr::getLeases6(Lease::Type /* not used yet */,
+Memfile_LeaseMgr::getLeases6(Lease::Type type,
const DUID& duid, uint32_t iaid,
SubnetID subnet_id) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID)
- .arg(iaid).arg(subnet_id).arg(duid.toText());
+ .arg(iaid)
+ .arg(subnet_id)
+ .arg(duid.toText())
+ .arg(Lease::typeToText(type));
// We are going to use index #1 of the multi index container.
- // We define SearchIndex locally in this function because
- // currently only this function uses this index.
typedef Lease6Storage::nth_index<1>::type SearchIndex;
// Get the index.
const SearchIndex& idx = storage6_.get<1>();
- // Try to get the lease using the DUID, IAID and Subnet ID.
- SearchIndex::const_iterator lease =
- idx.find(boost::make_tuple(duid.getDuid(), iaid, subnet_id));
- // Lease was not found. Return empty pointer.
- if (lease == idx.end()) {
- return (Lease6Collection());
+ // Try to get the lease using the DUID, IAID and lease type.
+ std::pair<SearchIndex::iterator, SearchIndex::iterator> l =
+ idx.equal_range(boost::make_tuple(duid.getDuid(), iaid, type));
+ Lease6Collection collection;
+ for(SearchIndex::iterator lease = l.first; lease != l.second; ++lease) {
+ // Filter out the leases which subnet id doesn't match.
+ if((*lease)->subnet_id_ == subnet_id) {
+ collection.push_back(Lease6Ptr(new Lease6(**lease)));
+ }
}
- // Lease was found, return it to the caller.
- /// @todo: allow multiple leases for a single duid+iaid+subnet_id tuple
- Lease6Collection collection;
- collection.push_back(Lease6Ptr(new Lease6(**lease)));
return (collection);
}
virtual Lease6Ptr getLease6(Lease::Type type,
const isc::asiolink::IOAddress& addr) const;
- /// @brief Returns existing IPv6 lease for a given DUID+IA combination
- ///
- /// @todo Not implemented yet
+ /// @brief Returns existing IPv6 lease for a given DUID + IA + lease type
+ /// combination
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
virtual Lease6Collection getLeases6(Lease::Type type,
const DUID& duid, uint32_t iaid) const;
- /// @brief Returns existing IPv6 lease for a given DUID/IA/subnet-id tuple
+ /// @brief Returns existing IPv6 lease for a given DUID + IA + subnet-id +
+ /// lease type combination.
///
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @return lease collection (may be empty if no lease is found)
virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
- uint32_t iaid, SubnetID subnet_id) const;
+ uint32_t iaid,
+ SubnetID subnet_id) const;
/// @brief Updates IPv4 lease.
///
/// will not be written to disk.
///
/// @param u Universe (v4 or v6)
- /// @param parameters Map holding parameters of the Lease Manager, passed to
- /// the constructor.
///
/// @return The location of the lease file that should be assigned to the
/// lease_file4_ or lease_file6_, depending on the universe specified as an
>,
// Specification of the second index starts here.
- boost::multi_index::ordered_unique<
+ boost::multi_index::ordered_non_unique<
// This is a composite index that will be used to search for
- // the lease using three attributes: DUID, IAID, Subnet Id.
+ // the lease using three attributes: DUID, IAID and lease type.
boost::multi_index::composite_key<
Lease6,
// The DUID can be retrieved from the Lease6 object using
boost::multi_index::const_mem_fun<Lease6, const std::vector<uint8_t>&,
&Lease6::getDuidVector>,
// The two other ingredients of this index are IAID and
- // subnet id.
+ // lease type.
boost::multi_index::member<Lease6, uint32_t, &Lease6::iaid_>,
- boost::multi_index::member<Lease, SubnetID, &Lease::subnet_id_>
+ boost::multi_index::member<Lease6, Lease::Type, &Lease6::type_>
>
>
>
/// a combination of DUID and IAID.
/// @todo: test disabled, because Memfile_LeaseMgr::getLeases6(Lease::Type,
/// const DUID& duid, uint32_t iaid) const is not implemented yet.
-TEST_F(MemfileLeaseMgrTest, DISABLED_getLeases6DuidIaid) {
+TEST_F(MemfileLeaseMgrTest, getLeases6DuidIaid) {
startBackend(V6);
testGetLeases6DuidIaid();
}
/// @todo: test disabled, because Memfile_LeaseMgr::getLeases6(Lease::Type,
/// const DUID& duid, uint32_t iaid) const is not implemented yet.
-TEST_F(MemfileLeaseMgrTest, DISABLED_getLeases6DuidSize) {
+TEST_F(MemfileLeaseMgrTest, getLeases6DuidSize) {
startBackend(V6);
testGetLeases6DuidSize();
}
/// discriminate between the leases based on lease type alone.
/// @todo: Disabled, because type parameter in Memfile_LeaseMgr::getLease6
/// (Lease::Type, const isc::asiolink::IOAddress& addr) const is not used.
-TEST_F(MemfileLeaseMgrTest, DISABLED_lease6LeaseTypeCheck) {
+TEST_F(MemfileLeaseMgrTest, lease6LeaseTypeCheck) {
startBackend(V6);
testLease6LeaseTypeCheck();
}