Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
43fc4271
Commit
43fc4271
authored
Apr 23, 2014
by
Marcin Siodelski
Browse files
[3148] Implemented getLeases6 methods which take lease type into account.
parent
8df5e8bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/dhcpsrv_messages.mes
View file @
43fc4271
...
...
@@ -236,7 +236,7 @@ address.
A debug message issued when the server is attempting to obtain an IPv4
lease from the memory file database for the specified address.
% DHCPSRV_MEMFILE_GET_ADDR6 obtaining IPv6 lease for address %1
% DHCPSRV_MEMFILE_GET_ADDR6 obtaining IPv6 lease for address %1
and lease type %2
A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for the specified address.
...
...
@@ -255,12 +255,12 @@ A debug message issued when the server is attempting to obtain a set of
IPv4 leases from the memory file database for a client with the specified
hardware address.
% DHCPSRV_MEMFILE_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2
% DHCPSRV_MEMFILE_GET_IAID_DUID obtaining IPv6 leases for IAID %1 and DUID %2
and lease type %3
A debug message issued when the server is attempting to obtain a set of
IPv6 lease from the memory file database for a client with the specified
IAID (Identity Association ID) and DUID (DHCP Unique Identifier).
% DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2
and
DUID %3
% DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID obtaining IPv6 leases for IAID %1, Subnet ID %2
,
DUID %3
and lease type %4
A debug message issued when the server is attempting to obtain an IPv6
lease from the memory file database for a client with the specified IAID
(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
...
...
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
43fc4271
...
...
@@ -235,13 +235,14 @@ Memfile_LeaseMgr::getLease4(const ClientId& client_id,
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
Lease
::
Type
/* not used yet */
,
Memfile_LeaseMgr
::
getLease6
(
Lease
::
Type
type
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_ADDR6
).
arg
(
addr
.
toText
());
DHCPSRV_MEMFILE_GET_ADDR6
)
.
arg
(
addr
.
toText
())
.
arg
(
Lease
::
typeToText
(
type
));
Lease6Storage
::
iterator
l
=
storage6_
.
find
(
addr
);
if
(
l
==
storage6_
.
end
())
{
if
(
l
==
storage6_
.
end
()
||
!
(
*
l
)
||
((
*
l
)
->
type_
!=
type
)
)
{
return
(
Lease6Ptr
());
}
else
{
return
(
Lease6Ptr
(
new
Lease6
(
**
l
)));
...
...
@@ -249,42 +250,55 @@ Memfile_LeaseMgr::getLease6(Lease::Type /* not used yet */,
}
Lease6Collection
Memfile_LeaseMgr
::
getLeases6
(
Lease
::
Type
/* not used yet */
,
Memfile_LeaseMgr
::
getLeases6
(
Lease
::
Type
type
,
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
());
DHCPSRV_MEMFILE_GET_IAID_DUID
)
.
arg
(
iaid
)
.
arg
(
duid
.
toText
())
.
arg
(
Lease
::
typeToText
(
type
));
/// @todo Not implemented.
// We are going to use index #1 of the multi index container.
typedef
Lease6Storage
::
nth_index
<
1
>::
type
SearchIndex
;
// Get the index.
const
SearchIndex
&
idx
=
storage6_
.
get
<
1
>
();
// Try to get the lease using the DUID, IAID and lease type.
std
::
pair
<
SearchIndex
::
iterator
,
SearchIndex
::
iterator
>
l
=
idx
.
equal_range
(
boost
::
make_tuple
(
duid
.
getDuid
(),
iaid
,
type
));
Lease6Collection
collection
;
for
(
SearchIndex
::
iterator
lease
=
l
.
first
;
lease
!=
l
.
second
;
++
lease
)
{
collection
.
push_back
(
Lease6Ptr
(
new
Lease6
(
**
lease
)));
}
return
(
Lease6C
ollection
()
);
return
(
c
ollection
);
}
Lease6Collection
Memfile_LeaseMgr
::
getLeases6
(
Lease
::
Type
/* not used yet */
,
Memfile_LeaseMgr
::
getLeases6
(
Lease
::
Type
type
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID
)
.
arg
(
iaid
).
arg
(
subnet_id
).
arg
(
duid
.
toText
());
.
arg
(
iaid
)
.
arg
(
subnet_id
)
.
arg
(
duid
.
toText
())
.
arg
(
Lease
::
typeToText
(
type
));
// We are going to use index #1 of the multi index container.
// We define SearchIndex locally in this function because
// currently only this function uses this index.
typedef
Lease6Storage
::
nth_index
<
1
>::
type
SearchIndex
;
// Get the index.
const
SearchIndex
&
idx
=
storage6_
.
get
<
1
>
();
// Try to get the lease using the DUID, IAID and Subnet ID.
SearchIndex
::
const_iterator
lease
=
idx
.
find
(
boost
::
make_tuple
(
duid
.
getDuid
(),
iaid
,
subnet_id
));
// Lease was not found. Return empty pointer.
if
(
lease
==
idx
.
end
())
{
return
(
Lease6Collection
());
// Try to get the lease using the DUID, IAID and lease type.
std
::
pair
<
SearchIndex
::
iterator
,
SearchIndex
::
iterator
>
l
=
idx
.
equal_range
(
boost
::
make_tuple
(
duid
.
getDuid
(),
iaid
,
type
));
Lease6Collection
collection
;
for
(
SearchIndex
::
iterator
lease
=
l
.
first
;
lease
!=
l
.
second
;
++
lease
)
{
// Filter out the leases which subnet id doesn't match.
if
((
*
lease
)
->
subnet_id_
==
subnet_id
)
{
collection
.
push_back
(
Lease6Ptr
(
new
Lease6
(
**
lease
)));
}
}
// Lease was found, return it to the caller.
/// @todo: allow multiple leases for a single duid+iaid+subnet_id tuple
Lease6Collection
collection
;
collection
.
push_back
(
Lease6Ptr
(
new
Lease6
(
**
lease
)));
return
(
collection
);
}
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
43fc4271
...
...
@@ -190,9 +190,8 @@ public:
virtual
Lease6Ptr
getLease6
(
Lease
::
Type
type
,
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
/// @brief Returns existing IPv6 lease for a given DUID+IA combination
///
/// @todo Not implemented yet
/// @brief Returns existing IPv6 lease for a given DUID + IA + lease type
/// combination
///
/// @param type specifies lease type: (NA, TA or PD)
/// @param duid client DUID
...
...
@@ -202,7 +201,8 @@ public:
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
/// @brief Returns existing IPv6 lease for a given DUID + IA + subnet-id +
/// lease type combination.
///
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
...
...
@@ -214,7 +214,8 @@ public:
///
/// @return lease collection (may be empty if no lease is found)
virtual
Lease6Collection
getLeases6
(
Lease
::
Type
type
,
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
/// @brief Updates IPv4 lease.
///
...
...
@@ -372,8 +373,6 @@ protected:
/// will not be written to disk.
///
/// @param u Universe (v4 or v6)
/// @param parameters Map holding parameters of the Lease Manager, passed to
/// the constructor.
///
/// @return The location of the lease file that should be assigned to the
/// lease_file4_ or lease_file6_, depending on the universe specified as an
...
...
@@ -394,9 +393,9 @@ protected:
>
,
// Specification of the second index starts here.
boost
::
multi_index
::
ordered_unique
<
boost
::
multi_index
::
ordered_
non_
unique
<
// This is a composite index that will be used to search for
// the lease using three attributes: DUID, IAID
, Subnet Id
.
// the lease using three attributes: DUID, IAID
and lease type
.
boost
::
multi_index
::
composite_key
<
Lease6
,
// The DUID can be retrieved from the Lease6 object using
...
...
@@ -404,9 +403,9 @@ protected:
boost
::
multi_index
::
const_mem_fun
<
Lease6
,
const
std
::
vector
<
uint8_t
>&
,
&
Lease6
::
getDuidVector
>
,
// The two other ingredients of this index are IAID and
//
subnet id
.
//
lease type
.
boost
::
multi_index
::
member
<
Lease6
,
uint32_t
,
&
Lease6
::
iaid_
>
,
boost
::
multi_index
::
member
<
Lease
,
SubnetID
,
&
Lease
::
subnet_id
_
>
boost
::
multi_index
::
member
<
Lease
6
,
Lease
::
Type
,
&
Lease
6
::
type
_
>
>
>
>
...
...
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
View file @
43fc4271
...
...
@@ -319,7 +319,7 @@ TEST_F(MemfileLeaseMgrTest, basicLease6) {
/// a combination of DUID and IAID.
/// @todo: test disabled, because Memfile_LeaseMgr::getLeases6(Lease::Type,
/// const DUID& duid, uint32_t iaid) const is not implemented yet.
TEST_F
(
MemfileLeaseMgrTest
,
DISABLED_
getLeases6DuidIaid
)
{
TEST_F
(
MemfileLeaseMgrTest
,
getLeases6DuidIaid
)
{
startBackend
(
V6
);
testGetLeases6DuidIaid
();
}
...
...
@@ -328,7 +328,7 @@ TEST_F(MemfileLeaseMgrTest, DISABLED_getLeases6DuidIaid) {
/// @todo: test disabled, because Memfile_LeaseMgr::getLeases6(Lease::Type,
/// const DUID& duid, uint32_t iaid) const is not implemented yet.
TEST_F
(
MemfileLeaseMgrTest
,
DISABLED_
getLeases6DuidSize
)
{
TEST_F
(
MemfileLeaseMgrTest
,
getLeases6DuidSize
)
{
startBackend
(
V6
);
testGetLeases6DuidSize
();
}
...
...
@@ -341,7 +341,7 @@ TEST_F(MemfileLeaseMgrTest, DISABLED_getLeases6DuidSize) {
/// discriminate between the leases based on lease type alone.
/// @todo: Disabled, because type parameter in Memfile_LeaseMgr::getLease6
/// (Lease::Type, const isc::asiolink::IOAddress& addr) const is not used.
TEST_F
(
MemfileLeaseMgrTest
,
DISABLED_
lease6LeaseTypeCheck
)
{
TEST_F
(
MemfileLeaseMgrTest
,
lease6LeaseTypeCheck
)
{
startBackend
(
V6
);
testLease6LeaseTypeCheck
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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