BIND 10 trac2546, updated. 4f17a81c04b1364a0835e9a9b9c26adc6c159cd3 [2546] Changed a missed "deleteLease6" to "deleteLease"
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Dec 10 14:23:33 UTC 2012
The branch, trac2546 has been updated
via 4f17a81c04b1364a0835e9a9b9c26adc6c159cd3 (commit)
via 7942b605f69740f853100f36abad05e9a98d1e90 (commit)
via e4e8de317591b5ac9fec818693fb2cdc5ce9e2a3 (commit)
via 03b92733bfd3c13bc86c8f878b274cf33740ef15 (commit)
via d87597de14b3c81e481b51ea6de8b3273305487a (commit)
via 084a16684541f0d19e99998a2a29a92619ee0b94 (commit)
from 93eddf78d2db40f314323dc708252c87ed846a48 (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 4f17a81c04b1364a0835e9a9b9c26adc6c159cd3
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 14:21:14 2012 +0000
[2546] Changed a missed "deleteLease6" to "deleteLease"
commit 7942b605f69740f853100f36abad05e9a98d1e90
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 13:54:46 2012 +0000
[2546] Fixed some Doxygen warnings
commit e4e8de317591b5ac9fec818693fb2cdc5ce9e2a3
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 12:06:06 2012 +0000
[2546] Correct issues raised by cppcheck
Mostly adding "const" to methods that don't change the class, but
also correcting a few other points that were raised.
commit 03b92733bfd3c13bc86c8f878b274cf33740ef15
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 11:21:24 2012 +0000
[2546] Unify deleteLease4() and deleteLease6() into a single deleteLease()
commit d87597de14b3c81e481b51ea6de8b3273305487a
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 10:35:28 2012 +0000
[2546] Define ClientIdPtr type
This is akin to the DuidPtr and is a shared point to a Client ID.
commit 084a16684541f0d19e99998a2a29a92619ee0b94
Author: Stephen Morris <stephen at isc.org>
Date: Mon Dec 10 10:13:53 2012 +0000
[2546] Remove LeaseMgr::getLease4(address, subnetid)
As the address is th eprimary key of the table, there can only ever
be at most one lease in the database with a given address. Additional
selection by subnet ID is not needed.
-----------------------------------------------------------------------
Summary of changes:
doc/devel/02-dhcp.dox | 4 +-
doc/devel/mainpage.dox | 6 +-
src/bin/dhcp4/ctrl_dhcp4_srv.h | 4 +-
src/bin/dhcp4/dhcp4_srv.h | 2 +-
src/bin/dhcp6/config_parser.cc | 2 +-
src/bin/dhcp6/ctrl_dhcp6_srv.cc | 1 -
src/bin/dhcp6/ctrl_dhcp6_srv.h | 4 +-
src/bin/dhcp6/dhcp6.dox | 6 +-
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 2 +-
src/lib/dhcp/duid.h | 3 +
src/lib/dhcp/option.h | 4 +-
src/lib/dhcp/option4_addrlst.h | 4 +-
src/lib/dhcp/option6_addrlst.h | 4 +-
src/lib/dhcp/option_data_types.cc | 2 +-
src/lib/dhcp/option_definition.cc | 2 +-
src/lib/dhcp/pkt4.cc | 2 +-
src/lib/dhcp/pkt4.h | 10 +-
src/lib/dhcp/pkt6.h | 14 ++-
src/lib/dhcpsrv/addr_utilities.h | 8 +-
src/lib/dhcpsrv/cfgmgr.h | 3 +
src/lib/dhcpsrv/lease_mgr.h | 96 ++++++++------------
src/lib/dhcpsrv/memfile_lease_mgr.cc | 28 +++---
src/lib/dhcpsrv/memfile_lease_mgr.h | 22 +----
src/lib/dhcpsrv/mysql_lease_mgr.cc | 71 +++++----------
src/lib/dhcpsrv/mysql_lease_mgr.h | 40 +-------
src/lib/dhcpsrv/subnet.h | 2 +-
src/lib/dhcpsrv/tests/lease_mgr_unittest.cc | 24 +----
.../dhcpsrv/tests/memfile_lease_mgr_unittest.cc | 4 +-
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc | 89 ++++++------------
src/lib/dhcpsrv/triplet.h | 2 +-
30 files changed, 165 insertions(+), 300 deletions(-)
-----------------------------------------------------------------------
diff --git a/doc/devel/02-dhcp.dox b/doc/devel/02-dhcp.dox
index 5c59daa..b98920f 100644
--- a/doc/devel/02-dhcp.dox
+++ b/doc/devel/02-dhcp.dox
@@ -19,7 +19,7 @@
*
* @section dhcpv4Session BIND10 message queue integration
*
- * DHCPv4 server component is now integrated with BIND10 message queue.
+ * DHCPv4 server component is now integrated with the BIND10 message queue.
* The integration is performed by establishSession() and disconnectSession()
* functions in isc::dhcp::ControlledDhcpv4Srv class. main() method deifined
* in the src/bin/dhcp4/main.cc file instantiates isc::dhcp::ControlledDhcpv4Srv
@@ -57,4 +57,4 @@
* that does not support msgq. That is useful for embedded environments.
* It may also be useful in validation.
*
- */
\ No newline at end of file
+ */
diff --git a/doc/devel/mainpage.dox b/doc/devel/mainpage.dox
index db42c14..c2c69ca 100644
--- a/doc/devel/mainpage.dox
+++ b/doc/devel/mainpage.dox
@@ -23,9 +23,9 @@
* - @subpage dhcpv4
* - @subpage dhcpv4Session
* - @subpage dhcpv6
- * - @subpage dhcpv6-session
- * - @subpage dhcpv6-config-parser
- * - @subpage dhcpv6-config-inherit
+ * - @subpage dhcpv6Session
+ * - @subpage dhcpv6ConfigParser
+ * - @subpage dhcpv6ConfigInherit
* - @subpage libdhcp
* - @subpage libdhcpIntro
* - @subpage libdhcpIfaceMgr
diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.h b/src/bin/dhcp4/ctrl_dhcp4_srv.h
index 9fd7668..5f45077 100644
--- a/src/bin/dhcp4/ctrl_dhcp4_srv.h
+++ b/src/bin/dhcp4/ctrl_dhcp4_srv.h
@@ -66,8 +66,8 @@ public:
/// @brief Session callback, processes received commands.
///
- /// @param command_id text represenation of the command (e.g. "shutdown")
- /// @param args optional parameters
+ /// @param command Text represenation of the command (e.g. "shutdown")
+ /// @param args Optional parameters
///
/// @return status of the command
static isc::data::ConstElementPtr
diff --git a/src/bin/dhcp4/dhcp4_srv.h b/src/bin/dhcp4/dhcp4_srv.h
index 48ccde6..db4b4bc 100644
--- a/src/bin/dhcp4/dhcp4_srv.h
+++ b/src/bin/dhcp4/dhcp4_srv.h
@@ -36,7 +36,7 @@ namespace dhcp {
/// appropriate responses.
///
/// This class does not support any controlling mechanisms directly.
-/// See derived \ref ControlledDhcv4Srv class for support for
+/// See the derived \ref ControlledDhcpv4Srv class for support for
/// command and configuration updates over msgq.
///
/// For detailed explanation or relations between main(), ControlledDhcpv4Srv,
diff --git a/src/bin/dhcp6/config_parser.cc b/src/bin/dhcp6/config_parser.cc
index 1c55649..2038d12 100644
--- a/src/bin/dhcp6/config_parser.cc
+++ b/src/bin/dhcp6/config_parser.cc
@@ -339,7 +339,7 @@ public:
/// @brief parses parameters value
///
/// Parses configuration entry (list of parameters) and stores it in
- /// storage. See \ref setStorage() for details.
+ /// storage.
///
/// @param value pointer to the content of parsed values
virtual void build(ConstElementPtr value) {
diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc
index 5d4d990..8611365 100644
--- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc
+++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc
@@ -17,7 +17,6 @@
#include <asiolink/asiolink.h>
#include <cc/data.h>
#include <cc/session.h>
-#include <cc/session.h>
#include <config/ccsession.h>
#include <dhcp/iface_mgr.h>
#include <dhcp6/config_parser.h>
diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.h b/src/bin/dhcp6/ctrl_dhcp6_srv.h
index 22cb3b6..ef1acab 100644
--- a/src/bin/dhcp6/ctrl_dhcp6_srv.h
+++ b/src/bin/dhcp6/ctrl_dhcp6_srv.h
@@ -68,8 +68,8 @@ public:
/// @brief Session callback, processes received commands.
///
- /// @param command_id text represenation of the command (e.g. "shutdown")
- /// @param args optional parameters
+ /// @param command Text represenation of the command (e.g. "shutdown")
+ /// @param args Optional parameters
///
/// @return status of the command
static isc::data::ConstElementPtr
diff --git a/src/bin/dhcp6/dhcp6.dox b/src/bin/dhcp6/dhcp6.dox
index c234f40..ba0fea9 100644
--- a/src/bin/dhcp6/dhcp6.dox
+++ b/src/bin/dhcp6/dhcp6.dox
@@ -16,13 +16,13 @@
DHCPv6 server component does not use BIND10 logging yet.
- @section dhcpv6-session BIND10 message queue integration
+ @section dhcpv6Session BIND10 message queue integration
DHCPv4 server component is now integrated with BIND10 message queue.
It follows the same principle as DHCPv4. See \ref dhcpv4Session for
details.
- @section dhcpv6-config-parser Configuration Parser in DHCPv6
+ @section dhcpv6ConfigParser Configuration Parser in DHCPv6
b10-dhcp6 component uses BIND10 cfgmgr for commands and configuration. During
initial configuration (See \ref
@@ -49,7 +49,7 @@
elements and creates parsers for a given scope. This process may be repeated
(sort of) recursively.
- @section dhcpv6-config-inherit DHCPv6 Configuration Inheritance
+ @section dhcpv6ConfigInherit DHCPv6 Configuration Inheritance
One notable useful feature of DHCP configuration is its parameter inheritance.
For example, renew-timer value may be specified at a global scope and it then
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 335fb7b..9679700 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -674,7 +674,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
// check that the lease is really in the database
Lease6Ptr l = checkLease(duid_, reply->getOption(D6O_IA_NA), addr);
EXPECT_TRUE(l);
- LeaseMgrFactory::instance().deleteLease6(addr->getAddress());
+ LeaseMgrFactory::instance().deleteLease(addr->getAddress());
}
// This test checks that the server is offering different addresses to different
diff --git a/src/lib/dhcp/duid.h b/src/lib/dhcp/duid.h
index 1b75f73..60b9706 100644
--- a/src/lib/dhcp/duid.h
+++ b/src/lib/dhcp/duid.h
@@ -114,6 +114,9 @@ public:
bool operator!=(const ClientId& other) const;
};
+/// @brief Shared pointer to a Client ID.
+typedef boost::shared_ptr<ClientId> ClientIdPtr;
+
}; // end of isc::dhcp namespace
}; // end of isc namespace
diff --git a/src/lib/dhcp/option.h b/src/lib/dhcp/option.h
index a6b0622..22ac291 100644
--- a/src/lib/dhcp/option.h
+++ b/src/lib/dhcp/option.h
@@ -152,7 +152,7 @@ public:
/// @brief returns option universe (V4 or V6)
///
/// @return universe type
- Universe getUniverse() { return universe_; };
+ Universe getUniverse() const { return universe_; };
/// @brief Writes option in wire-format to a buffer.
///
@@ -197,7 +197,7 @@ public:
/// Returns option type (0-255 for DHCPv4, 0-65535 for DHCPv6)
///
/// @return option type
- uint16_t getType() { return (type_); }
+ uint16_t getType() const { return (type_); }
/// Returns length of the complete option (data length + DHCPv4/DHCPv6
/// option header)
diff --git a/src/lib/dhcp/option4_addrlst.h b/src/lib/dhcp/option4_addrlst.h
index b266cbf..927f75b 100644
--- a/src/lib/dhcp/option4_addrlst.h
+++ b/src/lib/dhcp/option4_addrlst.h
@@ -111,10 +111,10 @@ public:
/// We return a copy of our list. Although this includes overhead,
/// it also makes this list safe to use after this option object
/// is no longer available. As options are expected to hold only
- /// a couple (1-3) addresses, the overhead is not that big.
+ /// a few (1-3) addresses, the overhead is not that big.
///
/// @return address container with addresses
- AddressContainer getAddresses() { return addrs_; };
+ AddressContainer getAddresses() const { return addrs_; };
/// @brief Sets addresses list.
///
diff --git a/src/lib/dhcp/option6_addrlst.h b/src/lib/dhcp/option6_addrlst.h
index b9c0deb..8327201 100644
--- a/src/lib/dhcp/option6_addrlst.h
+++ b/src/lib/dhcp/option6_addrlst.h
@@ -82,10 +82,10 @@ public:
/// We return a copy of our list. Although this includes overhead,
/// it also makes this list safe to use after this option object
/// is no longer available. As options are expected to hold only
- /// a couple (1-3) addresses, the overhead is not that big.
+ /// a few (1-3) addresses, the overhead is not that big.
///
/// @return address container with addresses
- AddressContainer getAddresses() { return addrs_; };
+ AddressContainer getAddresses() const { return addrs_; };
// returns data length (data length + DHCPv4/DHCPv6 option header)
virtual uint16_t len();
diff --git a/src/lib/dhcp/option_data_types.cc b/src/lib/dhcp/option_data_types.cc
index 46aa663..de09bc4 100644
--- a/src/lib/dhcp/option_data_types.cc
+++ b/src/lib/dhcp/option_data_types.cc
@@ -209,7 +209,7 @@ OptionDataTypeUtil::writeBool(const bool value,
std::string
OptionDataTypeUtil::readString(const std::vector<uint8_t>& buf) {
std::string value;
- if (buf.size() > 0) {
+ if (!buf.empty()) {
value.insert(value.end(), buf.begin(), buf.end());
}
return (value);
diff --git a/src/lib/dhcp/option_definition.cc b/src/lib/dhcp/option_definition.cc
index 58d0c4b..f1e89e2 100644
--- a/src/lib/dhcp/option_definition.cc
+++ b/src/lib/dhcp/option_definition.cc
@@ -144,7 +144,7 @@ OptionDefinition::optionFactory(Option::Universe u, uint16_t type,
OptionBuffer buf;
if (!array_type_ && type_ != OPT_RECORD_TYPE) {
- if (values.size() == 0) {
+ if (values.empty()) {
isc_throw(InvalidOptionValue, "no option value specified");
}
writeToBuffer(values[0], type_, buf);
diff --git a/src/lib/dhcp/pkt4.cc b/src/lib/dhcp/pkt4.cc
index 5be8211..a232d02 100644
--- a/src/lib/dhcp/pkt4.cc
+++ b/src/lib/dhcp/pkt4.cc
@@ -228,7 +228,7 @@ Pkt4::setHWAddr(uint8_t hType, uint8_t hlen,
isc_throw(OutOfRange, "Hardware address (len=" << hlen
<< " too long. Max " << MAX_CHADDR_LEN << " supported.");
}
- if ( (macAddr.size() == 0) && (hlen > 0) ) {
+ if (macAddr.empty() && (hlen > 0) ) {
isc_throw(OutOfRange, "Invalid HW Address specified");
}
diff --git a/src/lib/dhcp/pkt4.h b/src/lib/dhcp/pkt4.h
index e09069c..b35830f 100644
--- a/src/lib/dhcp/pkt4.h
+++ b/src/lib/dhcp/pkt4.h
@@ -367,7 +367,7 @@ public:
/// @brief Returns remote address
///
/// @return remote address
- const isc::asiolink::IOAddress& getRemoteAddr() {
+ const isc::asiolink::IOAddress& getRemoteAddr() const {
return (remote_addr_);
}
@@ -381,7 +381,7 @@ public:
/// @brief Returns local address.
///
/// @return local address
- const isc::asiolink::IOAddress& getLocalAddr() {
+ const isc::asiolink::IOAddress& getLocalAddr() const {
return (local_addr_);
}
@@ -393,7 +393,7 @@ public:
/// @brief Returns local port.
///
/// @return local port
- uint16_t getLocalPort() { return (local_port_); }
+ uint16_t getLocalPort() const { return (local_port_); }
/// @brief Sets remote port.
///
@@ -403,7 +403,7 @@ public:
/// @brief Returns remote port.
///
/// @return remote port
- uint16_t getRemotePort() { return (remote_port_); }
+ uint16_t getRemotePort() const { return (remote_port_); }
/// @brief Update packet timestamp.
///
@@ -525,7 +525,7 @@ protected:
/// collection of options present in this message
///
- /// @warnig This protected member is accessed by derived
+ /// @warning This protected member is accessed by derived
/// classes directly. One of such derived classes is
/// @ref perfdhcp::PerfPkt4. The impact on derived clasess'
/// behavior must be taken into consideration before making
diff --git a/src/lib/dhcp/pkt6.h b/src/lib/dhcp/pkt6.h
index 5782737..ac5e787 100644
--- a/src/lib/dhcp/pkt6.h
+++ b/src/lib/dhcp/pkt6.h
@@ -127,7 +127,7 @@ public:
/// Returns message type (e.g. 1 = SOLICIT)
///
/// @return message type
- uint8_t getType() { return (msg_type_); }
+ uint8_t getType() const { return (msg_type_); }
/// Sets message type (e.g. 1 = SOLICIT)
///
@@ -180,7 +180,9 @@ public:
/// @brief Returns remote address
///
/// @return remote address
- const isc::asiolink::IOAddress& getRemoteAddr() { return (remote_addr_); }
+ const isc::asiolink::IOAddress& getRemoteAddr() const {
+ return (remote_addr_);
+ }
/// @brief Sets local address.
///
@@ -190,7 +192,9 @@ public:
/// @brief Returns local address.
///
/// @return local address
- const isc::asiolink::IOAddress& getLocalAddr() { return (local_addr_); }
+ const isc::asiolink::IOAddress& getLocalAddr() const {
+ return (local_addr_);
+ }
/// @brief Sets local port.
///
@@ -200,7 +204,7 @@ public:
/// @brief Returns local port.
///
/// @return local port
- uint16_t getLocalPort() { return (local_port_); }
+ uint16_t getLocalPort() const { return (local_port_); }
/// @brief Sets remote port.
///
@@ -210,7 +214,7 @@ public:
/// @brief Returns remote port.
///
/// @return remote port
- uint16_t getRemotePort() { return (remote_port_); }
+ uint16_t getRemotePort() const { return (remote_port_); }
/// @brief Sets interface index.
///
diff --git a/src/lib/dhcpsrv/addr_utilities.h b/src/lib/dhcpsrv/addr_utilities.h
index a1d856c..784aeab 100644
--- a/src/lib/dhcpsrv/addr_utilities.h
+++ b/src/lib/dhcpsrv/addr_utilities.h
@@ -26,8 +26,8 @@ namespace dhcp {
/// @brief returns a first address in a given prefix
///
-/// Example: For 2001:db8:1::deaf:beef and length /120 the function will return
-/// 2001:db8:1::dead:be00. See also @ref lastAddrInPrefix.
+/// Example: For 2001:db8:1\::deaf:beef and length /120 the function will return
+/// 2001:db8:1\::dead:be00. See also @ref lastAddrInPrefix.
///
/// @todo It currently works for v6 only and will throw if v4 address is passed.
///
@@ -40,8 +40,8 @@ isc::asiolink::IOAddress firstAddrInPrefix(const isc::asiolink::IOAddress& prefi
/// @brief returns a last address in a given prefix
///
-/// Example: For 2001:db8:1::deaf:beef and length /112 the function will return
-/// 2001:db8:1::dead:ffff. See also @ref firstAddrInPrefix.
+/// Example: For 2001:db8:1\::deaf:beef and length /112 the function will return
+/// 2001:db8:1\::dead:ffff. See also @ref firstAddrInPrefix.
///
/// @todo It currently works for v6 only and will throw if v4 address is passed.
///
diff --git a/src/lib/dhcpsrv/cfgmgr.h b/src/lib/dhcpsrv/cfgmgr.h
index 5bff64a..65a33f0 100644
--- a/src/lib/dhcpsrv/cfgmgr.h
+++ b/src/lib/dhcpsrv/cfgmgr.h
@@ -43,6 +43,7 @@ namespace dhcp {
/// Below is a sketch of configuration inheritance (not implemented yet).
/// Let's investigate the following configuration:
///
+/// @code
/// preferred-lifetime 500;
/// valid-lifetime 1000;
/// subnet6 2001:db8:1::/48 {
@@ -52,6 +53,8 @@ namespace dhcp {
/// valid-lifetime 2000;
/// pool6 2001::db8:2::1 - 2001::db8:2::ff;
/// };
+/// @endcode
+///
/// Parameters defined in a global scope are applicable to everything until
/// they are overwritten in a smaller scope, in this case subnet6.
/// In the example above, the first subnet6 has preferred lifetime of 500s
diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h
index a264743..7865e11 100644
--- a/src/lib/dhcpsrv/lease_mgr.h
+++ b/src/lib/dhcpsrv/lease_mgr.h
@@ -30,7 +30,7 @@
#include <utility>
#include <vector>
-/// @file dhcp/lease_mgr.h
+/// @file lease_mgr.h
/// @brief An abstract API for lease database
///
/// This file contains declarations of Lease4, Lease6 and LeaseMgr classes.
@@ -118,32 +118,6 @@ struct Lease4 {
/// @brief Maximum size of a hardware address
static const size_t HWADDR_MAX = 20;
- /// @brief Constructor
- ///
- /// @param addr IPv4 address as unsigned 32-bit integer in network byte
- /// order.
- /// @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 cltt Client last transmission time
- /// @param subnet_id Subnet identification
- Lease4(uint32_t addr, const uint8_t* hwaddr, size_t hwaddr_len,
- const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft,
- time_t cltt, uint32_t subnet_id)
- : addr_(addr), ext_(0), hwaddr_(hwaddr, hwaddr + hwaddr_len),
- client_id_(new ClientId(clientid, clientid_len)), t1_(0), t2_(0),
- valid_lft_(valid_lft), cltt_(cltt), subnet_id_(subnet_id),
- fixed_(false), hostname_(), fqdn_fwd_(false), fqdn_rev_(false),
- comments_()
- {}
-
- /// @brief Default Constructor
- ///
- /// Initialize fields that don't have a default constructor.
- Lease4() : addr_(0) {}
-
/// IPv4 address
isc::asiolink::IOAddress addr_;
@@ -165,7 +139,7 @@ struct Lease4 {
///
/// @todo Should this be a pointer to a client ID or the ID itself?
/// Compare with the DUID in the Lease6 structure.
- boost::shared_ptr<ClientId> client_id_;
+ ClientIdPtr client_id_;
/// @brief Renewal timer
///
@@ -227,6 +201,33 @@ struct Lease4 {
/// system administrator.
std::string comments_;
+ /// @brief Constructor
+ ///
+ /// @param addr IPv4 address as unsigned 32-bit integer in network byte
+ /// order.
+ /// @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 cltt Client last transmission time
+ /// @param subnet_id Subnet identification
+ Lease4(uint32_t addr, const uint8_t* hwaddr, size_t hwaddr_len,
+ const uint8_t* clientid, size_t clientid_len, uint32_t valid_lft,
+ time_t cltt, uint32_t subnet_id)
+ : addr_(addr), ext_(0), hwaddr_(hwaddr, hwaddr + hwaddr_len),
+ client_id_(new ClientId(clientid, clientid_len)), t1_(0), t2_(0),
+ valid_lft_(valid_lft), cltt_(cltt), subnet_id_(subnet_id),
+ fixed_(false), hostname_(), fqdn_fwd_(false), fqdn_rev_(false),
+ comments_()
+ {}
+
+ /// @brief Default Constructor
+ ///
+ /// Initialize fields that don't have a default constructor.
+ Lease4() : addr_(0), fixed_(false), fqdn_fwd_(false), fqdn_rev_(false)
+ {}
+
/// @brief Compare two leases for equality
///
/// @param other lease6 object with which to compare
@@ -265,11 +266,6 @@ struct Lease6 {
LEASE_IA_PD /// the lease contains IPv6 prefix (for prefix delegation)
} LeaseType;
- /// @brief Constructor
- 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 IPv6 address
///
/// IPv6 address or, in the case of a prefix delegation, the prefix.
@@ -367,9 +363,16 @@ struct Lease6 {
/// @todo: Add DHCPv6 failover related fields here
/// @brief Constructor
+ 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
///
/// Initialize fields that don't have a default constructor.
- Lease6() : addr_("::") {}
+ Lease6() : addr_("::"), type_(LEASE_IA_NA), fixed_(false), fqdn_fwd_(false),
+ fqdn_rev_(false)
+ {}
/// @brief Convert Lease6 to Printable Form
///
@@ -443,19 +446,6 @@ public:
/// with the same address was already there).
virtual bool addLease(const Lease6Ptr& lease) = 0;
- /// @brief Returns IPv4 lease for specified IPv4 address and subnet_id
- ///
- /// This method is used to get a lease for specific subnet_id. There can be
- /// at most one lease for any given subnet, so this method returns a single
- /// pointer.
- ///
- /// @param addr address of the searched lease
- /// @param subnet_id ID of the subnet the lease must belong to
- ///
- /// @return smart pointer to the lease (or NULL if a lease is not found)
- virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
- SubnetID subnet_id) const = 0;
-
/// @brief Returns an IPv4 lease for specified IPv4 address
///
/// This method return a lease that is associated with a given address.
@@ -568,17 +558,11 @@ public:
/// @brief Deletes a lease.
///
- /// @param addr IPv4 address of the lease to be deleted.
- ///
- /// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease4(const isc::asiolink::IOAddress& addr) = 0;
-
- /// @brief Deletes a lease.
- ///
- /// @param addr IPv6 address of the lease to be deleted.
+ /// @param addr Address of the lease to be deleted. (This can be IPv4 or
+ /// IPv6.)
///
/// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease6(const isc::asiolink::IOAddress& addr) = 0;
+ virtual bool deleteLease(const isc::asiolink::IOAddress& addr) = 0;
/// @brief Return backend type
///
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index 8a59b73..b71b166 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -49,11 +49,6 @@ Lease4Collection Memfile_LeaseMgr::getLease4(const HWAddr& ) const {
return (Lease4Collection());
}
-Lease4Ptr Memfile_LeaseMgr::getLease4(const isc::asiolink::IOAddress&,
- SubnetID) const {
- return (Lease4Ptr());
-}
-
Lease4Ptr Memfile_LeaseMgr::getLease4(const HWAddr&,
SubnetID) const {
return (Lease4Ptr());
@@ -102,18 +97,21 @@ void Memfile_LeaseMgr::updateLease6(const Lease6Ptr& ) {
}
-bool Memfile_LeaseMgr::deleteLease4(const isc::asiolink::IOAddress&) {
- return (false);
-}
-
-bool Memfile_LeaseMgr::deleteLease6(const isc::asiolink::IOAddress& addr) {
- Lease6Storage::iterator l = storage6_.find(addr);
- if (l == storage6_.end()) {
- // no such lease
+bool Memfile_LeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) {
+ if (addr.isV4()) {
+ // V4 not implemented yet
return (false);
+
} else {
- storage6_.erase(l);
- return (true);
+ // V6 lease
+ Lease6Storage::iterator l = storage6_.find(addr);
+ if (l == storage6_.end()) {
+ // No such lease
+ return (false);
+ } else {
+ storage6_.erase(l);
+ return (true);
+ }
}
}
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.h b/src/lib/dhcpsrv/memfile_lease_mgr.h
index 3f54edc..268b722 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.h
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.h
@@ -68,16 +68,6 @@ public:
/// @return a collection of leases
virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr) const;
- /// @brief Returns existing IPv4 lease for specific address and subnet
- ///
- /// @todo Not implemented yet
- /// @param addr address of the searched lease
- /// @param subnet_id ID of the subnet the lease must belong to
- ///
- /// @return smart pointer to the lease (or NULL if a lease is not found)
- virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
- SubnetID subnet_id) const;
-
/// @brief Returns existing IPv4 leases for specified hardware address.
///
/// @todo Not implemented yet
@@ -176,17 +166,11 @@ public:
/// @brief Deletes a lease.
///
- /// @param addr IPv4 address of the lease to be deleted.
- ///
- /// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease4(const isc::asiolink::IOAddress& addr);
-
- /// @brief Deletes a lease.
- ///
- /// @param addr IPv4 address of the lease to be deleted.
+ /// @param addr Address of the lease to be deleted. (This can be IPv4 or
+ /// IPv6.)
///
/// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease6(const isc::asiolink::IOAddress& addr);
+ virtual bool deleteLease(const isc::asiolink::IOAddress& addr);
/// @brief Return backend type
///
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc
index 73289ad..ad6e66c 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc
@@ -1274,24 +1274,6 @@ MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr) const {
}
-Lease4Ptr
-MySqlLeaseMgr::getLease4(const isc::asiolink::IOAddress& addr,
- SubnetID subnet_id) const {
-
- // As the address is the unique primary key of the lease4 table, there can
- // only be one lease with a given address. Therefore we will get that
- // lease and do the filtering on subnet ID here.
- Lease4Ptr result = getLease4(addr);
- if (result && (result->subnet_id_ != subnet_id)) {
-
- // Lease found but IDs do not match. Return null pointer
- result.reset();
- }
-
- return (result);
-}
-
-
Lease4Collection
MySqlLeaseMgr::getLease4(const HWAddr& hwaddr) const {
// Set up the WHERE clause value
@@ -1573,12 +1555,13 @@ MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
updateLeaseCommon(stindex, &bind[0], lease);
}
-// Delete lease methods. As with other groups of methods, these comprise
-// a per-type method that sets up the relevant MYSQL_BIND array and a
-// common method than handles the common processing.
+// Delete lease methods. Similar to other groups of methods, these comprise
+// a per-type method that sets up the relevant MYSQL_BIND array (in this
+// case, a single method for both V4 and V6 addresses) and a common method that
+// handles the common processing.
bool
-MySqlLeaseMgr::deleteLease(StatementIndex stindex, MYSQL_BIND* bind) {
+MySqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind) {
// Bind the input parameters to the statement
int status = mysql_stmt_bind_param(statements_[stindex], bind);
@@ -1595,42 +1578,34 @@ MySqlLeaseMgr::deleteLease(StatementIndex stindex, MYSQL_BIND* bind) {
bool
-MySqlLeaseMgr::deleteLease4(const isc::asiolink::IOAddress& addr) {
+MySqlLeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) {
// Set up the WHERE clause value
MYSQL_BIND inbind[1];
memset(inbind, 0, sizeof(inbind));
- uint32_t addr4 = static_cast<uint32_t>(addr);
+ if (addr.isV4()) {
+ uint32_t addr4 = static_cast<uint32_t>(addr);
- // See the earlier description of the use of "const_cast" when accessing
- // the address for an explanation of the reason.
- inbind[0].buffer_type = MYSQL_TYPE_LONG;
- inbind[0].buffer = reinterpret_cast<char*>(&addr4);
- inbind[0].is_unsigned = MLM_TRUE;
+ inbind[0].buffer_type = MYSQL_TYPE_LONG;
+ inbind[0].buffer = reinterpret_cast<char*>(&addr4);
+ inbind[0].is_unsigned = MLM_TRUE;
- return (deleteLease(DELETE_LEASE4, inbind));
-}
+ return (deleteLeaseCommon(DELETE_LEASE4, inbind));
+ } else {
+ std::string addr6 = addr.toText();
+ unsigned long addr6_length = addr6.size();
-bool
-MySqlLeaseMgr::deleteLease6(const isc::asiolink::IOAddress& addr) {
-
- // Set up the WHERE clause value
- MYSQL_BIND inbind[1];
- memset(inbind, 0, sizeof(inbind));
-
- std::string addr6 = addr.toText();
- unsigned long addr6_length = addr6.size();
-
- // See the earlier description of the use of "const_cast" when accessing
- // the address for an explanation of the reason.
- inbind[0].buffer_type = MYSQL_TYPE_STRING;
- inbind[0].buffer = const_cast<char*>(addr6.c_str());
- inbind[0].buffer_length = addr6_length;
- inbind[0].length = &addr6_length;
+ // See the earlier description of the use of "const_cast" when accessing
+ // the address for an explanation of the reason.
+ inbind[0].buffer_type = MYSQL_TYPE_STRING;
+ inbind[0].buffer = const_cast<char*>(addr6.c_str());
+ inbind[0].buffer_length = addr6_length;
+ inbind[0].length = &addr6_length;
- return (deleteLease(DELETE_LEASE6, inbind));
+ return (deleteLeaseCommon(DELETE_LEASE6, inbind));
+ }
}
// Miscellaneous database methods.
diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h
index 8a97fc0..68b0e1c 100644
--- a/src/lib/dhcpsrv/mysql_lease_mgr.h
+++ b/src/lib/dhcpsrv/mysql_lease_mgr.h
@@ -94,19 +94,6 @@ public:
/// failed.
virtual bool addLease(const Lease6Ptr& lease);
- /// @brief Return IPv4 lease for specified IPv4 address and subnet_id
- ///
- /// This method is used to get a lease for specific subnet_id. There can be
- /// at most one lease for any given subnet, so this method returns a single
- /// pointer.
- ///
- /// @param addr address of the sought lease
- /// @param subnet_id ID of the subnet the lease must belong to
- ///
- /// @return smart pointer to the lease (or NULL if a lease is not found)
- virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress& addr,
- SubnetID subnet_id) const;
-
/// @brief Returns an IPv4 lease for specified IPv4 address
///
/// This method return a lease that is associated with a given address.
@@ -286,33 +273,16 @@ public:
/// failed.
virtual void updateLease6(const Lease6Ptr& lease6);
- /// @brief Deletes an IPv4 lease.
- ///
- /// @todo Merge with deleteLease6: it is possible to determine whether
- /// an address is V4 or V6 from the IOAddress argument, so there
- /// is no need for separate V4 or V6 methods.
- ///
- /// @param addr IPv4 address of the lease to be deleted.
- ///
- /// @return true if deletion was successful, false if no such lease exists
- ///
- /// @throw isc::dhcp::DbOperationError An operation on the open database has
- /// failed.
- virtual bool deleteLease4(const isc::asiolink::IOAddress& addr);
-
- /// @brief Deletes an IPv6 lease.
- ///
- /// @todo Merge with deleteLease4: it is possible to determine whether
- /// an address is V4 or V6 from the IOAddress argument, so there
- /// is no need for separate V4 or V6 methods.
+ /// @brief Deletes a lease.
///
- /// @param addr IPv6 address of the lease to be deleted.
+ /// @param addr Address of the lease to be deleted. This can be an IPv4
+ /// address or an IPv6 address.
///
/// @return true if deletion was successful, false if no such lease exists
///
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
- virtual bool deleteLease6(const isc::asiolink::IOAddress& addr);
+ virtual bool deleteLease(const isc::asiolink::IOAddress& addr);
/// @brief Return backend type
///
@@ -613,7 +583,7 @@ private:
///
/// @throw isc::dhcp::DbOperationError An operation on the open database has
/// failed.
- bool deleteLease(StatementIndex stindex, MYSQL_BIND* bind);
+ bool deleteLeaseCommon(StatementIndex stindex, MYSQL_BIND* bind);
/// @brief Check Error and Throw Exception
///
diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h
index aa1ef1f..c7d7ac7 100644
--- a/src/lib/dhcpsrv/subnet.h
+++ b/src/lib/dhcpsrv/subnet.h
@@ -172,7 +172,7 @@ public:
// Use option type as the index key. The type is held
// in OptionPtr object so we have to call Option::getType
// to retrieve this key for each element.
- boost::multi_index::mem_fun<
+ boost::multi_index::const_mem_fun<
Option,
uint16_t,
&Option::getType
diff --git a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
index 6384c1c..a812811 100644
--- a/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/lease_mgr_unittest.cc
@@ -73,16 +73,6 @@ public:
return (Lease4Ptr());
}
- /// @brief Returns existing IPv4 lease for specific address and subnet
- /// @param addr address of the searched lease
- /// @param subnet_id ID of the subnet the lease must belong to
- ///
- /// @return smart pointer to the lease (or NULL if a lease is not found)
- virtual Lease4Ptr getLease4(const isc::asiolink::IOAddress&,
- SubnetID) const {
- return (Lease4Ptr());
- }
-
/// @brief Returns existing IPv4 leases for specified hardware address.
///
/// Although in the usual case there will be only one lease, for mobile
@@ -179,19 +169,11 @@ public:
/// @brief Deletes a lease.
///
- /// @param addr IPv4 address of the lease to be deleted.
- ///
- /// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease4(const isc::asiolink::IOAddress&) {
- return (false);
- }
-
- /// @brief Deletes a lease.
- ///
- /// @param addr IPv4 address of the lease to be deleted.
+ /// @param addr Address of the lease to be deleted. (This can be either
+ /// a V4 address or a V6 address.)
///
/// @return true if deletion was successful, false if no such lease exists
- virtual bool deleteLease6(const isc::asiolink::IOAddress&) {
+ virtual bool deleteLease(const isc::asiolink::IOAddress&) {
return (false);
}
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index b3f504f..08186dc 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -120,10 +120,10 @@ TEST_F(MemfileLeaseMgrTest, addGetDelete6) {
EXPECT_FALSE(y);
// should return false - there's no such address
- EXPECT_FALSE(lease_mgr->deleteLease6(IOAddress("2001:db8:1::789")));
+ EXPECT_FALSE(lease_mgr->deleteLease(IOAddress("2001:db8:1::789")));
// this one should succeed
- EXPECT_TRUE(lease_mgr->deleteLease6(IOAddress("2001:db8:1::456")));
+ EXPECT_TRUE(lease_mgr->deleteLease(IOAddress("2001:db8:1::456")));
// after the lease is deleted, it should really be gone
x = lease_mgr->getLease6(IOAddress("2001:db8:1::456"));
diff --git a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
index 7f6bcc9..7d6f4d1 100644
--- a/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
@@ -230,8 +230,8 @@ public:
///
/// @param address Address to use for the initialization
///
- /// @return Lease4Ptr. This will not point to anything if the initialization
- /// failed (e.g. unknown address).
+ /// @return Lease4Ptr. This will not point to anything if the
+ /// initialization failed (e.g. unknown address).
Lease4Ptr initializeLease4(std::string address) {
Lease4Ptr lease(new Lease4());
@@ -251,7 +251,7 @@ public:
// Set other parameters. For historical reasons, address 0 is not used.
if (address == straddress4_[0]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x08);
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x42)));
lease->valid_lft_ = 8677;
lease->cltt_ = 168256;
@@ -259,7 +259,7 @@ public:
} else if (address == straddress4_[1]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x19);
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x53)));
lease->valid_lft_ = 3677;
lease->cltt_ = 123456;
@@ -267,7 +267,7 @@ public:
} else if (address == straddress4_[2]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x2a);
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x64)));
lease->valid_lft_ = 5412;
lease->cltt_ = 234567;
@@ -275,7 +275,7 @@ public:
} else if (address == straddress4_[3]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x19); // Same as lease 1
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x75)));
// The times used in the next tests are deliberately restricted - we
@@ -289,7 +289,7 @@ public:
} else if (address == straddress4_[4]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x4c);
// Same ClientId as straddr4_[1]
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 7736;
lease->cltt_ = 222456;
@@ -298,7 +298,7 @@ public:
} else if (address == straddress4_[5]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x19); // Same as lease 1
// Same ClientId and IAID as straddress4_1
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 7832;
lease->cltt_ = 227476;
@@ -307,7 +307,7 @@ public:
} else if (address == straddress4_[6]) {
lease->hwaddr_ = vector<uint8_t>(6, 0x6e);
// Same ClientId as straddress4_1
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>(8, 0x53))); // Same as lease 1
lease->valid_lft_ = 1832;
lease->cltt_ = 627476;
@@ -315,7 +315,7 @@ public:
} else if (address == straddress4_[7]) {
lease->hwaddr_ = vector<uint8_t>(); // Empty
- lease->client_id_ = boost::shared_ptr<ClientId>(
+ lease->client_id_ = ClientIdPtr(
new ClientId(vector<uint8_t>())); // Empty
lease->valid_lft_ = 7975;
lease->cltt_ = 213876;
@@ -708,7 +708,8 @@ TEST_F(MySqlLeaseMgrTest, checkVersion) {
/// @brief Basic Lease4 Checks
///
-/// Checks that the addLease, getLease4 (by address) and deleteLease4 works.
+/// Checks that the addLease, getLease4 (by address) and deleteLease (with an
+/// IPv4 address) works.
TEST_F(MySqlLeaseMgrTest, basicLease4) {
// Get the leases to be used for the test.
vector<Lease4Ptr> leases = createLeases4();
@@ -740,10 +741,10 @@ TEST_F(MySqlLeaseMgrTest, basicLease4) {
// Delete a lease, check that it's gone, and that we can't delete it
// a second time.
- EXPECT_TRUE(lmptr_->deleteLease4(ioaddress4_[1]));
+ EXPECT_TRUE(lmptr_->deleteLease(ioaddress4_[1]));
l_returned = lmptr_->getLease4(ioaddress4_[1]);
EXPECT_FALSE(l_returned);
- EXPECT_FALSE(lmptr_->deleteLease4(ioaddress4_[1]));
+ EXPECT_FALSE(lmptr_->deleteLease(ioaddress4_[1]));
// Check that the second address is still there.
l_returned = lmptr_->getLease4(ioaddress4_[2]);
@@ -753,7 +754,8 @@ TEST_F(MySqlLeaseMgrTest, basicLease4) {
/// @brief Basic Lease6 Checks
///
-/// Checks that the addLease, getLease6 (by address) and deleteLease6 works.
+/// Checks that the addLease, getLease6 (by address) and deleteLease (with an
+/// IPv6 address) works.
TEST_F(MySqlLeaseMgrTest, basicLease6) {
// Get the leases to be used for the test.
vector<Lease6Ptr> leases = createLeases6();
@@ -785,10 +787,10 @@ TEST_F(MySqlLeaseMgrTest, basicLease6) {
// Delete a lease, check that it's gone, and that we can't delete it
// a second time.
- EXPECT_TRUE(lmptr_->deleteLease6(ioaddress6_[1]));
+ EXPECT_TRUE(lmptr_->deleteLease(ioaddress6_[1]));
l_returned = lmptr_->getLease6(ioaddress6_[1]);
EXPECT_FALSE(l_returned);
- EXPECT_FALSE(lmptr_->deleteLease6(ioaddress6_[1]));
+ EXPECT_FALSE(lmptr_->deleteLease(ioaddress6_[1]));
// Check that the second address is still there.
l_returned = lmptr_->getLease6(ioaddress6_[2]);
@@ -796,45 +798,6 @@ TEST_F(MySqlLeaseMgrTest, basicLease6) {
detailCompareLease(leases[2], l_returned);
}
-/// @brief Check GetLease4 methods - access by Address and SubnetID
-///
-/// Adds leases to the database and checks that they can be accessed via
-/// a the hardware address
-TEST_F(MySqlLeaseMgrTest, getLease4AddressSubnetId) {
- // Get the leases to be used for the test.
- vector<Lease4Ptr> leases = createLeases4();
- const SubnetID lease1_subnetid = leases[1]->subnet_id_;
-
- // Generate a Subnet ID known to be invalid - one more than the maximum
- // Subnet ID in all the leases.
- SubnetID invalid_subnetid = 0;
- for (int i = 0; i < leases.size(); ++i) {
- invalid_subnetid = max(invalid_subnetid, leases[i]->subnet_id_);
- }
- ++invalid_subnetid;
-
-
- // Add just one to the database.
- EXPECT_TRUE(lmptr_->addLease(leases[1]));
-
- // Look for a known lease with a valid Subnet ID
- Lease4Ptr l_returned = lmptr_->getLease4(ioaddress4_[1], lease1_subnetid);
- ASSERT_TRUE(l_returned);
- detailCompareLease(leases[1], l_returned);
-
- // Look for a lease known to be in the database with an invalid Subnet ID
- l_returned = lmptr_->getLease4(ioaddress4_[1], invalid_subnetid);
- EXPECT_FALSE(l_returned);
-
- // Look for a lease known not to be in the database with a valid Subnet ID
- l_returned = lmptr_->getLease4(ioaddress4_[2], lease1_subnetid);
- EXPECT_FALSE(l_returned);
-
- // Look for a lease known not to be in the database with and invalid
- l_returned = lmptr_->getLease4(ioaddress4_[2], invalid_subnetid);
- EXPECT_FALSE(l_returned);
-}
-
/// @brief Check GetLease4 methods - access by Hardware Address
///
/// Adds leases to the database and checks that they can be accessed via
@@ -896,7 +859,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSize) {
Lease4Collection returned = lmptr_->getLease4(leases[1]->hwaddr_);
ASSERT_EQ(1, returned.size());
detailCompareLease(leases[1], *returned.begin());
- (void) lmptr_->deleteLease4(leases[1]->addr_);
+ (void) lmptr_->deleteLease(leases[1]->addr_);
}
// Expect some problem when accessing a lease that had too long a hardware
@@ -954,7 +917,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSubnetId) {
// "multiple records" exception. (We expect there to be only one record
// with that combination, so getting them via getLeaseX() (as opposed
// to getLeaseXCollection() should throw an exception.)
- EXPECT_TRUE(lmptr_->deleteLease4(leases[2]->addr_));
+ EXPECT_TRUE(lmptr_->deleteLease(leases[2]->addr_));
leases[1]->addr_ = leases[2]->addr_;
EXPECT_TRUE(lmptr_->addLease(leases[1]));
EXPECT_THROW(returned = lmptr_->getLease4(leases[1]->hwaddr_,
@@ -964,7 +927,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSubnetId) {
// Delete all leases in the database
for (int i = 0; ADDRESS4[i] != NULL; ++i) {
IOAddress addr(ADDRESS4[i]);
- (void) lmptr_->deleteLease4(addr);
+ (void) lmptr_->deleteLease(addr);
}
}
@@ -986,7 +949,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4HwaddrSubnetIdSize) {
leases[1]->subnet_id_);
ASSERT_TRUE(returned);
detailCompareLease(leases[1], returned);
- (void) lmptr_->deleteLease4(leases[1]->addr_);
+ (void) lmptr_->deleteLease(leases[1]->addr_);
}
// Expect some error when getting a lease with too long a hardware
@@ -1069,7 +1032,7 @@ TEST_F(MySqlLeaseMgrTest, getLease4ClientIdSize) {
Lease4Collection returned = lmptr_->getLease4(*leases[1]->client_id_);
ASSERT_TRUE(returned.size() == 1);
detailCompareLease(leases[1], *returned.begin());
- (void) lmptr_->deleteLease4(leases[1]->addr_);
+ (void) lmptr_->deleteLease(leases[1]->addr_);
}
// Don't bother to check client IDs longer than the maximum -
@@ -1179,7 +1142,7 @@ TEST_F(MySqlLeaseMgrTest, getLease6DuidIaidSize) {
leases[1]->iaid_);
EXPECT_EQ(1, returned.size());
detailCompareLease(leases[1], *returned.begin());
- (void) lmptr_->deleteLease6(leases[1]->addr_);
+ (void) lmptr_->deleteLease(leases[1]->addr_);
}
// Don't bother to check DUIDs longer than the maximum - these cannot be
@@ -1245,7 +1208,7 @@ TEST_F(MySqlLeaseMgrTest, getLease6DuidIaidSubnetIdSize) {
leases[1]->subnet_id_);
ASSERT_TRUE(returned);
detailCompareLease(leases[1], returned);
- (void) lmptr_->deleteLease6(leases[1]->addr_);
+ (void) lmptr_->deleteLease(leases[1]->addr_);
}
// Don't bother to check DUIDs longer than the maximum - these cannot be
@@ -1293,7 +1256,7 @@ TEST_F(MySqlLeaseMgrTest, updateLease4) {
detailCompareLease(leases[1], l_returned);
// Try updating a lease not in the database.
- lmptr_->deleteLease4(ioaddress4_[2]);
+ lmptr_->deleteLease(ioaddress4_[2]);
EXPECT_THROW(lmptr_->updateLease4(leases[2]), isc::dhcp::NoSuchLease);
}
diff --git a/src/lib/dhcpsrv/triplet.h b/src/lib/dhcpsrv/triplet.h
index d9388fe..c7b8156 100644
--- a/src/lib/dhcpsrv/triplet.h
+++ b/src/lib/dhcpsrv/triplet.h
@@ -37,7 +37,7 @@ public:
///
/// Typically: uint32_t to Triplet assignment. It is very convenient
/// to be able to simply write Triplet<uint32_t> x = 7;
- Triplet<T> operator=(T other) {
+ Triplet<T>& operator=(T other) {
min_ = other;
default_ = other;
max_ = other;
More information about the bind10-changes
mailing list