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
ISC Open Source Projects
Kea
Commits
5b02a964
Commit
5b02a964
authored
May 13, 2017
by
Francis Dupont
Browse files
[5104] Fixed comment and added unit tests
parent
e01f1d6f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcpsrv/subnet.cc
View file @
5b02a964
// Copyright (C) 2012-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-201
7
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
src/lib/dhcpsrv/subnet.h
View file @
5b02a964
...
...
@@ -72,11 +72,12 @@ public:
/// @brief checks if the specified address is in pools
///
/// Note the difference between inRange() and inPool(). For a given
/// subnet (e.g. 2001::/64) there may be one or more pools defined
/// that may or may not cover entire subnet, e.g. pool 2001::1-2001::10).
/// inPool() returning true implies inRange(), but the reverse implication
/// is not always true. For the given example, 2001::1234:abcd would return
/// Note the difference between inRange() and inPool() for addresses
/// (i.e. *not* prefixes). For a given subnet (e.g. 2001::/64) there
/// may be one or more pools defined that may or may not cover
/// entire subnet, e.g. pool 2001::1-2001::10). inPool() returning
/// true implies inRange(), but the reverse implication is not
/// always true. For the given example, 2001::1234:abcd would return
/// true for inRange(), but false for inPool() check.
///
/// @param type type of pools to iterate over
...
...
src/lib/dhcpsrv/tests/pool_unittest.cc
View file @
5b02a964
// Copyright (C) 2012-201
6
Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-201
7
Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -112,7 +112,7 @@ TEST(Pool4Test, unique_id) {
}
// Simple check if toText returns reasonable values
TEST
(
Pool4Test
,
toText
)
{
TEST
(
Pool4Test
,
toText
)
{
Pool4
pool1
(
IOAddress
(
"192.0.2.7"
),
IOAddress
(
"192.0.2.17"
));
EXPECT_EQ
(
"type=V4, 192.0.2.7-192.0.2.17"
,
pool1
.
toText
());
...
...
src/lib/dhcpsrv/tests/subnet_unittest.cc
View file @
5b02a964
// Copyright (C) 2012-
2015,
2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
...
...
@@ -1096,7 +1096,7 @@ TEST(Subnet6Test, inRangeinPool) {
IOAddress
(
"2001:db8::20"
)));
subnet
->
addPool
(
pool1
);
//
192.1.1.
1 belongs to the subnet...
//
2001:db8::
1 belongs to the subnet...
EXPECT_TRUE
(
subnet
->
inRange
(
IOAddress
(
"2001:db8::1"
)));
// ... but it does not belong to any pool within
EXPECT_FALSE
(
subnet
->
inPool
(
Lease
::
TYPE_NA
,
IOAddress
(
"2001:db8::1"
)));
...
...
@@ -1122,6 +1122,40 @@ TEST(Subnet6Test, inRangeinPool) {
EXPECT_FALSE
(
subnet
->
inPool
(
Lease
::
TYPE_NA
,
IOAddress
(
"2001:db8::21"
)));
}
// This test verifies that inRange() and inPool() methods work properly
// for prefixes too.
TEST
(
Subnet6Test
,
PdinRangeinPool
)
{
Subnet6Ptr
subnet
(
new
Subnet6
(
IOAddress
(
"2001:db8::"
),
64
,
1
,
2
,
3
,
4
));
// this one is in subnet
Pool6Ptr
pool1
(
new
Pool6
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8::"
),
96
,
112
));
subnet
->
addPool
(
pool1
);
// this one is not in subnet
Pool6Ptr
pool2
(
new
Pool6
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8:1::"
),
96
,
112
));
subnet
->
addPool
(
pool2
);
// 2001:db8::1:0:0 belongs to the subnet...
EXPECT_TRUE
(
subnet
->
inRange
(
IOAddress
(
"2001:db8::1:0:0"
)));
// ... but it does not belong to any pool within
EXPECT_FALSE
(
subnet
->
inPool
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8::1:0:0"
)));
// 2001:db8:1::1 does not belong to the subnet...
EXPECT_FALSE
(
subnet
->
inRange
(
IOAddress
(
"2001:db8:1::1"
)));
// ... but it belongs to the second pool
EXPECT_TRUE
(
subnet
->
inPool
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8:1::1"
)));
// 2001:db8::1 belongs to the subnet and to the first pool
EXPECT_TRUE
(
subnet
->
inRange
(
IOAddress
(
"2001:db8::1"
)));
EXPECT_TRUE
(
subnet
->
inPool
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8::1"
)));
// 2001:db8:0:1:0:1:: does not belong to the subnet and any pool
EXPECT_FALSE
(
subnet
->
inRange
(
IOAddress
(
"2001:db8:0:1:0:1::"
)));
EXPECT_FALSE
(
subnet
->
inPool
(
Lease
::
TYPE_PD
,
IOAddress
(
"2001:db8:0:1:0:1::"
)));
}
// This test checks if the toText() method returns text representation
TEST
(
Subnet6Test
,
toText
)
{
Subnet6
subnet
(
IOAddress
(
"2001:db8::"
),
32
,
1
,
2
,
3
,
4
);
...
...
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