Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
450
Issues
450
List
Boards
Labels
Service Desk
Milestones
Merge Requests
75
Merge Requests
75
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
a26a75c9
Commit
a26a75c9
authored
Sep 18, 2013
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3149] Lease6::LeaseType and Pool::PoolType unified.
parent
17021645
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
946 additions
and
832 deletions
+946
-832
src/bin/dhcp6/config_parser.cc
src/bin/dhcp6/config_parser.cc
+2
-2
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
+3
-3
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+16
-16
src/bin/dhcp6/tests/dhcp6_test_utils.h
src/bin/dhcp6/tests/dhcp6_test_utils.h
+2
-2
src/bin/dhcp6/tests/hooks_unittest.cc
src/bin/dhcp6/tests/hooks_unittest.cc
+15
-15
src/lib/dhcpsrv/Makefile.am
src/lib/dhcpsrv/Makefile.am
+1
-0
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.cc
+17
-15
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/alloc_engine.h
+12
-8
src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/lease.cc
+216
-0
src/lib/dhcpsrv/lease.h
src/lib/dhcpsrv/lease.h
+353
-0
src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/lease_mgr.cc
+1
-188
src/lib/dhcpsrv/lease_mgr.h
src/lib/dhcpsrv/lease_mgr.h
+6
-318
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.cc
+3
-3
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.h
+3
-3
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.cc
+10
-10
src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.h
+3
-3
src/lib/dhcpsrv/pool.cc
src/lib/dhcpsrv/pool.cc
+11
-9
src/lib/dhcpsrv/pool.h
src/lib/dhcpsrv/pool.h
+9
-26
src/lib/dhcpsrv/subnet.cc
src/lib/dhcpsrv/subnet.cc
+32
-31
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/subnet.h
+9
-9
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
src/lib/dhcpsrv/tests/alloc_engine_unittest.cc
+41
-40
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
+13
-13
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+9
-9
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+5
-5
src/lib/dhcpsrv/tests/pool_unittest.cc
src/lib/dhcpsrv/tests/pool_unittest.cc
+26
-26
src/lib/dhcpsrv/tests/subnet_unittest.cc
src/lib/dhcpsrv/tests/subnet_unittest.cc
+73
-73
src/lib/dhcpsrv/tests/test_libraries.h
src/lib/dhcpsrv/tests/test_libraries.h
+51
-0
src/lib/dhcpsrv/tests/test_utils.cc
src/lib/dhcpsrv/tests/test_utils.cc
+3
-4
src/lib/dhcpsrv/tests/test_utils.h
src/lib/dhcpsrv/tests/test_utils.h
+1
-1
No files found.
src/bin/dhcp6/config_parser.cc
View file @
a26a75c9
...
@@ -147,7 +147,7 @@ protected:
...
@@ -147,7 +147,7 @@ protected:
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
addr
,
uint32_t
len
,
int32_t
ptype
)
PoolPtr
poolMaker
(
IOAddress
&
addr
,
uint32_t
len
,
int32_t
ptype
)
{
{
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Pool
::
Pool
Type
>
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Lease
::
Type
>
(
ptype
),
addr
,
len
)));
(
ptype
),
addr
,
len
)));
}
}
...
@@ -161,7 +161,7 @@ protected:
...
@@ -161,7 +161,7 @@ protected:
/// @return returns a PoolPtr to the new Pool4 object.
/// @return returns a PoolPtr to the new Pool4 object.
PoolPtr
poolMaker
(
IOAddress
&
min
,
IOAddress
&
max
,
int32_t
ptype
)
PoolPtr
poolMaker
(
IOAddress
&
min
,
IOAddress
&
max
,
int32_t
ptype
)
{
{
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Pool
::
Pool
Type
>
return
(
PoolPtr
(
new
Pool6
(
static_cast
<
isc
::
dhcp
::
Lease
::
Type
>
(
ptype
),
min
,
max
)));
(
ptype
),
min
,
max
)));
}
}
};
};
...
...
src/bin/dhcp6/dhcp6_srv.cc
View file @
a26a75c9
...
@@ -1225,7 +1225,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
...
@@ -1225,7 +1225,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// be inserted into the LeaseMgr as well.
// be inserted into the LeaseMgr as well.
Lease6Collection
leases
=
alloc_engine_
->
allocateAddress6
(
subnet
,
duid
,
Lease6Collection
leases
=
alloc_engine_
->
allocateAddress6
(
subnet
,
duid
,
ia
->
getIAID
(),
ia
->
getIAID
(),
hint
,
hint
,
Lease
::
TYPE_NA
,
do_fwd
,
do_rev
,
do_fwd
,
do_rev
,
hostname
,
hostname
,
fake_allocation
,
fake_allocation
,
...
@@ -1321,7 +1321,7 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
...
@@ -1321,7 +1321,7 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
return
(
ia_rsp
);
return
(
ia_rsp
);
}
}
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
*
duid
,
ia
->
getIAID
(),
*
duid
,
ia
->
getIAID
(),
subnet
->
getID
());
subnet
->
getID
());
...
@@ -1585,7 +1585,7 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
...
@@ -1585,7 +1585,7 @@ Dhcpv6Srv::releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
return
(
ia_rsp
);
return
(
ia_rsp
);
}
}
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
release_addr
->
getAddress
());
release_addr
->
getAddress
());
if
(
!
lease
)
{
if
(
!
lease
)
{
...
...
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
View file @
a26a75c9
...
@@ -67,7 +67,7 @@ public:
...
@@ -67,7 +67,7 @@ public:
:
Dhcpv6SrvTest
()
{
:
Dhcpv6SrvTest
()
{
// generateClientId assigns DUID to duid_.
// generateClientId assigns DUID to duid_.
generateClientId
();
generateClientId
();
lease_
.
reset
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
IOAddress
(
"2001:db8:1::1"
),
lease_
.
reset
(
new
Lease6
(
Lease
::
TYPE
_NA
,
IOAddress
(
"2001:db8:1::1"
),
duid_
,
1234
,
501
,
502
,
503
,
duid_
,
1234
,
501
,
502
,
503
,
504
,
1
,
0
));
504
,
1
,
0
));
...
@@ -1018,13 +1018,13 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
...
@@ -1018,13 +1018,13 @@ TEST_F(Dhcpv6SrvTest, RenewBasic) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1117,7 +1117,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
...
@@ -1117,7 +1117,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
OptionPtr
clientid
=
generateClientId
();
OptionPtr
clientid
=
generateClientId
();
// Check that the lease is NOT in the database
// Check that the lease is NOT in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
...
@@ -1149,14 +1149,14 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
...
@@ -1149,14 +1149,14 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
// Check that there is no lease added
// Check that there is no lease added
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
// CASE 2: Lease is known and belongs to this client, but to a different IAID
// CASE 2: Lease is known and belongs to this client, but to a different IAID
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
valid_iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
valid_iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
123
;
// Let's use it as an indicator that the lease
lease
->
cltt_
=
123
;
// Let's use it as an indicator that the lease
// was NOT updated.
// was NOT updated.
...
@@ -1191,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
...
@@ -1191,7 +1191,7 @@ TEST_F(Dhcpv6SrvTest, RenewReject) {
ASSERT_TRUE
(
ia
);
ASSERT_TRUE
(
ia
);
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
checkIA_NAStatusCode
(
ia
,
STATUS_NoBinding
);
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_TRUE
(
lease
);
ASSERT_TRUE
(
lease
);
// Verify that the lease was not updated.
// Verify that the lease was not updated.
EXPECT_EQ
(
123
,
lease
->
cltt_
);
EXPECT_EQ
(
123
,
lease
->
cltt_
);
...
@@ -1222,13 +1222,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
...
@@ -1222,13 +1222,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1268,11 +1268,11 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
...
@@ -1268,11 +1268,11 @@ TEST_F(Dhcpv6SrvTest, ReleaseBasic) {
// Check that the lease is really gone in the database
// Check that the lease is really gone in the database
// get lease by address
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
// get lease by subnetid/duid/iaid combination
// get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
*
duid_
,
iaid
,
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
subnet_
->
getID
());
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
}
}
...
@@ -1305,7 +1305,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
...
@@ -1305,7 +1305,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
OptionPtr
clientid
=
generateClientId
();
OptionPtr
clientid
=
generateClientId
();
// Check that the lease is NOT in the database
// Check that the lease is NOT in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
...
@@ -1339,13 +1339,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
...
@@ -1339,13 +1339,13 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is not there
// Check that the lease is not there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
// CASE 2: Lease is known and belongs to this client, but to a different IAID
// CASE 2: Lease is known and belongs to this client, but to a different IAID
SCOPED_TRACE
(
"CASE 2: Lease is known and belongs to this client, but to a different IAID"
);
SCOPED_TRACE
(
"CASE 2: Lease is known and belongs to this client, but to a different IAID"
);
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
valid_iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
valid_iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
...
@@ -1361,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
...
@@ -1361,7 +1361,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is still there
// Check that the lease is still there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
// CASE 3: Lease belongs to a client with different client-id
// CASE 3: Lease belongs to a client with different client-id
...
@@ -1384,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
...
@@ -1384,7 +1384,7 @@ TEST_F(Dhcpv6SrvTest, ReleaseReject) {
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
checkMsgStatusCode
(
reply
,
STATUS_NoBinding
);
// Check that the lease is still there
// Check that the lease is still there
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
// Finally, let's cleanup the database
// Finally, let's cleanup the database
...
...
src/bin/dhcp6/tests/dhcp6_test_utils.h
View file @
a26a75c9
...
@@ -321,7 +321,7 @@ public:
...
@@ -321,7 +321,7 @@ public:
Dhcpv6SrvTest
()
{
Dhcpv6SrvTest
()
{
subnet_
=
Subnet6Ptr
(
new
Subnet6
(
IOAddress
(
"2001:db8:1::"
),
48
,
1000
,
subnet_
=
Subnet6Ptr
(
new
Subnet6
(
IOAddress
(
"2001:db8:1::"
),
48
,
1000
,
2000
,
3000
,
4000
));
2000
,
3000
,
4000
));
pool_
=
Pool6Ptr
(
new
Pool6
(
Pool6
::
TYPE_I
A
,
IOAddress
(
"2001:db8:1:1::"
),
64
));
pool_
=
Pool6Ptr
(
new
Pool6
(
Lease
::
TYPE_N
A
,
IOAddress
(
"2001:db8:1:1::"
),
64
));
subnet_
->
addPool
(
pool_
);
subnet_
->
addPool
(
pool_
);
CfgMgr
::
instance
().
deleteSubnets6
();
CfgMgr
::
instance
().
deleteSubnets6
();
...
@@ -377,7 +377,7 @@ public:
...
@@ -377,7 +377,7 @@ public:
boost
::
shared_ptr
<
Option6IAAddr
>
addr
)
{
boost
::
shared_ptr
<
Option6IAAddr
>
addr
)
{
boost
::
shared_ptr
<
Option6IA
>
ia
=
boost
::
dynamic_pointer_cast
<
Option6IA
>
(
ia_na
);
boost
::
shared_ptr
<
Option6IA
>
ia
=
boost
::
dynamic_pointer_cast
<
Option6IA
>
(
ia_na
);
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
->
getAddress
());
addr
->
getAddress
());
if
(
!
lease
)
{
if
(
!
lease
)
{
std
::
cout
<<
"Lease for "
<<
addr
->
getAddress
().
toText
()
std
::
cout
<<
"Lease for "
<<
addr
->
getAddress
().
toText
()
...
...
src/bin/dhcp6/tests/hooks_unittest.cc
View file @
a26a75c9
...
@@ -1070,13 +1070,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
...
@@ -1070,13 +1070,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1167,13 +1167,13 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
...
@@ -1167,13 +1167,13 @@ TEST_F(HooksDhcpv6SrvTest, leaseUpdate_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1258,13 +1258,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
...
@@ -1258,13 +1258,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1296,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
...
@@ -1296,7 +1296,7 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_renew) {
// Check that our callback was called
// Check that our callback was called
EXPECT_EQ
(
"lease6_renew"
,
callback_name_
);
EXPECT_EQ
(
"lease6_renew"
,
callback_name_
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
// Check that the old values are still there and they were not
// Check that the old values are still there and they were not
// updated by the renewal
// updated by the renewal
...
@@ -1334,13 +1334,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
...
@@ -1334,13 +1334,13 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1379,11 +1379,11 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
...
@@ -1379,11 +1379,11 @@ TEST_F(HooksDhcpv6SrvTest, basic_lease6_release) {
// Check that the lease is really gone in the database
// Check that the lease is really gone in the database
// get lease by address
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
);
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
// Get lease by subnetid/duid/iaid combination
// Get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
*
duid_
,
iaid
,
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
subnet_
->
getID
());
ASSERT_FALSE
(
l
);
ASSERT_FALSE
(
l
);
}
}
...
@@ -1415,13 +1415,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
...
@@ -1415,13 +1415,13 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// Note that preferred, valid, T1 and T2 timers and CLTT are set to invalid
// value on purpose. They should be updated during RENEW.
// value on purpose. They should be updated during RENEW.
Lease6Ptr
lease
(
new
Lease6
(
Lease
6
::
LEASE_IA
_NA
,
addr
,
duid_
,
iaid
,
Lease6Ptr
lease
(
new
Lease6
(
Lease
::
TYPE
_NA
,
addr
,
duid_
,
iaid
,
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
501
,
502
,
503
,
504
,
subnet_
->
getID
(),
0
));
lease
->
cltt_
=
1234
;
lease
->
cltt_
=
1234
;
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
ASSERT_TRUE
(
LeaseMgrFactory
::
instance
().
addLease
(
lease
));
// Check that the lease is really in the database
// Check that the lease is really in the database
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
Lease6Ptr
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
...
@@ -1448,12 +1448,12 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
...
@@ -1448,12 +1448,12 @@ TEST_F(HooksDhcpv6SrvTest, skip_lease6_release) {
// Check that the lease is still there
// Check that the lease is still there
// get lease by address
// get lease by address
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
addr
);
addr
);
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
// Get lease by subnetid/duid/iaid combination
// Get lease by subnetid/duid/iaid combination
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
6
::
LEASE_IA
_NA
,
*
duid_
,
iaid
,
l
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease
::
TYPE
_NA
,
*
duid_
,
iaid
,
subnet_
->
getID
());
subnet_
->
getID
());
ASSERT_TRUE
(
l
);
ASSERT_TRUE
(
l
);
}
}
...
...
src/lib/dhcpsrv/Makefile.am
View file @
a26a75c9
...
@@ -42,6 +42,7 @@ libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
...
@@ -42,6 +42,7 @@ libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
libb10_dhcpsrv_la_SOURCES
+=
dhcp_config_parser.h
libb10_dhcpsrv_la_SOURCES
+=
dhcp_config_parser.h
libb10_dhcpsrv_la_SOURCES
+=
dhcp_parsers.cc dhcp_parsers.h
libb10_dhcpsrv_la_SOURCES
+=
dhcp_parsers.cc dhcp_parsers.h
libb10_dhcpsrv_la_SOURCES
+=
key_from_key.h
libb10_dhcpsrv_la_SOURCES
+=
key_from_key.h
libb10_dhcpsrv_la_SOURCES
+=
lease.cc lease.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr.cc lease_mgr.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr.cc lease_mgr.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr_factory.cc lease_mgr_factory.h
libb10_dhcpsrv_la_SOURCES
+=
lease_mgr_factory.cc lease_mgr_factory.h
libb10_dhcpsrv_la_SOURCES
+=
memfile_lease_mgr.cc memfile_lease_mgr.h
libb10_dhcpsrv_la_SOURCES
+=
memfile_lease_mgr.cc memfile_lease_mgr.h
...
...
src/lib/dhcpsrv/alloc_engine.cc
View file @
a26a75c9
...
@@ -53,7 +53,7 @@ AllocEngineHooks Hooks;
...
@@ -53,7 +53,7 @@ AllocEngineHooks Hooks;
namespace
isc
{
namespace
isc
{
namespace
dhcp
{
namespace
dhcp
{
AllocEngine
::
IterativeAllocator
::
IterativeAllocator
(
Pool
::
Pool
Type
lease_type
)
AllocEngine
::
IterativeAllocator
::
IterativeAllocator
(
Lease
::
Type
lease_type
)
:
Allocator
(
lease_type
)
{
:
Allocator
(
lease_type
)
{
}
}
...
@@ -146,7 +146,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
...
@@ -146,7 +146,7 @@ AllocEngine::IterativeAllocator::pickAddress(const SubnetPtr& subnet,
return
(
next
);
return
(
next
);
}
}
AllocEngine
::
HashedAllocator
::
HashedAllocator
(
Pool
::
Pool
Type
lease_type
)
AllocEngine
::
HashedAllocator
::
HashedAllocator
(
Lease
::
Type
lease_type
)
:
Allocator
(
lease_type
)
{
:
Allocator
(
lease_type
)
{
isc_throw
(
NotImplemented
,
"Hashed allocator is not implemented"
);
isc_throw
(
NotImplemented
,
"Hashed allocator is not implemented"
);
}
}
...
@@ -159,7 +159,7 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
...
@@ -159,7 +159,7 @@ AllocEngine::HashedAllocator::pickAddress(const SubnetPtr&,
isc_throw
(
NotImplemented
,
"Hashed allocator is not implemented"
);
isc_throw
(
NotImplemented
,
"Hashed allocator is not implemented"
);
}
}
AllocEngine
::
RandomAllocator
::
RandomAllocator
(
Pool
::
Pool
Type
lease_type
)
AllocEngine
::
RandomAllocator
::
RandomAllocator
(
Lease
::
Type
lease_type
)
:
Allocator
(
lease_type
)
{
:
Allocator
(
lease_type
)
{
isc_throw
(
NotImplemented
,
"Random allocator is not implemented"
);
isc_throw
(
NotImplemented
,
"Random allocator is not implemented"
);
}
}
...
@@ -204,6 +204,7 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
...
@@ -204,6 +204,7 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
const
DuidPtr
&
duid
,
const
DuidPtr
&
duid
,
uint32_t
iaid
,
uint32_t
iaid
,
const
IOAddress
&
hint
,
const
IOAddress
&
hint
,
Lease
::
Type
type
,
const
bool
fwd_dns_update
,
const
bool
fwd_dns_update
,
const
bool
rev_dns_update
,
const
bool
rev_dns_update
,
const
std
::
string
&
hostname
,
const
std
::
string
&
hostname
,
...
@@ -227,8 +228,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
...
@@ -227,8 +228,8 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
// check if there's existing lease for that subnet/duid/iaid combination.
// check if there's existing lease for that subnet/duid/iaid combination.
/// @todo: Make this generic (cover temp. addrs and prefixes)
/// @todo: Make this generic (cover temp. addrs and prefixes)
Lease6Collection
existing
=
LeaseMgrFactory
::
instance
().
getLeases6
(
Lease6Collection
existing
=
LeaseMgrFactory
::
instance
().
getLeases6
(
type
,
Lease6
::
LEASE_IA_NA
,
*
duid
,
iaid
,
subnet
->
getID
());
*
duid
,
iaid
,
subnet
->
getID
());
if
(
!
existing
.
empty
())
{
if
(
!
existing
.
empty
())
{
// we have at least one lease already. This is a returning client,
// we have at least one lease already. This is a returning client,
...
@@ -240,15 +241,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
...
@@ -240,15 +241,14 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
if
(
subnet
->
inPool
(
hint
))
{
if
(
subnet
->
inPool
(
hint
))
{
/// @todo: We support only one hint for now
/// @todo: We support only one hint for now
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
Lease6Ptr
lease
=
LeaseMgrFactory
::
instance
().
getLease6
(
type
,
hint
);
Lease6
::
LEASE_IA_NA
,
hint
);
if
(
!
lease
)
{
if
(
!
lease
)
{
/// @todo: check if the hint is reserved once we have host support
/// @todo: check if the hint is reserved once we have host support
/// implemented
/// implemented
// the hint is valid and not currently used, let's create a lease for it
// the hint is valid and not currently used, let's create a lease for it
/// @todo: We support only one lease per ia for now
/// @todo: We support only one lease per ia for now
lease
=
createLease6
(
subnet
,
duid
,
iaid
,
hint
,
fwd_dns_update
,
lease
=
createLease6
(
subnet
,
duid
,
iaid
,
hint
,
type
,
fwd_dns_update
,
rev_dns_update
,
hostname
,
callout_handle
,
rev_dns_update
,
hostname
,
callout_handle
,
fake_allocation
);
fake_allocation
);
...
@@ -264,11 +264,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
...
@@ -264,11 +264,12 @@ AllocEngine::allocateAddress6(const Subnet6Ptr& subnet,
}
else
{
}
else
{
if
(
lease
->
expired
())
{
if
(
lease
->
expired
())
{
/// We found a lease and it is expired, so we can reuse it
/// We found a lease and it is expired, so we can reuse it
/// @todo: We support only one lease per ia for now
lease
=
reuseExpiredLease
(
lease
,
subnet
,
duid
,
iaid
,