Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
415
Issues
415
List
Boards
Labels
Service Desk
Milestones
Merge Requests
65
Merge Requests
65
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
7da6edea
Commit
7da6edea
authored
Oct 27, 2014
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3555] Lease6::matches now checks hwaddr
parent
cb2fc012
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
src/lib/dhcpsrv/lease.cc
src/lib/dhcpsrv/lease.cc
+12
-0
src/lib/dhcpsrv/tests/lease_unittest.cc
src/lib/dhcpsrv/tests/lease_unittest.cc
+28
-0
No files found.
src/lib/dhcpsrv/lease.cc
View file @
7da6edea
...
@@ -277,6 +277,18 @@ Lease4::operator==(const Lease4& other) const {
...
@@ -277,6 +277,18 @@ Lease4::operator==(const Lease4& other) const {
bool
bool
Lease6
::
matches
(
const
Lease6
&
other
)
const
{
Lease6
::
matches
(
const
Lease6
&
other
)
const
{
// One lease has a hardware address, the other doesn't.
if
(
(
!
hwaddr_
&&
other
.
hwaddr_
)
||
(
hwaddr_
&&
!
other
.
hwaddr_
)
)
{
return
(
false
);
}
// Both leases have hardware address, but they are not equal.
if
(
hwaddr_
&&
(
*
hwaddr_
!=
*
other
.
hwaddr_
))
{
return
(
false
);
}
return
(
addr_
==
other
.
addr_
&&
return
(
addr_
==
other
.
addr_
&&
type_
==
other
.
type_
&&
type_
==
other
.
type_
&&
prefixlen_
==
other
.
prefixlen_
&&
prefixlen_
==
other
.
prefixlen_
&&
...
...
src/lib/dhcpsrv/tests/lease_unittest.cc
View file @
7da6edea
...
@@ -575,6 +575,34 @@ TEST(Lease6, matches) {
...
@@ -575,6 +575,34 @@ TEST(Lease6, matches) {
lease1
.
duid_
=
duid
;
lease1
.
duid_
=
duid
;
EXPECT_FALSE
(
lease1
.
matches
(
lease2
));
EXPECT_FALSE
(
lease1
.
matches
(
lease2
));
lease1
.
duid_
=
lease2
.
duid_
;
lease1
.
duid_
=
lease2
.
duid_
;
// Hardware address checks
EXPECT_TRUE
(
lease1
.
matches
(
lease2
));
// Neither lease have hardware address.
// Let's add a hardware lease to the first one.
HWAddrPtr
hwaddr
(
new
HWAddr
(
HWADDR
,
sizeof
(
HWADDR
),
HTYPE_ETHER
));
lease1
.
hwaddr_
=
hwaddr
;
// Only the first one has a hardware address, so not equal.
EXPECT_FALSE
(
lease1
.
matches
(
lease2
));
// Only the second one has it, so still not equal.
lease1
.
hwaddr_
.
reset
();
lease2
.
hwaddr_
=
hwaddr
;
EXPECT_FALSE
(
lease1
.
matches
(
lease2
));
// Ok, now both have it - they should be equal.
lease1
.
hwaddr_
=
hwaddr
;
EXPECT_TRUE
(
lease1
.
matches
(
lease2
));
// Let's create a second instance that have the same values.
HWAddrPtr
hwaddr2
(
new
HWAddr
(
HWADDR
,
sizeof
(
HWADDR
),
HTYPE_ETHER
));
lease2
.
hwaddr_
=
hwaddr2
;
EXPECT_TRUE
(
lease1
.
matches
(
lease2
));
// Let's modify the second address and check that they won't be equal anymore.
hwaddr2
->
hwaddr_
[
0
]
++
;
EXPECT_FALSE
(
lease1
.
matches
(
lease2
));
}
}
/// @brief Lease6 Equality Test
/// @brief Lease6 Equality Test
...
...
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