Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
e4f44ed5
Commit
e4f44ed5
authored
Jan 09, 2013
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2320] dynamic_cast in Subnet::getPool() removed
parent
2bbe63db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
src/lib/dhcpsrv/subnet.cc
src/lib/dhcpsrv/subnet.cc
+0
-9
src/lib/dhcpsrv/subnet.h
src/lib/dhcpsrv/subnet.h
+24
-2
No files found.
src/lib/dhcpsrv/subnet.cc
View file @
e4f44ed5
...
...
@@ -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
)
{
...
...
src/lib/dhcpsrv/subnet.h
View file @
e4f44ed5
...
...
@@ -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_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment