Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
07a33359
Commit
07a33359
authored
Oct 14, 2014
by
Marcin Siodelski
Browse files
[3560] Disallow IPv4 and IPv6 multicast addresses for IPv6 reservations.
parent
da9288ba
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/host.cc
View file @
07a33359
...
...
@@ -19,6 +19,15 @@
namespace
isc
{
namespace
dhcp
{
IPv6Resrv
::
IPv6Resrv
(
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
)
:
prefix_
(
prefix
),
prefix_len_
(
prefix_len
)
{
if
(
!
prefix
.
isV6
()
||
prefix
.
isV6Multicast
())
{
isc_throw
(
isc
::
BadValue
,
"invalid prefix '"
<<
prefix
<<
" for new IPv6 reservation"
);
}
}
bool
IPv6Resrv
::
operator
==
(
const
IPv6Resrv
&
other
)
const
{
return
(
prefix_
==
other
.
prefix_
&&
...
...
src/lib/dhcpsrv/host.h
View file @
07a33359
...
...
@@ -56,10 +56,11 @@ public:
///
/// @param prefix Address or prefix to be reserved.
/// @param prefix_len Prefix length.
///
/// @throw isc::BadValue if address is not IPv6 address or is a
/// multicast address.
IPv6Resrv
(
const
asiolink
::
IOAddress
&
prefix
,
const
uint8_t
prefix_len
=
128
)
:
prefix_
(
prefix
),
prefix_len_
(
prefix_len
)
{
}
const
uint8_t
prefix_len
=
128
);
/// @brief Returns prefix for the reservation.
const
asiolink
::
IOAddress
&
getPrefix
()
const
{
...
...
src/lib/dhcpsrv/tests/host_unittest.cc
View file @
07a33359
...
...
@@ -42,6 +42,11 @@ TEST(IPv6ResrvTest, constructorPrefix) {
EXPECT_EQ
(
IPv6Resrv
::
TYPE_PD
,
resrv
.
getType
());
}
TEST
(
IPv6ResrvTest
,
constructorInvalidPrefix
)
{
EXPECT_THROW
(
IPv6Resrv
(
IOAddress
(
"10.0.0.1"
),
128
),
isc
::
BadValue
);
EXPECT_THROW
(
IPv6Resrv
(
IOAddress
(
"ff02:1::2"
),
128
),
isc
::
BadValue
);
}
// This test verifies that it is possible to modify prefix and its
// length in an existing reservation.
TEST
(
IPv6ResrvTest
,
setPrefix
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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