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
8a0c9ae6
Commit
8a0c9ae6
authored
Jul 10, 2014
by
Marcin Siodelski
Browse files
[2893] Fixed failing ifacemgr unit test on BSD.
parent
67b078ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/dhcp/iface_mgr_bsd.cc
View file @
8a0c9ae6
...
...
@@ -19,6 +19,7 @@
#include
<dhcp/iface_mgr.h>
#include
<dhcp/iface_mgr_error_handler.h>
#include
<dhcp/pkt_filter_bpf.h>
#include
<dhcp/pkt_filter_inet.h>
#include
<exceptions/exceptions.h>
#include
<sys/types.h>
...
...
@@ -144,13 +145,21 @@ bool IfaceMgr::os_receive4(struct msghdr& /*m*/, Pkt4Ptr& /*pkt*/) {
}
void
IfaceMgr
::
setMatchingPacketFilter
(
const
bool
/* direct_response_desired */
)
{
// Ignore whether the direct response is desired or not. Even if the
// direct response is not desired we don't want to use PktFilterInet
// because the BSD doesn't support binding to the device and listening
// to broadcast traffic on individual interfaces. So, datagram socket
// supported by PktFilterInet is not really usable for DHCP.
setPacketFilter
(
PktFilterPtr
(
new
PktFilterBPF
()));
IfaceMgr
::
setMatchingPacketFilter
(
const
bool
direct_response_desired
)
{
// If direct response is desired we have to use BPF. If the direct
// response is not desired we use datagram socket supported by the
// PktFilterInet class. Note however that on BSD systems binding the
// datagram socket to the device is not supported and the server would
// have no means to determine on which interface the packet has been
// received. Hence, it is discouraged to use PktFilterInet for the
// server.
if
(
direct_response_desired
)
{
setPacketFilter
(
PktFilterPtr
(
new
PktFilterBPF
()));
}
else
{
setPacketFilter
(
PktFilterPtr
(
new
PktFilterInet
()));
}
}
bool
...
...
src/lib/dhcp/tests/iface_mgr_unittest.cc
View file @
8a0c9ae6
...
...
@@ -1290,12 +1290,12 @@ TEST_F(IfaceMgrTest, setPacketFilter6) {
}
#if defined OS_LINUX
#if defined OS_LINUX
|| OS_BSD
// This
Linux specific test checks whether it is possible to use
//
IfaceMgr to figure out which Pak
cket
F
ilter
object should be
// used
wh
en direct responses to host
s, having no address assigned
//
are
des
ired or not desired
.
// This
test is only supported on Linux and BSD systems. It checks
//
if it is possible to use the IfaceMgr to select the pa
cket
f
ilter
//
object which can be
used
to s
en
d
direct responses to
the
host
//
which
d
o
es
n't have an address yet
.
TEST_F
(
IfaceMgrTest
,
setMatchingPacketFilter
)
{
// Create an instance of IfaceMgr.
...
...
@@ -1304,23 +1304,22 @@ TEST_F(IfaceMgrTest, setMatchingPacketFilter) {
// Let IfaceMgr figure out which Packet Filter to use when
// direct response capability is not desired. It should pick
// PktFilterInet.
// PktFilterInet
on Linux
.
EXPECT_NO_THROW
(
iface_mgr
->
setMatchingPacketFilter
(
false
));
// The PktFilterInet is supposed to report lack of direct
// response capability.
EXPECT_FALSE
(
iface_mgr
->
isDirectResponseSupported
());
// There is working implementation of direct responses on Linux
// in PktFilterLPF. It uses Linux Packet Filtering as underlying
// mechanism. When direct responses are desired the object of
// this class should be set.
// and BSD (using PktFilterLPF and PktFilterBPF. When direct
// responses are desired the object of this class should be set.
EXPECT_NO_THROW
(
iface_mgr
->
setMatchingPacketFilter
(
true
));
// This object should report that direct responses are supported.
EXPECT_TRUE
(
iface_mgr
->
isDirectResponseSupported
());
}
// This test checks that it is not possible to open two sockets: IP/UDP
// and raw
(LPF)
socket and bind to the same address and port. The
// and raw socket and bind to the same address and port. The
// raw socket should be opened together with the fallback IP/UDP socket.
// The fallback socket should fail to open when there is another IP/UDP
// socket bound to the same address and port. Failing to open the fallback
...
...
@@ -1376,8 +1375,8 @@ TEST_F(IfaceMgrTest, checkPacketFilterLPFSocket) {
// on systems other than Linux the function under test should always
// set object of PktFilterInet type as current Packet Filter. This
// object does not support direct responses. Once implementation is
// added on
non-Linux systems
the OS specific version
of the test
// will be removed.
// added on
systems other than BSD and Linux
the OS specific version
//
of the test
will be removed.
TEST_F
(
IfaceMgrTest
,
setMatchingPacketFilter
)
{
// Create an instance of IfaceMgr.
...
...
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