From b3f9652ddcca121056c5ada9e323a594b60b6274 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Mon, 4 Jul 2016 16:24:24 +0200 Subject: [PATCH] [4497] Added Pkt method checking if retrieved options are copied. --- src/lib/dhcp/pkt.h | 9 +++++++++ src/lib/dhcp/tests/pkt4_unittest.cc | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/lib/dhcp/pkt.h b/src/lib/dhcp/pkt.h index 1b234e9251..21632cc45d 100644 --- a/src/lib/dhcp/pkt.h +++ b/src/lib/dhcp/pkt.h @@ -307,6 +307,15 @@ public: copy_retrieved_options_ = copy; } + /// @brief Returns whether the copying of retrieved options is enabled. + /// + /// Also see @ref setCopyRetrievedOptions. + /// + /// @return true if retrieved options are copied. + bool isCopyRetrievedOptions() const { + return (copy_retrieved_options_); + } + /// @brief Update packet timestamp. /// /// Updates packet timestamp. This method is invoked diff --git a/src/lib/dhcp/tests/pkt4_unittest.cc b/src/lib/dhcp/tests/pkt4_unittest.cc index 2c61cfea08..45cb0d0529 100644 --- a/src/lib/dhcp/tests/pkt4_unittest.cc +++ b/src/lib/dhcp/tests/pkt4_unittest.cc @@ -625,6 +625,7 @@ TEST_F(Pkt4Test, setCopyRetrievedOptions) { // Now force copying the options when they are retrieved. pkt->setCopyRetrievedOptions(true); + EXPECT_TRUE(pkt->isCopyRetrievedOptions()); // Option pointer returned must point to a new instance of option 2. OptionPtr option2_copy = pkt->getOption(2); @@ -632,6 +633,7 @@ TEST_F(Pkt4Test, setCopyRetrievedOptions) { // Disable copying. pkt->setCopyRetrievedOptions(false); + EXPECT_FALSE(pkt->isCopyRetrievedOptions()); // Expect that the original pointer is returned. This guarantees that // option1 wasn't affected by copying option 2. -- 2.47.2