]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2320] Default value for getPool() now works for both v4 and v6.
authorTomek Mrugalski <tomasz@isc.org>
Thu, 27 Dec 2012 18:45:41 +0000 (19:45 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 27 Dec 2012 18:45:41 +0000 (19:45 +0100)
src/lib/dhcpsrv/subnet.cc

index 6fc53e14d4e47fc89e690da3dfb702ceeccd081c..81097451284b718c5532562ab59611bf9734625b 100644 (file)
@@ -87,12 +87,15 @@ void Subnet::addPool(const PoolPtr& pool) {
 }
 
 PoolPtr Subnet::getPool(isc::asiolink::IOAddress hint) {
-    if (dynamic_cast<Subnet6*>(this)) {
-        if (hint.toText() == "::") {
-            hint = IOAddress("0.0.0.0");
-        }
-    }
 
+    // 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<Subnet6*>(this) && hint.toText() == "::") {
+        hint = IOAddress("0.0.0.0");
+    }
 
     PoolPtr candidate;
     for (PoolCollection::iterator pool = pools_.begin(); pool != pools_.end(); ++pool) {