BIND 10 trac2320, updated. e4f44ed5418cca60318c89472defcf24eea93826 [2320] dynamic_cast in Subnet::getPool() removed

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jan 9 13:41:23 UTC 2013


The branch, trac2320 has been updated
       via  e4f44ed5418cca60318c89472defcf24eea93826 (commit)
      from  2bbe63dbbdda8e75fa60df6ea19f4b0354edebeb (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 e4f44ed5418cca60318c89472defcf24eea93826
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Jan 9 14:40:27 2013 +0100

    [2320] dynamic_cast in Subnet::getPool() removed

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dhcpsrv/subnet.cc |    9 ---------
 src/lib/dhcpsrv/subnet.h  |   26 ++++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 11 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc
index 07d4d68..fccf75b 100644
--- a/src/lib/dhcpsrv/subnet.cc
+++ b/src/lib/dhcpsrv/subnet.cc
@@ -88,15 +88,6 @@ void Subnet::addPool(const PoolPtr& pool) {
 
 PoolPtr Subnet::getPool(isc::asiolink::IOAddress hint) {
 
-    // This is an ugly workaround for having the ability to have default value
-    // for both protocol families. The alternative to this would be to define
-    // getPool() as pure virtual and have Subnet4 and Subnet6 provide their
-    // own methods. Those two implementation would only differ by a default
-    // value, so it would just include duplicate code.
-    if (dynamic_cast<Subnet4*>(this) && hint.toText() == "::") {
-        hint = IOAddress("0.0.0.0");
-    }
-
     PoolPtr candidate;
     for (PoolCollection::iterator pool = pools_.begin(); pool != pools_.end(); ++pool) {
 
diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h
index c2c6b19..b04a3ac 100644
--- a/src/lib/dhcpsrv/subnet.h
+++ b/src/lib/dhcpsrv/subnet.h
@@ -306,8 +306,19 @@ public:
     ///
     /// @param addr address that the returned pool should cover (optional)
     /// @return Pointer to found Pool4 or Pool6 (or NULL)
-    PoolPtr getPool(isc::asiolink::IOAddress addr =
-                    isc::asiolink::IOAddress("::"));
+    PoolPtr getPool(isc::asiolink::IOAddress addr);
+
+    /// @brief Returns a pool without any address specified
+    /// @return returns one of the pools defined
+    PoolPtr getPool() {
+        return (getPool(default_pool()));
+    }
+
+    /// @brief Returns the default address that will be used for pool selection
+    ///
+    /// It must be implemented in derived classes (should return :: for Subnet6
+    /// and 0.0.0.0 for Subnet4)
+    virtual isc::asiolink::IOAddress default_pool() const = 0;
 
     /// @brief returns all pools
     ///
@@ -421,6 +432,11 @@ protected:
     /// @throw isc::BadValue if provided option is invalid.
     virtual void validateOption(const OptionPtr& option) const;
 
+    /// @brief Returns default address for pool selection
+    /// @return ANY IPv4 address
+    virtual isc::asiolink::IOAddress default_pool() const {
+        return (isc::asiolink::IOAddress("0.0.0.0"));
+    }
 };
 
 /// @brief A pointer to a Subnet4 object
@@ -466,6 +482,12 @@ protected:
     /// @throw isc::BadValue if provided option is invalid.
     virtual void validateOption(const OptionPtr& option) const;
 
+    /// @brief Returns default address for pool selection
+    /// @return ANY IPv6 address
+    virtual isc::asiolink::IOAddress default_pool() const {
+        return (isc::asiolink::IOAddress("::"));
+    }
+
     /// @brief collection of pools in that list
     Pool6Collection pools_;
 



More information about the bind10-changes mailing list