BIND 10 master, updated. 7759a99d23a5d3246a160ad4363c33edfda2ef74 [master] Merge branch 'master' of ssh://git.bind10.isc.org/var/bind10/git/bind10

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Sep 19 10:02:38 UTC 2013


The branch, master has been updated
       via  7759a99d23a5d3246a160ad4363c33edfda2ef74 (commit)
       via  f8bbd7fa7def41d09c458282aadbbd2ca352f3a6 (commit)
       via  d7d74b349336faa877191ed4cc9f157858325596 (commit)
       via  b190045d32b46b927e40146ecb3b0af56d21e586 (commit)
       via  a26a75c9487a45b3d6d73abf41590ae379c811df (commit)
      from  e33d14843af79aa49e86fe4f13b8e253fcbe7fb2 (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 7759a99d23a5d3246a160ad4363c33edfda2ef74
Merge: f8bbd7f e33d148
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Thu Sep 19 11:38:44 2013 +0200

    [master] Merge branch 'master' of ssh://git.bind10.isc.org/var/bind10/git/bind10

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/config_parser.cc                     |    4 +-
 src/bin/dhcp6/dhcp6_srv.cc                         |    6 +-
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc          |   32 +-
 src/bin/dhcp6/tests/dhcp6_test_utils.h             |    4 +-
 src/bin/dhcp6/tests/hooks_unittest.cc              |   30 +-
 src/lib/dhcpsrv/Makefile.am                        |    1 +
 src/lib/dhcpsrv/alloc_engine.cc                    |   92 +++--
 src/lib/dhcpsrv/alloc_engine.h                     |   36 +-
 src/lib/dhcpsrv/{lease_mgr.cc => lease.cc}         |   94 ++----
 src/lib/dhcpsrv/lease.h                            |  353 ++++++++++++++++++++
 src/lib/dhcpsrv/lease_mgr.cc                       |  189 +----------
 src/lib/dhcpsrv/lease_mgr.h                        |  324 +-----------------
 src/lib/dhcpsrv/memfile_lease_mgr.cc               |    6 +-
 src/lib/dhcpsrv/memfile_lease_mgr.h                |    6 +-
 src/lib/dhcpsrv/mysql_lease_mgr.cc                 |   20 +-
 src/lib/dhcpsrv/mysql_lease_mgr.h                  |    6 +-
 src/lib/dhcpsrv/pool.cc                            |   20 +-
 src/lib/dhcpsrv/pool.h                             |   39 +--
 src/lib/dhcpsrv/subnet.cc                          |   63 ++--
 src/lib/dhcpsrv/subnet.h                           |   18 +-
 src/lib/dhcpsrv/tests/alloc_engine_unittest.cc     |  126 ++++---
 src/lib/dhcpsrv/tests/lease_mgr_unittest.cc        |   26 +-
 .../dhcpsrv/tests/memfile_lease_mgr_unittest.cc    |   18 +-
 src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc  |   10 +-
 src/lib/dhcpsrv/tests/pool_unittest.cc             |   52 +--
 src/lib/dhcpsrv/tests/subnet_unittest.cc           |  146 ++++----
 .../{test_libraries.h.in => test_libraries.h}      |    6 +-
 src/lib/dhcpsrv/tests/test_utils.cc                |    7 +-
 src/lib/dhcpsrv/tests/test_utils.h                 |    2 +-
 29 files changed, 821 insertions(+), 915 deletions(-)
 copy src/lib/dhcpsrv/{lease_mgr.cc => lease.cc} (79%)
 create mode 100644 src/lib/dhcpsrv/lease.h
 copy src/lib/dhcpsrv/tests/{test_libraries.h.in => test_libraries.h} (83%)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/config_parser.cc b/src/bin/dhcp6/config_parser.cc
index a5c179f..57af60e 100644
--- a/src/bin/dhcp6/config_parser.cc
+++ b/src/bin/dhcp6/config_parser.cc
@@ -147,7 +147,7 @@ protected:
     /// @return returns a PoolPtr to the new Pool4 object.
     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)));
     }
 
@@ -161,7 +161,7 @@ protected:
     /// @return returns a PoolPtr to the new Pool4 object.
     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)));
     }
 };
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index c96b37f..2da5c8b 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1225,7 +1225,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
     // be inserted into the LeaseMgr as well.
     Lease6Collection leases = alloc_engine_->allocateAddress6(subnet, duid,
                                                               ia->getIAID(),
-                                                              hint,
+                                                              hint, Lease::TYPE_NA,
                                                               do_fwd, do_rev,
                                                               hostname,
                                                               fake_allocation,
@@ -1321,7 +1321,7 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
         return (ia_rsp);
     }
 
-    Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA,
+    Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
                                                             *duid, ia->getIAID(),
                                                             subnet->getID());
 
@@ -1585,7 +1585,7 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
         return (ia_rsp);
     }
 
-    Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA,
+    Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
                                                             release_addr->getAddress());
 
     if (!lease) {
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 758e2d0..3869d2b 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -67,7 +67,7 @@ public:
         : Dhcpv6SrvTest() {
         // generateClientId assigns DUID to duid_.
         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,
                                 504, 1, 0));
 
@@ -1018,13 +1018,13 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1117,7 +1117,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     OptionPtr clientid = generateClientId();
 
     // 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);
     ASSERT_FALSE(l);
 
@@ -1149,14 +1149,14 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     checkIA_NAStatusCode(ia, STATUS_NoBinding);
 
     // 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);
 
     // 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
     // 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));
     lease->cltt_ = 123; // Let's use it as an indicator that the lease
                         // was NOT updated.
@@ -1191,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
     ASSERT_TRUE(ia);
     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);
     // Verify that the lease was not updated.
     EXPECT_EQ(123, lease->cltt_);
@@ -1222,13 +1222,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1268,11 +1268,11 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
 
     // Check that the lease is really gone in the database
     // get lease by address
-    l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr);
+    l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
     ASSERT_FALSE(l);
 
     // 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());
     ASSERT_FALSE(l);
 }
@@ -1305,7 +1305,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     OptionPtr clientid = generateClientId();
 
     // 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);
     ASSERT_FALSE(l);
 
@@ -1339,13 +1339,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     checkMsgStatusCode(reply, STATUS_NoBinding);
 
     // 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);
 
     // 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));
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
@@ -1361,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     checkMsgStatusCode(reply, STATUS_NoBinding);
 
     // 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);
 
     // CASE 3: Lease belongs to a client with different client-id
@@ -1384,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
     checkMsgStatusCode(reply, STATUS_NoBinding);
 
     // 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);
 
     // Finally, let's cleanup the database
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h
index 6e713c9..0e5ad7c 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.h
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h
@@ -321,7 +321,7 @@ public:
     Dhcpv6SrvTest() {
         subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 48, 1000,
                                          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_);
 
         CfgMgr::instance().deleteSubnets6();
@@ -377,7 +377,7 @@ public:
                          boost::shared_ptr<Option6IAAddr> addr) {
         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());
         if (!lease) {
             std::cout << "Lease for " << addr->getAddress().toText()
diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc
index e895e5f..767560f 100644
--- a/src/bin/dhcp6/tests/hooks_unittest.cc
+++ b/src/bin/dhcp6/tests/hooks_unittest.cc
@@ -1070,13 +1070,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1167,13 +1167,13 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1258,13 +1258,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1296,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
     // Check that our callback was called
     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
     // updated by the renewal
@@ -1334,13 +1334,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1379,11 +1379,11 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
 
     // Check that the lease is really gone in the database
     // get lease by address
-    l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA, addr);
+    l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
     ASSERT_FALSE(l);
 
     // 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());
     ASSERT_FALSE(l);
 }
@@ -1415,13 +1415,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
 
     // Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
     // 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));
     lease->cltt_ = 1234;
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
 
     // 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);
     ASSERT_TRUE(l);
 
@@ -1448,12 +1448,12 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
 
     // Check that the lease is still there
     // get lease by address
-    l = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA,
+    l = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
                                               addr);
     ASSERT_TRUE(l);
 
     // 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());
     ASSERT_TRUE(l);
 }
diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am
index a738aba..b3c4206 100644
--- a/src/lib/dhcpsrv/Makefile.am
+++ b/src/lib/dhcpsrv/Makefile.am
@@ -45,6 +45,7 @@ libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
 libb10_dhcpsrv_la_SOURCES += dhcp_config_parser.h
 libb10_dhcpsrv_la_SOURCES += dhcp_parsers.cc dhcp_parsers.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_factory.cc lease_mgr_factory.h
 libb10_dhcpsrv_la_SOURCES += memfile_lease_mgr.cc memfile_lease_mgr.h
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index 923f7cc..2f41a85 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -53,7 +53,7 @@ AllocEngineHooks Hooks;
 namespace isc {
 namespace dhcp {
 
-AllocEngine::IterativeAllocator::IterativeAllocator(Pool::PoolType lease_type)
+AllocEngine::IterativeAllocator::IterativeAllocator(Lease::Type lease_type)
     :Allocator(lease_type) {
 }
 
@@ -146,7 +146,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
     return (next);
 }
 
-AllocEngine::HashedAllocator::HashedAllocator(Pool::PoolType lease_type)
+AllocEngine::HashedAllocator::HashedAllocator(Lease::Type lease_type)
     :Allocator(lease_type) {
     isc_throw(NotImplemented, "Hashed allocator is not implemented");
 }
@@ -159,7 +159,7 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
     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) {
     isc_throw(NotImplemented, "Random allocator is not implemented");
 }
@@ -177,23 +177,45 @@ AllocEngine::AllocEngine(AllocType engine_type, unsigned int attempts,
                          bool ipv6)
     :attempts_(attempts) {
 
-    Pool::PoolType pool_type = ipv6?Pool::TYPE_IA:Pool::TYPE_V4;
+    // Choose the basic (normal address) lease type
+    Lease::Type basic_type = ipv6 ? Lease::TYPE_NA : Lease::TYPE_V4;
 
+    // Initalize normal address allocators
     switch (engine_type) {
     case ALLOC_ITERATIVE:
-        allocator_.reset(new IterativeAllocator(pool_type));
+        allocators_[basic_type] = AllocatorPtr(new IterativeAllocator(basic_type));
         break;
     case ALLOC_HASHED:
-        allocator_.reset(new HashedAllocator(pool_type));
+        allocators_[basic_type] = AllocatorPtr(new HashedAllocator(basic_type));
         break;
     case ALLOC_RANDOM:
-        allocator_.reset(new RandomAllocator(pool_type));
+        allocators_[basic_type] = AllocatorPtr(new RandomAllocator(basic_type));
         break;
-
     default:
         isc_throw(BadValue, "Invalid/unsupported allocation algorithm");
     }
 
+    // If this is IPv6 allocation engine, initalize also temporary addrs
+    // and prefixes
+    if (ipv6) {
+        switch (engine_type) {
+        case ALLOC_ITERATIVE:
+            allocators_[Lease::TYPE_TA] = AllocatorPtr(new IterativeAllocator(Lease::TYPE_TA));
+            allocators_[Lease::TYPE_PD] = AllocatorPtr(new IterativeAllocator(Lease::TYPE_PD));
+            break;
+        case ALLOC_HASHED:
+            allocators_[Lease::TYPE_TA] = AllocatorPtr(new HashedAllocator(Lease::TYPE_TA));
+            allocators_[Lease::TYPE_PD] = AllocatorPtr(new HashedAllocator(Lease::TYPE_PD));
+            break;
+        case ALLOC_RANDOM:
+            allocators_[Lease::TYPE_TA] = AllocatorPtr(new RandomAllocator(Lease::TYPE_TA));
+            allocators_[Lease::TYPE_PD] = AllocatorPtr(new RandomAllocator(Lease::TYPE_PD));
+            break;
+        default:
+            isc_throw(BadValue, "Invalid/unsupported allocation algorithm");
+        }
+    }
+
     // Register hook points
     hook_index_lease4_select_ = Hooks.hook_index_lease4_select_;
     hook_index_lease6_select_ = Hooks.hook_index_lease6_select_;
@@ -204,6 +226,7 @@ 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,
@@ -211,10 +234,11 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
                               const isc::hooks::CalloutHandlePtr& callout_handle) {
 
     try {
-        // That check is not necessary. We create allocator in AllocEngine
-        // constructor
-        if (!allocator_) {
-            isc_throw(InvalidOperation, "No allocator selected");
+        AllocatorPtr allocator = getAllocator(type);
+
+        if (!allocator) {
+            isc_throw(InvalidOperation, "No allocator specified for "
+                      << Lease6::typeToText(type));
         }
 
         if (!subnet) {
@@ -227,8 +251,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
 
         // check if there's existing lease for that subnet/duid/iaid combination.
         /// @todo: Make this generic (cover temp. addrs and prefixes)
-        Lease6Collection existing = LeaseMgrFactory::instance().getLeases6(
-            Lease6::LEASE_IA_NA, *duid, iaid, subnet->getID());
+        Lease6Collection existing = LeaseMgrFactory::instance().getLeases6(type,
+                                    *duid, iaid, subnet->getID());
 
         if (!existing.empty()) {
             // we have at least one lease already. This is a returning client,
@@ -240,15 +264,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
         if (subnet->inPool(hint)) {
 
             /// @todo: We support only one hint for now
-            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(
-                Lease6::LEASE_IA_NA, hint);
+            Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(type, hint);
             if (!lease) {
                 /// @todo: check if the hint is reserved once we have host support
                 /// implemented
 
                 // 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
-                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,
                                      fake_allocation);
 
@@ -264,11 +287,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
             } else {
                 if (lease->expired()) {
                     /// 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,
                                               fwd_dns_update, rev_dns_update,
                                               hostname, callout_handle,
                                               fake_allocation);
+
+                    /// @todo: We support only one lease per ia for now
                     Lease6Collection collection;
                     collection.push_back(lease);
                     return (collection);
@@ -295,19 +319,19 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
 
         unsigned int i = attempts_;
         do {
-            IOAddress candidate = allocator_->pickAddress(subnet, duid, hint);
+            IOAddress candidate = allocator->pickAddress(subnet, duid, hint);
 
             /// @todo: check if the address is reserved once we have host support
             /// implemented
 
-            Lease6Ptr existing = LeaseMgrFactory::instance().getLease6(
-                                 Lease6::LEASE_IA_NA, candidate);
+            Lease6Ptr existing = LeaseMgrFactory::instance().getLease6(type,
+                                 candidate);
             if (!existing) {
                 // there's no existing lease for selected candidate, so it is
                 // free. Let's allocate it.
                 Lease6Ptr lease = createLease6(subnet, duid, iaid, candidate,
-                                               fwd_dns_update, rev_dns_update,
-                                               hostname,
+                                               type, fwd_dns_update,
+                                               rev_dns_update, hostname,
                                                callout_handle, fake_allocation);
                 if (lease) {
                     Lease6Collection collection;
@@ -365,9 +389,12 @@ AllocEngine::allocateAddress4(const SubnetPtr& subnet,
     old_lease.reset();
 
     try {
+
+        AllocatorPtr allocator = getAllocator(Lease::TYPE_V4);
+
         // Allocator is always created in AllocEngine constructor and there is
         // currently no other way to set it, so that check is not really necessary.
-        if (!allocator_) {
+        if (!allocator) {
             isc_throw(InvalidOperation, "No allocator selected");
         }
 
@@ -466,7 +493,7 @@ AllocEngine::allocateAddress4(const SubnetPtr& subnet,
 
         unsigned int i = attempts_;
         do {
-            IOAddress candidate = allocator_->pickAddress(subnet, clientid, hint);
+            IOAddress candidate = allocator->pickAddress(subnet, clientid, hint);
 
             /// @todo: check if the address is reserved once we have host support
             /// implemented
@@ -752,13 +779,14 @@ Lease6Ptr AllocEngine::createLease6(const Subnet6Ptr& subnet,
                                     const DuidPtr& duid,
                                     uint32_t iaid,
                                     const IOAddress& addr,
+                                    Lease::Type type,
                                     const bool fwd_dns_update,
                                     const bool rev_dns_update,
                                     const std::string& hostname,
                                     const isc::hooks::CalloutHandlePtr& callout_handle,
                                     bool fake_allocation /*= false */ ) {
 
-    Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, duid, iaid,
+    Lease6Ptr lease(new Lease6(type, addr, duid, iaid,
                                subnet->getPreferred(), subnet->getValid(),
                                subnet->getT1(), subnet->getT2(), subnet->getID()));
 
@@ -818,7 +846,7 @@ Lease6Ptr AllocEngine::createLease6(const Subnet6Ptr& subnet,
         // It is for advertise only. We should not insert the lease into LeaseMgr,
         // but rather check that we could have inserted it.
         Lease6Ptr existing = LeaseMgrFactory::instance().getLease6(
-                             Lease6::LEASE_IA_NA, addr);
+                             Lease::TYPE_NA, addr);
         if (!existing) {
             return (lease);
         } else {
@@ -921,6 +949,16 @@ Lease4Ptr AllocEngine::createLease4(const SubnetPtr& subnet,
     }
 }
 
+AllocEngine::AllocatorPtr AllocEngine::getAllocator(Lease::Type type) {
+    std::map<Lease::Type, AllocatorPtr>::const_iterator alloc = allocators_.find(type);
+
+    if (alloc == allocators_.end()) {
+        isc_throw(BadValue, "No allocator initialized for pool type "
+                  << Lease::typeToText(type));
+    }
+    return (alloc->second);
+}
+
 AllocEngine::~AllocEngine() {
     // no need to delete allocator. smart_ptr will do the trick for us
 }
diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h
index 507d769..faf9c55 100644
--- a/src/lib/dhcpsrv/alloc_engine.h
+++ b/src/lib/dhcpsrv/alloc_engine.h
@@ -25,6 +25,8 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/noncopyable.hpp>
 
+#include <map>
+
 namespace isc {
 namespace dhcp {
 
@@ -81,7 +83,7 @@ protected:
         ///
         /// Specifies which type of leases this allocator will assign
         /// @param pool_type specifies pool type (addresses, temp. addr or prefixes)
-        Allocator(Pool::PoolType pool_type)
+        Allocator(Lease::Type pool_type)
             :pool_type_(pool_type) {
         }
 
@@ -90,10 +92,13 @@ protected:
         }
     protected:
 
-        /// @brief defines lease type allocation
-        Pool::PoolType pool_type_;
+        /// @brief defines pool type allocation
+        Lease::Type pool_type_;
     };
 
+    /// defines a pointer to allocator
+    typedef boost::shared_ptr<Allocator> AllocatorPtr;
+
     /// @brief Address/prefix allocator that iterates over all addresses
     ///
     /// This class implements iterative algorithm that returns all addresses in
@@ -107,7 +112,7 @@ protected:
         ///
         /// Does not do anything
         /// @param type - specifies allocation type
-        IterativeAllocator(Pool::PoolType type);
+        IterativeAllocator(Lease::Type type);
 
         /// @brief returns the next address from pools in a subnet
         ///
@@ -136,7 +141,7 @@ protected:
 
         /// @brief default constructor (does nothing)
         /// @param type - specifies allocation type
-        HashedAllocator(Pool::PoolType type);
+        HashedAllocator(Lease::Type type);
 
         /// @brief returns an address based on hash calculated from client's DUID.
         ///
@@ -159,7 +164,7 @@ protected:
 
         /// @brief default constructor (does nothing)
         /// @param type - specifies allocation type
-        RandomAllocator(Pool::PoolType type);
+        RandomAllocator(Lease::Type type);
 
         /// @brief returns an random address from pool of specified subnet
         ///
@@ -298,6 +303,7 @@ protected:
     /// @param duid Client's DUID
     /// @param iaid iaid field from the IA_NA container that client sent
     /// @param hint a hint that the client provided
+    /// @param type lease type (IA, TA or PD)
     /// @param fwd_dns_update A boolean value which indicates that server takes
     ///        responsibility for the forward DNS Update for this lease
     ///        (if true).
@@ -316,12 +322,19 @@ protected:
                      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)
+    /// @throw BadValue if allocator for a given type is missing
+    /// @return pointer to allocator handing a given resource types
+    AllocatorPtr getAllocator(Lease::Type type);
+
     /// @brief Destructor. Used during DHCPv6 service shutdown.
     virtual ~AllocEngine();
 private:
@@ -367,7 +380,8 @@ private:
     /// @param duid client's DUID
     /// @param iaid IAID from the IA_NA container the client sent to us
     /// @param addr an address that was selected and is confirmed to be
-    /// available
+    ///        available
+    /// @param type lease type (IA, TA or PD)
     /// @param fwd_dns_update A boolean value which indicates that server takes
     ///        responsibility for the forward DNS Update for this lease
     ///        (if true).
@@ -384,7 +398,8 @@ private:
     ///         became unavailable)
     Lease6Ptr createLease6(const Subnet6Ptr& subnet, const DuidPtr& duid,
                            uint32_t iaid, const isc::asiolink::IOAddress& addr,
-                           const bool fwd_dns_update, const bool rev_dns_update,
+                           Lease::Type type, const bool fwd_dns_update,
+                           const bool rev_dns_update,
                            const std::string& hostname,
                            const isc::hooks::CalloutHandlePtr& callout_handle,
                            bool fake_allocation = false);
@@ -452,7 +467,10 @@ private:
                                 bool fake_allocation = false);
 
     /// @brief a pointer to currently used allocator
-    boost::shared_ptr<Allocator> allocator_;
+    ///
+    /// For IPv4, there will be only one allocator: TYPE_V4
+    /// For IPv6, there will be 3 allocators: TYPE_NA, TYPE_TA, TYPE_PD
+    std::map<Lease::Type, AllocatorPtr> allocators_;
 
     /// @brief number of attempts before we give up lease allocation (0=unlimited)
     unsigned int attempts_;
diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc
new file mode 100644
index 0000000..81a4f87
--- /dev/null
+++ b/src/lib/dhcpsrv/lease.cc
@@ -0,0 +1,218 @@
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <dhcpsrv/lease.h>
+#include <sstream>
+
+using namespace std;
+
+namespace isc {
+namespace dhcp {
+
+Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
+             uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
+             const bool fqdn_fwd, const bool fqdn_rev,
+             const std::string& hostname)
+    :addr_(addr), t1_(t1), t2_(t2), valid_lft_(valid_lft), cltt_(cltt),
+     subnet_id_(subnet_id), fixed_(false), hostname_(hostname),
+     fqdn_fwd_(fqdn_fwd), fqdn_rev_(fqdn_rev) {
+}
+
+std::string
+Lease::typeToText(Lease::Type type) {
+   switch (type) {
+   case Lease::TYPE_V4:
+       return string("V4");
+   case Lease::TYPE_NA:
+       return string("IA_NA");
+   case Lease::TYPE_TA:
+       return string("IA_TA");
+   case Lease::TYPE_PD:
+       return string("IA_PD");
+       break;
+   default: {
+       stringstream tmp;
+       tmp << "unknown (" << type << ")";
+       return (tmp.str());
+   }
+   }
+}
+
+bool Lease::expired() const {
+
+    // Let's use int64 to avoid problems with negative/large uint32 values
+    int64_t expire_time = cltt_ + valid_lft_;
+    return (expire_time < time(NULL));
+}
+
+Lease4::Lease4(const Lease4& other)
+    : Lease(other.addr_, other.t1_, other.t2_, other.valid_lft_,
+            other.subnet_id_, other.cltt_, other.fqdn_fwd_,
+            other.fqdn_rev_, other.hostname_), ext_(other.ext_),
+      hwaddr_(other.hwaddr_) {
+
+    fixed_ = other.fixed_;
+    comments_ = other.comments_;
+
+    if (other.client_id_) {
+        client_id_.reset(new ClientId(other.client_id_->getClientId()));
+
+    } else {
+        client_id_.reset();
+
+    }
+}
+
+Lease4&
+Lease4::operator=(const Lease4& other) {
+    if (this != &other) {
+        addr_ = other.addr_;
+        t1_ = other.t1_;
+        t2_ = other.t2_;
+        valid_lft_ = other.valid_lft_;
+        cltt_ = other.cltt_;
+        subnet_id_ = other.subnet_id_;
+        fixed_ = other.fixed_;
+        hostname_ = other.hostname_;
+        fqdn_fwd_ = other.fqdn_fwd_;
+        fqdn_rev_ = other.fqdn_rev_;
+        comments_ = other.comments_;
+        ext_ = other.ext_;
+        hwaddr_ = other.hwaddr_;
+
+        if (other.client_id_) {
+            client_id_.reset(new ClientId(other.client_id_->getClientId()));
+        } else {
+            client_id_.reset();
+        }
+    }
+    return (*this);
+}
+
+Lease6::Lease6(Type type, const isc::asiolink::IOAddress& addr,
+               DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
+               uint32_t t1, uint32_t t2, SubnetID subnet_id, uint8_t prefixlen)
+    : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/, false, false, ""),
+      type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
+      preferred_lft_(preferred) {
+    if (!duid) {
+        isc_throw(InvalidOperation, "DUID must be specified for a lease");
+    }
+
+    cltt_ = time(NULL);
+}
+
+Lease6::Lease6(Type type, const isc::asiolink::IOAddress& addr,
+               DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
+               uint32_t t1, uint32_t t2, SubnetID subnet_id,
+               const bool fqdn_fwd, const bool fqdn_rev,
+               const std::string& hostname, uint8_t prefixlen)
+    : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/,
+            fqdn_fwd, fqdn_rev, hostname),
+      type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
+      preferred_lft_(preferred) {
+    if (!duid) {
+        isc_throw(InvalidOperation, "DUID must be specified for a lease");
+    }
+
+    cltt_ = time(NULL);
+}
+
+std::string
+Lease6::toText() const {
+    ostringstream stream;
+
+    stream << "Type:          " << typeToText(type_) << "(" 
+           << static_cast<int>(type_) << ") ";
+    stream << "Address:       " << addr_.toText() << "\n"
+           << "Prefix length: " << static_cast<int>(prefixlen_) << "\n"
+           << "IAID:          " << iaid_ << "\n"
+           << "Pref life:     " << preferred_lft_ << "\n"
+           << "Valid life:    " << valid_lft_ << "\n"
+           << "Cltt:          " << cltt_ << "\n"
+           << "Subnet ID:     " << subnet_id_ << "\n";
+
+    return (stream.str());
+}
+
+std::string
+Lease4::toText() const {
+    ostringstream stream;
+
+    stream << "Address:       " << addr_.toText() << "\n"
+           << "Valid life:    " << valid_lft_ << "\n"
+           << "T1:            " << t1_ << "\n"
+           << "T2:            " << t2_ << "\n"
+           << "Cltt:          " << cltt_ << "\n"
+           << "Subnet ID:     " << subnet_id_ << "\n";
+
+    return (stream.str());
+}
+
+
+bool
+Lease4::operator==(const Lease4& other) const {
+    if ( (client_id_ && !other.client_id_) ||
+         (!client_id_ && other.client_id_) ) {
+        // One lease has client-id, but the other doesn't
+        return false;
+    }
+
+    if (client_id_ && other.client_id_ &&
+        *client_id_ != *other.client_id_) {
+        // Different client-ids
+        return false;
+    }
+
+    return (
+        addr_ == other.addr_ &&
+        ext_ == other.ext_ &&
+        hwaddr_ == other.hwaddr_ &&
+        t1_ == other.t1_ &&
+        t2_ == other.t2_ &&
+        valid_lft_ == other.valid_lft_ &&
+        cltt_ == other.cltt_ &&
+        subnet_id_ == other.subnet_id_ &&
+        fixed_ == other.fixed_ &&
+        hostname_ == other.hostname_ &&
+        fqdn_fwd_ == other.fqdn_fwd_ &&
+        fqdn_rev_ == other.fqdn_rev_ &&
+        comments_ == other.comments_
+    );
+}
+
+bool
+Lease6::operator==(const Lease6& other) const {
+    return (
+        addr_ == other.addr_ &&
+        type_ == other.type_ &&
+        prefixlen_ == other.prefixlen_ &&
+        iaid_ == other.iaid_ &&
+        *duid_ == *other.duid_ &&
+        preferred_lft_ == other.preferred_lft_ &&
+        valid_lft_ == other.valid_lft_ &&
+        t1_ == other.t1_ &&
+        t2_ == other.t2_ &&
+        cltt_ == other.cltt_ &&
+        subnet_id_ == other.subnet_id_ &&
+        fixed_ == other.fixed_ &&
+        hostname_ == other.hostname_ &&
+        fqdn_fwd_ == other.fqdn_fwd_ &&
+        fqdn_rev_ == other.fqdn_rev_ &&
+        comments_ == other.comments_
+    );
+}
+
+} // namespace isc::dhcp
+} // namespace isc
diff --git a/src/lib/dhcpsrv/lease.h b/src/lib/dhcpsrv/lease.h
new file mode 100644
index 0000000..b6efa8d
--- /dev/null
+++ b/src/lib/dhcpsrv/lease.h
@@ -0,0 +1,353 @@
+// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef LEASE_H
+#define LEASE_H
+
+#include <asiolink/io_address.h>
+#include <dhcp/duid.h>
+#include <dhcp/option.h>
+#include <dhcp/hwaddr.h>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Unique identifier for a subnet (both v4 and v6)
+///
+/// Let's copy SubnetID definition from subnet.h. We can't include it directly,
+/// because subnet.h needs Lease::Type, so it includes lease.h
+typedef uint32_t SubnetID;
+
+/// @brief a common structure for IPv4 and IPv6 leases
+///
+/// This structure holds all information that is common between IPv4 and IPv6
+/// leases.
+struct Lease {
+
+    /// @brief Type of lease or pool
+    typedef enum {
+        TYPE_NA = 0, /// the lease contains non-temporary IPv6 address
+        TYPE_TA = 1, /// the lease contains temporary IPv6 address
+        TYPE_PD = 2, /// the lease contains IPv6 prefix (for prefix delegation)
+        TYPE_V4 = 3  /// IPv4 lease
+    } Type;
+
+    /// @brief returns text representation of a lease type
+    /// @param type lease or pool type to be converted
+    /// @return text decription
+    static std::string typeToText(Type type);
+
+    /// @brief Constructor
+    ///
+    /// @param addr IP address
+    /// @param t1 renewal time
+    /// @param t2 rebinding time
+    /// @param valid_lft Lifetime of the lease
+    /// @param subnet_id Subnet identification
+    /// @param cltt Client last transmission time
+    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
+    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
+    /// @param hostname FQDN of the client which gets the lease.
+    Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
+          uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
+          const bool fqdn_fwd, const bool fqdn_rev,
+          const std::string& hostname);
+
+    /// @brief Destructor
+    virtual ~Lease() {}
+
+    /// @brief IPv4 ot IPv6 address
+    ///
+    /// IPv4, IPv6 address or, in the case of a prefix delegation, the prefix.
+    isc::asiolink::IOAddress addr_;
+
+    /// @brief Renewal timer
+    ///
+    /// Specifies renewal time. Although technically it is a property of the
+    /// IA container and not the address itself, since our data model does not
+    /// define a separate IA entity, we are keeping it in the lease. In the
+    /// case of multiple addresses/prefixes for the same IA, each must have
+    /// consistent T1 and T2 values. This is specified in seconds since cltt.
+    uint32_t t1_;
+
+    /// @brief Rebinding timer
+    ///
+    /// Specifies rebinding time. Although technically it is a property of the
+    /// IA container and not the address itself, since our data model does not
+    /// define a separate IA entity, we are keeping it in the lease. In the
+    /// case of multiple addresses/prefixes for the same IA, each must have
+    /// consistent T1 and T2 values. This is specified in seconds since cltt.
+    uint32_t t2_;
+
+    /// @brief Valid lifetime
+    ///
+    /// Expressed as number of seconds since cltt.
+    uint32_t valid_lft_;
+
+    /// @brief Client last transmission time
+    ///
+    /// Specifies a timestamp giving the time when the last transmission from a
+    /// client was received.
+    time_t cltt_;
+
+    /// @brief Subnet identifier
+    ///
+    /// Specifies the identification of the subnet to which the lease belongs.
+    SubnetID subnet_id_;
+
+    /// @brief Fixed lease?
+    ///
+    /// Fixed leases are kept after they are released/expired.
+    bool fixed_;
+
+    /// @brief Client hostname
+    ///
+    /// This field may be empty
+    std::string hostname_;
+
+    /// @brief Forward zone updated?
+    ///
+    /// Set true if the DNS AAAA record for this lease has been updated.
+    bool fqdn_fwd_;
+
+    /// @brief Reverse zone updated?
+    ///
+    /// Set true if the DNS PTR record for this lease has been updated.
+    bool fqdn_rev_;
+
+    /// @brief Lease comments
+    ///
+    /// Currently not used. It may be used for keeping comments made by the
+    /// system administrator.
+    std::string comments_;
+
+    /// @brief Convert Lease to Printable Form
+    ///
+    /// @return String form of the lease
+    virtual std::string toText() const = 0;
+
+    /// @brief returns true if the lease is expired
+    /// @return true if the lease is expired
+    bool expired() const;
+
+};
+
+/// @brief Structure that holds a lease for IPv4 address
+///
+/// For performance reasons it is a simple structure, not a class. If we chose
+/// make it a class, all fields would have to made private and getters/setters
+/// would be required. As this is a critical part of the code that will be used
+/// extensively, direct access is warranted.
+struct Lease4 : public Lease {
+
+    /// @brief Address extension
+    ///
+    /// It is envisaged that in some cases IPv4 address will be accompanied
+    /// with some additional data. One example of such use are Address + Port
+    /// solutions (or Port-restricted Addresses), where several clients may get
+    /// the same address, but different port ranges. This feature is not
+    /// expected to be widely used.  Under normal circumstances, the value
+    /// should be 0.
+    uint32_t ext_;
+
+    /// @brief Hardware address
+    std::vector<uint8_t> hwaddr_;
+
+    /// @brief Client identifier
+    ///
+    /// @todo Should this be a pointer to a client ID or the ID itself?
+    ///       Compare with the DUID in the Lease6 structure.
+    ClientIdPtr client_id_;
+
+    /// @brief Constructor
+    ///
+    /// @param addr IPv4 address.
+    /// @param hwaddr Hardware address buffer
+    /// @param hwaddr_len Length of hardware address buffer
+    /// @param clientid Client identification buffer
+    /// @param clientid_len Length of client identification buffer
+    /// @param valid_lft Lifetime of the lease
+    /// @param t1 renewal time
+    /// @param t2 rebinding time
+    /// @param cltt Client last transmission time
+    /// @param subnet_id Subnet identification
+    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
+    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
+    /// @param hostname FQDN of the client which gets the lease.
+    Lease4(const isc::asiolink::IOAddress& addr, const uint8_t* hwaddr, size_t hwaddr_len,
+           const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft,
+           uint32_t t1, uint32_t t2, time_t cltt, uint32_t subnet_id,
+           const bool fqdn_fwd = false, const bool fqdn_rev = false,
+           const std::string& hostname = "")
+        : Lease(addr, t1, t2, valid_lft, subnet_id, cltt, fqdn_fwd, fqdn_rev,
+                hostname),
+        ext_(0), hwaddr_(hwaddr, hwaddr + hwaddr_len) {
+        if (clientid_len) {
+            client_id_.reset(new ClientId(clientid, clientid_len));
+        }
+    }
+
+    /// @brief Default constructor
+    ///
+    /// Initialize fields that don't have a default constructor.
+    Lease4() : Lease(0, 0, 0, 0, 0, 0, false, false, "") {
+    }
+
+    /// @brief Copy constructor
+    ///
+    /// @param other the @c Lease4 object to be copied.
+    Lease4(const Lease4& other);
+
+    /// @brief Assignment operator.
+    ///
+    /// @param other the @c Lease4 object to be assigned.
+    Lease4& operator=(const Lease4& other);
+
+    /// @brief Compare two leases for equality
+    ///
+    /// @param other lease6 object with which to compare
+    bool operator==(const Lease4& other) const;
+
+    /// @brief Compare two leases for inequality
+    ///
+    /// @param other lease6 object with which to compare
+    bool operator!=(const Lease4& other) const {
+        return (!operator==(other));
+    }
+
+    /// @brief Convert lease to printable form
+    ///
+    /// @return Textual represenation of lease data
+    virtual std::string toText() const;
+
+    /// @todo: Add DHCPv4 failover related fields here
+};
+
+/// @brief Pointer to a Lease4 structure.
+typedef boost::shared_ptr<Lease4> Lease4Ptr;
+
+/// @brief A collection of IPv4 leases.
+typedef std::vector<Lease4Ptr> Lease4Collection;
+
+/// @brief Structure that holds a lease for IPv6 address and/or prefix
+///
+/// For performance reasons it is a simple structure, not a class. If we chose
+/// make it a class, all fields would have to made private and getters/setters
+/// would be required. As this is a critical part of the code that will be used
+/// extensively, direct access is warranted.
+struct Lease6 : public Lease {
+
+    /// @brief Lease type
+    ///
+    /// One of normal address, temporary address, or prefix.
+    Type type_;
+
+    /// @brief IPv6 prefix length
+    ///
+    /// This is used only for prefix delegations and is ignored otherwise.
+    uint8_t prefixlen_;
+
+    /// @brief Identity Association Identifier (IAID)
+    ///
+    /// DHCPv6 stores all addresses and prefixes in IA containers (IA_NA,
+    /// IA_TA, IA_PD). All containers may appear more than once in a message.
+    /// To differentiate between them, the IAID field is present
+    uint32_t iaid_;
+
+    /// @brief Client identifier
+    DuidPtr duid_;
+
+    /// @brief preferred lifetime
+    ///
+    /// This parameter specifies the preferred lifetime since the lease was
+    /// assigned or renewed (cltt), expressed in seconds.
+    uint32_t preferred_lft_;
+
+    /// @todo: Add DHCPv6 failover related fields here
+
+    /// @brief Constructor
+    /// @param type Lease type.
+    /// @param addr Assigned address.
+    /// @param duid A pointer to an object representing DUID.
+    /// @param iaid IAID.
+    /// @param preferred Preferred lifetime.
+    /// @param valid Valid lifetime.
+    /// @param t1 A value of the T1 timer.
+    /// @param t2 A value of the T2 timer.
+    /// @param subnet_id A Subnet identifier.
+    /// @param prefixlen An address prefix length.
+    Lease6(Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
+           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
+           uint32_t t2, SubnetID subnet_id, uint8_t prefixlen = 0);
+
+    /// @brief Constructor, including FQDN data.
+    ///
+    /// @param type Lease type.
+    /// @param addr Assigned address.
+    /// @param duid A pointer to an object representing DUID.
+    /// @param iaid IAID.
+    /// @param preferred Preferred lifetime.
+    /// @param valid Valid lifetime.
+    /// @param t1 A value of the T1 timer.
+    /// @param t2 A value of the T2 timer.
+    /// @param subnet_id A Subnet identifier.
+    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
+    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
+    /// @param hostname FQDN of the client which gets the lease.
+    /// @param prefixlen An address prefix length.
+    Lease6(Type type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
+           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
+           uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd,
+           const bool fqdn_rev, const std::string& hostname,
+           uint8_t prefixlen = 0);
+
+    /// @brief Constructor
+    ///
+    /// Initialize fields that don't have a default constructor.
+    Lease6() : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0,
+                     false, false, ""),
+        type_(TYPE_NA) {
+    }
+
+    /// @brief Compare two leases for equality
+    ///
+    /// @param other lease6 object with which to compare
+    bool operator==(const Lease6& other) const;
+
+    /// @brief Compare two leases for inequality
+    ///
+    /// @param other lease6 object with which to compare
+    bool operator!=(const Lease6& other) const {
+        return (!operator==(other));
+    }
+
+    /// @brief Convert Lease to Printable Form
+    ///
+    /// @return String form of the lease
+    virtual std::string toText() const;
+};
+
+/// @brief Pointer to a Lease6 structure.
+typedef boost::shared_ptr<Lease6> Lease6Ptr;
+
+/// @brief Pointer to a const Lease6 structure.
+typedef boost::shared_ptr<const Lease6> ConstLease6Ptr;
+
+/// @brief A collection of IPv6 leases.
+typedef std::vector<Lease6Ptr> Lease6Collection;
+
+}; // end of isc::dhcp namespace
+}; // end of isc namespace
+
+#endif // LEASE_H
diff --git a/src/lib/dhcpsrv/lease_mgr.cc b/src/lib/dhcpsrv/lease_mgr.cc
index 64b08be..e4fa07f 100644
--- a/src/lib/dhcpsrv/lease_mgr.cc
+++ b/src/lib/dhcpsrv/lease_mgr.cc
@@ -32,96 +32,6 @@ using namespace std;
 namespace isc {
 namespace dhcp {
 
-Lease::Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
-             uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
-             const bool fqdn_fwd, const bool fqdn_rev,
-             const std::string& hostname)
-    :addr_(addr), t1_(t1), t2_(t2), valid_lft_(valid_lft), cltt_(cltt),
-     subnet_id_(subnet_id), fixed_(false), hostname_(hostname),
-     fqdn_fwd_(fqdn_fwd), fqdn_rev_(fqdn_rev) {
-}
-
-Lease4::Lease4(const Lease4& other)
-    : Lease(other.addr_, other.t1_, other.t2_, other.valid_lft_,
-            other.subnet_id_, other.cltt_, other.fqdn_fwd_,
-            other.fqdn_rev_, other.hostname_), ext_(other.ext_),
-      hwaddr_(other.hwaddr_) {
-
-    fixed_ = other.fixed_;
-    comments_ = other.comments_;
-
-    if (other.client_id_) {
-        client_id_.reset(new ClientId(other.client_id_->getClientId()));
-
-    } else {
-        client_id_.reset();
-
-    }
-}
-
-Lease4&
-Lease4::operator=(const Lease4& other) {
-    if (this != &other) {
-        addr_ = other.addr_;
-        t1_ = other.t1_;
-        t2_ = other.t2_;
-        valid_lft_ = other.valid_lft_;
-        cltt_ = other.cltt_;
-        subnet_id_ = other.subnet_id_;
-        fixed_ = other.fixed_;
-        hostname_ = other.hostname_;
-        fqdn_fwd_ = other.fqdn_fwd_;
-        fqdn_rev_ = other.fqdn_rev_;
-        comments_ = other.comments_;
-        ext_ = other.ext_;
-        hwaddr_ = other.hwaddr_;
-
-        if (other.client_id_) {
-            client_id_.reset(new ClientId(other.client_id_->getClientId()));
-        } else {
-            client_id_.reset();
-        }
-    }
-    return (*this);
-}
-
-Lease6::Lease6(LeaseType type, const isc::asiolink::IOAddress& addr,
-               DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
-               uint32_t t1, uint32_t t2, SubnetID subnet_id, uint8_t prefixlen)
-    : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/, false, false, ""),
-      type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
-      preferred_lft_(preferred) {
-    if (!duid) {
-        isc_throw(InvalidOperation, "DUID must be specified for a lease");
-    }
-
-    cltt_ = time(NULL);
-}
-
-Lease6::Lease6(LeaseType type, const isc::asiolink::IOAddress& addr,
-               DuidPtr duid, uint32_t iaid, uint32_t preferred, uint32_t valid,
-               uint32_t t1, uint32_t t2, SubnetID subnet_id,
-               const bool fqdn_fwd, const bool fqdn_rev,
-               const std::string& hostname, uint8_t prefixlen)
-    : Lease(addr, t1, t2, valid, subnet_id, 0/*cltt*/,
-            fqdn_fwd, fqdn_rev, hostname),
-      type_(type), prefixlen_(prefixlen), iaid_(iaid), duid_(duid),
-      preferred_lft_(preferred) {
-    if (!duid) {
-        isc_throw(InvalidOperation, "DUID must be specified for a lease");
-    }
-
-    cltt_ = time(NULL);
-}
-
-bool Lease::expired() const {
-
-    // Let's use int64 to avoid problems with negative/large uint32 values
-    int64_t expire_time = cltt_ + valid_lft_;
-    return (expire_time < time(NULL));
-}
-
-
 std::string LeaseMgr::getParameter(const std::string& name) const {
     ParameterMap::const_iterator param = parameters_.find(name);
     if (param == parameters_.end()) {
@@ -131,7 +41,7 @@ std::string LeaseMgr::getParameter(const std::string& name) const {
 }
 
 Lease6Ptr
-LeaseMgr::getLease6(Lease6::LeaseType type, const DUID& duid,
+LeaseMgr::getLease6(Lease::Type type, const DUID& duid,
                     uint32_t iaid, SubnetID subnet_id) const {
     Lease6Collection col = getLeases6(type, duid, iaid, subnet_id);
 
@@ -147,102 +57,5 @@ LeaseMgr::getLease6(Lease6::LeaseType type, const DUID& duid,
     return (*col.begin());
 }
 
-std::string
-Lease6::toText() const {
-    ostringstream stream;
-
-    stream << "Type:          " << static_cast<int>(type_) << " (";
-    switch (type_) {
-        case Lease6::LEASE_IA_NA:
-            stream << "IA_NA)\n";
-            break;
-        case Lease6::LEASE_IA_TA:
-            stream << "IA_TA)\n";
-            break;
-        case Lease6::LEASE_IA_PD:
-            stream << "IA_PD)\n";
-            break;
-        default:
-            stream << "unknown)\n";
-    }
-    stream << "Address:       " << addr_.toText() << "\n"
-           << "Prefix length: " << static_cast<int>(prefixlen_) << "\n"
-           << "IAID:          " << iaid_ << "\n"
-           << "Pref life:     " << preferred_lft_ << "\n"
-           << "Valid life:    " << valid_lft_ << "\n"
-           << "Cltt:          " << cltt_ << "\n"
-           << "Subnet ID:     " << subnet_id_ << "\n";
-
-    return (stream.str());
-}
-
-std::string
-Lease4::toText() const {
-    ostringstream stream;
-
-    stream << "Address:       " << addr_.toText() << "\n"
-           << "Valid life:    " << valid_lft_ << "\n"
-           << "T1:            " << t1_ << "\n"
-           << "T2:            " << t2_ << "\n"
-           << "Cltt:          " << cltt_ << "\n"
-           << "Subnet ID:     " << subnet_id_ << "\n";
-
-    return (stream.str());
-}
-
-
-bool
-Lease4::operator==(const Lease4& other) const {
-    if ( (client_id_ && !other.client_id_) ||
-         (!client_id_ && other.client_id_) ) {
-        // One lease has client-id, but the other doesn't
-        return false;
-    }
-
-    if (client_id_ && other.client_id_ &&
-        *client_id_ != *other.client_id_) {
-        // Different client-ids
-        return false;
-    }
-
-    return (
-        addr_ == other.addr_ &&
-        ext_ == other.ext_ &&
-        hwaddr_ == other.hwaddr_ &&
-        t1_ == other.t1_ &&
-        t2_ == other.t2_ &&
-        valid_lft_ == other.valid_lft_ &&
-        cltt_ == other.cltt_ &&
-        subnet_id_ == other.subnet_id_ &&
-        fixed_ == other.fixed_ &&
-        hostname_ == other.hostname_ &&
-        fqdn_fwd_ == other.fqdn_fwd_ &&
-        fqdn_rev_ == other.fqdn_rev_ &&
-        comments_ == other.comments_
-    );
-}
-
-bool
-Lease6::operator==(const Lease6& other) const {
-    return (
-        addr_ == other.addr_ &&
-        type_ == other.type_ &&
-        prefixlen_ == other.prefixlen_ &&
-        iaid_ == other.iaid_ &&
-        *duid_ == *other.duid_ &&
-        preferred_lft_ == other.preferred_lft_ &&
-        valid_lft_ == other.valid_lft_ &&
-        t1_ == other.t1_ &&
-        t2_ == other.t2_ &&
-        cltt_ == other.cltt_ &&
-        subnet_id_ == other.subnet_id_ &&
-        fixed_ == other.fixed_ &&
-        hostname_ == other.hostname_ &&
-        fqdn_fwd_ == other.fqdn_fwd_ &&
-        fqdn_rev_ == other.fqdn_rev_ &&
-        comments_ == other.comments_
-    );
-}
-
 } // namespace isc::dhcp
 } // namespace isc
diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h
index edff4c6..a4579b8 100644
--- a/src/lib/dhcpsrv/lease_mgr.h
+++ b/src/lib/dhcpsrv/lease_mgr.h
@@ -19,6 +19,7 @@
 #include <dhcp/duid.h>
 #include <dhcp/option.h>
 #include <dhcp/hwaddr.h>
+#include <dhcpsrv/lease.h>
 #include <dhcpsrv/subnet.h>
 #include <exceptions/exceptions.h>
 
@@ -108,319 +109,6 @@ public:
         isc::Exception(file, line, what) {}
 };
 
-/// @brief a common structure for IPv4 and IPv6 leases
-///
-/// This structure holds all information that is common between IPv4 and IPv6
-/// leases.
-struct Lease {
-
-    /// @brief Constructor
-    ///
-    /// @param addr IP address
-    /// @param t1 renewal time
-    /// @param t2 rebinding time
-    /// @param valid_lft Lifetime of the lease
-    /// @param subnet_id Subnet identification
-    /// @param cltt Client last transmission time
-    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
-    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
-    /// @param hostname FQDN of the client which gets the lease.
-    Lease(const isc::asiolink::IOAddress& addr, uint32_t t1, uint32_t t2,
-          uint32_t valid_lft, SubnetID subnet_id, time_t cltt,
-          const bool fqdn_fwd, const bool fqdn_rev,
-          const std::string& hostname);
-
-    /// @brief Destructor
-    virtual ~Lease() {}
-
-    /// @brief IPv4 ot IPv6 address
-    ///
-    /// IPv4, IPv6 address or, in the case of a prefix delegation, the prefix.
-    isc::asiolink::IOAddress addr_;
-
-    /// @brief Renewal timer
-    ///
-    /// Specifies renewal time. Although technically it is a property of the
-    /// IA container and not the address itself, since our data model does not
-    /// define a separate IA entity, we are keeping it in the lease. In the
-    /// case of multiple addresses/prefixes for the same IA, each must have
-    /// consistent T1 and T2 values. This is specified in seconds since cltt.
-    uint32_t t1_;
-
-    /// @brief Rebinding timer
-    ///
-    /// Specifies rebinding time. Although technically it is a property of the
-    /// IA container and not the address itself, since our data model does not
-    /// define a separate IA entity, we are keeping it in the lease. In the
-    /// case of multiple addresses/prefixes for the same IA, each must have
-    /// consistent T1 and T2 values. This is specified in seconds since cltt.
-    uint32_t t2_;
-
-    /// @brief Valid lifetime
-    ///
-    /// Expressed as number of seconds since cltt.
-    uint32_t valid_lft_;
-
-    /// @brief Client last transmission time
-    ///
-    /// Specifies a timestamp giving the time when the last transmission from a
-    /// client was received.
-    time_t cltt_;
-
-    /// @brief Subnet identifier
-    ///
-    /// Specifies the identification of the subnet to which the lease belongs.
-    SubnetID subnet_id_;
-
-    /// @brief Fixed lease?
-    ///
-    /// Fixed leases are kept after they are released/expired.
-    bool fixed_;
-
-    /// @brief Client hostname
-    ///
-    /// This field may be empty
-    std::string hostname_;
-
-    /// @brief Forward zone updated?
-    ///
-    /// Set true if the DNS AAAA record for this lease has been updated.
-    bool fqdn_fwd_;
-
-    /// @brief Reverse zone updated?
-    ///
-    /// Set true if the DNS PTR record for this lease has been updated.
-    bool fqdn_rev_;
-
-    /// @brief Lease comments
-    ///
-    /// Currently not used. It may be used for keeping comments made by the
-    /// system administrator.
-    std::string comments_;
-
-    /// @brief Convert Lease to Printable Form
-    ///
-    /// @return String form of the lease
-    virtual std::string toText() const = 0;
-
-    /// @brief returns true if the lease is expired
-    /// @return true if the lease is expired
-    bool expired() const;
-
-};
-
-/// @brief Structure that holds a lease for IPv4 address
-///
-/// For performance reasons it is a simple structure, not a class. If we chose
-/// make it a class, all fields would have to made private and getters/setters
-/// would be required. As this is a critical part of the code that will be used
-/// extensively, direct access is warranted.
-struct Lease4 : public Lease {
-
-    /// @brief Address extension
-    ///
-    /// It is envisaged that in some cases IPv4 address will be accompanied
-    /// with some additional data. One example of such use are Address + Port
-    /// solutions (or Port-restricted Addresses), where several clients may get
-    /// the same address, but different port ranges. This feature is not
-    /// expected to be widely used.  Under normal circumstances, the value
-    /// should be 0.
-    uint32_t ext_;
-
-    /// @brief Hardware address
-    std::vector<uint8_t> hwaddr_;
-
-    /// @brief Client identifier
-    ///
-    /// @todo Should this be a pointer to a client ID or the ID itself?
-    ///       Compare with the DUID in the Lease6 structure.
-    ClientIdPtr client_id_;
-
-    /// @brief Constructor
-    ///
-    /// @param addr IPv4 address.
-    /// @param hwaddr Hardware address buffer
-    /// @param hwaddr_len Length of hardware address buffer
-    /// @param clientid Client identification buffer
-    /// @param clientid_len Length of client identification buffer
-    /// @param valid_lft Lifetime of the lease
-    /// @param t1 renewal time
-    /// @param t2 rebinding time
-    /// @param cltt Client last transmission time
-    /// @param subnet_id Subnet identification
-    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
-    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
-    /// @param hostname FQDN of the client which gets the lease.
-    Lease4(const isc::asiolink::IOAddress& addr, const uint8_t* hwaddr, size_t hwaddr_len,
-           const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft,
-           uint32_t t1, uint32_t t2, time_t cltt, uint32_t subnet_id,
-           const bool fqdn_fwd = false, const bool fqdn_rev = false,
-           const std::string& hostname = "")
-        : Lease(addr, t1, t2, valid_lft, subnet_id, cltt, fqdn_fwd, fqdn_rev,
-                hostname),
-        ext_(0), hwaddr_(hwaddr, hwaddr + hwaddr_len) {
-        if (clientid_len) {
-            client_id_.reset(new ClientId(clientid, clientid_len));
-        }
-    }
-
-    /// @brief Default constructor
-    ///
-    /// Initialize fields that don't have a default constructor.
-    Lease4() : Lease(0, 0, 0, 0, 0, 0, false, false, "") {
-    }
-
-    /// @brief Copy constructor
-    ///
-    /// @param other the @c Lease4 object to be copied.
-    Lease4(const Lease4& other);
-
-    /// @brief Assignment operator.
-    ///
-    /// @param other the @c Lease4 object to be assigned.
-    Lease4& operator=(const Lease4& other);
-
-    /// @brief Compare two leases for equality
-    ///
-    /// @param other lease6 object with which to compare
-    bool operator==(const Lease4& other) const;
-
-    /// @brief Compare two leases for inequality
-    ///
-    /// @param other lease6 object with which to compare
-    bool operator!=(const Lease4& other) const {
-        return (!operator==(other));
-    }
-
-    /// @brief Convert lease to printable form
-    ///
-    /// @return Textual represenation of lease data
-    virtual std::string toText() const;
-
-    /// @todo: Add DHCPv4 failover related fields here
-};
-
-/// @brief Pointer to a Lease4 structure.
-typedef boost::shared_ptr<Lease4> Lease4Ptr;
-
-/// @brief A collection of IPv4 leases.
-typedef std::vector<Lease4Ptr> Lease4Collection;
-
-
-
-/// @brief Structure that holds a lease for IPv6 address and/or prefix
-///
-/// For performance reasons it is a simple structure, not a class. If we chose
-/// make it a class, all fields would have to made private and getters/setters
-/// would be required. As this is a critical part of the code that will be used
-/// extensively, direct access is warranted.
-struct Lease6 : public Lease {
-
-    /// @brief Type of lease contents
-    typedef enum {
-        LEASE_IA_NA = 0, /// the lease contains non-temporary IPv6 address
-        LEASE_IA_TA = 1, /// the lease contains temporary IPv6 address
-        LEASE_IA_PD = 2  /// the lease contains IPv6 prefix (for prefix delegation)
-    } LeaseType;
-
-    /// @brief Lease type
-    ///
-    /// One of normal address, temporary address, or prefix.
-    LeaseType type_;
-
-    /// @brief IPv6 prefix length
-    ///
-    /// This is used only for prefix delegations and is ignored otherwise.
-    uint8_t prefixlen_;
-
-    /// @brief Identity Association Identifier (IAID)
-    ///
-    /// DHCPv6 stores all addresses and prefixes in IA containers (IA_NA,
-    /// IA_TA, IA_PD). All containers may appear more than once in a message.
-    /// To differentiate between them, the IAID field is present
-    uint32_t iaid_;
-
-    /// @brief Client identifier
-    DuidPtr duid_;
-
-    /// @brief preferred lifetime
-    ///
-    /// This parameter specifies the preferred lifetime since the lease was
-    /// assigned or renewed (cltt), expressed in seconds.
-    uint32_t preferred_lft_;
-
-    /// @todo: Add DHCPv6 failover related fields here
-
-    /// @brief Constructor
-    /// @param type Lease type.
-    /// @param addr Assigned address.
-    /// @param duid A pointer to an object representing DUID.
-    /// @param iaid IAID.
-    /// @param preferred Preferred lifetime.
-    /// @param valid Valid lifetime.
-    /// @param t1 A value of the T1 timer.
-    /// @param t2 A value of the T2 timer.
-    /// @param subnet_id A Subnet identifier.
-    /// @param prefixlen An address prefix length.
-    Lease6(LeaseType type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
-           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
-           uint32_t t2, SubnetID subnet_id, uint8_t prefixlen = 0);
-
-    /// @brief Constructor, including FQDN data.
-    ///
-    /// @param type Lease type.
-    /// @param addr Assigned address.
-    /// @param duid A pointer to an object representing DUID.
-    /// @param iaid IAID.
-    /// @param preferred Preferred lifetime.
-    /// @param valid Valid lifetime.
-    /// @param t1 A value of the T1 timer.
-    /// @param t2 A value of the T2 timer.
-    /// @param subnet_id A Subnet identifier.
-    /// @param fqdn_fwd If true, forward DNS update is performed for a lease.
-    /// @param fqdn_rev If true, reverse DNS update is performed for a lease.
-    /// @param hostname FQDN of the client which gets the lease.
-    /// @param prefixlen An address prefix length.
-    Lease6(LeaseType type, const isc::asiolink::IOAddress& addr, DuidPtr duid,
-           uint32_t iaid, uint32_t preferred, uint32_t valid, uint32_t t1,
-           uint32_t t2, SubnetID subnet_id, const bool fqdn_fwd,
-           const bool fqdn_rev, const std::string& hostname,
-           uint8_t prefixlen = 0);
-
-    /// @brief Constructor
-    ///
-    /// Initialize fields that don't have a default constructor.
-    Lease6() : Lease(isc::asiolink::IOAddress("::"), 0, 0, 0, 0, 0,
-                     false, false, ""),
-        type_(LEASE_IA_NA) {
-    }
-
-    /// @brief Compare two leases for equality
-    ///
-    /// @param other lease6 object with which to compare
-    bool operator==(const Lease6& other) const;
-
-    /// @brief Compare two leases for inequality
-    ///
-    /// @param other lease6 object with which to compare
-    bool operator!=(const Lease6& other) const {
-        return (!operator==(other));
-    }
-
-    /// @brief Convert Lease to Printable Form
-    ///
-    /// @return String form of the lease
-    virtual std::string toText() const;
-};
-
-/// @brief Pointer to a Lease6 structure.
-typedef boost::shared_ptr<Lease6> Lease6Ptr;
-
-/// @brief Pointer to a const Lease6 structure.
-typedef boost::shared_ptr<const Lease6> ConstLease6Ptr;
-
-/// @brief A collection of IPv6 leases.
-typedef std::vector<Lease6Ptr> Lease6Collection;
 
 /// @brief Abstract Lease Manager
 ///
@@ -454,7 +142,7 @@ public:
     ///
     /// @result true if the lease was added, false if not (because a lease
     ///         with the same address was already there).
-    virtual bool addLease(const Lease4Ptr& lease) = 0;
+    virtual bool addLease(const isc::dhcp::Lease4Ptr& lease) = 0;
 
     /// @brief Adds an IPv6 lease.
     ///
@@ -537,7 +225,7 @@ public:
     /// @param addr address of the searched lease
     ///
     /// @return smart pointer to the lease (or NULL if a lease is not found)
-    virtual Lease6Ptr getLease6(Lease6::LeaseType type,
+    virtual Lease6Ptr getLease6(Lease::Type type,
                                 const isc::asiolink::IOAddress& addr) const = 0;
 
     /// @brief Returns existing IPv6 leases for a given DUID+IA combination
@@ -552,7 +240,7 @@ public:
     /// @param iaid IA identifier
     ///
     /// @return Lease collection (may be empty if no lease is found)
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type, const DUID& duid,
+    virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                         uint32_t iaid) const = 0;
 
     /// @brief Returns existing IPv6 lease for a given DUID+IA combination
@@ -566,7 +254,7 @@ public:
     /// @param subnet_id subnet id of the subnet the lease belongs to
     ///
     /// @return Lease collection (may be empty if no lease is found)
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type, const DUID& duid,
+    virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                         uint32_t iaid, SubnetID subnet_id) const = 0;
 
 
@@ -593,7 +281,7 @@ public:
     /// @throw MultipleRecords if there is more than one lease matching
     ///
     /// @return Lease pointer (or NULL if none is found)
-    Lease6Ptr getLease6(Lease6::LeaseType type, const DUID& duid,
+    Lease6Ptr getLease6(Lease::Type type, const DUID& duid,
                         uint32_t iaid, SubnetID subnet_id) const;
 
     /// @brief Updates IPv4 lease.
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index d84bab6..4f73278 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -186,7 +186,7 @@ Memfile_LeaseMgr::getLease4(const ClientId& client_id,
 }
 
 Lease6Ptr
-Memfile_LeaseMgr::getLease6(Lease6::LeaseType /* not used yet */,
+Memfile_LeaseMgr::getLease6(Lease::Type /* not used yet */,
                             const isc::asiolink::IOAddress& addr) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
               DHCPSRV_MEMFILE_GET_ADDR6).arg(addr.toText());
@@ -200,7 +200,7 @@ Memfile_LeaseMgr::getLease6(Lease6::LeaseType /* not used yet */,
 }
 
 Lease6Collection
-Memfile_LeaseMgr::getLeases6(Lease6::LeaseType /* not used yet */,
+Memfile_LeaseMgr::getLeases6(Lease::Type /* not used yet */,
                             const DUID& duid, uint32_t iaid) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
               DHCPSRV_MEMFILE_GET_IAID_DUID).arg(iaid).arg(duid.toText());
@@ -211,7 +211,7 @@ Memfile_LeaseMgr::getLeases6(Lease6::LeaseType /* not used yet */,
 }
 
 Lease6Collection
-Memfile_LeaseMgr::getLeases6(Lease6::LeaseType /* not used yet */,
+Memfile_LeaseMgr::getLeases6(Lease::Type /* not used yet */,
                              const DUID& duid, uint32_t iaid,
                              SubnetID subnet_id) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index d88250f..aa81f00 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -144,7 +144,7 @@ public:
     /// @param addr An address of the searched lease.
     ///
     /// @return smart pointer to the lease (or NULL if a lease is not found)
-    virtual Lease6Ptr getLease6(Lease6::LeaseType type,
+    virtual Lease6Ptr getLease6(Lease::Type type,
                                 const isc::asiolink::IOAddress& addr) const;
 
     /// @brief Returns existing IPv6 lease for a given DUID+IA combination
@@ -156,7 +156,7 @@ public:
     /// @param iaid IA identifier
     ///
     /// @return collection of IPv6 leases
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type,
+    virtual Lease6Collection getLeases6(Lease::Type type,
                                         const DUID& duid, uint32_t iaid) const;
 
     /// @brief Returns existing IPv6 lease for a given DUID/IA/subnet-id tuple
@@ -170,7 +170,7 @@ public:
     /// @param subnet_id identifier of the subnet the lease must belong to
     ///
     /// @return lease collection (may be empty if no lease is found)
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type, const DUID& duid,
+    virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                         uint32_t iaid, SubnetID subnet_id) const;
 
     /// @brief Updates IPv4 lease.
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc
index e9d15ae..e695584 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc
@@ -969,18 +969,18 @@ public:
 
         // Set the lease type in a variable of the appropriate data type, which
         // has been initialized with an arbitrary (but valid) value.
-        Lease6::LeaseType type = Lease6::LEASE_IA_NA;
+        Lease::Type type = Lease::TYPE_NA;
         switch (lease_type_) {
-            case Lease6::LEASE_IA_NA:
-                type = Lease6::LEASE_IA_NA;
+            case Lease::TYPE_NA:
+                type = Lease::TYPE_NA;
                 break;
 
-            case Lease6::LEASE_IA_TA:
-                type = Lease6::LEASE_IA_TA;
+            case Lease::TYPE_TA:
+                type = Lease::TYPE_TA;
                 break;
 
-            case Lease6::LEASE_IA_PD:
-                type = Lease6::LEASE_IA_PD;
+            case Lease::TYPE_PD:
+                type = Lease::TYPE_PD;
                 break;
 
             default:
@@ -1653,7 +1653,7 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
 
 
 Lease6Ptr
-MySqlLeaseMgr::getLease6(Lease6::LeaseType lease_type,
+MySqlLeaseMgr::getLease6(Lease::Type lease_type,
                          const isc::asiolink::IOAddress& addr) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
               DHCPSRV_MYSQL_GET_ADDR6).arg(addr.toText())
@@ -1686,7 +1686,7 @@ MySqlLeaseMgr::getLease6(Lease6::LeaseType lease_type,
 
 
 Lease6Collection
-MySqlLeaseMgr::getLeases6(Lease6::LeaseType lease_type,
+MySqlLeaseMgr::getLeases6(Lease::Type lease_type,
                           const DUID& duid, uint32_t iaid) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
               DHCPSRV_MYSQL_GET_IAID_DUID).arg(iaid).arg(duid.toText())
@@ -1734,7 +1734,7 @@ MySqlLeaseMgr::getLeases6(Lease6::LeaseType lease_type,
 }
 
 Lease6Collection
-MySqlLeaseMgr::getLeases6(Lease6::LeaseType lease_type,
+MySqlLeaseMgr::getLeases6(Lease::Type lease_type,
                           const DUID& duid, uint32_t iaid,
                           SubnetID subnet_id) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h
index 1009037..6fae5e2 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.h
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.h
@@ -256,7 +256,7 @@ public:
     ///        programming error.
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.
-    virtual Lease6Ptr getLease6(Lease6::LeaseType type,
+    virtual Lease6Ptr getLease6(Lease::Type type,
                                 const isc::asiolink::IOAddress& addr) const;
 
     /// @brief Returns existing IPv6 leases for a given DUID+IA combination
@@ -279,7 +279,7 @@ public:
     ///        programming error.
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type, const DUID& duid,
+    virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                         uint32_t iaid) const;
 
     /// @brief Returns existing IPv6 lease for a given DUID+IA combination
@@ -298,7 +298,7 @@ public:
     ///        programming error.
     /// @throw isc::dhcp::DbOperationError An operation on the open database has
     ///        failed.
-    virtual Lease6Collection getLeases6(Lease6::LeaseType type, const DUID& duid,
+    virtual Lease6Collection getLeases6(Lease::Type type, const DUID& duid,
                                         uint32_t iaid, SubnetID subnet_id) const;
 
     /// @brief Updates IPv4 lease.
diff --git a/src/lib/dhcpsrv/pool.cc b/src/lib/dhcpsrv/pool.cc
index 7c01da0..53c4d09 100644
--- a/src/lib/dhcpsrv/pool.cc
+++ b/src/lib/dhcpsrv/pool.cc
@@ -15,13 +15,14 @@
 #include <asiolink/io_address.h>
 #include <dhcpsrv/addr_utilities.h>
 #include <dhcpsrv/pool.h>
+#include <sstream>
 
 using namespace isc::asiolink;
 
 namespace isc {
 namespace dhcp {
 
-Pool::Pool(PoolType type, const isc::asiolink::IOAddress& first,
+Pool::Pool(Lease::Type type, const isc::asiolink::IOAddress& first,
            const isc::asiolink::IOAddress& last)
     :id_(getNextID()), first_(first), last_(last), type_(type) {
 }
@@ -32,7 +33,7 @@ bool Pool::inRange(const isc::asiolink::IOAddress& addr) const {
 
 Pool4::Pool4(const isc::asiolink::IOAddress& first,
              const isc::asiolink::IOAddress& last)
-:Pool(Pool::TYPE_V4, first, last) {
+:Pool(Lease::TYPE_V4, first, last) {
     // check if specified address boundaries are sane
     if (!first.isV4() || !last.isV4()) {
         isc_throw(BadValue, "Invalid Pool4 address boundaries: not IPv4");
@@ -44,7 +45,7 @@ Pool4::Pool4(const isc::asiolink::IOAddress& first,
 }
 
 Pool4::Pool4( const isc::asiolink::IOAddress& prefix, uint8_t prefix_len)
-:Pool(Pool::TYPE_V4, prefix, IOAddress("0.0.0.0")) {
+:Pool(Lease::TYPE_V4, prefix, IOAddress("0.0.0.0")) {
 
     // check if the prefix is sane
     if (!prefix.isV4()) {
@@ -61,7 +62,7 @@ Pool4::Pool4( const isc::asiolink::IOAddress& prefix, uint8_t prefix_len)
 }
 
 
-Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& first,
+Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
              const isc::asiolink::IOAddress& last)
     :Pool(type, first, last), prefix_len_(128) {
 
@@ -70,8 +71,8 @@ Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& first,
         isc_throw(BadValue, "Invalid Pool6 address boundaries: not IPv6");
     }
 
-    if ( (type != Pool::TYPE_IA) && (type != Pool::TYPE_TA) &&
-         (type != Pool::TYPE_PD)) {
+    if ( (type != Lease::TYPE_NA) && (type != Lease::TYPE_TA) &&
+         (type != Lease::TYPE_PD)) {
         isc_throw(BadValue, "Invalid Pool6 type: " << static_cast<int>(type)
                   << ", must be TYPE_IA, TYPE_TA or TYPE_PD");
     }
@@ -92,13 +93,13 @@ Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& first,
     // TYPE_PD is not supported by this constructor. first-last style
     // parameters are for IA and TA only. There is another dedicated
     // constructor for that (it uses prefix/length)
-    if ((type != TYPE_IA) && (type != TYPE_TA)) {
+    if ((type != Lease::TYPE_NA) && (type != Lease::TYPE_TA)) {
         isc_throw(BadValue, "Invalid Pool6 type specified:"
                   << static_cast<int>(type));
     }
 }
 
-Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& prefix,
+Pool6::Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
              uint8_t prefix_len, uint8_t delegated_len /* = 128 */)
     :Pool(type, prefix, IOAddress("::")), prefix_len_(delegated_len) {
 
@@ -118,7 +119,8 @@ Pool6::Pool6(PoolType type, const isc::asiolink::IOAddress& prefix,
                   << static_cast<int>(prefix_len) << ")");
     }
 
-    if ( ( (type == TYPE_IA) || (type == TYPE_TA)) && (delegated_len != 128)) {
+    if ( ( (type == Lease::TYPE_NA) || (type == Lease::TYPE_TA)) &&
+         (delegated_len != 128)) {
         isc_throw(BadValue, "For IA or TA pools, delegated prefix length must "
                   << " be 128.");
     }
diff --git a/src/lib/dhcpsrv/pool.h b/src/lib/dhcpsrv/pool.h
index 199fe0b..0d73b40 100644
--- a/src/lib/dhcpsrv/pool.h
+++ b/src/lib/dhcpsrv/pool.h
@@ -16,8 +16,8 @@
 #define POOL_H
 
 #include <asiolink/io_address.h>
-
 #include <boost/shared_ptr.hpp>
+#include <dhcpsrv/lease.h>
 
 #include <vector>
 
@@ -31,25 +31,8 @@ namespace dhcp {
 class Pool {
 
 public:
-
-    /// @brief specifies Pool type
-    ///
-    /// Currently there are 3 pool types defined in DHCPv6:
-    /// - Non-temporary addresses (conveyed in IA_NA)
-    /// - Temporary addresses (conveyed in IA_TA)
-    /// - Delegated Prefixes (conveyed in IA_PD)
-    ///
-    /// The fourth one (TYPE_V4) is used in DHCPv4 use cases when getPool()
-    /// code is shared between v4 and v6 code.
-    ///
-    /// There is a new one being worked on (IA_PA, see draft-ietf-dhc-host-gen-id), but
-    /// support for it is not planned for now.
-    typedef enum {
-        TYPE_IA,
-        TYPE_TA,
-        TYPE_PD,
-        TYPE_V4
-    }  PoolType;
+    /// @note:
+    /// PoolType enum was removed. Please use Lease::Type instead
 
     /// @brief returns Pool-id
     ///
@@ -79,7 +62,7 @@ public:
 
     /// @brief Returns pool type (v4, v6 non-temporary, v6 temp, v6 prefix)
     /// @return returns pool type
-    PoolType getType() const {
+    Lease::Type getType() const {
         return (type_);
     }
 
@@ -99,10 +82,10 @@ protected:
     /// Pool class directly. Instances of Pool4 and Pool6 should be created
     /// instead.
     ///
-    /// @param type type of the pool
+    /// @param type type of lease that will be served from this pool
     /// @param first first address of a range
     /// @param last last address of a range
-    Pool(PoolType type,
+    Pool(Lease::Type type,
          const isc::asiolink::IOAddress& first,
          const isc::asiolink::IOAddress& last);
 
@@ -130,8 +113,8 @@ protected:
     /// @todo: This field is currently not used.
     std::string comments_;
 
-    /// @brief defines a pool type
-    PoolType type_;
+    /// @brief defines a lease type that will be served from this pool
+    Lease::Type type_;
 };
 
 /// @brief Pool information for IPv4 addresses
@@ -172,7 +155,7 @@ public:
     /// @param type type of the pool (IA or TA)
     /// @param first the first address in a pool
     /// @param last the last address in a pool
-    Pool6(PoolType type, const isc::asiolink::IOAddress& first,
+    Pool6(Lease::Type type, const isc::asiolink::IOAddress& first,
           const isc::asiolink::IOAddress& last);
 
     /// @brief the constructor for Pool6 "prefix/len" style definition
@@ -202,13 +185,13 @@ public:
     /// @param prefix specifies prefix of the pool
     /// @param prefix_len specifies prefix length of the pool
     /// @param delegated_len specifies lenght of the delegated prefixes
-    Pool6(PoolType type, const isc::asiolink::IOAddress& prefix,
+    Pool6(Lease::Type type, const isc::asiolink::IOAddress& prefix,
           uint8_t prefix_len, uint8_t delegated_len = 128);
 
     /// @brief returns pool type
     ///
     /// @return pool type
-    PoolType getType() const {
+    Lease::Type getType() const {
         return (type_);
     }
 
diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc
index b491454..5704fa9 100644
--- a/src/lib/dhcpsrv/subnet.cc
+++ b/src/lib/dhcpsrv/subnet.cc
@@ -88,38 +88,38 @@ Subnet::getOptionDescriptor(const std::string& option_space,
     return (*range.first);
 }
 
-isc::asiolink::IOAddress Subnet::getLastAllocated(Pool::PoolType type) const {
+isc::asiolink::IOAddress Subnet::getLastAllocated(Lease::Type type) const {
     // check if the type is valid (and throw if it isn't)
     checkType(type);
 
     switch (type) {
-    case Pool::TYPE_V4:
-    case Pool::TYPE_IA:
+    case Lease::TYPE_V4:
+    case Lease::TYPE_NA:
         return last_allocated_ia_;
-    case Pool::TYPE_TA:
+    case Lease::TYPE_TA:
         return last_allocated_ta_;
-    case Pool::TYPE_PD:
+    case Lease::TYPE_PD:
         return last_allocated_pd_;
     default:
         isc_throw(BadValue, "Pool type " << type << " not supported");
     }
 }
 
-void Subnet::setLastAllocated(Pool::PoolType type,
+void Subnet::setLastAllocated(Lease::Type type,
                               const isc::asiolink::IOAddress& addr) {
 
     // check if the type is valid (and throw if it isn't)
     checkType(type);
 
     switch (type) {
-    case Pool::TYPE_V4:
-    case Pool::TYPE_IA:
+    case Lease::TYPE_V4:
+    case Lease::TYPE_NA:
         last_allocated_ia_ = addr;
         return;
-    case Pool::TYPE_TA:
+    case Lease::TYPE_TA:
         last_allocated_ta_ = addr;
         return;
-    case Pool::TYPE_PD:
+    case Lease::TYPE_PD:
         last_allocated_pd_ = addr;
         return;
     default:
@@ -134,8 +134,8 @@ Subnet::toText() const {
     return (tmp.str());
 }
 
-void Subnet4::checkType(Pool::PoolType type) const {
-    if (type != Pool::TYPE_V4) {
+void Subnet4::checkType(Lease::Type type) const {
+    if (type != Lease::TYPE_V4) {
         isc_throw(BadValue, "Only TYPE_V4 is allowed for Subnet4");
     }
 }
@@ -151,38 +151,38 @@ Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
     }
 }
 
-const PoolCollection& Subnet::getPools(Pool::PoolType type) const {
+const PoolCollection& Subnet::getPools(Lease::Type type) const {
     // check if the type is valid (and throw if it isn't)
     checkType(type);
 
     switch (type) {
-    case Pool::TYPE_V4:
-    case Pool::TYPE_IA:
+    case Lease::TYPE_V4:
+    case Lease::TYPE_NA:
         return (pools_);
-    case Pool::TYPE_TA:
+    case Lease::TYPE_TA:
         return (pools_ta_);
-    case Pool::TYPE_PD:
+    case Lease::TYPE_PD:
         return (pools_pd_);
     default:
         isc_throw(BadValue, "Unsupported pool type: " << type);
     }
 }
 
-PoolPtr Subnet::getPool(Pool::PoolType type, isc::asiolink::IOAddress hint) {
+PoolPtr Subnet::getPool(Lease::Type type, isc::asiolink::IOAddress hint) {
     // check if the type is valid (and throw if it isn't)
     checkType(type);
 
     PoolCollection* pools = NULL;
 
     switch (type) {
-    case Pool::TYPE_V4:
-    case Pool::TYPE_IA:
+    case Lease::TYPE_V4:
+    case Lease::TYPE_NA:
         pools = &pools_;
         break;
-    case Pool::TYPE_TA:
+    case Lease::TYPE_TA:
         pools = &pools_ta_;
         break;
-    case Pool::TYPE_PD:
+    case Lease::TYPE_PD:
         pools = &pools_pd_;
         break;
     default:
@@ -226,14 +226,14 @@ Subnet::addPool(const PoolPtr& pool) {
     checkType(pool->getType());
 
     switch (pool->getType()) {
-    case Pool::TYPE_V4:
-    case Pool::TYPE_IA:
+    case Lease::TYPE_V4:
+    case Lease::TYPE_NA:
         pools_.push_back(pool);
         return;
-    case Pool6::TYPE_TA:
+    case Lease::TYPE_TA:
         pools_ta_.push_back(pool);
         return;
-    case Pool6::TYPE_PD:
+    case Lease::TYPE_PD:
         pools_pd_.push_back(pool);
         return;
     default:
@@ -294,11 +294,12 @@ Subnet6::Subnet6(const isc::asiolink::IOAddress& prefix, uint8_t length,
     }
 }
 
-void Subnet6::checkType(Pool::PoolType type) const {
-    if ( (type != Pool::TYPE_IA) && (type != Pool::TYPE_TA) &&
-         (type != Pool::TYPE_PD)) {
-        isc_throw(BadValue, "Invalid Pool type: " << static_cast<int>(type)
-                  << ", must be TYPE_IA, TYPE_TA or TYPE_PD for Subnet6");
+void Subnet6::checkType(Lease::Type type) const {
+    if ( (type != Lease::TYPE_NA) && (type != Lease::TYPE_TA) &&
+         (type != Lease::TYPE_PD)) {
+        isc_throw(BadValue, "Invalid Pool type: " << Lease::typeToText(type)
+                  << "(" << static_cast<int>(type)
+                  << "), must be TYPE_NA, TYPE_TA or TYPE_PD for Subnet6");
     }
 }
 
diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h
index 7f88a2e..923e3d1 100644
--- a/src/lib/dhcpsrv/subnet.h
+++ b/src/lib/dhcpsrv/subnet.h
@@ -28,6 +28,7 @@
 #include <dhcpsrv/option_space_container.h>
 #include <dhcpsrv/pool.h>
 #include <dhcpsrv/triplet.h>
+#include <dhcpsrv/lease.h>
 
 namespace isc {
 namespace dhcp {
@@ -46,7 +47,6 @@ namespace dhcp {
 ///
 /// @todo: Implement support for options here
 
-
 /// @brief Unique identifier for a subnet (both v4 and v6)
 typedef uint32_t SubnetID;
 
@@ -242,7 +242,7 @@ public:
     ///
     /// @param type lease type to be returned
     /// @return address/prefix that was last tried from this pool
-    isc::asiolink::IOAddress getLastAllocated(Pool::PoolType type) const;
+    isc::asiolink::IOAddress getLastAllocated(Lease::Type type) const;
 
     /// @brief sets the last address that was tried from this pool
     ///
@@ -254,7 +254,7 @@ public:
     ///        AllocEngine::IterativeAllocator and keep the data there
     /// @param addr address/prefix to that was tried last
     /// @param type lease type to be set
-    void setLastAllocated(Pool::PoolType type,
+    void setLastAllocated(Lease::Type type,
                           const isc::asiolink::IOAddress& addr);
 
     /// @brief returns unique ID for that subnet
@@ -280,13 +280,13 @@ public:
     /// @param type pool type that the pool is looked for
     /// @param addr address that the returned pool should cover (optional)
     /// @return found pool (or NULL)
-    PoolPtr getPool(Pool::PoolType type, isc::asiolink::IOAddress addr);
+    PoolPtr getPool(Lease::Type type, isc::asiolink::IOAddress addr);
 
     /// @brief Returns a pool without any address specified
     ///
     /// @param type pool type that the pool is looked for
     /// @return returns one of the pools defined
-    PoolPtr getAnyPool(Pool::PoolType type) {
+    PoolPtr getAnyPool(Lease::Type type) {
         return (getPool(type, default_pool()));
     }
 
@@ -302,7 +302,7 @@ public:
     ///
     /// @param type lease type to be set
     /// @return a collection of all pools
-    const PoolCollection& getPools(Pool::PoolType type) const;
+    const PoolCollection& getPools(Lease::Type type) const;
 
     /// @brief sets name of the network interface for directly attached networks
     ///
@@ -352,7 +352,7 @@ protected:
     ///
     /// @param type type to be checked
     /// @throw BadValue if invalid value is used
-    virtual void checkType(Pool::PoolType type) const = 0;
+    virtual void checkType(Lease::Type type) const = 0;
 
     /// @brief Check if option is valid and can be added to a subnet.
     ///
@@ -464,7 +464,7 @@ protected:
     ///
     /// @param type type to be checked
     /// @throw BadValue if invalid value is used
-    virtual void checkType(Pool::PoolType type) const;
+    virtual void checkType(Lease::Type type) const;
 };
 
 /// @brief A pointer to a Subnet4 object
@@ -535,7 +535,7 @@ protected:
     ///
     /// @param type type to be checked
     /// @throw BadValue if invalid value is used
-    virtual void checkType(Pool::PoolType type) const;
+    virtual void checkType(Lease::Type type) const;
 
     /// @brief specifies optional interface-id
     OptionPtr interface_id_;
diff --git a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
index 66fb8c1..3141f05 100644
--- a/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+++ b/src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
@@ -64,6 +64,7 @@ public:
     // Expose internal classes for testing purposes
     using AllocEngine::Allocator;
     using AllocEngine::IterativeAllocator;
+    using AllocEngine::getAllocator;
 };
 
 /// @brief Used in Allocation Engine tests for IPv6
@@ -83,7 +84,7 @@ public:
         CfgMgr& cfg_mgr = CfgMgr::instance();
 
         subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-        pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1::10"),
+        pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::10"),
                                    IOAddress("2001:db8:1::20")));
         subnet_->addPool(pool_);
         cfg_mgr.addSubnet6(subnet_);
@@ -209,8 +210,8 @@ public:
     Lease4Ptr old_lease_;     ///< Holds previous instance of the lease.
 };
 
-// This test checks if the Allocation Engine can be instantiated and that it
-// parses parameters string properly.
+// This test checks if the v6 Allocation Engine can be instantiated, parses
+// parameters string and allocators are created.
 TEST_F(AllocEngine6Test, constructor) {
     boost::scoped_ptr<AllocEngine> x;
 
@@ -218,7 +219,19 @@ TEST_F(AllocEngine6Test, constructor) {
     ASSERT_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_HASHED, 5)), NotImplemented);
     ASSERT_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_RANDOM, 5)), NotImplemented);
 
-    ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
+    ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100, true)));
+
+    // Check that allocator for normal addresses is created
+    ASSERT_TRUE(x->getAllocator(Lease::TYPE_NA));
+
+    // Check that allocator for temporary address is created
+    ASSERT_TRUE(x->getAllocator(Lease::TYPE_TA));
+
+    // Check that allocator for prefixes is created
+    ASSERT_TRUE(x->getAllocator(Lease::TYPE_PD));
+
+    // There should be no V4 allocator
+    EXPECT_THROW(x->getAllocator(Lease::TYPE_V4), BadValue);
 }
 
 // This test checks if the simple allocation can succeed
@@ -229,8 +242,8 @@ TEST_F(AllocEngine6Test, simpleAlloc6) {
 
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", false,
-                    CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", false, CalloutHandlePtr())));
 
     // Check that we got a lease
     ASSERT_TRUE(lease);
@@ -255,8 +268,8 @@ TEST_F(AllocEngine6Test, fakeAlloc6) {
 
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", true,
-                    CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", true, CalloutHandlePtr())));
 
     // Check that we got a lease
     ASSERT_TRUE(lease);
@@ -279,8 +292,9 @@ TEST_F(AllocEngine6Test, allocWithValidHint6) {
 
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                            duid_, iaid_, IOAddress("2001:db8:1::15"), false,
-                            false, "", false, CalloutHandlePtr())));
+                            duid_, iaid_, IOAddress("2001:db8:1::15"),
+                            Lease::TYPE_NA, false, false, "", false,
+                            CalloutHandlePtr())));
 
     // Check that we got a lease
     ASSERT_TRUE(lease);
@@ -310,7 +324,7 @@ TEST_F(AllocEngine6Test, allocWithUsedHint6) {
     // Let's create a lease and put it in the LeaseMgr
     DuidPtr duid2 = boost::shared_ptr<DUID>(new DUID(vector<uint8_t>(8, 0xff)));
     time_t now = time(NULL);
-    Lease6Ptr used(new Lease6(Lease6::LEASE_IA_NA, IOAddress("2001:db8:1::1f"),
+    Lease6Ptr used(new Lease6(Lease::TYPE_NA, IOAddress("2001:db8:1::1f"),
                               duid2, 1, 2, 3, 4, now, subnet_->getID()));
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
 
@@ -319,8 +333,8 @@ TEST_F(AllocEngine6Test, allocWithUsedHint6) {
     // twice.
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("2001:db8:1::1f"), false, false, "",
-                    false, CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("2001:db8:1::1f"), Lease::TYPE_NA,
+                    false, false, "", false, CalloutHandlePtr())));
 
     // Check that we got a lease
     ASSERT_TRUE(lease);
@@ -355,8 +369,8 @@ TEST_F(AllocEngine6Test, allocBogusHint6) {
     // with the normal allocation
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("3000::abc"), false, false, "",
-                    false, CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("3000::abc"), Lease::TYPE_NA, false,
+                    false, "", false, CalloutHandlePtr())));
 
     // Check that we got a lease
     ASSERT_TRUE(lease);
@@ -385,14 +399,14 @@ TEST_F(AllocEngine6Test, allocateAddress6Nulls) {
     // Allocations without subnet are not allowed
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(
-                    Subnet6Ptr(), duid_, iaid_, IOAddress("::"), false, false,
-                    "", false, CalloutHandlePtr())));
+                    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_,
-                    DuidPtr(), iaid_, IOAddress("::"), false, false, "", false,
-                    CalloutHandlePtr())));
+                    DuidPtr(), iaid_, IOAddress("::"), Lease::TYPE_NA, false,
+                    false, "", false, CalloutHandlePtr())));
     ASSERT_FALSE(lease);
 }
 
@@ -401,7 +415,7 @@ TEST_F(AllocEngine6Test, allocateAddress6Nulls) {
 // pool
 TEST_F(AllocEngine6Test, IterativeAllocator) {
     boost::scoped_ptr<NakedAllocEngine::Allocator>
-        alloc(new NakedAllocEngine::IterativeAllocator(Pool6::TYPE_IA));
+        alloc(new NakedAllocEngine::IterativeAllocator(Lease::TYPE_NA));
 
     for (int i = 0; i < 1000; ++i) {
         IOAddress candidate = alloc->pickAddress(subnet_, duid_, IOAddress("::"));
@@ -414,7 +428,7 @@ TEST_F(AllocEngine6Test, IterativeAllocator) {
 // in all pools in specified subnet. It also must not pick the same address twice
 // unless it runs out of pool space and must start over.
 TEST_F(AllocEngine6Test, IterativeAllocator_manyPools6) {
-    NakedAllocEngine::IterativeAllocator alloc(Pool6::TYPE_IA);
+    NakedAllocEngine::IterativeAllocator alloc(Lease::TYPE_NA);
 
     // let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
     for (int i = 2; i < 10; ++i) {
@@ -423,7 +437,7 @@ TEST_F(AllocEngine6Test, IterativeAllocator_manyPools6) {
         min << "2001:db8:1::" << hex << i*16 + 1;
         max << "2001:db8:1::" << hex << i*16 + 9;
 
-        Pool6Ptr pool(new Pool6(Pool6::TYPE_IA, IOAddress(min.str()),
+        Pool6Ptr pool(new Pool6(Lease::TYPE_NA, IOAddress(min.str()),
                                 IOAddress(max.str())));
         subnet_->addPool(pool);
     }
@@ -476,14 +490,14 @@ TEST_F(AllocEngine6Test, smallPool6) {
 
     // Create configuration similar to other tests, but with a single address pool
     subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-    pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, addr, addr)); // just a single address
+    pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
     subnet_->addPool(pool_);
     cfg_mgr.addSubnet6(subnet_);
 
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", false,
-                    CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", false, CalloutHandlePtr())));
 
     // Check that we got that single lease
     ASSERT_TRUE(lease);
@@ -515,14 +529,14 @@ TEST_F(AllocEngine6Test, outOfAddresses6) {
 
     // Create configuration similar to other tests, but with a single address pool
     subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-    pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, addr, addr)); // just a single address
+    pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
     subnet_->addPool(pool_);
     cfg_mgr.addSubnet6(subnet_);
 
     // Just a different duid
     DuidPtr other_duid = DuidPtr(new DUID(vector<uint8_t>(12, 0xff)));
     const uint32_t other_iaid = 3568;
-    Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, other_duid, other_iaid,
+    Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid,
                                501, 502, 503, 504, subnet_->getID(), 0));
     lease->cltt_ = time(NULL) - 10; // Allocated 10 seconds ago
     ASSERT_TRUE(LeaseMgrFactory::instance().addLease(lease));
@@ -531,8 +545,8 @@ TEST_F(AllocEngine6Test, outOfAddresses6) {
     // else, so the allocation should fail
     Lease6Ptr lease2;
     EXPECT_NO_THROW(lease2 = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", false,
-                    CalloutHandlePtr())));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", false, CalloutHandlePtr())));
     EXPECT_FALSE(lease2);
 }
 
@@ -548,14 +562,14 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
 
     // Create configuration similar to other tests, but with a single address pool
     subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-    pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, addr, addr)); // just a single address
+    pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
     subnet_->addPool(pool_);
     cfg_mgr.addSubnet6(subnet_);
 
     // Just a different duid
     DuidPtr other_duid = DuidPtr(new DUID(vector<uint8_t>(12, 0xff)));
     const uint32_t other_iaid = 3568;
-    Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, other_duid, other_iaid,
+    Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid,
                                501, 502, 503, 504, subnet_->getID(), 0));
     lease->cltt_ = time(NULL) - 500; // Allocated 500 seconds ago
     lease->valid_lft_ = 495; // Lease was valid for 495 seconds
@@ -566,7 +580,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
 
     // CASE 1: Asking for any address
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", true,
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false, "", true,
                     CalloutHandlePtr())));
     // Check that we got that single lease
     ASSERT_TRUE(lease);
@@ -577,7 +591,7 @@ TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
 
     // CASE 2: Asking specifically for this address
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress(addr.toText()), false, false, "",
+                    duid_, iaid_, addr, Lease::TYPE_NA, false, false, "",
                     true, CalloutHandlePtr())));
 
     // Check that we got that single lease
@@ -597,7 +611,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
 
     // Create configuration similar to other tests, but with a single address pool
     subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-    pool_ = Pool6Ptr(new Pool6(Pool6::TYPE_IA, addr, addr)); // just a single address
+    pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr)); // just a single address
     subnet_->addPool(pool_);
     cfg_mgr.addSubnet6(subnet_);
 
@@ -605,7 +619,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
     DuidPtr other_duid = DuidPtr(new DUID(vector<uint8_t>(12, 0xff)));
     const uint32_t other_iaid = 3568;
     const SubnetID other_subnetid = 999;
-    Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr, other_duid, other_iaid,
+    Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr, other_duid, other_iaid,
                                501, 502, 503, 504, other_subnetid, 0));
     lease->cltt_ = time(NULL) - 500; // Allocated 500 seconds ago
     lease->valid_lft_ = 495; // Lease was valid for 495 seconds
@@ -613,7 +627,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
 
     // A client comes along, asking specifically for this address
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress(addr.toText()), false, false, "",
+                    duid_, iaid_, addr, Lease::TYPE_NA, false, false, "",
                     false, CalloutHandlePtr())));
 
     // Check that he got that single lease
@@ -621,7 +635,7 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
     EXPECT_EQ(addr.toText(), lease->addr_.toText());
 
     // Check that the lease is indeed updated in LeaseMgr
-    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(Lease6::LEASE_IA_NA,
+    Lease6Ptr from_mgr = LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA,
                                                                addr);
     ASSERT_TRUE(from_mgr);
 
@@ -631,6 +645,32 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
 
 // --- IPv4 ---
 
+// This test checks if the v4 Allocation Engine can be instantiated, parses
+// parameters string and allocators are created.
+TEST_F(AllocEngine4Test, constructor) {
+    boost::scoped_ptr<AllocEngine> x;
+
+    // Hashed and random allocators are not supported yet
+    ASSERT_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_HASHED, 5, false)),
+                 NotImplemented);
+    ASSERT_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_RANDOM, 5, false)),
+                 NotImplemented);
+
+    // Create V4 (ipv6=false) Allocation Engine that will try at most
+    // 100 attempts to pick up a lease
+    ASSERT_NO_THROW(x.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100,
+                                            false)));
+
+    // There should be V4 allocator
+    ASSERT_TRUE(x->getAllocator(Lease::TYPE_V4));
+
+    // Check that allocators for V6 stuff are not created
+    EXPECT_THROW(x->getAllocator(Lease::TYPE_NA), BadValue);
+    EXPECT_THROW(x->getAllocator(Lease::TYPE_TA), BadValue);
+    EXPECT_THROW(x->getAllocator(Lease::TYPE_PD), BadValue);
+}
+
+
 // This test checks if the simple IPv4 allocation can succeed
 TEST_F(AllocEngine4Test, simpleAlloc4) {
     boost::scoped_ptr<AllocEngine> engine;
@@ -862,7 +902,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
 // pool
 TEST_F(AllocEngine4Test, IterativeAllocator) {
     boost::scoped_ptr<NakedAllocEngine::Allocator>
-        alloc(new NakedAllocEngine::IterativeAllocator(Pool6::TYPE_V4));
+        alloc(new NakedAllocEngine::IterativeAllocator(Lease::TYPE_V4));
 
     for (int i = 0; i < 1000; ++i) {
         IOAddress candidate = alloc->pickAddress(subnet_, clientid_,
@@ -876,7 +916,7 @@ TEST_F(AllocEngine4Test, IterativeAllocator) {
 // in all pools in specified subnet. It also must not pick the same address twice
 // unless it runs out of pool space and must start over.
 TEST_F(AllocEngine4Test, IterativeAllocator_manyPools4) {
-    NakedAllocEngine::IterativeAllocator alloc(Pool6::TYPE_V4);
+    NakedAllocEngine::IterativeAllocator alloc(Lease::TYPE_V4);
 
     // Let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
     for (int i = 2; i < 10; ++i) {
@@ -1302,8 +1342,8 @@ TEST_F(HookAllocEngine6Test, lease6_select) {
 
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", false,
-                    callout_handle)));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", false, callout_handle)));
     // Check that we got a lease
     ASSERT_TRUE(lease);
 
@@ -1373,8 +1413,8 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) {
     // Call allocateAddress6. Callouts should be triggered here.
     Lease6Ptr lease;
     EXPECT_NO_THROW(lease = expectOneLease(engine->allocateAddress6(subnet_,
-                    duid_, iaid_, IOAddress("::"), false, false, "", false,
-                    callout_handle)));
+                    duid_, iaid_, IOAddress("::"), Lease::TYPE_NA, false, false,
+                    "", false, callout_handle)));
     // Check that we got a lease
     ASSERT_TRUE(lease);
 
diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
index 6cc1a3c..776f593 100644
--- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
@@ -131,7 +131,7 @@ public:
     /// @param addr address of the searched lease
     ///
     /// @return smart pointer to the lease (or NULL if a lease is not found)
-    virtual Lease6Ptr getLease6(Lease6::LeaseType /* not used yet */,
+    virtual Lease6Ptr getLease6(Lease::Type /* not used yet */,
                                 const isc::asiolink::IOAddress&) const {
         return (Lease6Ptr());
     }
@@ -142,7 +142,7 @@ public:
     /// @param iaid ignored
     ///
     /// @return whatever is set in leases6_ field
-    virtual Lease6Collection getLeases6(Lease6::LeaseType /* not used yet */,
+    virtual Lease6Collection getLeases6(Lease::Type /* not used yet */,
                                         const DUID&, uint32_t) const {
         return (leases6_);
     }
@@ -154,7 +154,7 @@ public:
     /// @param subnet_id ignored
     ///
     /// @return whatever is set in leases6_ field
-    virtual Lease6Collection getLeases6(Lease6::LeaseType /* not used yet */,
+    virtual Lease6Collection getLeases6(Lease::Type /* not used yet */,
                                         const DUID&, uint32_t, SubnetID) const {
         return (leases6_);
     }
@@ -568,7 +568,7 @@ TEST(Lease6, Lease6ConstructorDefault) {
 
     for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) {
         IOAddress addr(ADDRESS[i]);
-        Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr,
+        Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr,
                                duid, iaid, 100, 200, 50, 80,
                                subnet_id));
 
@@ -576,7 +576,7 @@ TEST(Lease6, Lease6ConstructorDefault) {
         EXPECT_TRUE(*lease->duid_ == *duid);
         EXPECT_TRUE(lease->iaid_ == iaid);
         EXPECT_TRUE(lease->subnet_id_ == subnet_id);
-        EXPECT_TRUE(lease->type_ == Lease6::LEASE_IA_NA);
+        EXPECT_TRUE(lease->type_ == Lease::TYPE_NA);
         EXPECT_TRUE(lease->preferred_lft_ == 100);
         EXPECT_TRUE(lease->valid_lft_ == 200);
         EXPECT_TRUE(lease->t1_ == 50);
@@ -590,7 +590,7 @@ TEST(Lease6, Lease6ConstructorDefault) {
     // Lease6 must be instantiated with a DUID, not with NULL pointer
     IOAddress addr(ADDRESS[0]);
     Lease6Ptr lease2;
-    EXPECT_THROW(lease2.reset(new Lease6(Lease6::LEASE_IA_NA, addr,
+    EXPECT_THROW(lease2.reset(new Lease6(Lease::TYPE_NA, addr,
                                          DuidPtr(), iaid, 100, 200, 50, 80,
                                          subnet_id)), InvalidOperation);
 }
@@ -615,7 +615,7 @@ TEST(Lease6, Lease6ConstructorWithFQDN) {
 
     for (int i = 0; i < sizeof(ADDRESS) / sizeof(ADDRESS[0]); ++i) {
         IOAddress addr(ADDRESS[i]);
-        Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr,
+        Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr,
                                duid, iaid, 100, 200, 50, 80, subnet_id,
                                    true, true, "host.example.com."));
 
@@ -623,7 +623,7 @@ TEST(Lease6, Lease6ConstructorWithFQDN) {
         EXPECT_TRUE(*lease->duid_ == *duid);
         EXPECT_TRUE(lease->iaid_ == iaid);
         EXPECT_TRUE(lease->subnet_id_ == subnet_id);
-        EXPECT_TRUE(lease->type_ == Lease6::LEASE_IA_NA);
+        EXPECT_TRUE(lease->type_ == Lease::TYPE_NA);
         EXPECT_TRUE(lease->preferred_lft_ == 100);
         EXPECT_TRUE(lease->valid_lft_ == 200);
         EXPECT_TRUE(lease->t1_ == 50);
@@ -636,7 +636,7 @@ TEST(Lease6, Lease6ConstructorWithFQDN) {
     // Lease6 must be instantiated with a DUID, not with NULL pointer
     IOAddress addr(ADDRESS[0]);
     Lease6Ptr lease2;
-    EXPECT_THROW(lease2.reset(new Lease6(Lease6::LEASE_IA_NA, addr,
+    EXPECT_THROW(lease2.reset(new Lease6(Lease::TYPE_NA, addr,
                                          DuidPtr(), iaid, 100, 200, 50, 80,
                                          subnet_id)), InvalidOperation);
 }
@@ -657,9 +657,9 @@ TEST(Lease6, OperatorEquals) {
     SubnetID subnet_id = 8; // just another number
 
     // Check for equality.
-    Lease6 lease1(Lease6::LEASE_IA_NA, addr, duid, iaid, 100, 200, 50, 80,
+    Lease6 lease1(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80,
                                subnet_id);
-    Lease6 lease2(Lease6::LEASE_IA_NA, addr, duid, iaid, 100, 200, 50, 80,
+    Lease6 lease2(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80,
                                subnet_id);
 
     // cltt_ constructs with time(NULL), make sure they are always equal
@@ -677,7 +677,7 @@ TEST(Lease6, OperatorEquals) {
     EXPECT_TRUE(lease1 == lease2);  // Check that the reversion has made the
     EXPECT_FALSE(lease1 != lease2); // ... leases equal
 
-    lease1.type_ = Lease6::LEASE_IA_PD;
+    lease1.type_ = Lease::TYPE_PD;
     EXPECT_FALSE(lease1 == lease2);
     EXPECT_TRUE(lease1 != lease2);
     lease1.type_ = lease2.type_;
@@ -792,7 +792,7 @@ TEST(Lease6, Lease6Expired) {
     const DuidPtr duid(new DUID(duid_array, sizeof(duid_array)));
     const uint32_t iaid = 7;        // Just a number
     const SubnetID subnet_id = 8;   // Just another number
-    Lease6 lease(Lease6::LEASE_IA_NA, addr, duid, iaid, 100, 200, 50, 80,
+    Lease6 lease(Lease::TYPE_NA, addr, duid, iaid, 100, 200, 50, 80,
                                subnet_id);
 
     // Case 1: a second before expiration
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 395e0b9..a995f1a 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -71,7 +71,7 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
 
     SubnetID subnet_id = 8; // just another number
 
-    Lease6Ptr lease(new Lease6(Lease6::LEASE_IA_NA, addr,
+    Lease6Ptr lease(new Lease6(Lease::TYPE_NA, addr,
                                duid, iaid, 100, 200, 50, 80,
                                subnet_id));
 
@@ -80,11 +80,11 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
     // should not be allowed to add a second lease with the same address
     EXPECT_FALSE(lease_mgr->addLease(lease));
 
-    Lease6Ptr x = lease_mgr->getLease6(Lease6::LEASE_IA_NA,
+    Lease6Ptr x = lease_mgr->getLease6(Lease::TYPE_NA,
                                        IOAddress("2001:db8:1::234"));
     EXPECT_EQ(Lease6Ptr(), x);
 
-    x = lease_mgr->getLease6(Lease6::LEASE_IA_NA,
+    x = lease_mgr->getLease6(Lease::TYPE_NA,
                              IOAddress("2001:db8:1::456"));
     ASSERT_TRUE(x);
 
@@ -95,14 +95,14 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
 
     // These are not important from lease management perspective, but
     // let's check them anyway.
-    EXPECT_EQ(x->type_, Lease6::LEASE_IA_NA);
+    EXPECT_EQ(x->type_, Lease::TYPE_NA);
     EXPECT_EQ(x->preferred_lft_, 100);
     EXPECT_EQ(x->valid_lft_, 200);
     EXPECT_EQ(x->t1_, 50);
     EXPECT_EQ(x->t2_, 80);
 
     // Test getLease6(duid, iaid, subnet_id) - positive case
-    Lease6Ptr y = lease_mgr->getLease6(Lease6::LEASE_IA_NA, *duid, iaid,
+    Lease6Ptr y = lease_mgr->getLease6(Lease::TYPE_NA, *duid, iaid,
                                        subnet_id);
     ASSERT_TRUE(y);
     EXPECT_TRUE(*y->duid_ == *duid);
@@ -111,18 +111,18 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
 
     // Test getLease6(duid, iaid, subnet_id) - wrong iaid
     uint32_t invalid_iaid = 9; // no such iaid
-    y = lease_mgr->getLease6(Lease6::LEASE_IA_NA, *duid, invalid_iaid,
+    y = lease_mgr->getLease6(Lease::TYPE_NA, *duid, invalid_iaid,
                              subnet_id);
     EXPECT_FALSE(y);
 
     uint32_t invalid_subnet_id = 999;
-    y = lease_mgr->getLease6(Lease6::LEASE_IA_NA, *duid, iaid,
+    y = lease_mgr->getLease6(Lease::TYPE_NA, *duid, iaid,
                              invalid_subnet_id);
     EXPECT_FALSE(y);
 
     // truncated duid
     DuidPtr invalid_duid(new DUID(llt, sizeof(llt) - 1));
-    y = lease_mgr->getLease6(Lease6::LEASE_IA_NA, *invalid_duid, iaid,
+    y = lease_mgr->getLease6(Lease::TYPE_NA, *invalid_duid, iaid,
                              subnet_id);
     EXPECT_FALSE(y);
 
@@ -133,7 +133,7 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
     EXPECT_TRUE(lease_mgr->deleteLease(IOAddress("2001:db8:1::456")));
 
     // after the lease is deleted, it should really be gone
-    x = lease_mgr->getLease6(Lease6::LEASE_IA_NA, IOAddress("2001:db8:1::456"));
+    x = lease_mgr->getLease6(Lease::TYPE_NA, IOAddress("2001:db8:1::456"));
     EXPECT_EQ(Lease6Ptr(), x);
 }
 
diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
index d1759d3..d5e00ab 100644
--- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
@@ -1137,7 +1137,7 @@ TEST_F(MySqlLeaseMgrTest, updateLease6) {
 
     // Modify some fields in lease 1 (not the address) and update it.
     ++leases[1]->iaid_;
-    leases[1]->type_ = Lease6::LEASE_IA_PD;
+    leases[1]->type_ = Lease::TYPE_PD;
     leases[1]->valid_lft_ *= 2;
     leases[1]->hostname_ = "modified.hostname.v6.";
     leases[1]->fqdn_fwd_ = !leases[1]->fqdn_fwd_;
@@ -1147,26 +1147,26 @@ TEST_F(MySqlLeaseMgrTest, updateLease6) {
 
     // ... and check what is returned is what is expected.
     l_returned.reset();
-    l_returned = lmptr_->getLease6(Lease6::LEASE_IA_PD, ioaddress6_[1]);
+    l_returned = lmptr_->getLease6(Lease::TYPE_PD, ioaddress6_[1]);
     ASSERT_TRUE(l_returned);
     detailCompareLease(leases[1], l_returned);
 
     // Alter the lease again and check.
     ++leases[1]->iaid_;
-    leases[1]->type_ = Lease6::LEASE_IA_TA;
+    leases[1]->type_ = Lease::TYPE_TA;
     leases[1]->cltt_ += 6;
     leases[1]->prefixlen_ = 93;
     lmptr_->updateLease6(leases[1]);
 
     l_returned.reset();
-    l_returned = lmptr_->getLease6(Lease6::LEASE_IA_TA, ioaddress6_[1]);
+    l_returned = lmptr_->getLease6(Lease::TYPE_TA, ioaddress6_[1]);
     ASSERT_TRUE(l_returned);
     detailCompareLease(leases[1], l_returned);
 
     // Check we can do an update without changing data.
     lmptr_->updateLease6(leases[1]);
     l_returned.reset();
-    l_returned = lmptr_->getLease6(Lease6::LEASE_IA_TA, ioaddress6_[1]);
+    l_returned = lmptr_->getLease6(Lease::TYPE_TA, ioaddress6_[1]);
     ASSERT_TRUE(l_returned);
     detailCompareLease(leases[1], l_returned);
 
diff --git a/src/lib/dhcpsrv/tests/pool_unittest.cc b/src/lib/dhcpsrv/tests/pool_unittest.cc
index e7d8540..bf89508 100644
--- a/src/lib/dhcpsrv/tests/pool_unittest.cc
+++ b/src/lib/dhcpsrv/tests/pool_unittest.cc
@@ -39,14 +39,14 @@ TEST(Pool4Test, constructor_first_last) {
     EXPECT_EQ(IOAddress("192.0.2.255"), pool1.getLastAddress());
 
     // This is Pool4, IPv6 addresses do not belong here
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::1"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8::1"),
                        IOAddress("192.168.0.5")), BadValue);
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("192.168.0.2"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("192.168.0.2"),
                        IOAddress("2001:db8::1")), BadValue);
 
     // Should throw. Range should be 192.0.2.1-192.0.2.2, not
     // the other way around.
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("192.0.2.2"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("192.0.2.2"),
                        IOAddress("192.0.2.1")), BadValue);
 }
 
@@ -106,54 +106,54 @@ TEST(Pool4Test, unique_id) {
 TEST(Pool6Test, constructor_first_last) {
 
     // let's construct 2001:db8:1:: - 2001:db8:1::ffff:ffff:ffff:ffff pool
-    Pool6 pool1(Pool6::TYPE_IA, IOAddress("2001:db8:1::"),
+    Pool6 pool1(Lease::TYPE_NA, IOAddress("2001:db8:1::"),
                 IOAddress("2001:db8:1::ffff:ffff:ffff:ffff"));
 
-    EXPECT_EQ(Pool6::TYPE_IA, pool1.getType());
+    EXPECT_EQ(Lease::TYPE_NA, pool1.getType());
     EXPECT_EQ(IOAddress("2001:db8:1::"), pool1.getFirstAddress());
     EXPECT_EQ(IOAddress("2001:db8:1::ffff:ffff:ffff:ffff"),
               pool1.getLastAddress());
 
     // This is Pool6, IPv4 addresses do not belong here
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::1"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8::1"),
                        IOAddress("192.168.0.5")), BadValue);
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("192.168.0.2"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("192.168.0.2"),
                        IOAddress("2001:db8::1")), BadValue);
 
     // Should throw. Range should be 2001:db8::1 - 2001:db8::2, not
     // the other way around.
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::2"),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8::2"),
                        IOAddress("2001:db8::1")), BadValue);
 }
 
 TEST(Pool6Test, constructor_prefix_len) {
 
     // let's construct 2001:db8:1::/96 pool
-    Pool6 pool1(Pool6::TYPE_IA, IOAddress("2001:db8:1::"), 96);
+    Pool6 pool1(Lease::TYPE_NA, IOAddress("2001:db8:1::"), 96);
 
-    EXPECT_EQ(Pool6::TYPE_IA, pool1.getType());
+    EXPECT_EQ(Lease::TYPE_NA, pool1.getType());
     EXPECT_EQ("2001:db8:1::", pool1.getFirstAddress().toText());
     EXPECT_EQ("2001:db8:1::ffff:ffff", pool1.getLastAddress().toText());
 
     // No such thing as /130 prefix
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::"), 130),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8::"), 130),
                  BadValue);
 
     // /0 prefix does not make sense
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::"), 0),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8::"), 0),
                  BadValue);
 
     // This is Pool6, IPv4 addresses do not belong here
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("192.168.0.2"), 96),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("192.168.0.2"), 96),
                  BadValue);
 
     // Delegated prefix length for addresses must be /128
-    EXPECT_THROW(Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1::"), 96, 125),
+    EXPECT_THROW(Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::"), 96, 125),
                  BadValue);
 }
 
 TEST(Pool6Test, in_range) {
-   Pool6 pool1(Pool6::TYPE_IA, IOAddress("2001:db8:1::1"),
+   Pool6 pool1(Lease::TYPE_NA, IOAddress("2001:db8:1::1"),
                IOAddress("2001:db8:1::f"));
 
    EXPECT_FALSE(pool1.inRange(IOAddress("2001:db8:1::")));
@@ -168,25 +168,25 @@ TEST(Pool6Test, in_range) {
 TEST(Pool6Test, PD) {
 
     // Let's construct 2001:db8:1::/96 PD pool, split into /112 prefixes
-    Pool6 pool1(Pool6::TYPE_PD, IOAddress("2001:db8:1::"), 96, 112);
+    Pool6 pool1(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 96, 112);
 
-    EXPECT_EQ(Pool6::TYPE_PD, pool1.getType());
+    EXPECT_EQ(Lease::TYPE_PD, pool1.getType());
     EXPECT_EQ(112, pool1.getLength());
     EXPECT_EQ("2001:db8:1::", pool1.getFirstAddress().toText());
     EXPECT_EQ("2001:db8:1::ffff:ffff", pool1.getLastAddress().toText());
 
     // Check that it's not possible to have min-max range for PD
-    EXPECT_THROW(Pool6 pool2(Pool6::TYPE_PD, IOAddress("2001:db8:1::1"),
+    EXPECT_THROW(Pool6 pool2(Lease::TYPE_PD, IOAddress("2001:db8:1::1"),
                              IOAddress("2001:db8:1::f")), BadValue);
 
     // Check that it's not allowed to delegate bigger prefix than the pool
     // Let's try to split /64 prefix into /56 chunks (should be impossible)
-    EXPECT_THROW(Pool6 pool3(Pool6::TYPE_PD, IOAddress("2001:db8:1::"),
+    EXPECT_THROW(Pool6 pool3(Lease::TYPE_PD, IOAddress("2001:db8:1::"),
                              64, 56), BadValue);
 
     // It should be possible to have a pool split into just a single chunk
     // Let's try to split 2001:db8:1::/77 into a single /77 delegated prefix
-    EXPECT_NO_THROW(Pool6 pool4(Pool6::TYPE_PD, IOAddress("2001:db8:1::"),
+    EXPECT_NO_THROW(Pool6 pool4(Lease::TYPE_PD, IOAddress("2001:db8:1::"),
                                 77, 77));
 }
 
@@ -198,26 +198,26 @@ TEST(Pool6Test, TA) {
 
     // Let's construct 2001:db8:1::/96 temporary addresses
     Pool6Ptr pool1;
-    EXPECT_NO_THROW(pool1.reset(new Pool6(Pool6::TYPE_TA,
+    EXPECT_NO_THROW(pool1.reset(new Pool6(Lease::TYPE_TA,
                                           IOAddress("2001:db8:1::"), 96)));
 
     // Check that TA range can be only defined for single addresses
-    EXPECT_THROW(Pool6(Pool6::TYPE_TA, IOAddress("2001:db8:1::"), 96, 127),
+    EXPECT_THROW(Pool6(Lease::TYPE_TA, IOAddress("2001:db8:1::"), 96, 127),
                  BadValue);
 
     ASSERT_TRUE(pool1);
-    EXPECT_EQ(Pool6::TYPE_TA, pool1->getType());
+    EXPECT_EQ(Lease::TYPE_TA, pool1->getType());
     EXPECT_EQ(128, pool1->getLength()); // singular addresses, not prefixes
     EXPECT_EQ("2001:db8:1::", pool1->getFirstAddress().toText());
     EXPECT_EQ("2001:db8:1::ffff:ffff", pool1->getLastAddress().toText());
 
     // Check that it's possible to have min-max range for TA
     Pool6Ptr pool2;
-    EXPECT_NO_THROW(pool2.reset(new Pool6(Pool6::TYPE_TA,
+    EXPECT_NO_THROW(pool2.reset(new Pool6(Lease::TYPE_TA,
                                           IOAddress("2001:db8:1::1"),
                                           IOAddress("2001:db8:1::f"))));
     ASSERT_TRUE(pool2);
-    EXPECT_EQ(Pool6::TYPE_TA, pool2->getType());
+    EXPECT_EQ(Lease::TYPE_TA, pool2->getType());
     EXPECT_EQ(128, pool2->getLength()); // singular addresses, not prefixes
     EXPECT_EQ("2001:db8:1::1", pool2->getFirstAddress().toText());
     EXPECT_EQ("2001:db8:1::f", pool2->getLastAddress().toText());
@@ -230,7 +230,7 @@ TEST(Pool6Test, unique_id) {
     std::vector<Pool6Ptr> pools;
 
     for (int i = 0; i < num_pools; ++i) {
-        pools.push_back(Pool6Ptr(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1::"),
+        pools.push_back(Pool6Ptr(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::"),
                                            IOAddress("2001:db8:1::ffff:ffff:ffff:ffff"))));
     }
 
diff --git a/src/lib/dhcpsrv/tests/subnet_unittest.cc b/src/lib/dhcpsrv/tests/subnet_unittest.cc
index 4ebc508..a3dcbdc 100644
--- a/src/lib/dhcpsrv/tests/subnet_unittest.cc
+++ b/src/lib/dhcpsrv/tests/subnet_unittest.cc
@@ -69,7 +69,7 @@ TEST(Subnet4Test, Pool4InSubnet4) {
     EXPECT_NO_THROW(subnet->addPool(pool1));
 
     // If there's only one pool, get that pool
-    PoolPtr mypool = subnet->getAnyPool(Pool::TYPE_V4);
+    PoolPtr mypool = subnet->getAnyPool(Lease::TYPE_V4);
     EXPECT_EQ(mypool, pool1);
 
 
@@ -78,12 +78,12 @@ TEST(Subnet4Test, Pool4InSubnet4) {
 
     // If there are more than one pool and we didn't provide hint, we
     // should get the first pool
-    EXPECT_NO_THROW(mypool = subnet->getAnyPool(Pool::TYPE_V4));
+    EXPECT_NO_THROW(mypool = subnet->getAnyPool(Lease::TYPE_V4));
 
     EXPECT_EQ(mypool, pool1);
 
     // If we provide a hint, we should get a pool that this hint belongs to
-    EXPECT_NO_THROW(mypool = subnet->getPool(Pool::TYPE_V4,
+    EXPECT_NO_THROW(mypool = subnet->getPool(Lease::TYPE_V4,
                                              IOAddress("192.1.2.195")));
 
     EXPECT_EQ(mypool, pool3);
@@ -186,16 +186,16 @@ TEST(Subnet4Test, lastAllocated) {
     Subnet4Ptr subnet(new Subnet4(IOAddress("192.0.2.0"), 24, 1, 2, 3));
 
     // Check initial conditions (all should be set to the last address in range)
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_V4).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_V4).toText());
 
     // Now set last allocated for IA
-    EXPECT_NO_THROW(subnet->setLastAllocated(Pool::TYPE_V4, addr));
-    EXPECT_EQ(addr.toText(), subnet->getLastAllocated(Pool::TYPE_V4).toText());
+    EXPECT_NO_THROW(subnet->setLastAllocated(Lease::TYPE_V4, addr));
+    EXPECT_EQ(addr.toText(), subnet->getLastAllocated(Lease::TYPE_V4).toText());
 
     // No, you can't set the last allocated IPv6 address in IPv4 subnet
-    EXPECT_THROW(subnet->setLastAllocated(Pool::TYPE_IA, addr), BadValue);
-    EXPECT_THROW(subnet->setLastAllocated(Pool::TYPE_TA, addr), BadValue);
-    EXPECT_THROW(subnet->setLastAllocated(Pool::TYPE_PD, addr), BadValue);
+    EXPECT_THROW(subnet->setLastAllocated(Lease::TYPE_TA, addr), BadValue);
+    EXPECT_THROW(subnet->setLastAllocated(Lease::TYPE_TA, addr), BadValue);
+    EXPECT_THROW(subnet->setLastAllocated(Lease::TYPE_PD, addr), BadValue);
 }
 
 // Checks if the V4 is the only allowed type for Pool4 and if getPool()
@@ -206,37 +206,37 @@ TEST(Subnet4Test, PoolType) {
 
     PoolPtr pool1(new Pool4(IOAddress("192.2.1.0"), 24));
     PoolPtr pool2(new Pool4(IOAddress("192.2.2.0"), 24));
-    PoolPtr pool3(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:3::"), 64));
-    PoolPtr pool4(new Pool6(Pool6::TYPE_TA, IOAddress("2001:db8:1:4::"), 64));
-    PoolPtr pool5(new Pool6(Pool6::TYPE_PD, IOAddress("2001:db8:1:1::"), 64));
+    PoolPtr pool3(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:3::"), 64));
+    PoolPtr pool4(new Pool6(Lease::TYPE_TA, IOAddress("2001:db8:1:4::"), 64));
+    PoolPtr pool5(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:1::"), 64));
 
     // There should be no pools of any type by default
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_V4));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_V4));
 
     // It should not be possible to ask for V6 pools in Subnet4
-    EXPECT_THROW(subnet->getAnyPool(Pool::TYPE_IA), BadValue);
-    EXPECT_THROW(subnet->getAnyPool(Pool::TYPE_TA), BadValue);
-    EXPECT_THROW(subnet->getAnyPool(Pool::TYPE_PD), BadValue);
+    EXPECT_THROW(subnet->getAnyPool(Lease::TYPE_NA), BadValue);
+    EXPECT_THROW(subnet->getAnyPool(Lease::TYPE_TA), BadValue);
+    EXPECT_THROW(subnet->getAnyPool(Lease::TYPE_PD), BadValue);
 
     // Let's add a single V4 pool and check that it can be retrieved
     EXPECT_NO_THROW(subnet->addPool(pool1));
 
     // If there's only one IA pool, get that pool (without and with hint)
-    EXPECT_EQ(pool1, subnet->getAnyPool(Pool::TYPE_V4));
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_V4, IOAddress("192.0.1.167")));
+    EXPECT_EQ(pool1, subnet->getAnyPool(Lease::TYPE_V4));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_V4, IOAddress("192.0.1.167")));
 
     // Let's add additional V4 pool
     EXPECT_NO_THROW(subnet->addPool(pool2));
 
     // Try without hints
-    EXPECT_EQ(pool1, subnet->getAnyPool(Pool::TYPE_V4));
+    EXPECT_EQ(pool1, subnet->getAnyPool(Lease::TYPE_V4));
 
     // Try with valid hints
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_V4, IOAddress("192.2.1.5")));
-    EXPECT_EQ(pool2, subnet->getPool(Pool::TYPE_V4, IOAddress("192.2.2.254")));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_V4, IOAddress("192.2.1.5")));
+    EXPECT_EQ(pool2, subnet->getPool(Lease::TYPE_V4, IOAddress("192.2.2.254")));
 
     // Try with bogus hints (hints should be ingored)
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_V4, IOAddress("10.1.1.1")));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_V4, IOAddress("10.1.1.1")));
 
     // Trying to add Pool6 to Subnet4 is a big no,no!
     EXPECT_THROW(subnet->addPool(pool3), BadValue);
@@ -277,14 +277,14 @@ TEST(Subnet6Test, Pool6InSubnet6) {
 
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
 
-    PoolPtr pool1(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:1::"), 64));
-    PoolPtr pool2(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:2::"), 64));
-    PoolPtr pool3(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:3::"), 64));
+    PoolPtr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
+    PoolPtr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:2::"), 64));
+    PoolPtr pool3(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:3::"), 64));
 
     subnet->addPool(pool1);
 
     // If there's only one pool, get that pool
-    PoolPtr mypool = subnet->getAnyPool(Pool::TYPE_IA);
+    PoolPtr mypool = subnet->getAnyPool(Lease::TYPE_NA);
     EXPECT_EQ(mypool, pool1);
 
     subnet->addPool(pool2);
@@ -292,12 +292,12 @@ TEST(Subnet6Test, Pool6InSubnet6) {
 
     // If there are more than one pool and we didn't provide hint, we
     // should get the first pool
-    mypool = subnet->getAnyPool(Pool::TYPE_IA);
+    mypool = subnet->getAnyPool(Lease::TYPE_NA);
 
     EXPECT_EQ(mypool, pool1);
 
     // If we provide a hint, we should get a pool that this hint belongs to
-    mypool = subnet->getPool(Pool::TYPE_IA, IOAddress("2001:db8:1:3::dead:beef"));
+    mypool = subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8:1:3::dead:beef"));
 
     EXPECT_EQ(mypool, pool3);
 }
@@ -307,67 +307,67 @@ TEST(Subnet6Test, PoolTypes) {
 
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
 
-    PoolPtr pool1(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:1::"), 64));
-    PoolPtr pool2(new Pool6(Pool6::TYPE_TA, IOAddress("2001:db8:1:2::"), 64));
-    PoolPtr pool3(new Pool6(Pool6::TYPE_PD, IOAddress("2001:db8:1:3::"), 64));
-    PoolPtr pool4(new Pool6(Pool6::TYPE_PD, IOAddress("2001:db8:1:4::"), 64));
+    PoolPtr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
+    PoolPtr pool2(new Pool6(Lease::TYPE_TA, IOAddress("2001:db8:1:2::"), 64));
+    PoolPtr pool3(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 64));
+    PoolPtr pool4(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:4::"), 64));
 
     PoolPtr pool5(new Pool4(IOAddress("192.0.2.0"), 24));
 
     // There should be no pools of any type by default
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_IA));
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_TA));
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_PD));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_NA));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_TA));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_PD));
 
     // Trying to get IPv4 pool from Subnet6 is not allowed
-    EXPECT_THROW(subnet->getAnyPool(Pool::TYPE_V4), BadValue);
+    EXPECT_THROW(subnet->getAnyPool(Lease::TYPE_V4), BadValue);
 
     // Let's add a single IA pool and check that it can be retrieved
     EXPECT_NO_THROW(subnet->addPool(pool1));
 
     // If there's only one IA pool, get that pool
-    EXPECT_EQ(pool1, subnet->getAnyPool(Pool::TYPE_IA));
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_IA, IOAddress("2001:db8:1:1::1")));
+    EXPECT_EQ(pool1, subnet->getAnyPool(Lease::TYPE_NA));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8:1:1::1")));
 
     // Check if pools of different type are not returned
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_TA));
-    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Pool::TYPE_PD));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_TA));
+    EXPECT_EQ(PoolPtr(), subnet->getAnyPool(Lease::TYPE_PD));
 
     // We ask with good hints, but wrong types, should return nothing
-    EXPECT_EQ(PoolPtr(), subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8:1:2::1")));
-    EXPECT_EQ(PoolPtr(), subnet->getPool(Pool::TYPE_TA, IOAddress("2001:db8:1:3::1")));
+    EXPECT_EQ(PoolPtr(), subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:1:2::1")));
+    EXPECT_EQ(PoolPtr(), subnet->getPool(Lease::TYPE_TA, IOAddress("2001:db8:1:3::1")));
 
     // Let's add TA and PD pools
     EXPECT_NO_THROW(subnet->addPool(pool2));
     EXPECT_NO_THROW(subnet->addPool(pool3));
 
     // Try without hints
-    EXPECT_EQ(pool1, subnet->getAnyPool(Pool::TYPE_IA));
-    EXPECT_EQ(pool2, subnet->getAnyPool(Pool::TYPE_TA));
-    EXPECT_EQ(pool3, subnet->getAnyPool(Pool::TYPE_PD));
+    EXPECT_EQ(pool1, subnet->getAnyPool(Lease::TYPE_NA));
+    EXPECT_EQ(pool2, subnet->getAnyPool(Lease::TYPE_TA));
+    EXPECT_EQ(pool3, subnet->getAnyPool(Lease::TYPE_PD));
 
     // Try with valid hints
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_IA, IOAddress("2001:db8:1:1::1")));
-    EXPECT_EQ(pool2, subnet->getPool(Pool::TYPE_TA, IOAddress("2001:db8:1:2::1")));
-    EXPECT_EQ(pool3, subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8:1:3::1")));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8:1:1::1")));
+    EXPECT_EQ(pool2, subnet->getPool(Lease::TYPE_TA, IOAddress("2001:db8:1:2::1")));
+    EXPECT_EQ(pool3, subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:1:3::1")));
 
     // Try with bogus hints (hints should be ingored)
-    EXPECT_EQ(pool1, subnet->getPool(Pool::TYPE_IA, IOAddress("2001:db8:1:7::1")));
-    EXPECT_EQ(pool2, subnet->getPool(Pool::TYPE_TA, IOAddress("2001:db8:1:7::1")));
-    EXPECT_EQ(pool3, subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8:1:7::1")));
+    EXPECT_EQ(pool1, subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8:1:7::1")));
+    EXPECT_EQ(pool2, subnet->getPool(Lease::TYPE_TA, IOAddress("2001:db8:1:7::1")));
+    EXPECT_EQ(pool3, subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:1:7::1")));
 
     // Let's add a second PD pool
     EXPECT_NO_THROW(subnet->addPool(pool4));
 
     // Without hints, it should return the first pool
-    EXPECT_EQ(pool3, subnet->getAnyPool(Pool::TYPE_PD));
+    EXPECT_EQ(pool3, subnet->getAnyPool(Lease::TYPE_PD));
 
     // With valid hint, it should return that hint
-    EXPECT_EQ(pool3, subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8:1:3::1")));
-    EXPECT_EQ(pool4, subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8:1:4::1")));
+    EXPECT_EQ(pool3, subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:1:3::1")));
+    EXPECT_EQ(pool4, subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8:1:4::1")));
 
     // With invalid hint, it should return the first pool
-    EXPECT_EQ(pool3, subnet->getPool(Pool::TYPE_PD, IOAddress("2001:db8::123")));
+    EXPECT_EQ(pool3, subnet->getPool(Lease::TYPE_PD, IOAddress("2001:db8::123")));
 
     // Adding Pool4 to Subnet6 is a big no, no!
     EXPECT_THROW(subnet->addPool(pool5), BadValue);
@@ -378,21 +378,21 @@ TEST(Subnet6Test, Subnet6_Pool6_checks) {
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
 
     // this one is in subnet
-    Pool6Ptr pool1(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8:1:1::"), 64));
+    Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1:1::"), 64));
     subnet->addPool(pool1);
 
     // this one is larger than the subnet!
-    Pool6Ptr pool2(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::"), 48));
+    Pool6Ptr pool2(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8::"), 48));
 
     EXPECT_THROW(subnet->addPool(pool2), BadValue);
 
 
     // this one is totally out of blue
-    Pool6Ptr pool3(new Pool6(Pool6::TYPE_IA, IOAddress("3000::"), 16));
+    Pool6Ptr pool3(new Pool6(Lease::TYPE_NA, IOAddress("3000::"), 16));
     EXPECT_THROW(subnet->addPool(pool3), BadValue);
 
 
-    Pool6Ptr pool4(new Pool6(Pool6::TYPE_IA, IOAddress("4001:db8:1::"), 80));
+    Pool6Ptr pool4(new Pool6(Lease::TYPE_NA, IOAddress("4001:db8:1::"), 80));
     EXPECT_THROW(subnet->addPool(pool4), BadValue);
 }
 
@@ -602,7 +602,7 @@ TEST(Subnet6Test, inRangeinPool) {
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8::"), 32, 1, 2, 3, 4));
 
     // this one is in subnet
-    Pool6Ptr pool1(new Pool6(Pool6::TYPE_IA, IOAddress("2001:db8::10"),
+    Pool6Ptr pool1(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8::10"),
                              IOAddress("2001:db8::20")));
     subnet->addPool(pool1);
 
@@ -682,28 +682,28 @@ TEST(Subnet6Test, lastAllocated) {
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 64, 1, 2, 3, 4));
 
     // Check initial conditions (all should be set to the last address in range)
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_IA).toText());
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_TA).toText());
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_PD).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_NA).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_TA).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_PD).toText());
 
     // Now set last allocated for IA
-    EXPECT_NO_THROW(subnet->setLastAllocated(Pool::TYPE_IA, ia));
-    EXPECT_EQ(ia.toText(), subnet->getLastAllocated(Pool::TYPE_IA).toText());
+    EXPECT_NO_THROW(subnet->setLastAllocated(Lease::TYPE_NA, ia));
+    EXPECT_EQ(ia.toText(), subnet->getLastAllocated(Lease::TYPE_NA).toText());
 
     // TA and PD should be unchanged
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_TA).toText());
-    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Pool::TYPE_PD).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_TA).toText());
+    EXPECT_EQ(last.toText(), subnet->getLastAllocated(Lease::TYPE_PD).toText());
 
     // Now set TA and PD
-    EXPECT_NO_THROW(subnet->setLastAllocated(Pool::TYPE_TA, ta));
-    EXPECT_NO_THROW(subnet->setLastAllocated(Pool::TYPE_PD, pd));
+    EXPECT_NO_THROW(subnet->setLastAllocated(Lease::TYPE_TA, ta));
+    EXPECT_NO_THROW(subnet->setLastAllocated(Lease::TYPE_PD, pd));
 
-    EXPECT_EQ(ia.toText(), subnet->getLastAllocated(Pool::TYPE_IA).toText());
-    EXPECT_EQ(ta.toText(), subnet->getLastAllocated(Pool::TYPE_TA).toText());
-    EXPECT_EQ(pd.toText(), subnet->getLastAllocated(Pool::TYPE_PD).toText());
+    EXPECT_EQ(ia.toText(), subnet->getLastAllocated(Lease::TYPE_NA).toText());
+    EXPECT_EQ(ta.toText(), subnet->getLastAllocated(Lease::TYPE_TA).toText());
+    EXPECT_EQ(pd.toText(), subnet->getLastAllocated(Lease::TYPE_PD).toText());
 
     // No, you can't set the last allocated IPv4 address in IPv6 subnet
-    EXPECT_THROW(subnet->setLastAllocated(Pool::TYPE_V4, ia), BadValue);
+    EXPECT_THROW(subnet->setLastAllocated(Lease::TYPE_V4, ia), BadValue);
 }
 
 };
diff --git a/src/lib/dhcpsrv/tests/test_libraries.h b/src/lib/dhcpsrv/tests/test_libraries.h
new file mode 100644
index 0000000..03fd5af
--- /dev/null
+++ b/src/lib/dhcpsrv/tests/test_libraries.h
@@ -0,0 +1,51 @@
+// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef TEST_LIBRARIES_H
+#define TEST_LIBRARIES_H
+
+#include <config.h>
+
+namespace {
+
+
+// Take care of differences in DLL naming between operating systems.
+
+#ifdef OS_OSX
+#define DLL_SUFFIX ".dylib"
+
+#else
+#define DLL_SUFFIX ".so"
+
+#endif
+
+
+// Names of the libraries used in these tests.  These libraries are built using
+// libtool, so we need to look in the hidden ".libs" directory to locate the
+// shared library.
+
+// Library with load/unload functions creating marker files to check their
+// operation.
+static const char* CALLOUT_LIBRARY_1 = "/home/thomson/devel/bind10/src/lib/dhcpsrv/tests/.libs/libco1"
+                                           DLL_SUFFIX;
+static const char* CALLOUT_LIBRARY_2 = "/home/thomson/devel/bind10/src/lib/dhcpsrv/tests/.libs/libco2"
+                                           DLL_SUFFIX;
+
+// Name of a library which is not present.
+static const char* NOT_PRESENT_LIBRARY = "/home/thomson/devel/bind10/src/lib/dhcpsrv/tests/.libs/libnothere"
+                                         DLL_SUFFIX;
+} // anonymous namespace
+
+
+#endif // TEST_LIBRARIES_H
diff --git a/src/lib/dhcpsrv/tests/test_utils.cc b/src/lib/dhcpsrv/tests/test_utils.cc
index 85b2423..9b4263f 100644
--- a/src/lib/dhcpsrv/tests/test_utils.cc
+++ b/src/lib/dhcpsrv/tests/test_utils.cc
@@ -37,10 +37,9 @@ const char* ADDRESS6[] = {
 };
 
 // Lease types that correspond to ADDRESS6 leases
-static const Lease6::LeaseType LEASETYPE6[] = {
-    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA, Lease6::LEASE_IA_PD,
-    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA, Lease6::LEASE_IA_PD,
-    Lease6::LEASE_IA_NA, Lease6::LEASE_IA_TA
+static const Lease::Type LEASETYPE6[] = {
+    Lease::TYPE_NA, Lease::TYPE_TA, Lease::TYPE_PD, Lease::TYPE_NA,
+    Lease::TYPE_TA, Lease::TYPE_PD, Lease::TYPE_NA, Lease::TYPE_TA
 };
 
 void
diff --git a/src/lib/dhcpsrv/tests/test_utils.h b/src/lib/dhcpsrv/tests/test_utils.h
index ff9a1a8..af10a31 100644
--- a/src/lib/dhcpsrv/tests/test_utils.h
+++ b/src/lib/dhcpsrv/tests/test_utils.h
@@ -105,7 +105,7 @@ public:
     std::vector<std::string>  straddress4_;   ///< String forms of IPv4 addresses
     std::vector<isc::asiolink::IOAddress> ioaddress4_;  ///< IOAddress forms of IPv4 addresses
     std::vector<std::string>  straddress6_;   ///< String forms of IPv6 addresses
-    std::vector<Lease6::LeaseType> leasetype6_; ///< Lease types
+    std::vector<Lease::Type> leasetype6_; ///< Lease types
     std::vector<isc::asiolink::IOAddress> ioaddress6_;  ///< IOAddress forms of IPv6 addresses
 
     LeaseMgr*   lmptr_;             ///< Pointer to the lease manager



More information about the bind10-changes mailing list