Browse Source

[2324] Changes after review (including compilation fixes for Sol, Fedora and Mac OS)

Tomek Mrugalski 12 years ago
parent
commit
7e2dedc024

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+4XX.	[func]		tomek
+	DHCPv6 Allocation Engine implemented. It allows address allocation
+	from the configured subnets/pools. It currently features a single
+	allocator: IterativeAllocator, which assigns addresses iteratively.
+	Other allocators (hashed, random) are planned.
+	(Trac #2324, git TBD)
+
 494.	[bug]		jinmei
 	Fixed a problem that shutting down BIND 10 kept some of the
 	processes alive.  It was two-fold: when the main bind10 process

+ 4 - 0
src/lib/dhcp/alloc_engine.h

@@ -67,6 +67,10 @@ protected:
         virtual isc::asiolink::IOAddress
         pickAddress(const Subnet6Ptr& subnet, const DuidPtr& duid,
                     const isc::asiolink::IOAddress& hint) = 0;
+
+        /// @brief virtual destructor
+        virtual ~Allocator() {
+        }
     protected:
     };
 

+ 2 - 2
src/lib/dhcp/lease_mgr.h

@@ -398,7 +398,7 @@ public:
     /// @param addr address of the searched lease
     ///
     /// @return smart pointer to the lease (or NULL if a lease is not found)
-    virtual Lease6Ptr getLease6(isc::asiolink::IOAddress addr) const = 0;
+    virtual Lease6Ptr getLease6(const isc::asiolink::IOAddress& addr) const = 0;
 
     /// @brief Returns existing IPv6 leases for a given DUID+IA combination
     ///
@@ -450,7 +450,7 @@ public:
     /// @param addr IPv4 address of the lease to be deleted.
     ///
     /// @return true if deletion was successful, false if no such lease exists
-    virtual bool deleteLease6(isc::asiolink::IOAddress addr) = 0;
+    virtual bool deleteLease6(const isc::asiolink::IOAddress& addr) = 0;
 
     /// @brief Returns backend name.
     ///

+ 5 - 1
src/lib/dhcp/tests/alloc_engine_unittest.cc

@@ -22,6 +22,7 @@
 #include <boost/shared_ptr.hpp>
 #include <iostream>
 #include <sstream>
+#include <map>
 #include <gtest/gtest.h>
 
 using namespace std;
@@ -35,6 +36,9 @@ namespace {
 
 class NakedAllocEngine : public AllocEngine {
 public:
+    NakedAllocEngine(AllocEngine::AllocType engine_type, unsigned int attempts)
+        :AllocEngine(engine_type, attempts) {
+    }
     using AllocEngine::Allocator;
     using AllocEngine::IterativeAllocator;
 };
@@ -308,7 +312,7 @@ TEST_F(AllocEngineTest, IterativeAllocator_manyPools) {
                           // there are 8 extra pools with 9 addresses in each.
 
     // Let's keep picked addresses here and check their uniqueness.
-    map<IOAddress, int> generated_addrs;
+    std::map<IOAddress, int> generated_addrs;
     int cnt = 0;
     while (++cnt) {
         IOAddress candidate = alloc->pickAddress(subnet_, duid_, IOAddress("::"));

+ 2 - 2
src/lib/dhcp/tests/memfile_lease_mgr.cc

@@ -65,7 +65,7 @@ Lease4Collection Memfile_LeaseMgr::getLease4(const ClientId& ) const {
     return (Lease4Collection());
 }
 
-Lease6Ptr Memfile_LeaseMgr::getLease6(isc::asiolink::IOAddress addr) const {
+Lease6Ptr Memfile_LeaseMgr::getLease6(const isc::asiolink::IOAddress& addr) const {
     Lease6Storage::iterator l = storage6_.find(addr);
     if (l == storage6_.end()) {
         return (Lease6Ptr());
@@ -95,7 +95,7 @@ bool Memfile_LeaseMgr::deleteLease4(uint32_t ) {
     return (false);
 }
 
-bool Memfile_LeaseMgr::deleteLease6(isc::asiolink::IOAddress addr) {
+bool Memfile_LeaseMgr::deleteLease6(const isc::asiolink::IOAddress& addr) {
     Lease6Storage::iterator l = storage6_.find(addr);
     if (l == storage6_.end()) {
         // no such lease

+ 4 - 4
src/lib/dhcp/tests/memfile_lease_mgr.h

@@ -132,7 +132,7 @@ public:
     /// @param addr address of the searched lease
     ///
     /// @return smart pointer to the lease (or NULL if a lease is not found)
-    Lease6Ptr getLease6(isc::asiolink::IOAddress addr) const;
+    Lease6Ptr getLease6(const isc::asiolink::IOAddress& addr) const;
 
     /// @brief Returns existing IPv6 lease for a given DUID+IA combination
     ///
@@ -187,12 +187,12 @@ public:
     /// @param addr IPv4 address of the lease to be deleted.
     ///
     /// @return true if deletion was successful, false if no such lease exists
-    bool deleteLease6(isc::asiolink::IOAddress addr);
+    bool deleteLease6(const isc::asiolink::IOAddress& addr);
 
     /// @brief Returns backend name.
     ///
     /// Each backend have specific name, e.g. "mysql" or "sqlite".
-    std::string getName() const { return "memfile"; }
+    std::string getName() const { return ("memfile"); }
 
     /// @brief Returns description of the backend.
     ///
@@ -200,7 +200,7 @@ public:
     std::string getDescription() const;
 
     /// @brief Returns backend version.
-    std::string getVersion() const { return "test-version"; }
+    std::string getVersion() const { return ("test-version"); }
 
     using LeaseMgr::getParameter;