Lease6Collection leases;
vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
vector<uint8_t> relay_bin(8, 0x64);
DuidPtr relay_id(new DUID(relay_bin));
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
// Check that BLQ tables were updated.
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
// The lease must be retrieved from the remote id table.
// The lease must be retrieved from the relay id table.
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
ASSERT_EQ(1, leases.size());
Lease6Collection leases;
vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
vector<uint8_t> relay_bin(8, 0x64);
DuidPtr relay_id(new DUID(relay_bin));
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
// Check that BLQ tables were updated.
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
// The lease must be retrieved from the remote id table.
// The lease must be retrieved from the relay id table.
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
ASSERT_EQ(1, leases.size());
Lease6Collection leases;
vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
vector<uint8_t> relay_bin(8, 0x64);
DuidPtr relay_id(new DUID(relay_bin));
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
EXPECT_TRUE(leases.empty());
// Check that BLQ tables were updated.
leases = lmptr_->getLeases6ByRemoteId(remote_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
ASSERT_EQ(1, leases.size());
EXPECT_EQ(IOAddress("2001:db8:1::2"), lx->addr_);
EXPECT_EQ(*lease2, *lx);
leases = lmptr_->getLeases6ByRelayId(*relay_id,
- IOAddress::IPV6_ZERO_ADDRESS(),
- 0,
IOAddress::IPV6_ZERO_ADDRESS(),
LeasePageSize(10));
ASSERT_EQ(1, leases.size());
"DHCPSRV_MEMFILE_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MEMFILE_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
- "DHCPSRV_MEMFILE_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5",
+ "DHCPSRV_MEMFILE_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3",
"DHCPSRV_MEMFILE_GET_REMOTEID4", "obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5",
- "DHCPSRV_MEMFILE_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5",
+ "DHCPSRV_MEMFILE_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3",
"DHCPSRV_MEMFILE_GET_SUBID4", "obtaining IPv4 leases for subnet ID %1",
"DHCPSRV_MEMFILE_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_MEMFILE_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
"DHCPSRV_MYSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_MYSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_MYSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
- "DHCPSRV_MYSQL_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5",
+ "DHCPSRV_MYSQL_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3",
"DHCPSRV_MYSQL_GET_REMOTEID4", "obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5",
- "DHCPSRV_MYSQL_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5",
+ "DHCPSRV_MYSQL_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3",
"DHCPSRV_MYSQL_GET_SUBID4", "obtaining IPv4 leases for subnet ID %1",
"DHCPSRV_MYSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_MYSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
"DHCPSRV_PGSQL_GET_PAGE4", "obtaining at most %1 IPv4 leases starting from address %2",
"DHCPSRV_PGSQL_GET_PAGE6", "obtaining at most %1 IPv6 leases starting from address %2",
"DHCPSRV_PGSQL_GET_RELAYID4", "obtaining at most %1 IPv4 leases starting from address %2 with relay id %3 and cltt between %4 and %5",
- "DHCPSRV_PGSQL_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5",
+ "DHCPSRV_PGSQL_GET_RELAYID6", "obtaining at most %1 IPv6 leases starting from address %2 with relay id %3",
"DHCPSRV_PGSQL_GET_REMOTEID4", "obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5",
- "DHCPSRV_PGSQL_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5",
+ "DHCPSRV_PGSQL_GET_REMOTEID6", "obtaining at most %1 IPv6 leases starting from address %2 with remote id %3",
"DHCPSRV_PGSQL_GET_SUBID4", "obtaining IPv4 leases for subnet ID %1",
"DHCPSRV_PGSQL_GET_SUBID6", "obtaining IPv6 leases for subnet ID %1",
"DHCPSRV_PGSQL_GET_SUBID_CLIENTID", "obtaining IPv4 lease for subnet ID %1 and client ID %2",
IPv4 leases beginning with the specified address with a relay id and client
transaction time between start and end dates.
-% DHCPSRV_MEMFILE_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5
+% DHCPSRV_MEMFILE_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a relay id and a link.
+IPv6 leases beginning with the specified address with a relay id.
% DHCPSRV_MEMFILE_GET_REMOTEID4 obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5
A debug message issued when the server is attempting to obtain a page of
IPv4 leases beginning with the specified address with a remote id and
client transaction time between start and end dates.
-% DHCPSRV_MEMFILE_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5
+% DHCPSRV_MEMFILE_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a remote id and a link.
+IPv6 leases beginning with the specified address with a remote id.
% DHCPSRV_MEMFILE_GET_SUBID4 obtaining IPv4 leases for subnet ID %1
A debug message issued when the server is attempting to obtain all IPv4
IPv4 leases beginning with the specified address with a relay id and client
transaction time between start and end dates.
-% DHCPSRV_MYSQL_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5
+% DHCPSRV_MYSQL_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a relay id and a link.
+IPv6 leases beginning with the specified address with a relay id.
% DHCPSRV_MYSQL_GET_REMOTEID4 obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5
A debug message issued when the server is attempting to obtain a page of
IPv4 leases beginning with the specified address with a remote id and client
transaction time between start and end dates.
-% DHCPSRV_MYSQL_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5
+% DHCPSRV_MYSQL_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a remote id and a link.
+IPv6 leases beginning with the specified address with a remote id.
% DHCPSRV_MYSQL_GET_SUBID4 obtaining IPv4 leases for subnet ID %1
A debug message issued when the server is attempting to obtain all IPv4
IPv4 leases beginning with the specified address with a relay id and client
transaction time between start and end dates.
-% DHCPSRV_PGSQL_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3 and link %4/%5
+% DHCPSRV_PGSQL_GET_RELAYID6 obtaining at most %1 IPv6 leases starting from address %2 with relay id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a relay id and a link.
+IPv6 leases beginning with the specified address with a relay id.
% DHCPSRV_PGSQL_GET_REMOTEID4 obtaining at most %1 IPv4 leases starting from address %2 with remote id %3 and cltt between %4 and %5
A debug message issued when the server is attempting to obtain a page of
IPv4 leases beginning with the specified address with a remote id and client
transaction time between start and end dates.
-% DHCPSRV_PGSQL_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3 and link %4/%5
+% DHCPSRV_PGSQL_GET_REMOTEID6 obtaining at most %1 IPv6 leases starting from address %2 with remote id %3
A debug message issued when the server is attempting to obtain a page of
-IPv6 leases beginning with the specified address with a remote id and a link.
+IPv6 leases beginning with the specified address with a remote id.
% DHCPSRV_PGSQL_GET_SUBID4 obtaining IPv4 leases for subnet ID %1
A debug message issued when the server is attempting to obtain all IPv4
/// @brief Returns existing IPv6 leases with a given relay-id.
///
/// @param relay_id DUID for relay_id of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv6 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRelayId(const DUID& relay_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) = 0;
/// @brief Returns existing IPv6 leases with a given remote-id.
///
/// @param remote_id remote-id option data of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv6 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) = 0;
Lease6Collection
Memfile_LeaseMgr::getLeases6ByRelayId(const DUID& relay_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MEMFILE_GET_RELAYID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(relay_id.toText())
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(relay_id.toText());
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 address while "
"retrieving leases from the lease database, got "
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
return (getLeases6ByRelayIdInternal(relay_id,
- link_addr,
- link_len,
lower_bound_address,
page_size));
} else {
return (getLeases6ByRelayIdInternal(relay_id,
- link_addr,
- link_len,
lower_bound_address,
page_size));
}
Lease6Collection
Memfile_LeaseMgr::getLeases6ByRelayIdInternal(const DUID& relay_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
const std::vector<uint8_t>& relay_id_data = relay_id.getDuid();
Lease6Collection collection;
const RelayIdIndex& idx = relay_id6_.get<RelayIdIndexTag>();
- if (!link_len) {
- RelayIdIndex::const_iterator lb =
- idx.lower_bound(boost::make_tuple(relay_id_data,
- lower_bound_address));
-
- // Return all leases being within the page size.
- IOAddress last_addr = lower_bound_address;
- for (; lb != idx.end(); ++lb) {
- if ((*lb)->lease_addr_ == last_addr) {
- // Already seen: skip it.
- continue;
- }
- if ((*lb)->id_ != relay_id_data) {
- // Gone after the relay id index.
- break;
- }
- last_addr = (*lb)->lease_addr_;
- Lease6Ptr lease = getAnyLease6Internal(last_addr);
- if (lease) {
- collection.push_back(lease);
- if (collection.size() >= page_size.page_size_) {
- break;
- }
- }
+ RelayIdIndex::const_iterator lb =
+ idx.lower_bound(boost::make_tuple(relay_id_data, lower_bound_address));
+
+ // Return all leases being within the page size.
+ IOAddress last_addr = lower_bound_address;
+ for (; lb != idx.end(); ++lb) {
+ if ((*lb)->lease_addr_ == last_addr) {
+ // Already seen: skip it.
+ continue;
}
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
- const IOAddress& start_addr =
- (lower_bound_address < first_addr ? first_addr : lower_bound_address);
- RelayIdIndex::const_iterator lb =
- idx.lower_bound(boost::make_tuple(relay_id_data, start_addr));
- RelayIdIndex::const_iterator ub =
- idx.upper_bound(boost::make_tuple(relay_id_data, last_addr));
-
- // Return all leases being within the page size.
- IOAddress last_seen_addr = lower_bound_address;
- for (auto it = lb; it != ub; ++it) {
- if ((*it)->lease_addr_ == last_seen_addr) {
- // Already seen: skip it.
- continue;
- }
- last_seen_addr = (*it)->lease_addr_;
- Lease6Ptr lease = getAnyLease6Internal(last_seen_addr);
- if (lease) {
- collection.push_back(lease);
- if (collection.size() >= page_size.page_size_) {
- break;
- }
+ if ((*lb)->id_ != relay_id_data) {
+ // Gone after the relay id index.
+ break;
+ }
+ last_addr = (*lb)->lease_addr_;
+ Lease6Ptr lease = getAnyLease6Internal(last_addr);
+ if (lease) {
+ collection.push_back(lease);
+ if (collection.size() >= page_size.page_size_) {
+ break;
}
}
}
Lease6Collection
Memfile_LeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MEMFILE_GET_REMOTEID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(idToText(remote_id))
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(idToText(remote_id));
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 address while "
"retrieving leases from the lease database, got "
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lock(*mutex_);
return (getLeases6ByRemoteIdInternal(remote_id,
- link_addr,
- link_len,
lower_bound_address,
page_size));
} else {
return (getLeases6ByRemoteIdInternal(remote_id,
- link_addr,
- link_len,
lower_bound_address,
page_size));
}
Lease6Collection
Memfile_LeaseMgr::getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
Lease6Collection collection;
std::set<IOAddress> sorted;
const RemoteIdIndex& idx = remote_id6_.get<RemoteIdIndexTag>();
RemoteIdIndexRange er = idx.equal_range(remote_id);
- if (!link_len) {
- // Store all addresses greater than lower_bound_address.
- for (auto it = er.first; it != er.second; ++it) {
- const IOAddress& addr = (*it)->lease_addr_;
- if (addr <= lower_bound_address) {
- continue;
- }
- static_cast<void>(sorted.insert(addr));
- }
-
- // Return all leases being within the page size.
- for (const IOAddress& addr : sorted) {
- Lease6Ptr lease = getAnyLease6Internal(addr);
- if (lease) {
- collection.push_back(lease);
- if (collection.size() >= page_size.page_size_) {
- break;
- }
- }
- }
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
-
- // Store all addresses greater than lower_bound_address in the link.
- for (auto it = er.first; it != er.second; ++it) {
- const IOAddress& addr = (*it)->lease_addr_;
- if (addr <= lower_bound_address) {
- continue;
- }
- if ((addr < first_addr) || (last_addr < addr)) {
- continue;
- }
- static_cast<void>(sorted.insert(addr));
+ // Store all addresses greater than lower_bound_address.
+ for (auto it = er.first; it != er.second; ++it) {
+ const IOAddress& addr = (*it)->lease_addr_;
+ if (addr <= lower_bound_address) {
+ continue;
}
+ static_cast<void>(sorted.insert(addr));
+ }
- // Return all leases being within the page size.
- for (const IOAddress& addr : sorted) {
- Lease6Ptr lease = getAnyLease6Internal(addr);
- if (lease) {
- collection.push_back(lease);
- if (collection.size() >= page_size.page_size_) {
- break;
- }
+ // Return all leases being within the page size.
+ for (const IOAddress& addr : sorted) {
+ Lease6Ptr lease = getAnyLease6Internal(addr);
+ if (lease) {
+ collection.push_back(lease);
+ if (collection.size() >= page_size.page_size_) {
+ break;
}
}
}
/// @brief Returns existing IPv6 leases with a given relay-id.
///
/// @param relay_id DUID for relay_id of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRelayId(const DUID& relay_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
/// @brief Returns existing IPv6 leases with a given remote-id.
///
/// @param remote_id remote-id option data of interest
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
/// @brief Returns existing IPv6 leases with a given relay-id.
///
/// @param relay_id DUID for relay_id of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
Lease6Collection
getLeases6ByRelayIdInternal(const DUID& relay_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size);
/// @brief Returns existing IPv6 leases with a given remote-id.
///
/// @param remote_id remote-id option data of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
Lease6Collection
getLeases6ByRemoteIdInternal(const OptionBuffer& remote_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size);
"GROUP BY l.address "
"ORDER BY l.address "
"LIMIT ?"},
- {MySqlLeaseMgr::GET_RELAY_ID6_LINK,
- "SELECT l.address, l.duid, l.valid_lifetime, "
- "l.expire, l.subnet_id, l.pref_lifetime, "
- "l.lease_type, l.iaid, l.prefix_len, "
- "l.fqdn_fwd, l.fqdn_rev, l.hostname, "
- "l.hwaddr, l.hwtype, l.hwaddr_source, "
- "l.state, l.user_context, l.pool_id "
- "FROM lease6 AS l "
- "INNER JOIN lease6_relay_id AS r "
- " ON l.address = r.lease_addr "
- " WHERE r.relay_id = ? AND r.lease_addr BETWEEN ? AND ? "
- "GROUP BY l.address "
- "ORDER BY l.address "
- "LIMIT ?"},
- {MySqlLeaseMgr::GET_REMOTE_ID6_LINK,
- "SELECT l.address, l.duid, l.valid_lifetime, "
- "l.expire, l.subnet_id, l.pref_lifetime, "
- "l.lease_type, l.iaid, l.prefix_len, "
- "l.fqdn_fwd, l.fqdn_rev, l.hostname, "
- "l.hwaddr, l.hwtype, l.hwaddr_source, "
- "l.state, l.user_context, l.pool_id "
- "FROM lease6 AS l "
- "INNER JOIN lease6_remote_id AS r "
- " ON l.address = r.lease_addr "
- " WHERE r.remote_id = ? AND r.lease_addr BETWEEN ? AND ? "
- "GROUP BY l.address "
- "ORDER BY l.address "
- "LIMIT ?"},
{MySqlLeaseMgr::COUNT_RELAY_ID6,
"SELECT COUNT(*) FROM lease6_relay_id"},
{MySqlLeaseMgr::COUNT_REMOTE_ID6,
Lease6Collection
MySqlLeaseMgr::getLeases6ByRelayId(const DUID& relay_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MYSQL_GET_RELAYID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(relay_id.toText())
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(relay_id.toText());
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
isc_throw(BadValue, "empty relay id");
}
- Lease6Collection result;
-
- if (!link_len) {
- // Bind the relay id.
- MYSQL_BIND inbind[3];
- memset(inbind, 0, sizeof(inbind));
-
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = reinterpret_cast<char*>(&relay_id_data[0]);
- inbind[0].buffer_length = relay_id_size;
- inbind[0].length = &relay_id_size;
-
- // Bind the lower bound address.
- std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
- unsigned long lb_addr_size = lb_addr_data.size();
- if (lb_addr_size != 16) {
- isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
- }
- inbind[1].buffer_type = MYSQL_TYPE_BLOB;
- inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
- inbind[1].buffer_length = lb_addr_size;
- inbind[1].length = &lb_addr_size;
-
- // Bind the size value.
- uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
- inbind[2].buffer_type = MYSQL_TYPE_LONG;
- inbind[2].buffer = reinterpret_cast<char*>(&ps);
- inbind[2].is_unsigned = MLM_TRUE;
-
- // Get a context.
- MySqlLeaseContextAlloc get_context(*this);
- MySqlLeaseContextPtr ctx = get_context.ctx_;
-
- getLeaseCollection(ctx, GET_RELAY_ID6, inbind, result);
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
- IOAddress start_addr = lower_bound_address;
- if (lower_bound_address < first_addr) {
- start_addr = first_addr;
- } else if (last_addr <= lower_bound_address) {
- // Range was already done.
- return (result);
- } else {
- // The lower bound address is from the last call so skip it.
- start_addr = IOAddress::increase(lower_bound_address);
- }
-
- // Bind the relay id.
- MYSQL_BIND inbind[4];
- memset(inbind, 0, sizeof(inbind));
-
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = reinterpret_cast<char*>(&relay_id_data[0]);
- inbind[0].buffer_length = relay_id_size;
- inbind[0].length = &relay_id_size;
-
- // Bind the start address.
- std::vector<uint8_t> start_addr_data = start_addr.toBytes();
- unsigned long start_addr_size = start_addr_data.size();
- if (start_addr_size != 16) {
- isc_throw(DbOperationError, "start address is not 16 bytes long");
- }
- inbind[1].buffer_type = MYSQL_TYPE_BLOB;
- inbind[1].buffer = reinterpret_cast<char*>(&start_addr_data[0]);
- inbind[1].buffer_length = start_addr_size;
- inbind[1].length = &start_addr_size;
-
- // Bind the last address.
- std::vector<uint8_t> last_addr_data = last_addr.toBytes();
- unsigned long last_addr_size = last_addr_data.size();
- if (last_addr_size != 16) {
- isc_throw(DbOperationError, "last address is not 16 bytes long");
- }
- inbind[2].buffer_type = MYSQL_TYPE_BLOB;
- inbind[2].buffer = reinterpret_cast<char*>(&last_addr_data[0]);
- inbind[2].buffer_length = last_addr_size;
- inbind[2].length = &last_addr_size;
+ // Bind the relay id.
+ MYSQL_BIND inbind[3];
+ memset(inbind, 0, sizeof(inbind));
- // Bind the size value.
- uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
- inbind[3].buffer_type = MYSQL_TYPE_LONG;
- inbind[3].buffer = reinterpret_cast<char*>(&ps);
- inbind[3].is_unsigned = MLM_TRUE;
+ inbind[0].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[0].buffer = reinterpret_cast<char*>(&relay_id_data[0]);
+ inbind[0].buffer_length = relay_id_size;
+ inbind[0].length = &relay_id_size;
+
+ // Bind the lower bound address.
+ std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
+ unsigned long lb_addr_size = lb_addr_data.size();
+ if (lb_addr_size != 16) {
+ isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
+ }
+ inbind[1].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
+ inbind[1].buffer_length = lb_addr_size;
+ inbind[1].length = &lb_addr_size;
- // Get a context.
- MySqlLeaseContextAlloc get_context(*this);
- MySqlLeaseContextPtr ctx = get_context.ctx_;
+ // Bind the size value.
+ uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
+ inbind[2].buffer_type = MYSQL_TYPE_LONG;
+ inbind[2].buffer = reinterpret_cast<char*>(&ps);
+ inbind[2].is_unsigned = MLM_TRUE;
- getLeaseCollection(ctx, GET_RELAY_ID6_LINK, inbind, result);
- }
+ // Get a context.
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+ Lease6Collection result;
+ getLeaseCollection(ctx, GET_RELAY_ID6, inbind, result);
return (result);
}
Lease6Collection
MySqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MYSQL_GET_REMOTEID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(idToText(remote_id))
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(idToText(remote_id));
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
isc_throw(BadValue, "empty remote id");
}
- Lease6Collection result;
-
- if (!link_len) {
- // Bind the remote id.
- MYSQL_BIND inbind[3];
- memset(inbind, 0, sizeof(inbind));
-
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = reinterpret_cast<char*>(&remote_id_data[0]);
- inbind[0].buffer_length = remote_id_size;
- inbind[0].length = &remote_id_size;
-
- // Bind the lower bound address.
- std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
- unsigned long lb_addr_size = lb_addr_data.size();
- if (lb_addr_size != 16) {
- isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
- }
- inbind[1].buffer_type = MYSQL_TYPE_BLOB;
- inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
- inbind[1].buffer_length = lb_addr_size;
- inbind[1].length = &lb_addr_size;
-
- // Bind the size value.
- uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
- inbind[2].buffer_type = MYSQL_TYPE_LONG;
- inbind[2].buffer = reinterpret_cast<char*>(&ps);
- inbind[2].is_unsigned = MLM_TRUE;
-
- // Get a context.
- MySqlLeaseContextAlloc get_context(*this);
- MySqlLeaseContextPtr ctx = get_context.ctx_;
-
- getLeaseCollection(ctx, GET_REMOTE_ID6, inbind, result);
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
- IOAddress start_addr = lower_bound_address;
- if (lower_bound_address < first_addr) {
- start_addr = first_addr;
- } else if (last_addr <= lower_bound_address) {
- // Range was already done.
- return (result);
- } else {
- // The lower bound address is from the last call so skip it.
- start_addr = IOAddress::increase(lower_bound_address);
- }
-
- // Bind the remote id.
- MYSQL_BIND inbind[4];
- memset(inbind, 0, sizeof(inbind));
+ // Bind the remote id.
+ MYSQL_BIND inbind[3];
+ memset(inbind, 0, sizeof(inbind));
- inbind[0].buffer_type = MYSQL_TYPE_BLOB;
- inbind[0].buffer = reinterpret_cast<char*>(&remote_id_data[0]);
- inbind[0].buffer_length = remote_id_size;
- inbind[0].length = &remote_id_size;
-
- // Bind the start address.
- std::vector<uint8_t> start_addr_data = start_addr.toBytes();
- unsigned long start_addr_size = start_addr_data.size();
- if (start_addr_size != 16) {
- isc_throw(DbOperationError, "start address is not 16 bytes long");
- }
- inbind[1].buffer_type = MYSQL_TYPE_BLOB;
- inbind[1].buffer = reinterpret_cast<char*>(&start_addr_data[0]);
- inbind[1].buffer_length = start_addr_size;
- inbind[1].length = &start_addr_size;
-
- // Bind the last address.
- std::vector<uint8_t> last_addr_data = last_addr.toBytes();
- unsigned long last_addr_size = last_addr_data.size();
- if (last_addr_size != 16) {
- isc_throw(DbOperationError, "last address is not 16 bytes long");
- }
- inbind[2].buffer_type = MYSQL_TYPE_BLOB;
- inbind[2].buffer = reinterpret_cast<char*>(&last_addr_data[0]);
- inbind[2].buffer_length = last_addr_size;
- inbind[2].length = &last_addr_size;
+ inbind[0].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[0].buffer = reinterpret_cast<char*>(&remote_id_data[0]);
+ inbind[0].buffer_length = remote_id_size;
+ inbind[0].length = &remote_id_size;
+
+ // Bind the lower bound address.
+ std::vector<uint8_t> lb_addr_data = lower_bound_address.toBytes();
+ unsigned long lb_addr_size = lb_addr_data.size();
+ if (lb_addr_size != 16) {
+ isc_throw(DbOperationError, "lower bound address is not 16 bytes long");
+ }
+ inbind[1].buffer_type = MYSQL_TYPE_BLOB;
+ inbind[1].buffer = reinterpret_cast<char*>(&lb_addr_data[0]);
+ inbind[1].buffer_length = lb_addr_size;
+ inbind[1].length = &lb_addr_size;
- // Bind the size value.
- uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
- inbind[3].buffer_type = MYSQL_TYPE_LONG;
- inbind[3].buffer = reinterpret_cast<char*>(&ps);
- inbind[3].is_unsigned = MLM_TRUE;
+ // Bind the size value.
+ uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
+ inbind[2].buffer_type = MYSQL_TYPE_LONG;
+ inbind[2].buffer = reinterpret_cast<char*>(&ps);
+ inbind[2].is_unsigned = MLM_TRUE;
- // Get a context.
- MySqlLeaseContextAlloc get_context(*this);
- MySqlLeaseContextPtr ctx = get_context.ctx_;
+ // Get a context.
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+ Lease6Collection result;
- getLeaseCollection(ctx, GET_REMOTE_ID6_LINK, inbind, result);
- }
+ getLeaseCollection(ctx, GET_REMOTE_ID6, inbind, result);
return (result);
}
ADD_REMOTE_ID6, // Add a lease6_remote_id entry
GET_RELAY_ID6, // Get lease6_relay_id entries
GET_REMOTE_ID6, // Get lease6_remote_id entries
- GET_RELAY_ID6_LINK, // Get lease6_relay_id entries by link
- GET_REMOTE_ID6_LINK, // Get lease6_remote_id entries by link
COUNT_RELAY_ID6, // Count the lease6_relay_id number of entries
COUNT_REMOTE_ID6, // Count the lease6_remote_id number of entries
NUM_STATEMENTS // Number of statements
/// @brief Returns existing IPv6 leases with a given relay-id.
///
/// @param relay_id DUID for relay_id of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRelayId(const DUID& relay_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
/// @brief Returns existing IPv6 leases with a given remote-id.
///
/// @param remote_id remote-id option data of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
"ORDER BY l.address "
"LIMIT $3" },
- // GET_RELAY_ID6_LINK
- { 4, { OID_BYTEA, OID_VARCHAR, OID_VARCHAR, OID_INT8 },
- "get_relay_id6_link",
- "SELECT DISTINCT ON(l.address) "
- "host(l.address), l.duid, l.valid_lifetime, "
- "extract(epoch from l.expire)::bigint, l.subnet_id, l.pref_lifetime, "
- "l.lease_type, l.iaid, l.prefix_len, l.fqdn_fwd, l.fqdn_rev, "
- "l.hostname, l.hwaddr, l.hwtype, l.hwaddr_source, "
- "l.state, l.user_context, l.pool_id "
- "FROM lease6 AS l "
- "INNER JOIN lease6_relay_id AS r "
- " ON l.address = r.lease_addr "
- " WHERE r.relay_id = $1 AND r.lease_addr "
- "BETWEEN cast($2 as inet) and cast($3 as inet) "
- "ORDER BY l.address "
- "LIMIT $4" },
-
- // GET_REMOTE_ID6_LINK
- { 4, { OID_BYTEA, OID_VARCHAR, OID_VARCHAR, OID_INT8 },
- "get_remote_id6_link",
- "SELECT DISTINCT ON(l.address) "
- "host(l.address), l.duid, l.valid_lifetime, "
- "extract(epoch from l.expire)::bigint, l.subnet_id, l.pref_lifetime, "
- "l.lease_type, l.iaid, l.prefix_len, l.fqdn_fwd, l.fqdn_rev, "
- "l.hostname, l.hwaddr, l.hwtype, l.hwaddr_source, "
- "l.state, l.user_context, l.pool_id "
- "FROM lease6 AS l "
- "INNER JOIN lease6_remote_id AS r "
- " ON l.address = r.lease_addr "
- " WHERE r.remote_id = $1 AND r.lease_addr "
- "BETWEEN cast($2 as inet) and cast($3 as inet) "
- "ORDER BY l.address "
- "LIMIT $4" },
-
// COUNT_RELAY_ID6
{ 0, { OID_NONE },
"count_relay_id6",
Lease6Collection
PgSqlLeaseMgr::getLeases6ByRelayId(const DUID& relay_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_PGSQL_GET_RELAYID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(relay_id.toText())
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(relay_id.toText());
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
isc_throw(BadValue, "empty relay id");
}
- Lease6Collection result;
-
- if (!link_len) {
- // Set up the WHERE clause value.
- PsqlBindArray bind_array;
-
- // Bind the relay id.
- bind_array.add(relay_id_data);
-
- // Bind the lower bound address.
- std::string lb_addr_data = lower_bound_address.toText();
- bind_array.add(lb_addr_data);
-
- // Bind page size value.
- std::string page_size_data =
- boost::lexical_cast<std::string>(page_size.page_size_);
- bind_array.add(page_size_data);
-
- // Get a context.
- PgSqlLeaseContextAlloc get_context(*this);
- PgSqlLeaseContextPtr ctx = get_context.ctx_;
-
- getLeaseCollection(ctx, GET_RELAY_ID6, bind_array, result);
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
- IOAddress start_addr = lower_bound_address;
- if (lower_bound_address < first_addr) {
- start_addr = first_addr;
- } else if (last_addr <= lower_bound_address) {
- // Range was already done.
- return (result);
- } else {
- // The lower bound address is from the last call so skip it.
- start_addr = IOAddress::increase(lower_bound_address);
- }
-
- // Set up the WHERE clause value.
- PsqlBindArray bind_array;
-
- // Bind the relay id.
- bind_array.add(relay_id_data);
-
- // Bind the start address.
- std::string start_addr_data = start_addr.toText();
- bind_array.add(start_addr_data);
+ // Set up the WHERE clause value.
+ PsqlBindArray bind_array;
- // Bind the last address.
- std::string last_addr_data = last_addr.toText();
- bind_array.add(last_addr_data);
+ // Bind the relay id.
+ bind_array.add(relay_id_data);
- // Bind page size value.
- std::string page_size_data =
- boost::lexical_cast<std::string>(page_size.page_size_);
- bind_array.add(page_size_data);
+ // Bind the lower bound address.
+ std::string lb_addr_data = lower_bound_address.toText();
+ bind_array.add(lb_addr_data);
- // Get a context.
- PgSqlLeaseContextAlloc get_context(*this);
- PgSqlLeaseContextPtr ctx = get_context.ctx_;
+ // Bind page size value.
+ std::string page_size_data =
+ boost::lexical_cast<std::string>(page_size.page_size_);
+ bind_array.add(page_size_data);
- getLeaseCollection(ctx, GET_RELAY_ID6_LINK, bind_array, result);
- }
+ // Get a context.
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+ Lease6Collection result;
+ getLeaseCollection(ctx, GET_RELAY_ID6, bind_array, result);
return (result);
}
Lease6Collection
PgSqlLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const IOAddress& link_addr,
- uint8_t link_len,
const IOAddress& lower_bound_address,
const LeasePageSize& page_size) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_PGSQL_GET_REMOTEID6)
.arg(page_size.page_size_)
.arg(lower_bound_address.toText())
- .arg(idToText(remote_id))
- .arg(link_addr.toText())
- .arg(static_cast<unsigned>(link_len));
+ .arg(idToText(remote_id));
- // Expecting IPv6 valid prefix and address.
- if (!link_addr.isV6()) {
- isc_throw(InvalidAddressFamily, "expected IPv6 link address while "
- "retrieving leases from the lease database, got "
- << link_addr);
- }
- if (link_len > 128) {
- isc_throw(OutOfRange, "invalid IPv6 prefix length "
- << static_cast<unsigned>(link_len));
- }
+ // Expecting IPv6 valid address.
if (!lower_bound_address.isV6()) {
isc_throw(InvalidAddressFamily, "expected IPv6 start address while "
"retrieving leases from the lease database, got "
isc_throw(BadValue, "empty remote id");
}
- Lease6Collection result;
-
- if (!link_len) {
- // Set up the WHERE clause value.
- PsqlBindArray bind_array;
-
- // Bind the remote id.
- bind_array.add(remote_id);
-
- // Bind the lower bound address.
- std::string lb_addr_data = lower_bound_address.toText();
- bind_array.add(lb_addr_data);
-
- // Bind page size value.
- std::string page_size_data =
- boost::lexical_cast<std::string>(page_size.page_size_);
- bind_array.add(page_size_data);
-
- // Get a context.
- PgSqlLeaseContextAlloc get_context(*this);
- PgSqlLeaseContextPtr ctx = get_context.ctx_;
-
- getLeaseCollection(ctx, GET_REMOTE_ID6, bind_array, result);
- } else {
- const IOAddress& first_addr = firstAddrInPrefix(link_addr, link_len);
- const IOAddress& last_addr = lastAddrInPrefix(link_addr, link_len);
- IOAddress start_addr = lower_bound_address;
- if (lower_bound_address < first_addr) {
- start_addr = first_addr;
- } else if (last_addr <= lower_bound_address) {
- // Range was already done.
- return (result);
- } else {
- // The lower bound address is from the last call so skip it.
- start_addr = IOAddress::increase(lower_bound_address);
- }
-
- // Set up the WHERE clause value.
- PsqlBindArray bind_array;
-
- // Bind the remote id.
- bind_array.add(remote_id);
-
- // Bind the start address.
- std::string start_addr_data = start_addr.toText();
- bind_array.add(start_addr_data);
+ // Set up the WHERE clause value.
+ PsqlBindArray bind_array;
- // Bind the last address.
- std::string last_addr_data = last_addr.toText();
- bind_array.add(last_addr_data);
+ // Bind the remote id.
+ bind_array.add(remote_id);
- // Bind page size value.
- std::string page_size_data =
- boost::lexical_cast<std::string>(page_size.page_size_);
- bind_array.add(page_size_data);
+ // Bind the lower bound address.
+ std::string lb_addr_data = lower_bound_address.toText();
+ bind_array.add(lb_addr_data);
- // Get a context.
- PgSqlLeaseContextAlloc get_context(*this);
- PgSqlLeaseContextPtr ctx = get_context.ctx_;
+ // Bind page size value.
+ std::string page_size_data =
+ boost::lexical_cast<std::string>(page_size.page_size_);
+ bind_array.add(page_size_data);
- getLeaseCollection(ctx, GET_REMOTE_ID6_LINK, bind_array, result);
- }
+ // Get a context.
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+ Lease6Collection result;
+ getLeaseCollection(ctx, GET_REMOTE_ID6, bind_array, result);
return (result);
}
ADD_REMOTE_ID6, // Add a lease6_remote_id entry
GET_RELAY_ID6, // Get lease6_relay_id entries
GET_REMOTE_ID6, // Get lease6_remote_id entries
- GET_RELAY_ID6_LINK, // Get lease6_relay_id entries by link
- GET_REMOTE_ID6_LINK, // Get lease6_remote_id entries by link
COUNT_RELAY_ID6, // Count the lease6_relay_id number of entries
COUNT_REMOTE_ID6, // Count the lease6_remote_id number of entries
NUM_STATEMENTS // Number of statements
/// @brief Returns existing IPv6 leases with a given relay-id.
///
/// @param relay_id DUID for relay_id of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRelayId(const DUID& relay_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
/// @brief Returns existing IPv6 leases with a given remote-id.
///
/// @param remote_id remote-id option data of interest.
- /// @param link_addr limit results to leases on this link (prefix).
- /// @param link_len limit results to leases on this link (length).
/// @param lower_bound_address IPv4 address used as lower bound for the
/// returned range.
/// @param page_size maximum size of the page returned.
/// @return collection of IPv6 leases
virtual Lease6Collection
getLeases6ByRemoteId(const OptionBuffer& remote_id,
- const asiolink::IOAddress& link_addr,
- uint8_t link_len,
const asiolink::IOAddress& lower_bound_address,
const LeasePageSize& page_size) override;
IOAddress lease_addr0(ADDRESS6[0]);
IOAddress lease_addr1(ADDRESS6[1]);
IOAddress lease_addr2(ADDRESS6[2]);
- IOAddress link_addr(ADDRESS6[4]);
- IOAddress other_link_addr("2001:db8:1::4");
IOAddress zero = IOAddress::IPV6_ZERO_ADDRESS();
vector<uint8_t> relay_id_data0 = createFromString(DUIDS[0]);
DUID relay_id0(relay_id_data0);
EXPECT_EQ(6, lease_mgr_->relay_id6_.size());
Lease6Collection got;
- // Unknown relay id #2, no link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id2,
- zero,
- 0,
- zero,
- LeasePageSize(100)));
- EXPECT_EQ(0, got.size());
-
- // Unknown relay id #2, link: nothing.
+ // Unknown relay id #2: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id2,
- link_addr,
- 64,
zero,
LeasePageSize(100)));
EXPECT_EQ(0, got.size());
- // Relay id #0, other link: nothing.
+ // Relay id #0: 3 entries but 2 addresses.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id0,
- other_link_addr,
- 64,
- zero,
- LeasePageSize(100)));
- EXPECT_EQ(0, got.size());
-
- // Relay id #0, no link: 3 entries but 2 addresses.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id0,
- zero,
- 0,
zero,
LeasePageSize(100)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Relay id #1, no link, partial: 2 entries.
+ // Relay id #1, partial: 2 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- zero,
- 0,
zero,
LeasePageSize(2)));
ASSERT_EQ(2, got.size());
// Relay id #1, no link, partial from previous: 1 entry.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- zero,
- 0,
lease->addr_,
LeasePageSize(2)));
ASSERT_EQ(1, got.size());
lease = got[0];
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Add another entry for last tests.
- EXPECT_NO_THROW(lease_mgr_->addRelayId6(lease_addr0, relay_id_data1));
- EXPECT_EQ(7, lease_mgr_->relay_id6_.size());
-
- // Relay id #1, link: 3 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(100)));
- ASSERT_EQ(3, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
- lease = got[1];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
- lease = got[2];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Relay id #1, link, initial partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
-
- // Relay id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
-
- // Relay id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Relay id #1, link, final partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- EXPECT_EQ(0, got.size());
}
TEST_F(MemfileExtendedInfoTest, getLeases6ByRelayId) {
IOAddress lease_addr0(ADDRESS6[0]);
IOAddress lease_addr1(ADDRESS6[1]);
IOAddress lease_addr2(ADDRESS6[2]);
- IOAddress link_addr(ADDRESS6[4]);
- IOAddress other_link_addr("2001:db8:1::4");
IOAddress zero = IOAddress::IPV6_ZERO_ADDRESS();
vector<uint8_t> remote_id0 = createFromString(DUIDS[0]);
vector<uint8_t> remote_id1 = createFromString(DUIDS[1]);
EXPECT_EQ(6, lease_mgr_->remote_id6_.size());
Lease6Collection got;
- // Unknown remote id #2, no link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id2,
- zero,
- 0,
- zero,
- LeasePageSize(10)));
- EXPECT_EQ(0, got.size());
-
- // Unknown remote id #2, link: nothing.
+ // Unknown remote id #2: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id2,
- link_addr,
- 64,
zero,
LeasePageSize(10)));
EXPECT_EQ(0, got.size());
- // Remote id #0, other link: nothing.
+ // Remote id #0: 3 entries but 2 addresses.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id0,
- other_link_addr,
- 64,
- zero,
- LeasePageSize(10)));
- EXPECT_EQ(0, got.size());
-
- // Remote id #0, no link: 3 entries but 2 addresses.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id0,
- zero,
- 0,
zero,
LeasePageSize(10)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Remote id #1, no link, partial: 2 entries.
+ // Remote id #1, partial: 2 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- zero,
- 0,
zero,
LeasePageSize(2)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Remote id #1, no link, partial from previous: 1 entry.
+ // Remote id #1, partial from previous: 1 entry.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- zero,
- 0,
lease->addr_,
LeasePageSize(2)));
ASSERT_EQ(1, got.size());
lease = got[0];
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Add another entry for last tests.
- EXPECT_NO_THROW(lease_mgr_->addRemoteId6(lease_addr0, remote_id1));
- EXPECT_EQ(7, lease_mgr_->remote_id6_.size());
-
- // Remote id #1, link: 3 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(10)));
- ASSERT_EQ(3, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
- lease = got[1];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
- lease = got[2];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Remote id #1, link, initial partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
-
- // Remote id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
-
- // Remote id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Remote id #1, link, final partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- EXPECT_EQ(0, got.size());
}
TEST_F(MemfileExtendedInfoTest, getLeases6ByRemoteId) {
Lease6Collection
ConcreteLeaseMgr::getLeases6ByRelayId(const DUID& /* relay_id */,
- const IOAddress& /* link_addr */,
- uint8_t /* link_len */,
const IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size */) {
isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByRelayId not implemented");
Lease6Collection
ConcreteLeaseMgr::getLeases6ByRemoteId(const OptionBuffer& /* remote_id */,
- const IOAddress& /* link_addr */,
- uint8_t /* link_len */,
- const IOAddress& /* lower_bound_address */,
+ const IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size*/) {
isc_throw(NotImplemented, "ConcreteLeaseMgr::getLeases6ByRemoteId not implemented");
}
/// @brief Stub implementation.
Lease6Collection
getLeases6ByRelayId(const DUID& /* relay_id */,
- const asiolink::IOAddress& /* link_addr */,
- uint8_t /* link_len */,
const asiolink::IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size */) override;
/// @brief Stub implementation.
Lease6Collection
getLeases6ByRemoteId(const OptionBuffer& /* remote_id */,
- const asiolink::IOAddress& /* link_addr */,
- uint8_t /* link_len */,
const asiolink::IOAddress& /* lower_bound_address */,
const LeasePageSize& /* page_size*/) override;
asiolink::IOAddress lease_addr0(ADDRESS6[0]);
asiolink::IOAddress lease_addr1(ADDRESS6[1]);
asiolink::IOAddress lease_addr2(ADDRESS6[2]);
- asiolink::IOAddress link_addr(ADDRESS6[4]);
- asiolink::IOAddress other_link_addr("2001:db8:1::4");
asiolink::IOAddress zero = asiolink::IOAddress::IPV6_ZERO_ADDRESS();
std::vector<uint8_t> relay_id_data0 = createFromString(DUIDS[0]);
DUID relay_id0(relay_id_data0);
EXPECT_EQ(6, lease_mgr_->byRelayId6size());
Lease6Collection got;
- // Unknown relay id #2, no link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id2,
- zero,
- 0,
- zero,
- LeasePageSize(100)));
- EXPECT_EQ(0, got.size());
-
- // Unknown relay id #2, link: nothing.
+ // Unknown relay id #2: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id2,
- link_addr,
- 64,
- zero,
- LeasePageSize(100)));
- EXPECT_EQ(0, got.size());
-
- // Relay id #0, other link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id0,
- other_link_addr,
- 64,
zero,
LeasePageSize(100)));
EXPECT_EQ(0, got.size());
- // Relay id #0, no link: 3 entries but 2 addresses.
+ // Relay id #0: 3 entries but 2 addresses.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id0,
- zero,
- 0,
zero,
LeasePageSize(100)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Relay id #1, no link, partial: 2 entries.
+ // Relay id #1, partial: 2 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- zero,
- 0,
zero,
LeasePageSize(2)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Relay id #1, no link, partial from previous: 1 entry.
+ // Relay id #1, partial from previous: 1 entry.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- zero,
- 0,
lease->addr_,
LeasePageSize(2)));
ASSERT_EQ(1, got.size());
lease = got[0];
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Add another entry for last tests.
- EXPECT_NO_THROW(lease_mgr_->addRelayId6(lease_addr0, relay_id_data1));
- EXPECT_EQ(7, lease_mgr_->byRelayId6size());
-
- // Relay id #1, link: 3 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(100)));
- ASSERT_EQ(3, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
- lease = got[1];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
- lease = got[2];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Relay id #1, link, initial partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
-
- // Relay id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
-
- // Relay id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Relay id #1, link, final partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- EXPECT_EQ(0, got.size());
}
/// @brief Verifies that getLeases6ByRemoteId works as expected.
asiolink::IOAddress lease_addr0(ADDRESS6[0]);
asiolink::IOAddress lease_addr1(ADDRESS6[1]);
asiolink::IOAddress lease_addr2(ADDRESS6[2]);
- asiolink::IOAddress link_addr(ADDRESS6[4]);
- asiolink::IOAddress other_link_addr("2001:db8:1::4");
asiolink::IOAddress zero = asiolink::IOAddress::IPV6_ZERO_ADDRESS();
std::vector<uint8_t> remote_id0 = createFromString(DUIDS[0]);
std::vector<uint8_t> remote_id1 = createFromString(DUIDS[1]);
EXPECT_EQ(6, lease_mgr_->byRemoteId6size());
Lease6Collection got;
- // Unknown remote id #2, no link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id2,
- zero,
- 0,
- zero,
- LeasePageSize(10)));
- EXPECT_EQ(0, got.size());
-
- // Unknown remote id #2, link: nothing.
+ // Unknown remote id #2: nothing.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id2,
- link_addr,
- 64,
- zero,
- LeasePageSize(10)));
- EXPECT_EQ(0, got.size());
-
- // Remote id #0, other link: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id0,
- other_link_addr,
- 64,
zero,
LeasePageSize(10)));
EXPECT_EQ(0, got.size());
- // Remote id #0, no link: 3 entries but 2 addresses.
+ // Remote id #0: 3 entries but 2 addresses.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id0,
- zero,
- 0,
zero,
LeasePageSize(10)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Remote id #1, no link, partial: 2 entries.
+ // Remote id #1, partial: 2 entries.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- zero,
- 0,
zero,
LeasePageSize(2)));
ASSERT_EQ(2, got.size());
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr1, lease->addr_);
- // Remote id #1, no link, partial from previous: 1 entry.
+ // Remote id #1, partial from previous: 1 entry.
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- zero,
- 0,
lease->addr_,
LeasePageSize(2)));
ASSERT_EQ(1, got.size());
lease = got[0];
ASSERT_TRUE(lease);
EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Add another entry for last tests.
- EXPECT_NO_THROW(lease_mgr_->addRemoteId6(lease_addr0, remote_id1));
- EXPECT_EQ(7, lease_mgr_->byRemoteId6size());
-
- // Remote id #1, link: 3 entries.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(10)));
- ASSERT_EQ(3, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
- lease = got[1];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
- lease = got[2];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Remote id #1, link, initial partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- zero,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr0, lease->addr_);
-
- // Remote id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr1, lease->addr_);
-
- // Remote id #1, link, next partial: 1 entry.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- ASSERT_EQ(1, got.size());
- lease = got[0];
- ASSERT_TRUE(lease);
- EXPECT_EQ(lease_addr2, lease->addr_);
-
- // Remote id #1, link, final partial: nothing.
- EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id1,
- link_addr,
- 64,
- lease->addr_,
- LeasePageSize(1)));
- EXPECT_EQ(0, got.size());
}
/// @brief Verifies that getLeases6ByLink works as expected.
std::vector<uint8_t> relay_id_data = createFromString(DUIDS[4]);
DUID relay_id(relay_id_data);
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(1, got.size());
// Check remote id.
std::vector<uint8_t> remote_id = createFromString(DUIDS[5]);
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(1, got.size());
DUID relay_id(std::vector<uint8_t>(8, 0x64));
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(1, got.size());
std::vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(1, got.size());
DUID relay_id(std::vector<uint8_t>(8, 0x64));
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRelayId(relay_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(2, got.size());
std::vector<uint8_t> remote_id = { 1, 2, 3, 4, 5, 6 };
EXPECT_NO_THROW(got = lease_mgr_->getLeases6ByRemoteId(remote_id,
- zero,
- 0,
zero,
ps100));
ASSERT_EQ(2, got.size());