BIND 10 trac2318, updated. 17749f1ef367d560e5b878e814352e8b8082542e [2318] Removed function that searches for options using option code.

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Oct 30 17:42:25 UTC 2012


The branch, trac2318 has been updated
       via  17749f1ef367d560e5b878e814352e8b8082542e (commit)
      from  c4159fc5c746ee7df7aae8c590789e675050d75c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 17749f1ef367d560e5b878e814352e8b8082542e
Author: Marcin Siodelski <marcin at isc.org>
Date:   Tue Oct 30 18:42:16 2012 +0100

    [2318] Removed function that searches for options using option code.
    
    The index object used to get the range of searched options was local
    to the function and when returned from it search results were destroyed
    along with index (Mac, Solaris only). The alternative solution to
    copy results to another container was not picked due to performance
    considerations.

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/config_parser.cc                |    9 +++---
 src/bin/dhcp6/tests/config_parser_unittest.cc |    2 +-
 src/lib/dhcp/subnet.cc                        |   12 --------
 src/lib/dhcp/subnet.h                         |    7 -----
 src/lib/dhcp/tests/subnet_unittest.cc         |   37 -------------------------
 5 files changed, 6 insertions(+), 61 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/config_parser.cc b/src/bin/dhcp6/config_parser.cc
index 2476497..0fca770 100644
--- a/src/bin/dhcp6/config_parser.cc
+++ b/src/bin/dhcp6/config_parser.cc
@@ -829,10 +829,12 @@ public:
             subnet->addPool6(*it);
         }
 
+        const Subnet::OptionContainer& options = subnet->getOptions();
+        const Subnet::OptionContainerTypeIndex& idx = options.get<1>();
+
         // Add subnet specific options.
         BOOST_FOREACH(OptionPtr option, options_) {
-            Subnet::OptionContainerTypeRange range =
-                subnet->getOptions(option->getType());
+            Subnet::OptionContainerTypeRange range = idx.equal_range(option->getType());
             if (std::distance(range.first, range.second) > 0) {
                 LOG_WARN(dhcp6_logger, DHCP6_CONFIG_OPTION_DUPLICATE)
                     .arg(option->getType()).arg(addr.toText());
@@ -847,8 +849,7 @@ public:
         BOOST_FOREACH(OptionPtr option, option_defaults) {
             // Get all options specified locally in the subnet and having
             // code equal to global option's code.
-            Subnet::OptionContainerTypeRange range =
-                subnet->getOptions(option->getType());
+            Subnet::OptionContainerTypeRange range = idx.equal_range(option->getType());
             // @todo: In the future we will be searching for options using either
             // option code or namespace. Currently we have only the option
             // code available so if there is at least one option found with the
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index 576e81f..dafe314 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -408,7 +408,7 @@ TEST_F(Dhcp6ParserTest, optionDataDefaults) {
 
     // Check that options with other option codes are not returned.
     for (uint16_t code = 102; code < 110; ++code) {
-        ASSERT_NO_THROW(range = subnet->getOptions(code));
+        range = idx.equal_range(code);
         EXPECT_EQ(0, std::distance(range.first, range.second));
     }
 }
diff --git a/src/lib/dhcp/subnet.cc b/src/lib/dhcp/subnet.cc
index 61f70a7..cb82a9f 100644
--- a/src/lib/dhcp/subnet.cc
+++ b/src/lib/dhcp/subnet.cc
@@ -52,18 +52,6 @@ Subnet::delOptions() {
     options_.clear();
 }
 
-Subnet::OptionContainerTypeRange
-Subnet::getOptions(uint16_t type) {
-    OptionContainer options = getOptions();
-    // Get the search index #1. This index allows to search
-    // for options using option type.
-    OptionContainerTypeIndex& idx = options.get<1>();
-    OptionContainerTypeRange range = idx.equal_range(type);
-    // We don't perform any check if this range is empty. It is
-    // up to the calling function to check it with std::distance().
-    return (range);
-}
-
 Subnet4::Subnet4(const isc::asiolink::IOAddress& prefix, uint8_t length,
                  const Triplet<uint32_t>& t1,
                  const Triplet<uint32_t>& t2,
diff --git a/src/lib/dhcp/subnet.h b/src/lib/dhcp/subnet.h
index c157e7a..514f422 100644
--- a/src/lib/dhcp/subnet.h
+++ b/src/lib/dhcp/subnet.h
@@ -233,13 +233,6 @@ public:
         return (options_);
     }
 
-    /// @brief Return a collection of options of a specified type.
-    ///
-    /// @param type option type.
-    /// @return pair of iterators, first indicating begining of
-    /// options range, second indicating end of the range.
-    OptionContainerTypeRange getOptions(uint16_t type);
-
 protected:
     /// @brief protected constructor
     //
diff --git a/src/lib/dhcp/tests/subnet_unittest.cc b/src/lib/dhcp/tests/subnet_unittest.cc
index c1d8d76..0e2e846 100644
--- a/src/lib/dhcp/tests/subnet_unittest.cc
+++ b/src/lib/dhcp/tests/subnet_unittest.cc
@@ -285,43 +285,6 @@ TEST(Subnet6Test, addNonUniqueOptions) {
     EXPECT_EQ(0, options.size());
 }
 
-TEST(Subnet6Test, getOptionsByType) {
-    Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));
-    Subnet::OptionContainerTypeRange range;
-
-    // First check that subnet does not contain any options with
-    // option codes 100 and 101.
-    ASSERT_NO_THROW(range = subnet->getOptions(100));
-    EXPECT_EQ(0, std::distance(range.first, range.second));
-    ASSERT_NO_THROW(range = subnet->getOptions(101));
-    EXPECT_EQ(0, std::distance(range.first, range.second));
-
-    // Add 3 options with option code 100.
-    for (int i = 0; i < 3; ++i) {
-        OptionPtr option(new Option(Option::V6, 100, OptionBuffer(10, 0xFF)));
-        ASSERT_NO_THROW(subnet->addOption(option));
-    }
-    // Add 7 options with option code 101.
-    for (int i = 0; i < 7; ++i) {
-        OptionPtr option(new Option(Option::V6, 101, OptionBuffer(10, 0xFF)));
-        ASSERT_NO_THROW(subnet->addOption(option));
-    }
-    // Get options by their type and check that 3 options with the
-    // code 100 and 7 options with the code 101 are returned.
-    ASSERT_NO_THROW(range = subnet->getOptions(100));
-    EXPECT_EQ(3, std::distance(range.first, range.second));
-    ASSERT_NO_THROW(range = subnet->getOptions(101));
-    EXPECT_EQ(7, std::distance(range.first, range.second));
-    // Delete all options.
-    EXPECT_NO_THROW(subnet->delOptions());
-    // Verify that after deletion getOptions will not return
-    // any options.
-    ASSERT_NO_THROW(range = subnet->getOptions(100));
-    EXPECT_EQ(0, std::distance(range.first, range.second));
-    ASSERT_NO_THROW(range = subnet->getOptions(101));
-    EXPECT_EQ(0, std::distance(range.first, range.second));
-}
-
 TEST(Subnet6Test, addInvalidOption) {
     // Create as subnet to add options to it.
     Subnet6Ptr subnet(new Subnet6(IOAddress("2001:db8:1::"), 56, 1, 2, 3, 4));



More information about the bind10-changes mailing list