From: Tomek Mrugalski Date: Thu, 27 Dec 2012 18:45:41 +0000 (+0100) Subject: [2320] Default value for getPool() now works for both v4 and v6. X-Git-Tag: bind10-1.0.0-rc-release~95^2~16^2~2^2~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92e4f34d7c74ff7b34599e1d3e8d0622ebc633d6;p=thirdparty%2Fkea.git [2320] Default value for getPool() now works for both v4 and v6. --- diff --git a/src/lib/dhcpsrv/subnet.cc b/src/lib/dhcpsrv/subnet.cc index 6fc53e14d4..8109745128 100644 --- a/src/lib/dhcpsrv/subnet.cc +++ b/src/lib/dhcpsrv/subnet.cc @@ -87,12 +87,15 @@ void Subnet::addPool(const PoolPtr& pool) { } PoolPtr Subnet::getPool(isc::asiolink::IOAddress hint) { - if (dynamic_cast(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(this) && hint.toText() == "::") { + hint = IOAddress("0.0.0.0"); + } PoolPtr candidate; for (PoolCollection::iterator pool = pools_.begin(); pool != pools_.end(); ++pool) {