Commit a26a75c9 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[3149] Lease6::LeaseType and Pool::PoolType unified.

parent 17021645
...@@ -147,7 +147,7 @@ protected: ...@@ -147,7 +147,7 @@ protected:
/// @return returns a PoolPtr to the new Pool4 object. /// @return returns a PoolPtr to the new Pool4 object.
PoolPtr poolMaker (IOAddress &addr, uint32_t len, int32_t ptype) PoolPtr poolMaker (IOAddress &addr, uint32_t len, int32_t ptype)
{ {
return (PoolPtr(new Pool6(static_cast<isc::dhcp::Pool::PoolType> return (PoolPtr(new Pool6(static_cast<isc::dhcp::Lease::Type>
(ptype), addr, len))); (ptype), addr, len)));
} }
...@@ -161,7 +161,7 @@ protected: ...@@ -161,7 +161,7 @@ protected:
/// @return returns a PoolPtr to the new Pool4 object. /// @return returns a PoolPtr to the new Pool4 object.
PoolPtr poolMaker (IOAddress &min, IOAddress &max, int32_t ptype) PoolPtr poolMaker (IOAddress &min, IOAddress &max, int32_t ptype)
{ {
return (PoolPtr(new Pool6(static_cast<isc::dhcp::Pool::PoolType> return (PoolPtr(new Pool6(static_cast<isc::dhcp::Lease::Type>
(ptype), min, max))); (ptype), min, max)));
} }
}; };
......
...@@ -1225,7 +1225,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid, ...@@ -1225,7 +1225,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// be inserted into the LeaseMgr as well. // be inserted into the LeaseMgr as well.
Lease6Collection leases = alloc_engine_->allocateAddress6(subnet, duid, Lease6Collection leases = alloc_engine_->allocateAddress6(subnet, duid,
ia->getIAID(), ia->getIAID(),
hint, hint, Lease::TYPE_NA,
do_fwd, do_rev, do_fwd, do_rev,
hostname, hostname,
fake_allocation, fake_allocation,
...@@ -1321,7 +1321,7 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid, ...@@ -1321,7 +1321,7 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
return (ia_rsp); return (ia_rsp);
} }
Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
*duid, ia->getIAID(), *duid, ia->getIAID(),
subnet->getID()); subnet->getID());
...@@ -1585,7 +1585,7 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query, ...@@ -1585,7 +1585,7 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
return (ia_rsp); return (ia_rsp);
} }
Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
release_addr->getAddress()); release_addr->getAddress());
if (!lease) { if (!lease) {
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
: Dhcpv6SrvTest() { : Dhcpv6SrvTest() {
// generateClientId assigns DUID to duid_. // generateClientId assigns DUID to duid_.
generateClientId(); generateClientId();
lease_.reset(new Lease6(Lease6::LEASE_IA_NA, IOAddress("2001:db8:1::1"), lease_.reset(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
duid_, 1234, 501, 502, 503, duid_, 1234, 501, 502, 503,
504, 1, 0)); 504, 1, 0));
...@@ -1018,13 +1018,13 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) { ...@@ -1018,13 +1018,13 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1117,7 +1117,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) { ...@@ -1117,7 +1117,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
OptionPtr clientid = generateClientId(); OptionPtr clientid = generateClientId();
// Check that the lease is NOT in the database // Check that the lease is NOT in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
...@@ -1149,14 +1149,14 @@ TEST_F(Dhcpv6SrvTest, RenewReject) { ...@@ -1149,14 +1149,14 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
checkIA_NAStatusCode(ia, STATUS_NoBinding); checkIA_NAStatusCode(ia, STATUS_NoBinding);
// Check that there is no lease added // Check that there is no lease added
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
// CASE 2: Lease is known and belongs to this client, but to a different IAID // CASE 2: Lease is known and belongs to this client, but to a different IAID
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, valid_iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, valid_iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 123; // Let's use it as an indicator that the lease lease->cltt_ = 123; // Let's use it as an indicator that the lease
// was NOT updated. // was NOT updated.
...@@ -1191,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) { ...@@ -1191,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
ASSERT_TRUE(ia); ASSERT_TRUE(ia);
checkIA_NAStatusCode(ia, STATUS_NoBinding); checkIA_NAStatusCode(ia, STATUS_NoBinding);
lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_TRUE(lease); ASSERT_TRUE(lease);
// Verify that the lease was not updated. // Verify that the lease was not updated.
EXPECT_EQ(123, lease->cltt_); EXPECT_EQ(123, lease->cltt_);
...@@ -1222,13 +1222,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) { ...@@ -1222,13 +1222,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1268,11 +1268,11 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) { ...@@ -1268,11 +1268,11 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
// Check that the lease is really gone in the database // Check that the lease is really gone in the database
// get lease by address // get lease by address
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
// get lease by subnetid/duid/iaid combination // get lease by subnetid/duid/iaid combination
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, *duid_, iaid, l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, *duid_, iaid,
subnet_->getID()); subnet_->getID());
ASSERT_FALSE(l); ASSERT_FALSE(l);
} }
...@@ -1305,7 +1305,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) { ...@@ -1305,7 +1305,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
OptionPtr clientid = generateClientId(); OptionPtr clientid = generateClientId();
// Check that the lease is NOT in the database // Check that the lease is NOT in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
...@@ -1339,13 +1339,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) { ...@@ -1339,13 +1339,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode(reply, STATUS_NoBinding); checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is not there // Check that the lease is not there
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
// CASE 2: Lease is known and belongs to this client, but to a different IAID // CASE 2: Lease is known and belongs to this client, but to a different IAID
SCOPED_TRACE("CASE 2: Lease is known and belongs to this client, but to a different IAID"); SCOPED_TRACE("CASE 2: Lease is known and belongs to this client, but to a different IAID");
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, valid_iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, valid_iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
...@@ -1361,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) { ...@@ -1361,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode(reply, STATUS_NoBinding); checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is still there // Check that the lease is still there
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
// CASE 3: Lease belongs to a client with different client-id // CASE 3: Lease belongs to a client with different client-id
...@@ -1384,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) { ...@@ -1384,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode(reply, STATUS_NoBinding); checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is still there // Check that the lease is still there
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
// Finally, let's cleanup the database // Finally, let's cleanup the database
......
...@@ -321,7 +321,7 @@ public: ...@@ -321,7 +321,7 @@ public:
Dhcpv6SrvTest() { Dhcpv6SrvTest() {
subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 48, 1000, subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 48, 1000,
2000, 3000, 4000)); 2000, 3000, 4000));
pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:1::"), 64)); pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
subnet_->addPool(pool_); subnet_->addPool(pool_);
CfgMgr::instance().deleteSubnets6(); CfgMgr::instance().deleteSubnets6();
...@@ -377,7 +377,7 @@ public: ...@@ -377,7 +377,7 @@ public:
boost::shared_ptr<Option6IAAddr> addr) { boost::shared_ptr<Option6IAAddr> addr) {
boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(ia_na); boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(ia_na);
Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr->getAddress()); addr->getAddress());
if (!lease) { if (!lease) {
std::cout << "Lease for " << addr->getAddress().toText() std::cout << "Lease for " << addr->getAddress().toText()
......
...@@ -1070,13 +1070,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) { ...@@ -1070,13 +1070,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1167,13 +1167,13 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) { ...@@ -1167,13 +1167,13 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1258,13 +1258,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) { ...@@ -1258,13 +1258,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1296,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) { ...@@ -1296,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
// Check that our callback was called // Check that our callback was called
EXPECT_EQ("lease6_renew", callback_name_); EXPECT_EQ("lease6_renew", callback_name_);
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
// Check that the old values are still there and they were not // Check that the old values are still there and they were not
// updated by the renewal // updated by the renewal
...@@ -1334,13 +1334,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) { ...@@ -1334,13 +1334,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1379,11 +1379,11 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) { ...@@ -1379,11 +1379,11 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
// Check that the lease is really gone in the database // Check that the lease is really gone in the database
// get lease by address // get lease by address
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr); l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
ASSERT_FALSE(l); ASSERT_FALSE(l);
// Get lease by subnetid/duid/iaid combination // Get lease by subnetid/duid/iaid combination
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, *duid_, iaid, l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, *duid_, iaid,
subnet_->getID()); subnet_->getID());
ASSERT_FALSE(l); ASSERT_FALSE(l);
} }
...@@ -1415,13 +1415,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) { ...@@ -1415,13 +1415,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW. // value on purpose. They should be updated during RENEW.
Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid_, iaid, Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, duid_, iaid,
501, 502, 503, 504, subnet_->getID(), 0)); 501, 502, 503, 504, subnet_->getID(), 0));
lease->cltt_ = 1234; lease->cltt_ = 1234;
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease)); ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
// Check that the lease is really in the database // Check that the lease is really in the database
Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, Lease6Ptr l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
...@@ -1448,12 +1448,12 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) { ...@@ -1448,12 +1448,12 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
// Check that the lease is still there // Check that the lease is still there
// get lease by address // get lease by address
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
addr); addr);
ASSERT_TRUE(l); ASSERT_TRUE(l);
// Get lease by subnetid/duid/iaid combination // Get lease by subnetid/duid/iaid combination
l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, *duid_, iaid, l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, *duid_, iaid,
subnet_->getID()); subnet_->getID());
ASSERT_TRUE(l); ASSERT_TRUE(l);
} }
......
...@@ -42,6 +42,7 @@ libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h ...@@ -42,6 +42,7 @@ libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
libb10_dhcpsrv_la_SOURCES += dhcp_config_parser.h libb10_dhcpsrv_la_SOURCES += dhcp_config_parser.h
libb10_dhcpsrv_la_SOURCES += dhcp_parsers.cc dhcp_parsers.h libb10_dhcpsrv_la_SOURCES += dhcp_parsers.cc dhcp_parsers.h
libb10_dhcpsrv_la_SOURCES += key_from_key.h libb10_dhcpsrv_la_SOURCES += key_from_key.h
libb10_dhcpsrv_la_SOURCES += lease.cc lease.h
libb10_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h libb10_dhcpsrv_la_SOURCES += lease_mgr.cc lease_mgr.h
libb10_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h libb10_dhcpsrv_la_SOURCES += lease_mgr_factory.cc lease_mgr_factory.h
libb10_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h libb10_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
......
...@@ -53,7 +53,7 @@ AllocEngineHooks Hooks; ...@@ -53,7 +53,7 @@ AllocEngineHooks Hooks;
namespace isc { namespace isc {
namespace dhcp { namespace dhcp {
AllocEngine::IterativeAllocator::IterativeAllocator(Pool::PoolType lease_type) AllocEngine::IterativeAllocator::IterativeAllocator(Lease::Type lease_type)
:Allocator(lease_type) { :Allocator(lease_type) {
} }
...@@ -146,7 +146,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet, ...@@ -146,7 +146,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
return (next); return (next);
} }
AllocEngine::HashedAllocator::HashedAllocator(Pool::PoolType lease_type) AllocEngine::HashedAllocator::HashedAllocator(Lease::Type lease_type)
:Allocator(lease_type) { :Allocator(lease_type) {
isc_throw(NotImplemented, "Hashed allocator is not implemented"); isc_throw(NotImplemented, "Hashed allocator is not implemented");
} }
...@@ -159,7 +159,7 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&, ...@@ -159,7 +159,7 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
isc_throw(NotImplemented, "Hashed allocator is not implemented"); isc_throw(NotImplemented, "Hashed allocator is not implemented");
} }
AllocEngine::RandomAllocator::RandomAllocator(Pool::PoolType lease_type) AllocEngine::RandomAllocator::RandomAllocator(Lease::Type lease_type)
:Allocator(lease_type) { :Allocator(lease_type) {
isc_throw(NotImplemented, "Random allocator is not implemented"); isc_throw(NotImplemented, "Random allocator is not implemented");
} }
...@@ -204,6 +204,7 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet, ...@@ -204,6 +204,7 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
const DuidPtr& duid, const DuidPtr& duid,
uint32_t iaid, uint32_t iaid,
const IOAddress& hint, const IOAddress& hint,
Lease::Type type,
const bool fwd_dns_update, const bool fwd_dns_update,
const bool rev_dns_update, const bool rev_dns_update,
const std::string& hostname, const std::string& hostname,
...@@ -227,8 +228,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet, ...@@ -227,8 +228,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
// check if there's existing lease for that subnet/duid/iaid combination. // check if there's existing lease for that subnet/duid/iaid combination.
/// @todo: Make this generic (cover temp. addrs and prefixes) /// @todo: Make this generic (cover temp. addrs and prefixes)
Lease6Collection existing = LeaseMgrFactory::instance().getLeases6( Lease6Collection existing = LeaseMgrFactory::instance().getLeases6(type,
Lease6::LEASE_IA_NA, *duid, iaid, subnet->getID()); *duid, iaid, subnet->getID());
if (!existing.empty()) { if (!existing.empty()) {
// we have at least one lease already. This is a returning client, // we have at least one lease already. This is a returning client,
...@@ -240,15 +241,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet, ...@@ -240,15 +241,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
if (subnet->inPool(hint)) { if (subnet->inPool(hint)) {
/// @todo: We support only one hint for now /// @todo: We support only one hint for now
Lease6Ptr lease = LeaseMgrFactory::instance().getLease6( Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(type, hint);
Lease6::LEASE_IA_NA, hint);
if (!lease) { if (!lease) {
/// @todo: check if the hint is reserved once we have host support /// @todo: check if the hint is reserved once we have host support
/// implemented /// implemented
// the hint is valid and not currently used, let's create a lease for it // the hint is valid and not currently used, let's create a lease for it
/// @todo: We support only one lease per ia for now /// @todo: We support only one lease per ia for now
lease = createLease6(subnet, duid, iaid, hint, fwd_dns_update, lease = createLease6(subnet, duid, iaid, hint, type, fwd_dns_update,
rev_dns_update, hostname, callout_handle, rev_dns_update, hostname, callout_handle,
fake_allocation); fake_allocation);
...@@ -264,11 +264,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet, ...@@ -264,11 +264,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
} else { } else {
if (lease->expired()) { if (lease->expired()) {
/// We found a lease and it is expired, so we can reuse it /// We found a lease and it is expired, so we can reuse it
/// @todo: We support only one lease per ia for now
lease = reuseExpiredLease(lease, subnet, duid, iaid, lease = reuseExpiredLease(lease, subnet, duid, iaid,
fwd_dns_update, rev_dns_update, fwd_dns_update, rev_dns_update,
hostname, callout_handle, hostname, callout_handle,
fake_allocation); fake_allocation);
/// @todo: We support only one lease per ia for now
Lease6Collection collection; Lease6Collection collection;
collection.push_back(lease); collection.push_back(lease);
return (collection); return (collection);
...@@ -300,14 +301,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet, ...@@ -300,14 +301,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
/// @todo: check if the address is reserved once we have host support /// @todo: check if the address is reserved once we have host support
/// implemented /// implemented
Lease6Ptr existing = LeaseMgrFactory::instance().getLease6( Lease6Ptr existing = LeaseMgrFactory::instance().getLease6