#include <gtest/gtest.h>
#include <stdint.h>
+#include <utility>
using namespace isc;
using namespace isc::asiolink;
EXPECT_TRUE(srv);
// Let's wipe all existing statistics.
StatsMgr::instance().removeAll();
+
+ // Set the flags to false as we expect them to be set in callouts.
+ callback_recv_pkt_options_copy_ = std::make_pair(false, false);
+ callback_sent_pkt_options_copy_ = std::make_pair(false, false);
}
/// @brief Configure DHCP4o6 port.
///
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
- static int
- buffer4_receive_callout(CalloutHandle& callout_handle) {
+ static int buffer4_receive_callout(CalloutHandle& callout_handle) {
callout_handle.getArgument("query4", callback_recv_pkt_);
+ Pkt4o6Ptr pkt4 = boost::dynamic_pointer_cast<Pkt4o6>(callback_recv_pkt_);
+ if (pkt4) {
+ callback_recv_pkt_options_copy_.first = pkt4->isCopyRetrievedOptions();
+ Pkt6Ptr pkt6 = pkt4->getPkt6();
+ if (pkt6) {
+ callback_recv_pkt_options_copy_.second =
+ pkt6->isCopyRetrievedOptions();
+ }
+ }
return (0);
}
///
/// @param callout_handle handle passed by the hooks framework
/// @return always 0
- static int
- buffer4_send_callout(CalloutHandle& callout_handle) {
+ static int buffer4_send_callout(CalloutHandle& callout_handle) {
callout_handle.getArgument("response4", callback_sent_pkt_);
+ Pkt4o6Ptr pkt4 = boost::dynamic_pointer_cast<Pkt4o6>(callback_sent_pkt_);
+ if (pkt4) {
+ callback_sent_pkt_options_copy_.first = pkt4->isCopyRetrievedOptions();
+ Pkt6Ptr pkt6 = pkt4->getPkt6();
+ if (pkt6) {
+ callback_sent_pkt_options_copy_.second =
+ pkt6->isCopyRetrievedOptions();
+ }
+ }
return (0);
}
/// @brief Response Pkt4 shared pointer returned in the send callout
static Pkt4Ptr callback_sent_pkt_;
+ /// Flags indicating if copying retrieved options was enabled for
+ /// a received packet during callout execution.
+ static std::pair<bool, bool> callback_recv_pkt_options_copy_;
+
+ /// Flags indicating if copying retrieved options was enabled for
+ /// a sent packet during callout execution.
+ static std::pair<bool, bool> callback_sent_pkt_options_copy_;
+
/// @brief reference to a controlled server
///
/// Dhcp4to6Ipc::handler() uses the instance of the controlled server
Pkt4Ptr Dhcp4to6IpcTest::callback_recv_pkt_;
Pkt4Ptr Dhcp4to6IpcTest::callback_sent_pkt_;
+std::pair<bool, bool> Dhcp4to6IpcTest::callback_recv_pkt_options_copy_;
+std::pair<bool, bool> Dhcp4to6IpcTest::callback_sent_pkt_options_copy_;
void
Dhcp4to6IpcTest::configurePort(uint16_t port) {
ASSERT_TRUE(pkt6_received);
EXPECT_EQ("eth0", pkt6_received->getIface());
EXPECT_EQ("2001:db8:1::123", pkt6_received->getRemoteAddr().toText());
+
+ // Both DHCP4o6 and encapsulated DHCPv6 packet should have the
+ // flag enabled.
+ EXPECT_TRUE(callback_recv_pkt_options_copy_.first);
+ EXPECT_TRUE(callback_recv_pkt_options_copy_.second);
}
// This test verifies that message with multiple DHCPv4 query options
EXPECT_EQ("eth0", pkt6_sent->getIface());
EXPECT_EQ("2001:db8:1::123", pkt6_sent->getRemoteAddr().toText());
+ // Both DHCP4o6 and encapsulated DHCPv6 packet should have the
+ // flag enabled.
+ EXPECT_TRUE(callback_sent_pkt_options_copy_.first);
+ EXPECT_TRUE(callback_sent_pkt_options_copy_.second);
+
// Verify the 4o6 part
OptionCollection sent_msgs = pkt6_sent->getOptions(D6O_DHCPV4_MSG);
ASSERT_EQ(1, sent_msgs.size());
registerCallout("buffer6_send", buffer6_send_callout));
// Let's wipe all existing statistics.
StatsMgr::instance().removeAll();
+
+ // Reset the flag which we expect to be set in the callout.
+ callback_pkt_options_copy_ = false;
}
/// @brief Configure DHCP4o6 port.
static int
buffer6_send_callout(CalloutHandle& callout_handle) {
callout_handle.getArgument("response6", callback_pkt_);
+ if (callback_pkt_) {
+ callback_pkt_options_copy_ = callback_pkt_->isCopyRetrievedOptions();
+ }
return (0);
}
/// @brief Response Pkt6 shared pointer returned in the callout
static Pkt6Ptr callback_pkt_;
+ /// Flag indicating if copying retrieved options was enabled for
+ /// a received packet during callout execution.
+ static bool callback_pkt_options_copy_;
+
private:
/// @brief Provides fake configuration of interfaces.
};
Pkt6Ptr Dhcp6to4IpcTest::callback_pkt_;
+bool Dhcp6to4IpcTest::callback_pkt_options_copy_;
void
Dhcp6to4IpcTest::configurePort(const uint16_t port) {
ASSERT_NO_THROW(src_ipc.send(pkt));
ASSERT_NO_THROW(IfaceMgr::instance().receive6(1, 0));
+ // Make sure that the received packet was configured to return copy of
+ // retrieved options within a callout.
+ EXPECT_TRUE(callback_pkt_options_copy_);
+
// Get the forwarded packet from the callout
Pkt6Ptr forwarded = Dhcp6to4IpcTest::callback_pkt_;
ASSERT_TRUE(forwarded);