Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
fdcffb79
Commit
fdcffb79
authored
Oct 30, 2012
by
Tomek Mrugalski
🛰
Browse files
[2414] getLease6(duid, iaid, subnet_id) implemented in memfile backend
parent
2e7420da
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/tests/lease_mgr_unittest.cc
View file @
fdcffb79
...
...
@@ -99,6 +99,27 @@ TEST_F(LeaseMgrTest, addGetDelete) {
EXPECT_EQ
(
x
->
t1_
,
50
);
EXPECT_EQ
(
x
->
t2_
,
80
);
// Test getLease6(duid, iaid, subnet_id) - positive case
Lease6Ptr
y
=
leaseMgr
->
getLease6
(
*
duid
,
iaid
,
subnet_id
);
ASSERT_TRUE
(
y
);
EXPECT_TRUE
(
*
y
->
duid_
==
*
duid
);
EXPECT_EQ
(
y
->
iaid_
,
iaid
);
EXPECT_EQ
(
y
->
addr_
.
toText
(),
addr
.
toText
());
// Test getLease6(duid, iaid, subnet_id) - wrong iaid
uint32_t
invalid_iaid
=
9
;
// no such iaid
y
=
leaseMgr
->
getLease6
(
*
duid
,
invalid_iaid
,
subnet_id
);
EXPECT_FALSE
(
y
);
uint32_t
invalid_subnet_id
=
999
;
y
=
leaseMgr
->
getLease6
(
*
duid
,
iaid
,
invalid_subnet_id
);
EXPECT_FALSE
(
y
);
// truncated duid
DuidPtr
invalid_duid
(
new
DUID
(
llt
,
sizeof
(
llt
)
-
1
));
y
=
leaseMgr
->
getLease6
(
*
invalid_duid
,
iaid
,
subnet_id
);
EXPECT_FALSE
(
y
);
// should return false - there's no such address
EXPECT_FALSE
(
leaseMgr
->
deleteLease6
(
IOAddress
(
"2001:db8:1::789"
)));
...
...
src/lib/dhcp/tests/memfile_lease_mgr.cc
View file @
fdcffb79
...
...
@@ -78,9 +78,16 @@ Lease6Collection Memfile_LeaseMgr::getLease6(const DUID& , uint32_t ) const {
return
(
Lease6Collection
());
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
,
uint32_t
,
SubnetID
)
const
{
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
/// @todo: Slow, naive implementation. Write it using additional indexes
for
(
Lease6Storage
::
iterator
l
=
storage6_
.
begin
();
l
!=
storage6_
.
end
();
++
l
)
{
if
(
(
*
((
*
l
)
->
duid_
)
==
duid
)
&&
(
(
*
l
)
->
iaid_
==
iaid
)
&&
(
(
*
l
)
->
subnet_id_
==
subnet_id
))
{
return
(
*
l
);
}
}
return
(
Lease6Ptr
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment