Commit 3c0afa72 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5003] Test local port of the received message in pkt filter tests.

parent cb7a76ef
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -198,7 +198,6 @@ PktFilterInet::receive(Iface& iface, const SocketInfo& socket_info) {
if ((cmsg->cmsg_level == IPPROTO_IP) &&
(cmsg->cmsg_type == IP_RECVDSTADDR)) {
to_addr = (struct in_addr*)CMSG_DATA(cmsg);
pkt->setLocalAddr(IOAddress(htonl(to_addr->s_addr)));
break;
}
......
// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-2016 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
......@@ -192,6 +192,7 @@ TEST_F(PktFilterBPFTest, DISABLED_receive) {
// Check if the received message is correct.
testRcvdMessage(rcvd_pkt);
testRcvdMessageAddressPort(rcvd_pkt);
}
// This test verifies that if the packet is received over the raw
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -140,6 +140,7 @@ TEST_F(PktFilterInetTest, receive) {
// Check if the received message is correct.
testRcvdMessage(rcvd_pkt);
testRcvdMessageAddressPort(rcvd_pkt);
}
} // anonymous namespace
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -179,6 +179,7 @@ TEST_F(PktFilterLPFTest, DISABLED_receive) {
// Check if the received message is correct.
testRcvdMessage(rcvd_pkt);
testRcvdMessageAddressPort(rcvd_pkt);
}
// This test verifies that if the packet is received over the raw
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -160,6 +160,14 @@ PktFilterTest::testRcvdMessage(const Pkt4Ptr& rcvd_msg) const {
EXPECT_EQ(test_message_->getHlen(), rcvd_msg->getHlen());
}
void
PktFilterTest::testRcvdMessageAddressPort(const Pkt4Ptr& rcvd_msg) const {
EXPECT_EQ(test_message_->getRemoteAddr(), rcvd_msg->getLocalAddr());
EXPECT_EQ(test_message_->getLocalAddr(), rcvd_msg->getRemoteAddr());
EXPECT_EQ(test_message_->getRemotePort(), rcvd_msg->getLocalPort());
EXPECT_EQ(test_message_->getLocalPort(), rcvd_msg->getRemotePort());
}
bool
PktFilterStub::isDirectResponseSupported() const {
return (true);
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -71,11 +71,17 @@ public:
/// @param sock A descriptor of the open socket.
void testDgramSocket(const int sock) const;
/// @brief Checks if the received message matches the test_message_.
/// @brief Checks if a received message matches the test_message_.
///
/// @param rcvd_msg An instance of the message to be tested.
void testRcvdMessage(const Pkt4Ptr& rcvd_msg) const;
/// @brief Checks if received message has appropriate addresses and
/// port values set.
///
/// @param rcvd_msg An instance of the message to be tested.
void testRcvdMessageAddressPort(const Pkt4Ptr& rcvd_msg) const;
std::string ifname_; ///< Loopback interface name
uint16_t ifindex_; ///< Loopback interface index.
uint16_t port_; ///< A port number used for the test.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment