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
231fed6c
Commit
231fed6c
authored
Aug 21, 2013
by
Marcin Siodelski
Browse files
[3083] Return a copy of the lease when getLease is called.
Also, updateLease4 and updateLease6 are implemented.
parent
bf6d6bcd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/memfile_lease_mgr.cc
View file @
231fed6c
...
...
@@ -62,7 +62,7 @@ Lease4Ptr Memfile_LeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) cons
if
(
l
==
storage4_
.
end
())
{
return
(
Lease4Ptr
());
}
else
{
return
(
*
l
);
return
(
Lease4Ptr
(
new
Lease4
(
**
l
))
);
}
}
...
...
@@ -94,7 +94,7 @@ Lease4Ptr Memfile_LeaseMgr::getLease4(const HWAddr& hwaddr,
}
// Lease was found. Return it to the caller.
return
(
*
lease
);
return
(
Lease4Ptr
(
new
Lease4
(
*
*
lease
)
))
;
}
Lease4Collection
Memfile_LeaseMgr
::
getLease4
(
const
ClientId
&
clientid
)
const
{
...
...
@@ -123,11 +123,11 @@ Lease4Ptr Memfile_LeaseMgr::getLease4(const ClientId& client_id,
return
Lease4Ptr
();
}
// Lease was found. Return it to the caller.
return
(
*
lease
);
return
(
Lease4Ptr
(
new
Lease4
(
*
*
lease
)
))
;
}
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
Lease6Ptr
Memfile_LeaseMgr
::
getLease6
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_GET_ADDR6
).
arg
(
addr
.
toText
());
...
...
@@ -135,7 +135,7 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(
if
(
l
==
storage6_
.
end
())
{
return
(
Lease6Ptr
());
}
else
{
return
(
*
l
);
return
(
Lease6Ptr
(
new
Lease6
(
**
l
))
);
}
}
...
...
@@ -167,20 +167,31 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid,
return
(
Lease6Ptr
());
}
// Lease was found, return it to the caller.
return
(
*
lease
);
return
(
Lease6Ptr
(
new
Lease6
(
*
*
lease
)
))
;
}
void
Memfile_LeaseMgr
::
updateLease4
(
const
Lease4Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_UPDATE_ADDR4
).
arg
(
lease
->
addr_
.
toText
());
Lease4Storage
::
iterator
lease_it
=
storage4_
.
find
(
lease
->
addr_
);
if
(
lease_it
==
storage4_
.
end
())
{
isc_throw
(
NoSuchLease
,
"failed to update the lease with address "
<<
lease
->
addr_
.
toText
()
<<
" - no such lease"
);
}
**
lease_it
=
*
lease
;
}
void
Memfile_LeaseMgr
::
updateLease6
(
const
Lease6Ptr
&
lease
)
{
LOG_DEBUG
(
dhcpsrv_logger
,
DHCPSRV_DBG_TRACE_DETAIL
,
DHCPSRV_MEMFILE_UPDATE_ADDR6
).
arg
(
lease
->
addr_
.
toText
());
Lease6Storage
::
iterator
lease_it
=
storage6_
.
find
(
lease
->
addr_
);
if
(
lease_it
==
storage6_
.
end
())
{
isc_throw
(
NoSuchLease
,
"failed to update the lease with address "
<<
lease
->
addr_
.
toText
()
<<
" - no such lease"
);
}
**
lease_it
=
*
lease
;
}
bool
Memfile_LeaseMgr
::
deleteLease
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
{
...
...
src/lib/dhcpsrv/memfile_lease_mgr.h
View file @
231fed6c
...
...
@@ -65,8 +65,10 @@ public:
/// @brief Returns existing IPv4 lease for specified IPv4 address.
///
/// @todo Not implemented yet
/// @param addr address of the searched lease
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @param addr An address of the searched lease.
///
/// @return a collection of leases
virtual
Lease4Ptr
getLease4
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
...
...
@@ -85,10 +87,11 @@ public:
/// @return lease collection
virtual
Lease4Collection
getLease4
(
const
isc
::
dhcp
::
HWAddr
&
hwaddr
)
const
;
/// @brief Returns existing IPv4 lease
s
for specified hardware address
/// @brief Returns existing IPv4 lease for specified hardware address
/// and a subnet
///
/// @todo Not implemented yet
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// There can be at most one lease for a given HW address in a single
/// pool, so this method with either return a single lease or NULL.
...
...
@@ -109,11 +112,12 @@ public:
/// @brief Returns existing IPv4 lease for specified client-id
///
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// There can be at most one lease for a given HW address in a single
/// pool, so this method with either return a single lease or NULL.
///
/// @todo Not implemented yet
///
/// @param clientid client identifier
/// @param subnet_id identifier of the subnet that lease must belong to
///
...
...
@@ -123,7 +127,10 @@ public:
/// @brief Returns existing IPv6 lease for a given IPv6 address.
///
/// @param addr address of the searched lease
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @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
(
const
isc
::
asiolink
::
IOAddress
&
addr
)
const
;
...
...
@@ -140,27 +147,31 @@ public:
/// @brief Returns existing IPv6 lease for a given DUID+IA combination
///
/// @todo Not implemented yet
/// This function returns a copy of the lease. The modification in the
/// return lease does not affect the instance held in the lease storage.
///
/// @param duid client DUID
/// @param iaid IA identifier
/// @param subnet_id identifier of the subnet the lease must belong to
///
/// @return smart pointer to the lease (or NULL if a lease is not found)
virtual
Lease6Ptr
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
virtual
Lease6Ptr
getLease6
(
const
DUID
&
duid
,
uint32_t
iaid
,
SubnetID
subnet_id
)
const
;
/// @brief Updates IPv4 lease.
///
/// @todo Not implemented yet
/// @warning This function does not validate the pointer to the lease.
/// It is caller's responsibility to pass the valid pointer.
///
/// @param lease4 The lease to be updated.
///
/// If no such lease is present, an exception will be thrown.
virtual
void
updateLease4
(
const
Lease4Ptr
&
lease4
);
/// @brief Updates IPv
4
lease.
/// @brief Updates IPv
6
lease.
///
/// @todo Not implemented yet
/// @warning This function does not validate the pointer to the lease.
/// It is caller's responsibility to pass the valid pointer.
///
/// @param lease6 The lease to be updated.
///
...
...
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