Browse Source

[2524] Add logging messages to memory file database code

Also make the hardware address to string function common to both
database modules.
Stephen Morris 12 years ago
parent
commit
593eacf16f

+ 1 - 0
src/lib/dhcpsrv/Makefile.am

@@ -34,6 +34,7 @@ libb10_dhcpsrv_la_SOURCES += addr_utilities.cc addr_utilities.h
 libb10_dhcpsrv_la_SOURCES += alloc_engine.cc alloc_engine.h
 libb10_dhcpsrv_la_SOURCES += alloc_engine.cc alloc_engine.h
 libb10_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
 libb10_dhcpsrv_la_SOURCES += dhcpsrv_log.cc dhcpsrv_log.h
 libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
 libb10_dhcpsrv_la_SOURCES += cfgmgr.cc cfgmgr.h
+libb10_dhcpsrv_la_SOURCES += hwaddr.cc hwaddr.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

+ 107 - 41
src/lib/dhcpsrv/dhcpsrv_messages.mes

@@ -16,13 +16,78 @@ $NAMESPACE isc::dhcp
 
 
 % DHCPSRV_INVALID_ACCESS invalid database access string: %1
 % DHCPSRV_INVALID_ACCESS invalid database access string: %1
 This is logged when an attempt has been made to parse a database access string
 This is logged when an attempt has been made to parse a database access string
-and the attempt ended in error.  The access string in question - which should
-be of the form 'keyword=value keyword=value...' is included in the message.
+and the attempt ended in error.  The access string in question - which
+should be of the form 'keyword=value keyword=value...' is included in
+the message.
+
+% DHCPSRV_MEMFILE_ADD_ADDR4 adding IPv4 lease with address %1
+A debug message issued when the server is about to add an IPv4 lease
+with the specified address to the memory file backend database.
+
+% DHCPSRV_MEMFILE_ADD_ADDR6 adding IPv6 lease with address %1
+A debug message issued when the server is about to add an IPv6 lease
+with the specified address to the memory file backend database.
 
 
 % DHCPSRV_MEMFILE_DB opening memory file lease database: %1
 % DHCPSRV_MEMFILE_DB opening memory file lease database: %1
-This informational message is logged when a DHCP server (either V4 or V6) is
-about to open a memory file lease database.  The parameters of the connection
-are logged.
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a memory file lease database.  The parameters of
+the connection including database name and username needed to access it
+(but not the password if any) are logged.
+
+% DHCPSRV_MEMFILE_DELETE_ADDR deleting lease for address %1
+A debug message issued when the server is attempting to delete a lease
+for the specified address from the memory file database for the specified
+address.
+
+% DHCPSRV_MEMFILE_GET_ADDR4 obtaining IPv4 lease for address %1
+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
+A debug message issued when the server is attempting to obtain an IPv6
+lease from the memory file database for the specified address.
+
+% DHCPSRV_MEMFILE_GET_CLIENTID obtaining IPv4 leases for client ID %1
+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
+client identification.
+
+% DHCPSRV_MEMFILE_GET_HWADDR obtaining IPv4 leases for hardware address %1
+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 IPv4 leases for IAID %1 and DUID %2
+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 IPv4 leases for IAID %1, Subnet ID %2 and DUID %3
+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).
+
+% DHCPSRV_MEMFILE_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the memory file database for a client with the specified
+subnet ID and client ID.
+
+% DHCPSRV_MEMFILE_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the memory file database for a client with the specified
+subnet ID and hardware address.
+
+% DHCPSRV_MEMFILE_GET_VERSION obtaining schema version information
+A debug message issued when the server is about to obtain schema version
+information from the memory file database.
+
+% DHCPSRV_MEMFILE_UPDATE_ADDR4 updating IPv4 lease for address %1
+A debug message issued when the server is attempting to update IPv4
+lease from the memory file database for the specified address.
+
+% DHCPSRV_MEMFILE_UPDATE_ADDR6 updating IPv6 lease for address %1
+A debug message issued when the server is attempting to update IPv6
+lease from the memory file database for the specified address.
 
 
 % DHCPSRV_MYSQL_ADD_ADDR4 adding IPv4 lease with address %1
 % DHCPSRV_MYSQL_ADD_ADDR4 adding IPv4 lease with address %1
 A debug message issued when the server is about to add an IPv4 lease
 A debug message issued when the server is about to add an IPv4 lease
@@ -33,70 +98,71 @@ A debug message issued when the server is about to add an IPv6 lease
 with the specified address to the MySQL backend database.
 with the specified address to the MySQL backend database.
 
 
 % DHCPSRV_MYSQL_DB opening MySQL lease database: %1
 % DHCPSRV_MYSQL_DB opening MySQL lease database: %1
-This informational message is logged when a DHCP server (either V4 or V6) is
-about to open a MySQL lease database.  The parameters of the connection
-including database name and username needed to access it (but not the
-password if any) are logged.
+This informational message is logged when a DHCP server (either V4 or
+V6) is about to open a MySQL lease database.  The parameters of the
+connection including database name and username needed to access it
+(but not the password if any) are logged.
 
 
 % DHCPSRV_MYSQL_DELETE_ADDR deleting lease for address %1
 % DHCPSRV_MYSQL_DELETE_ADDR deleting lease for address %1
-A debug message issued when the server is attempting to delete
-a lease for the specified address from the database for the specified address.
+A debug message issued when the server is attempting to delete a lease for
+the specified address from the MySQL database for the specified address.
 
 
 % DHCPSRV_MYSQL_GET_ADDR4 obtaining IPv4 lease for address %1
 % DHCPSRV_MYSQL_GET_ADDR4 obtaining IPv4 lease for address %1
-A debug message issued when the server is attempting to obtain an
-IPv4 lease from the database for the specified address.
+A debug message issued when the server is attempting to obtain an IPv4
+lease from the MySQL database for the specified address.
 
 
 % DHCPSRV_MYSQL_GET_ADDR6 obtaining IPv6 lease for address %1
 % DHCPSRV_MYSQL_GET_ADDR6 obtaining IPv6 lease for address %1
-A debug message issued when the server is attempting to obtain an
-IPv6 lease from the database for the specified address.
+A debug message issued when the server is attempting to obtain an IPv6
+lease from the MySQL database for the specified address.
 
 
 % DHCPSRV_MYSQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
 % DHCPSRV_MYSQL_GET_CLIENTID obtaining IPv4 leases for client ID %1
-A debug message issued when the server is attempting to obtain a set of
-IPv4 leases from the database for a client with the specified client
-identification.
+A debug message issued when the server is attempting to obtain a set
+of IPv4 leases from the MySQL database for a client with the specified
+client identification.
 
 
 % DHCPSRV_MYSQL_GET_HWADDR obtaining IPv4 leases for hardware address %1
 % DHCPSRV_MYSQL_GET_HWADDR obtaining IPv4 leases for hardware address %1
-A debug message issued when the server is attempting to obtain a set of
-IPv4 leases from the database for a client with the specified hardware
-address.
+A debug message issued when the server is attempting to obtain a set
+of IPv4 leases from the MySQL database for a client with the specified
+hardware address.
 
 
 % DHCPSRV_MYSQL_GET_IAID_DUID obtaining IPv4 leases for IAID %1 and DUID %2
 % DHCPSRV_MYSQL_GET_IAID_DUID obtaining IPv4 leases for IAID %1 and DUID %2
-A debug message issued when the server is attempting to obtain a set of IPv6
-lease from the database for a client with the specified IAID (Identity Association ID) and
-DUID (DHCP Unique Identifier).
+A debug message issued when the server is attempting to obtain a set of
+IPv6 lease from the MySQL database for a client with the specified IAID
+(Identity Association ID) and DUID (DHCP Unique Identifier).
 
 
 % DHCPSRV_MYSQL_GET_IAID_SUBID_DUID obtaining IPv4 leases for IAID %1, Subnet ID %2 and DUID %3
 % DHCPSRV_MYSQL_GET_IAID_SUBID_DUID obtaining IPv4 leases for IAID %1, Subnet ID %2 and DUID %3
-A debug message issued when the server is attempting to obtain an IPv6 lease
-from the database for a client with the specified IAID (Identity Association ID),
-Subnet ID and DUID (DHCP Unique Identifier).
+A debug message issued when the server is attempting to obtain an IPv6
+lease from the MySQL database for a client with the specified IAID
+(Identity Association ID), Subnet ID and DUID (DHCP Unique Identifier).
 
 
 % DHCPSRV_MYSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
 % DHCPSRV_MYSQL_GET_SUBID_CLIENTID obtaining IPv4 lease for subnet ID %1 and client ID %2
 A debug message issued when the server is attempting to obtain an IPv4
 A debug message issued when the server is attempting to obtain an IPv4
-lease from the database for a client with the specified subnet ID and
-client ID.
+lease from the MySQL database for a client with the specified subnet ID
+and client ID.
 
 
 % DHCPSRV_MYSQL_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
 % DHCPSRV_MYSQL_GET_SUBID_HWADDR obtaining IPv4 lease for subnet ID %1 and hardware address %2
 A debug message issued when the server is attempting to obtain an IPv4
 A debug message issued when the server is attempting to obtain an IPv4
-lease from the database for a client with the specified subnet ID and
-hardware address.
+lease from the MySQL database for a client with the specified subnet ID
+and hardware address.
 
 
 % DHCPSRV_MYSQL_GET_VERSION obtaining schema version information
 % DHCPSRV_MYSQL_GET_VERSION obtaining schema version information
 A debug message issued when the server is about to obtain schema version
 A debug message issued when the server is about to obtain schema version
-information from the database.
+information from the MySQL database.
 
 
 % DHCPSRV_MYSQL_UPDATE_ADDR4 updating IPv4 lease for address %1
 % DHCPSRV_MYSQL_UPDATE_ADDR4 updating IPv4 lease for address %1
-A debug message issued when the server is attempting to update
-IPv4 lease from the database for the specified address.
+A debug message issued when the server is attempting to update IPv4
+lease from the MySQL database for the specified address.
 
 
 % DHCPSRV_MYSQL_UPDATE_ADDR6 updating IPv6 lease for address %1
 % DHCPSRV_MYSQL_UPDATE_ADDR6 updating IPv6 lease for address %1
-A debug message issued when the server is attempting to update
-IPv6 lease from the database for the specified address.
+A debug message issued when the server is attempting to update IPv6
+lease from the MySQL database for the specified address.
 
 
 % DHCPSRV_NOTYPE_DB no 'type' keyword to determine database backend: %1
 % DHCPSRV_NOTYPE_DB no 'type' keyword to determine database backend: %1
-This is an error message, logged when an attempt has been made to access a
-database backend, but where no 'type' keyword has been included in the access
-string.  The access string (less any passwords) is included in the message.
+This is an error message, logged when an attempt has been made to access
+a database backend, but where no 'type' keyword has been included in
+the access string.  The access string (less any passwords) is included
+in the message.
 
 
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
 % DHCPSRV_UNKNOWN_DB unknown database type: %1
-The database access string specified a database type (given in the message)
-that is unknown to the software.  This is a configuration error.
+The database access string specified a database type (given in the
+message) that is unknown to the software.  This is a configuration error.

+ 42 - 0
src/lib/dhcpsrv/hwaddr.cc

@@ -0,0 +1,42 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+
+#include <dhcpsrv/hwaddr.h>
+
+#include <string>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+
+namespace isc {
+namespace dhcp {
+
+std::string
+hardwareAddressString(const HWAddr& hwaddr) {
+    std::ostringstream stream;
+
+    for (size_t i = 0; i < hwaddr.size(); ++i) {
+        if (i > 0) {
+            stream << ":";
+        }
+        stream << std::setw(2) << std::hex << std::setfill('0')
+               << static_cast<unsigned int>(hwaddr[i]);
+    }
+
+    return (stream.str());
+}
+
+};  // namespace dhcp
+};  // namespace isc

+ 47 - 0
src/lib/dhcpsrv/hwaddr.h

@@ -0,0 +1,47 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef __HWADDR_H
+#define __HWADDR_H
+
+#include <string>
+#include <vector>
+#include <stdint.h>
+
+namespace isc {
+namespace dhcp {
+
+/// @brief Hardware Address
+typedef std::vector<uint8_t> HWAddr;
+
+/// @brief Produce string representation of hardware address
+///
+/// Returns a string containing the hardware address. This is only used for
+/// logging.
+///
+/// @note Six characters is an arbitrary length, chosen to provide a
+///       suitably wide string.
+///
+/// @todo Create a "hardware address" class of which this will be a member.
+///
+/// @param hwaddr Hardware address to convert to string form
+///
+/// @return String form of the hardware address.
+std::string
+hardwareAddressString(const HWAddr& hwaddr);
+
+};  // namespace dhcp
+};  // namespace isc
+
+#endif // __HWADDR_H

+ 4 - 7
src/lib/dhcpsrv/lease_mgr.h

@@ -18,6 +18,7 @@
 #include <asiolink/io_address.h>
 #include <asiolink/io_address.h>
 #include <dhcp/duid.h>
 #include <dhcp/duid.h>
 #include <dhcp/option.h>
 #include <dhcp/option.h>
+#include <dhcpsrv/hwaddr.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/subnet.h>
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
 
 
@@ -25,6 +26,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 
 
 #include <fstream>
 #include <fstream>
+#include <iostream>
 #include <map>
 #include <map>
 #include <string>
 #include <string>
 #include <utility>
 #include <utility>
@@ -61,8 +63,6 @@
 /// Nevertheless, we hope to have failover protocol eventually implemented in
 /// Nevertheless, we hope to have failover protocol eventually implemented in
 /// the Kea.
 /// the Kea.
 
 
-#include <iostream>
-
 namespace isc {
 namespace isc {
 namespace dhcp {
 namespace dhcp {
 
 
@@ -418,9 +418,6 @@ typedef std::vector<Lease6Ptr> Lease6Collection;
 /// see the documentation of those classes for details.
 /// see the documentation of those classes for details.
 class LeaseMgr {
 class LeaseMgr {
 public:
 public:
-    /// Client hardware address
-    typedef std::vector<uint8_t> HWAddr;
-
     /// Database configuration parameter map
     /// Database configuration parameter map
     typedef std::map<std::string, std::string> ParameterMap;
     typedef std::map<std::string, std::string> ParameterMap;
 
 
@@ -475,7 +472,7 @@ public:
     /// @param hwaddr hardware address of the client
     /// @param hwaddr hardware address of the client
     ///
     ///
     /// @return lease collection
     /// @return lease collection
-    virtual Lease4Collection getLease4(const HWAddr& hwaddr) const = 0;
+    virtual Lease4Collection getLease4(const isc::dhcp::HWAddr& hwaddr) const = 0;
 
 
     /// @brief Returns existing IPv4 leases for specified hardware address
     /// @brief Returns existing IPv4 leases for specified hardware address
     ///        and a subnet
     ///        and a subnet
@@ -487,7 +484,7 @@ public:
     /// @param subnet_id identifier of the subnet that lease must belong to
     /// @param subnet_id identifier of the subnet that lease must belong to
     ///
     ///
     /// @return a pointer to the lease (or NULL if a lease is not found)
     /// @return a pointer to the lease (or NULL if a lease is not found)
-    virtual Lease4Ptr getLease4(const HWAddr& hwaddr,
+    virtual Lease4Ptr getLease4(const isc::dhcp::HWAddr& hwaddr,
                                 SubnetID subnet_id) const = 0;
                                 SubnetID subnet_id) const = 0;
 
 
     /// @brief Returns existing IPv4 lease for specified client-id
     /// @brief Returns existing IPv4 lease for specified client-id

+ 52 - 14
src/lib/dhcpsrv/memfile_lease_mgr.cc

@@ -12,6 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
+#include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/memfile_lease_mgr.h>
 #include <dhcpsrv/memfile_lease_mgr.h>
 
 
 #include <iostream>
 #include <iostream>
@@ -28,11 +29,16 @@ Memfile_LeaseMgr::Memfile_LeaseMgr(const ParameterMap& parameters)
 Memfile_LeaseMgr::~Memfile_LeaseMgr() {
 Memfile_LeaseMgr::~Memfile_LeaseMgr() {
 }
 }
 
 
-bool Memfile_LeaseMgr::addLease(const Lease4Ptr&) {
+bool Memfile_LeaseMgr::addLease(const Lease4Ptr& lease) {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_ADD_ADDR4)
+        .arg(lease->addr_.toText());
     return (false);
     return (false);
 }
 }
 
 
 bool Memfile_LeaseMgr::addLease(const Lease6Ptr& lease) {
 bool Memfile_LeaseMgr::addLease(const Lease6Ptr& lease) {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_ADD_ADDR6)
+        .arg(lease->addr_.toText());
+
     if (getLease6(lease->addr_)) {
     if (getLease6(lease->addr_)) {
         // there is a lease with specified address already
         // there is a lease with specified address already
         return (false);
         return (false);
@@ -41,30 +47,46 @@ bool Memfile_LeaseMgr::addLease(const Lease6Ptr& lease) {
     return (true);
     return (true);
 }
 }
 
 
-Lease4Ptr Memfile_LeaseMgr::getLease4(const isc::asiolink::IOAddress&) const {
+Lease4Ptr Memfile_LeaseMgr::getLease4(
+        const isc::asiolink::IOAddress& addr) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_ADDR4)
+        .arg(addr.toText());
+
     return (Lease4Ptr());
     return (Lease4Ptr());
 }
 }
 
 
-Lease4Collection Memfile_LeaseMgr::getLease4(const HWAddr& ) const {
+Lease4Collection Memfile_LeaseMgr::getLease4(const HWAddr& hwaddr) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_HWADDR)
+        .arg(hardwareAddressString(hwaddr));
+
     return (Lease4Collection());
     return (Lease4Collection());
 }
 }
 
 
-Lease4Ptr Memfile_LeaseMgr::getLease4(const HWAddr&,
-                                      SubnetID) const {
+Lease4Ptr Memfile_LeaseMgr::getLease4(const HWAddr& hwaddr,
+                                      SubnetID subnet_id) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_SUBID_HWADDR)
+        .arg(subnet_id).arg(hardwareAddressString(hwaddr));
     return (Lease4Ptr());
     return (Lease4Ptr());
 }
 }
 
 
+Lease4Collection Memfile_LeaseMgr::getLease4(const ClientId& clientid) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_CLIENTID)
+        .arg(clientid.toText());
+    return (Lease4Collection());
+}
 
 
-Lease4Ptr Memfile_LeaseMgr::getLease4(const ClientId&,
-                                      SubnetID) const {
+Lease4Ptr Memfile_LeaseMgr::getLease4(const ClientId& clientid,
+                                      SubnetID subnet_id) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_SUBID_CLIENTID)
+        .arg(subnet_id).arg(clientid.toText());
     return (Lease4Ptr());
     return (Lease4Ptr());
 }
 }
 
 
-Lease4Collection Memfile_LeaseMgr::getLease4(const ClientId& ) const {
-    return (Lease4Collection());
-}
+Lease6Ptr Memfile_LeaseMgr::getLease6(
+        const isc::asiolink::IOAddress& addr) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_ADDR6)
+        .arg(addr.toText());
 
 
-Lease6Ptr Memfile_LeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) const {
     Lease6Storage::iterator l = storage6_.find(addr);
     Lease6Storage::iterator l = storage6_.find(addr);
     if (l == storage6_.end()) {
     if (l == storage6_.end()) {
         return (Lease6Ptr());
         return (Lease6Ptr());
@@ -73,12 +95,20 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) cons
     }
     }
 }
 }
 
 
-Lease6Collection Memfile_LeaseMgr::getLease6(const DUID& , uint32_t ) const {
+Lease6Collection Memfile_LeaseMgr::getLease6(const DUID& duid,
+                                             uint32_t iaid) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_GET_IAID_DUID)
+        .arg(iaid).arg(duid.toText());
+
     return (Lease6Collection());
     return (Lease6Collection());
 }
 }
 
 
 Lease6Ptr Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid,
 Lease6Ptr Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid,
                                       SubnetID subnet_id) const {
                                       SubnetID subnet_id) const {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
+              DHCPSRV_MEMFILE_GET_IAID_SUBID_DUID)
+              .arg(iaid).arg(subnet_id).arg(duid.toText());
+
     /// @todo: Slow, naive implementation. Write it using additional indexes
     /// @todo: Slow, naive implementation. Write it using additional indexes
     for (Lease6Storage::iterator l = storage6_.begin(); l != storage6_.end(); ++l) {
     for (Lease6Storage::iterator l = storage6_.begin(); l != storage6_.end(); ++l) {
         if ( (*((*l)->duid_) == duid) &&
         if ( (*((*l)->duid_) == duid) &&
@@ -90,14 +120,22 @@ Lease6Ptr Memfile_LeaseMgr::getLease6(const DUID& duid, uint32_t iaid,
     return (Lease6Ptr());
     return (Lease6Ptr());
 }
 }
 
 
-void Memfile_LeaseMgr::updateLease4(const Lease4Ptr& ) {
+void Memfile_LeaseMgr::updateLease4(const Lease4Ptr& lease) {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_UPDATE_ADDR4)
+        .arg(lease->addr_.toText());
+
 }
 }
 
 
-void Memfile_LeaseMgr::updateLease6(const Lease6Ptr& ) {
+void Memfile_LeaseMgr::updateLease6(const Lease6Ptr& lease) {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_UPDATE_ADDR6)
+        .arg(lease->addr_.toText());
+
 
 
 }
 }
 
 
 bool Memfile_LeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) {
 bool Memfile_LeaseMgr::deleteLease(const isc::asiolink::IOAddress& addr) {
+    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_MEMFILE_DELETE_ADDR)
+        .arg(addr.toText());
     if (addr.isV4()) {
     if (addr.isV4()) {
         // V4 not implemented yet
         // V4 not implemented yet
         return (false);
         return (false);

+ 1 - 0
src/lib/dhcpsrv/memfile_lease_mgr.h

@@ -15,6 +15,7 @@
 #ifndef MEMFILE_LEASE_MGR_H
 #ifndef MEMFILE_LEASE_MGR_H
 #define MEMFILE_LEASE_MGR_H
 #define MEMFILE_LEASE_MGR_H
 
 
+#include <dhcpsrv/hwaddr.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <dhcpsrv/lease_mgr.h>
 
 
 #include <boost/multi_index/indexed_by.hpp>
 #include <boost/multi_index/indexed_by.hpp>

+ 0 - 28
src/lib/dhcpsrv/mysql_lease_mgr.cc

@@ -192,34 +192,6 @@ TaggedStatement tagged_statements[] = {
     {MySqlLeaseMgr::NUM_STATEMENTS, NULL}
     {MySqlLeaseMgr::NUM_STATEMENTS, NULL}
 };
 };
 
 
-/// @brief Produce string representation of hardware address
-///
-/// Returns a string containing the hardware address. This is only used for
-/// logging.
-///
-/// @note Six characters is an arbitrary length, chosen to provide a
-///       suitably wide string.
-///
-/// @todo Create a "hardware address" class of which this will be a member.
-///
-/// @param hwaddr Hardware address to convert to string form
-///
-/// @return String form of the hardware address.
-std::string
-hardwareAddressString(const LeaseMgr::HWAddr& hwaddr) {
-    std::ostringstream stream;
-
-    for (size_t i = 0; i < hwaddr.size(); ++i) {
-        if (i > 0) {
-            stream << ":";
-        }
-        stream << std::setw(2) << std::setfill('0')
-               << static_cast<unsigned int>(hwaddr[i]);
-    }
-
-    return (stream.str());
-}
-
 };  // Anonymous namespace
 };  // Anonymous namespace
 
 
 
 

+ 1 - 0
src/lib/dhcpsrv/mysql_lease_mgr.h

@@ -15,6 +15,7 @@
 #ifndef MYSQL_LEASE_MGR_H
 #ifndef MYSQL_LEASE_MGR_H
 #define MYSQL_LEASE_MGR_H
 #define MYSQL_LEASE_MGR_H
 
 
+#include <dhcpsrv/hwaddr.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <dhcpsrv/lease_mgr.h>
 
 
 #include <boost/scoped_ptr.hpp>
 #include <boost/scoped_ptr.hpp>

+ 1 - 0
src/lib/dhcpsrv/tests/Makefile.am

@@ -30,6 +30,7 @@ libdhcpsrv_unittests_SOURCES  = run_unittests.cc
 libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc
 libdhcpsrv_unittests_SOURCES += addr_utilities_unittest.cc
 libdhcpsrv_unittests_SOURCES += alloc_engine_unittest.cc
 libdhcpsrv_unittests_SOURCES += alloc_engine_unittest.cc
 libdhcpsrv_unittests_SOURCES += cfgmgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += cfgmgr_unittest.cc
+libdhcpsrv_unittests_SOURCES += hwaddr_unittest.cc
 libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
 libdhcpsrv_unittests_SOURCES += lease_mgr_factory_unittest.cc
 libdhcpsrv_unittests_SOURCES += lease_mgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += lease_mgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += memfile_lease_mgr_unittest.cc
 libdhcpsrv_unittests_SOURCES += memfile_lease_mgr_unittest.cc

+ 46 - 0
src/lib/dhcpsrv/tests/hwaddr_unittest.cc

@@ -0,0 +1,46 @@
+// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <dhcpsrv/hwaddr.h>
+
+#include <gtest/gtest.h>
+
+#include <string>
+
+using namespace isc::dhcp;
+
+namespace {
+
+TEST(HwaddrTest, stringConversion) {
+
+    // Check that an empty vector returns an appropriate string
+    HWAddr hwaddr;
+    std::string result = hardwareAddressString(hwaddr);
+    EXPECT_EQ(std::string(""), result);
+
+    // ... that a single-byte string is OK
+    hwaddr.push_back(0xc3);
+    result = hardwareAddressString(hwaddr);
+    EXPECT_EQ(std::string("c3"), result);
+
+    // ... and that a multi-byte string works
+    hwaddr.push_back(0x7);
+    hwaddr.push_back(0xa2);
+    hwaddr.push_back(0xe8);
+    hwaddr.push_back(0x42);
+    result = hardwareAddressString(hwaddr);
+    EXPECT_EQ(std::string("c3:07:a2:e8:42"), result);
+}
+
+};  // Anonymous namespace