BIND 10 trac3171, updated. e09660860573d1b76c65a200d3682d3592406b67 [3171] alloc{Address -> Lease} rename, compilation fixes
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Sep 24 09:26:27 UTC 2013
The branch, trac3171 has been updated
via e09660860573d1b76c65a200d3682d3592406b67 (commit)
from c83724e334548f586781ee77813348c75c111836 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e09660860573d1b76c65a200d3682d3592406b67
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Tue Sep 24 11:25:55 2013 +0200
[3171] alloc{Address -> Lease} rename, compilation fixes
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/dhcp4_srv.cc | 10 ++--
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc | 18 +++---
src/bin/dhcp6/dhcp6_srv.cc | 14 ++---
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 56 ++++++++++--------
src/bin/dhcp6/tests/dhcp6_test_utils.h | 3 +-
src/bin/dhcp6/tests/hooks_unittest.cc | 12 ++--
src/lib/dhcpsrv/alloc_engine.cc | 32 ++++-------
src/lib/dhcpsrv/alloc_engine.h | 32 ++++-------
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc | 72 ++++++++++++------------
9 files changed, 123 insertions(+), 126 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index 7d13631..edd9af4 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -718,11 +718,11 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
// be inserted into the LeaseMgr as well.
// @todo pass the actual FQDN data.
Lease4Ptr old_lease;
- Lease4Ptr lease = alloc_engine_->allocateAddress4(subnet, client_id, hwaddr,
- hint, false, false, "",
- fake_allocation,
- callout_handle,
- old_lease);
+ Lease4Ptr lease = alloc_engine_->allocateLease4(subnet, client_id, hwaddr,
+ hint, false, false, "",
+ fake_allocation,
+ callout_handle,
+ old_lease);
if (lease) {
// We have a lease! Let's set it in the packet and send it back to
diff --git a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
index 0abeb10..08961a2 100644
--- a/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+++ b/src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
@@ -390,7 +390,7 @@ public:
// Technically inPool implies inRange, but let's be on the safe
// side and check both.
EXPECT_TRUE(subnet->inRange(rsp->getYiaddr()));
- EXPECT_TRUE(subnet->inPool(rsp->getYiaddr()));
+ EXPECT_TRUE(subnet->inPool(Lease::TYPE_V4, rsp->getYiaddr()));
// Check lease time
OptionPtr opt = rsp->getOption(DHO_DHCP_LEASE_TIME);
@@ -1333,7 +1333,7 @@ TEST_F(Dhcpv4SrvTest, RenewBasic) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// let's create a lease and put it in the LeaseMgr
uint8_t hwaddr2[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
@@ -1444,7 +1444,7 @@ TEST_F(Dhcpv4SrvTest, ReleaseBasic) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// Let's create a lease and put it in the LeaseMgr
uint8_t mac_addr[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
@@ -1520,7 +1520,7 @@ TEST_F(Dhcpv4SrvTest, ReleaseReject) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// Let's create a RELEASE
// Generate client-id also duid_
@@ -2696,7 +2696,7 @@ TEST_F(HooksDhcpv4SrvTest, subnet4SelectChange) {
// Advertised address must belong to the second pool (in subnet's range,
// in dynamic pool)
EXPECT_TRUE((*subnets)[1]->inRange(addr));
- EXPECT_TRUE((*subnets)[1]->inPool(addr));
+ EXPECT_TRUE((*subnets)[1]->inPool(Lease::TYPE_V4, addr));
}
// This test verifies that incoming (positive) REQUEST/Renewing can be handled
@@ -2718,7 +2718,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSimple) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// let's create a lease and put it in the LeaseMgr
uint8_t hwaddr2[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
@@ -2802,7 +2802,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4RenewSkip) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// let's create a lease and put it in the LeaseMgr
uint8_t hwaddr2[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
@@ -2866,7 +2866,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSimple) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// Let's create a lease and put it in the LeaseMgr
uint8_t mac_addr[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
@@ -2951,7 +2951,7 @@ TEST_F(HooksDhcpv4SrvTest, lease4ReleaseSkip) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_V4, addr));
// Let's create a lease and put it in the LeaseMgr
uint8_t mac_addr[] = { 0, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe};
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 2da5c8b..7cdaaba 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1223,13 +1223,13 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// will try to honour the hint, but it is just a hint - some other address
// may be used instead. If fake_allocation is set to false, the lease will
// be inserted into the LeaseMgr as well.
- Lease6Collection leases = alloc_engine_->allocateAddress6(subnet, duid,
- ia->getIAID(),
- hint, Lease::TYPE_NA,
- do_fwd, do_rev,
- hostname,
- fake_allocation,
- callout_handle);
+ Lease6Collection leases = alloc_engine_->allocateLease6(subnet, duid,
+ ia->getIAID(),
+ hint, Lease::TYPE_NA,
+ do_fwd, do_rev,
+ hostname,
+ fake_allocation,
+ callout_handle);
/// @todo: Handle more than one lease
Lease6Ptr lease;
if (!leases.empty()) {
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 3869d2b..607b70b 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -265,7 +265,7 @@ public:
// Check that we have got the address we requested.
checkIAAddr(addr, IOAddress("2001:db8:1:1::dead:beef"),
- subnet_->getPreferred(),
+ Lease::TYPE_NA, subnet_->getPreferred(),
subnet_->getValid());
if (msg_type != DHCPV6_SOLICIT) {
@@ -663,7 +663,8 @@ TEST_F(Dhcpv6SrvTest, SolicitBasic) {
ASSERT_TRUE(addr);
// Check that the assigned address is indeed from the configured pool
- checkIAAddr(addr, addr->getAddress(), subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr, addr->getAddress(), Lease::TYPE_NA, subnet_->getPreferred(),
+ subnet_->getValid());
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -695,7 +696,7 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
// with a valid hint
IOAddress hint("2001:db8:1:1::dead:beef");
- ASSERT_TRUE(subnet_->inPool(hint));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, hint));
OptionPtr hint_opt(new Option6IAAddr(D6O_IAADDR, hint, 300, 500));
ia->addOption(hint_opt);
sol->addOption(ia);
@@ -717,7 +718,8 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
ASSERT_TRUE(addr);
// check that we've got the address we requested
- checkIAAddr(addr, hint, subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr, hint, Lease::TYPE_NA, subnet_->getPreferred(),
+ subnet_->getValid());
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -747,7 +749,7 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
sol->setRemoteAddr(IOAddress("fe80::abcd"));
boost::shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
IOAddress hint("2001:db8:1::cafe:babe");
- ASSERT_FALSE(subnet_->inPool(hint));
+ ASSERT_FALSE(subnet_->inPool(Lease::TYPE_NA, hint));
OptionPtr hint_opt(new Option6IAAddr(D6O_IAADDR, hint, 300, 500));
ia->addOption(hint_opt);
sol->addOption(ia);
@@ -766,8 +768,9 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
ASSERT_TRUE(addr);
// Check that the assigned address is indeed from the configured pool
- checkIAAddr(addr, addr->getAddress(), subnet_->getPreferred(), subnet_->getValid());
- EXPECT_TRUE(subnet_->inPool(addr->getAddress()));
+ checkIAAddr(addr, addr->getAddress(), Lease::TYPE_NA, subnet_->getPreferred(),
+ subnet_->getValid());
+ EXPECT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr->getAddress()));
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -830,9 +833,12 @@ TEST_F(Dhcpv6SrvTest, ManySolicits) {
ASSERT_TRUE(addr3);
// Check that the assigned address is indeed from the configured pool
- checkIAAddr(addr1, addr1->getAddress(), subnet_->getPreferred(), subnet_->getValid());
- checkIAAddr(addr2, addr2->getAddress(), subnet_->getPreferred(), subnet_->getValid());
- checkIAAddr(addr3, addr3->getAddress(), subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr1, addr1->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr2, addr2->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr3, addr3->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
// check DUIDs
checkServerId(reply1, srv.getServerID());
@@ -876,7 +882,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
// with a valid hint
IOAddress hint("2001:db8:1:1::dead:beef");
- ASSERT_TRUE(subnet_->inPool(hint));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, hint));
OptionPtr hint_opt(new Option6IAAddr(D6O_IAADDR, hint, 300, 500));
ia->addOption(hint_opt);
req->addOption(ia);
@@ -896,12 +902,14 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
ASSERT_TRUE(tmp);
// check that IA_NA was returned and that there's an address included
- boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
- subnet_->getT2());
+ boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234,
+ subnet_->getT1(),
+ subnet_->getT2());
ASSERT_TRUE(addr);
// check that we've got the address we requested
- checkIAAddr(addr, hint, subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr, hint, Lease::TYPE_NA, subnet_->getPreferred(),
+ subnet_->getValid());
// check DUIDs
checkServerId(reply, srv.getServerID());
@@ -974,9 +982,12 @@ TEST_F(Dhcpv6SrvTest, ManyRequests) {
ASSERT_TRUE(addr3);
// Check that the assigned address is indeed from the configured pool
- checkIAAddr(addr1, addr1->getAddress(), subnet_->getPreferred(), subnet_->getValid());
- checkIAAddr(addr2, addr2->getAddress(), subnet_->getPreferred(), subnet_->getValid());
- checkIAAddr(addr3, addr3->getAddress(), subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr1, addr1->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr2, addr2->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr3, addr3->getAddress(), Lease::TYPE_NA,
+ subnet_->getPreferred(), subnet_->getValid());
// check DUIDs
checkServerId(reply1, srv.getServerID());
@@ -1014,7 +1025,7 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1065,7 +1076,8 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
ASSERT_TRUE(addr_opt);
// Check that we've got the address we requested
- checkIAAddr(addr_opt, addr, subnet_->getPreferred(), subnet_->getValid());
+ checkIAAddr(addr_opt, addr, Lease::TYPE_NA, subnet_->getPreferred(),
+ subnet_->getValid());
// Check DUIDs
checkServerId(reply, srv.getServerID());
@@ -1111,7 +1123,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
const uint32_t bogus_iaid = 456;
// Quick sanity check that the address we're about to use is ok
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// GenerateClientId() also sets duid_
OptionPtr clientid = generateClientId();
@@ -1218,7 +1230,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1299,7 +1311,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
const uint32_t bogus_iaid = 456;
// Quick sanity check that the address we're about to use is ok
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// GenerateClientId() also sets duid_
OptionPtr clientid = generateClientId();
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h
index 0e5ad7c..eb40d71 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.h
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h
@@ -358,6 +358,7 @@ public:
// and lifetime values match the configured subnet
void checkIAAddr(const boost::shared_ptr<Option6IAAddr>& addr,
const IOAddress& expected_addr,
+ Lease::Type type,
uint32_t /* expected_preferred */,
uint32_t /* expected_valid */) {
@@ -365,7 +366,7 @@ public:
// Note that when comparing addresses, we compare the textual
// representation. IOAddress does not support being streamed to
// an ostream, which means it can't be used in EXPECT_EQ.
- EXPECT_TRUE(subnet_->inPool(addr->getAddress()));
+ EXPECT_TRUE(subnet_->inPool(type, addr->getAddress()));
EXPECT_EQ(expected_addr.toText(), addr->getAddress().toText());
EXPECT_EQ(addr->getPreferred(), subnet_->getPreferred());
EXPECT_EQ(addr->getValid(), subnet_->getValid());
diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc
index 767560f..a9df50f 100644
--- a/src/bin/dhcp6/tests/hooks_unittest.cc
+++ b/src/bin/dhcp6/tests/hooks_unittest.cc
@@ -1047,7 +1047,7 @@ TEST_F(HooksDhcpv6SrvTest, subnet_select_change) {
// Advertised address must belong to the second pool (in subnet's range,
// in dynamic pool)
EXPECT_TRUE((*subnets)[1]->inRange(addr_opt->getAddress()));
- EXPECT_TRUE((*subnets)[1]->inPool(addr_opt->getAddress()));
+ EXPECT_TRUE((*subnets)[1]->inPool(Lease::TYPE_NA, addr_opt->getAddress()));
}
// This test verifies that incoming (positive) RENEW can be handled properly,
@@ -1066,7 +1066,7 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1163,7 +1163,7 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1254,7 +1254,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1330,7 +1330,7 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
@@ -1411,7 +1411,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
OptionPtr clientid = generateClientId();
// Check that the address we are about to use is indeed in pool
- ASSERT_TRUE(subnet_->inPool(addr));
+ ASSERT_TRUE(subnet_->inPool(Lease::TYPE_NA, addr));
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index ff3cac2..1d2e5e6 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -282,16 +282,12 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts,
}
Lease6Collection
-AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
- const DuidPtr& duid,
- uint32_t iaid,
- const IOAddress& hint,
- Lease::Type type,
- const bool fwd_dns_update,
- const bool rev_dns_update,
- const std::string& hostname,
- bool fake_allocation,
- const isc::hooks::CalloutHandlePtr& callout_handle) {
+AllocEngine::allocateLease6(const Subnet6Ptr& subnet, const DuidPtr& duid,
+ uint32_t iaid, const IOAddress& hint,
+ Lease::Type type, const bool fwd_dns_update,
+ const bool rev_dns_update,
+ const std::string& hostname, bool fake_allocation,
+ const isc::hooks::CalloutHandlePtr& callout_handle) {
try {
AllocatorPtr allocator = getAllocator(type);
@@ -445,16 +441,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
}
Lease4Ptr
-AllocEngine::allocateAddress4(const SubnetPtr& subnet,
- const ClientIdPtr& clientid,
- const HWAddrPtr& hwaddr,
- const IOAddress& hint,
- const bool fwd_dns_update,
- const bool rev_dns_update,
- const std::string& hostname,
- bool fake_allocation,
- const isc::hooks::CalloutHandlePtr& callout_handle,
- Lease4Ptr& old_lease) {
+AllocEngine::allocateLease4(const SubnetPtr& subnet, const ClientIdPtr& clientid,
+ const HWAddrPtr& hwaddr, const IOAddress& hint,
+ const bool fwd_dns_update, const bool rev_dns_update,
+ const std::string& hostname, bool fake_allocation,
+ const isc::hooks::CalloutHandlePtr& callout_handle,
+ Lease4Ptr& old_lease) {
// The NULL pointer indicates that the old lease didn't exist. It may
// be later set to non NULL value if existing lease is found in the
diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h
index 49448a1..f6c550c 100644
--- a/src/lib/dhcpsrv/alloc_engine.h
+++ b/src/lib/dhcpsrv/alloc_engine.h
@@ -266,16 +266,13 @@ protected:
///
/// @return Allocated IPv4 lease (or NULL if allocation failed)
Lease4Ptr
- allocateAddress4(const SubnetPtr& subnet,
- const ClientIdPtr& clientid,
- const HWAddrPtr& hwaddr,
- const isc::asiolink::IOAddress& hint,
- const bool fwd_dns_update,
- const bool rev_dns_update,
- const std::string& hostname,
- bool fake_allocation,
- const isc::hooks::CalloutHandlePtr& callout_handle,
- Lease4Ptr& old_lease);
+ allocateLease4(const SubnetPtr& subnet, const ClientIdPtr& clientid,
+ const HWAddrPtr& hwaddr,
+ const isc::asiolink::IOAddress& hint,
+ const bool fwd_dns_update, const bool rev_dns_update,
+ const std::string& hostname, bool fake_allocation,
+ const isc::hooks::CalloutHandlePtr& callout_handle,
+ Lease4Ptr& old_lease);
/// @brief Renews a IPv4 lease
///
@@ -335,16 +332,11 @@ protected:
///
/// @return Allocated IPv6 leases (may be empty if allocation failed)
Lease6Collection
- allocateAddress6(const Subnet6Ptr& subnet,
- const DuidPtr& duid,
- uint32_t iaid,
- const isc::asiolink::IOAddress& hint,
- Lease::Type type,
- const bool fwd_dns_update,
- const bool rev_dns_update,
- const std::string& hostname,
- bool fake_allocation,
- const isc::hooks::CalloutHandlePtr& callout_handle);
+ allocateLease6(const Subnet6Ptr& subnet, const DuidPtr& duid, uint32_t iaid,
+ const isc::asiolink::IOAddress& hint, Lease::Type type,
+ const bool fwd_dns_update, const bool rev_dns_update,
+ const std::string& hostname, bool fake_allocation,
+ const isc::hooks::CalloutHandlePtr& callout_handle);
/// @brief returns allocator for a given pool type
/// @param type type of pool (V4, IA, TA or PD)
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
index 359dd58..2e9209b 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
@@ -194,7 +194,7 @@ public:
}
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, hint, type, false, false,
"", fake, CalloutHandlePtr())));
@@ -248,7 +248,7 @@ public:
// unfortunately it is used already. The same address must not be allocated
// twice.
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, requested, type, false, false, "", false,
CalloutHandlePtr())));
@@ -292,7 +292,7 @@ public:
// supported lease. Allocation engine should ignore it and carry on
// with the normal allocation
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, hint, type, false,
false, "", false, CalloutHandlePtr())));
@@ -494,13 +494,13 @@ TEST_F(AllocEngine6Test, allocateAddress6Nulls) {
// Allocations without subnet are not allowed
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(
Subnet6Ptr(), duid_, iaid_, IOAddress("::"), Lease::TYPE_NA,
false, false, "", false, CalloutHandlePtr())));
ASSERT_FALSE(lease);
// Allocations without DUID are not allowed either
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
DuidPtr(), iaid_, IOAddress("::"), Lease::TYPE_NA, false,
false, "", false, CalloutHandlePtr())));
ASSERT_FALSE(lease);
@@ -749,7 +749,7 @@ TEST_F(AllocEngine6Test, smallPool6) {
cfg_mgr.addSubnet6(subnet_);
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
"", false, CalloutHandlePtr())));
@@ -798,7 +798,7 @@ TEST_F(AllocEngine6Test, outOfAddresses6) {
// There is just a single address in the pool and allocated it to someone
// else, so the allocation should fail
Lease6Ptr lease2;
- EXPECT_NO_THROW(lease2 = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease2 = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
"", false, CalloutHandlePtr())));
EXPECT_FALSE(lease2);
@@ -833,7 +833,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
ASSERT_TRUE(lease->expired());
// CASE 1: Asking for any address
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false, "", true,
CalloutHandlePtr())));
// Check that we got that single lease
@@ -844,7 +844,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
checkLease6(lease, Lease::TYPE_NA, 128);
// CASE 2: Asking specifically for this address
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, addr, Lease::TYPE_NA, false, false, "",
true, CalloutHandlePtr())));
@@ -880,7 +880,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// A client comes along, asking specifically for this address
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, addr, Lease::TYPE_NA, false, false, "",
false, CalloutHandlePtr())));
@@ -932,7 +932,7 @@ TEST_F(AllocEngine4Test, simpleAlloc4) {
100, false)));
ASSERT_TRUE(engine);
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, true,
"somehost.example.com.",
@@ -962,7 +962,7 @@ TEST_F(AllocEngine4Test, fakeAlloc4) {
100, false)));
ASSERT_TRUE(engine);
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, true, "host.example.com.",
true, CalloutHandlePtr(),
@@ -991,7 +991,7 @@ TEST_F(AllocEngine4Test, allocWithValidHint4) {
100, false)));
ASSERT_TRUE(engine);
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("192.0.2.105"),
true, true, "host.example.com.",
false, CalloutHandlePtr(),
@@ -1036,7 +1036,7 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) {
// Another client comes in and request an address that is in pool, but
// unfortunately it is used already. The same address must not be allocated
// twice.
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("192.0.2.106"),
false, false, "",
false, CalloutHandlePtr(),
@@ -1077,7 +1077,7 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
// Client would like to get a 3000::abc lease, which does not belong to any
// supported lease. Allocation engine should ignore it and carry on
// with the normal allocation
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("10.1.1.1"),
false, false, "",
false, CalloutHandlePtr(),
@@ -1104,14 +1104,14 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
// This test checks that NULL values are handled properly
-TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
+TEST_F(AllocEngine4Test, allocateLease4Nulls) {
boost::scoped_ptr<AllocEngine> engine;
ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
100, false)));
ASSERT_TRUE(engine);
// Allocations without subnet are not allowed
- Lease4Ptr lease = engine->allocateAddress4(SubnetPtr(), clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(SubnetPtr(), clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, false, "",
false, CalloutHandlePtr(),
@@ -1119,7 +1119,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
EXPECT_FALSE(lease);
// Allocations without HW address are not allowed
- lease = engine->allocateAddress4(subnet_, clientid_, HWAddrPtr(),
+ lease = engine->allocateLease4(subnet_, clientid_, HWAddrPtr(),
IOAddress("0.0.0.0"),
false, false, "",
false, CalloutHandlePtr(),
@@ -1129,7 +1129,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
// Allocations without client-id are allowed
clientid_ = ClientIdPtr();
- lease = engine->allocateAddress4(subnet_, ClientIdPtr(), hwaddr_,
+ lease = engine->allocateLease4(subnet_, ClientIdPtr(), hwaddr_,
IOAddress("0.0.0.0"),
true, true, "myhost.example.com.",
false, CalloutHandlePtr(),
@@ -1239,7 +1239,7 @@ TEST_F(AllocEngine4Test, smallPool4) {
subnet_->addPool(pool_);
cfg_mgr.addSubnet4(subnet_);
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
true, true, "host.example.com.",
false, CalloutHandlePtr(),
@@ -1295,7 +1295,7 @@ TEST_F(AllocEngine4Test, outOfAddresses4) {
// There is just a single address in the pool and allocated it to someone
// else, so the allocation should fail
- Lease4Ptr lease2 = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease2 = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, false, "",
false, CalloutHandlePtr(),
@@ -1338,7 +1338,7 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// CASE 1: Asking for any address
- lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, false, "",
true, CalloutHandlePtr(),
@@ -1357,7 +1357,7 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
checkLease4(lease);
// CASE 2: Asking specifically for this address
- lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress(addr.toText()),
false, false, "",
true, CalloutHandlePtr(),
@@ -1398,7 +1398,7 @@ TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// A client comes along, asking specifically for this address
- lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress(addr.toText()),
false, true, "host.example.com.",
false, CalloutHandlePtr(),
@@ -1595,7 +1595,7 @@ TEST_F(HookAllocEngine6Test, lease6_select) {
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
"", false, callout_handle)));
// Check that we got a lease
@@ -1660,13 +1660,13 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) {
EXPECT_NO_THROW(HooksManager::preCalloutsLibraryHandle().registerCallout(
"lease6_select", lease6_select_different_callout));
- // Normally, dhcpv6_srv would passed the handle when calling allocateAddress6,
+ // Normally, dhcpv6_srv would passed the handle when calling allocateLease6,
// but in tests we need to create it on our own.
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
- // Call allocateAddress6. Callouts should be triggered here.
+ // Call allocateLease6. Callouts should be triggered here.
Lease6Ptr lease;
- EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
+ EXPECT_NO_THROW(lease = expectOneLease(engine->allocateLease6(subnet_,
duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
"", false, callout_handle)));
// Check that we got a lease
@@ -1821,7 +1821,7 @@ TEST_F(HookAllocEngine4Test, lease4_select) {
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
IOAddress("0.0.0.0"),
false, false, "",
false, callout_handle,
@@ -1883,16 +1883,16 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) {
EXPECT_NO_THROW(HooksManager::preCalloutsLibraryHandle().registerCallout(
"lease4_select", lease4_select_different_callout));
- // Normally, dhcpv4_srv would passed the handle when calling allocateAddress4,
+ // Normally, dhcpv4_srv would passed the handle when calling allocateLease4,
// but in tests we need to create it on our own.
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
- // Call allocateAddress4. Callouts should be triggered here.
- Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
- IOAddress("0.0.0.0"),
- false, false, "",
- false, callout_handle,
- old_lease_);
+ // Call allocateLease4. Callouts should be triggered here.
+ Lease4Ptr lease = engine->allocateLease4(subnet_, clientid_, hwaddr_,
+ IOAddress("0.0.0.0"),
+ false, false, "",
+ false, callout_handle,
+ old_lease_);
// Check that we got a lease
ASSERT_TRUE(lease);
More information about the bind10-changes
mailing list