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
450
Issues
450
List
Boards
Labels
Service Desk
Milestones
Merge Requests
75
Merge Requests
75
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
594b8277
Commit
594b8277
authored
Feb 04, 2014
by
Marcin Siodelski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[3242] Added unit test to check that direct packet is dropped on iface.
parent
c3a1bd5a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
+52
-0
src/bin/dhcp4/tests/dhcp4_test_utils.h
src/bin/dhcp4/tests/dhcp4_test_utils.h
+1
-0
No files found.
src/bin/dhcp4/tests/dhcp4_srv_unittest.cc
View file @
594b8277
...
...
@@ -3309,4 +3309,56 @@ TEST_F(Dhcpv4SrvTest, clientClassification) {
EXPECT_FALSE
(
dis2
->
inClass
(
"docsis3.0"
));
}
// This test verifies that the direct message is dropped when it has been
// received by the server via an interface for which there is no subnet
// configured. It also checks that the message is not dropped (is processed)
// when it is relayed or unicast.
TEST_F
(
Dhcpv4SrvTest
,
acceptDirectRequest
)
{
IfaceMgrTestConfig
test_config
(
true
);
IfaceMgr
::
instance
().
openSockets4
();
NakedDhcpv4Srv
srv
(
0
);
Pkt4Ptr
pkt
(
new
Pkt4
(
DHCPDISCOVER
,
1234
));
// Set Giaddr and local server's unicast address, but don't set hops.
// Hops value must be greater than 0, when giaddr is set. Otherwise,
// message is considered malformed and the accept() function should
// return false.
pkt
->
setGiaddr
(
IOAddress
(
"192.0.10.1"
));
pkt
->
setLocalAddr
(
IOAddress
(
"192.0.2.3"
));
pkt
->
setIface
(
"eth1"
);
EXPECT_FALSE
(
srv
.
accept
(
pkt
));
// Let's set hops and check that the message is now accepted as
// a relayed message.
pkt
->
setHops
(
1
);
EXPECT_TRUE
(
srv
.
accept
(
pkt
));
// Make it a direct message but keep unicast server's address. The
// messages sent to unicast address should be accepted as they are
// most likely to renew existing leases. The server should respond
// to renews so they have to be accepted and processed.
pkt
->
setHops
(
0
);
pkt
->
setGiaddr
(
IOAddress
(
"0.0.0.0"
));
EXPECT_TRUE
(
srv
.
accept
(
pkt
));
// Direct message is now sent to a broadcast address. The server
// should accept this message because it has been received via
// eth1 for which there is a subnet configured (see test fixture
// class constructor).
pkt
->
setLocalAddr
(
IOAddress
(
"255.255.255.255"
));
EXPECT_TRUE
(
srv
.
accept
(
pkt
));
// For eth0, there is no subnet configured. Such message is expected
// to be silently dropped.
pkt
->
setIface
(
"eth0"
);
EXPECT_FALSE
(
srv
.
accept
(
pkt
));
// But, if the message is unicast it should be accepted, even though
// it has been received via eth0.
pkt
->
setLocalAddr
(
IOAddress
(
"10.0.0.1"
));
EXPECT_TRUE
(
srv
.
accept
(
pkt
));
}
};
// end of anonymous namespace
src/bin/dhcp4/tests/dhcp4_test_utils.h
View file @
594b8277
...
...
@@ -408,6 +408,7 @@ public:
using
Dhcpv4Srv
::
unpackOptions
;
using
Dhcpv4Srv
::
name_change_reqs_
;
using
Dhcpv4Srv
::
classifyPacket
;
using
Dhcpv4Srv
::
accept
;
};
};
// end of isc::dhcp::test namespace
...
...
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